// Generated by scripts/protocol-gen-swift.ts — do not edit by hand
// swiftlint:disable file_length
import Foundation

public let GATEWAY_PROTOCOL_VERSION = 4
public let GATEWAY_MIN_PROTOCOL_VERSION = 4
public let GATEWAY_MIN_NODE_PROTOCOL_VERSION = 3

private struct GatewayAnyCodingKey: CodingKey, Hashable {
    let stringValue: String
    let intValue: Int?

    init?(stringValue: String) {
        self.stringValue = stringValue
        self.intValue = nil
    }

    init?(intValue: Int) {
        self.stringValue = String(intValue)
        self.intValue = intValue
    }
}

public enum ErrorCode: String, Codable, Sendable {
    case notLinked = "NOT_LINKED"
    case notPaired = "NOT_PAIRED"
    case agentTimeout = "AGENT_TIMEOUT"
    case invalidRequest = "INVALID_REQUEST"
    case forbidden = "FORBIDDEN"
    case approvalNotFound = "APPROVAL_NOT_FOUND"
    case unavailable = "UNAVAILABLE"
}

public enum AuthProbeStatus: String, Codable, Sendable {
    case ok = "ok"
    case auth = "auth"
    case rateLimit = "rate_limit"
    case billing = "billing"
    case timeout = "timeout"
    case format = "format"
    case unknown = "unknown"
    case noModel = "no_model"
}

public enum EnvironmentStatus: String, Codable, Sendable {
    case available = "available"
    case unavailable = "unavailable"
    case starting = "starting"
    case stopping = "stopping"
    case error = "error"
}

public enum WorkerEnvironmentState: String, Codable, Sendable {
    case requested = "requested"
    case provisioning = "provisioning"
    case bootstrapping = "bootstrapping"
    case ready = "ready"
    case attached = "attached"
    case idle = "idle"
    case draining = "draining"
    case destroying = "destroying"
    case destroyed = "destroyed"
    case failed = "failed"
    case orphaned = "orphaned"
}

public enum WorkerTunnelStatus: String, Codable, Sendable {
    case stopped = "stopped"
    case connecting = "connecting"
    case connected = "connected"
    case reconnecting = "reconnecting"
}

public enum WorktreeRepositoryStatus: String, Codable, Sendable {
    case git = "git"
    case notGit = "not_git"
    case unavailable = "unavailable"
}

public enum NodePresenceAliveReason: String, Codable, Sendable {
    case background = "background"
    case silentPush = "silent_push"
    case bgAppRefresh = "bg_app_refresh"
    case significantLocation = "significant_location"
    case manual = "manual"
    case connect = "connect"
}

public enum SessionObserverHealth: String, Codable, Sendable {
    case onTrack = "on-track"
    case grinding = "grinding"
    case stuck = "stuck"
    case waitingOnUser = "waiting-on-user"
    case wrappingUp = "wrapping-up"
    case done = "done"
    case failed = "failed"
}

public enum SessionVisibility: String, Codable, Sendable {
    case shared = "shared"
    case readOnly = "read-only"
    case suggest = "suggest"
    case draft = "draft"
}

public enum SessionSharingRole: String, Codable, Sendable {
    case admin = "admin"
    case owner = "owner"
    case member = "member"
    case viewer = "viewer"
}

public enum SessionSharingAction: String, Codable, Sendable {
    case visibility = "visibility"
    case memberAdded = "member-added"
    case memberRemoved = "member-removed"
}

public enum SessionSuggestionState: String, Codable, Sendable {
    case pending = "pending"
    case accepted = "accepted"
    case dismissed = "dismissed"
}

public enum SessionSuggestionAction: String, Codable, Sendable {
    case added = "added"
    case resolved = "resolved"
}

public enum SessionSuggestionResolution: String, Codable, Sendable {
    case send = "send"
    case queue = "queue"
    case edit = "edit"
    case dismiss = "dismiss"
}

public enum SessionPlacementState: String, Codable, Sendable {
    case local = "local"
    case requested = "requested"
    case provisioning = "provisioning"
    case syncing = "syncing"
    case starting = "starting"
    case active = "active"
    case draining = "draining"
    case reconciling = "reconciling"
    case reclaimed = "reclaimed"
    case failed = "failed"
}

public enum SessionDiscussionState: String, Codable, Sendable {
    case none = "none"
    case available = "available"
    case _open = "open"
}

public enum SessionFileKind: String, Codable, Sendable {
    case modified = "modified"
    case read = "read"
}

public enum SessionFileRelevance: String, Codable, Sendable {
    case modified = "modified"
    case read = "read"
    case mixed = "mixed"
}

public enum SessionDiffFileStatus: String, Codable, Sendable {
    case added = "added"
    case modified = "modified"
    case deleted = "deleted"
    case renamed = "renamed"
}

public enum TaskSuggestionResolution: String, Codable, Sendable {
    case dismissed = "dismissed"
    case accepted = "accepted"
    case expired = "expired"
}

public enum SystemChangeKind: String, Codable, Sendable {
    case operation = "operation"
    case configWrite = "config-write"
    case externalEdit = "external-edit"
}

public enum SystemChangeSource: String, Codable, Sendable {
    case systemAgent = "system-agent"
    case doctor = "doctor"
    case configRpc = "config-rpc"
    case cli = "cli"
    case pluginInstall = "plugin-install"
    case external = "external"
    case unknown = "unknown"
}

public enum AgentKind: String, Codable, Sendable {
    case agent = "agent"
    case system = "system"
}

public enum MemoryMigrationItemStatus: String, Codable, Sendable {
    case planned = "planned"
    case migrated = "migrated"
    case skipped = "skipped"
    case warning = "warning"
    case conflict = "conflict"
    case error = "error"
}

public enum ApprovalKind: String, Codable, Sendable {
    case exec = "exec"
    case plugin = "plugin"
    case systemAgent = "system-agent"
}

public enum ApprovalDecision: String, Codable, Sendable {
    case allowOnce = "allow-once"
    case allowAlways = "allow-always"
    case deny = "deny"
}

public enum ApprovalAllowDecision: String, Codable, Sendable {
    case allowOnce = "allow-once"
    case allowAlways = "allow-always"
}

public enum ApprovalAllowedReason: String, Codable, Sendable {
    case user = "user"
}

public enum ApprovalDeniedReason: String, Codable, Sendable {
    case user = "user"
    case malformedVerdict = "malformed-verdict"
    case noRoute = "no-route"
    case storageCorrupt = "storage-corrupt"
}

public enum ApprovalExpiredReason: String, Codable, Sendable {
    case timeout = "timeout"
}

public enum ApprovalCancelledReason: String, Codable, Sendable {
    case runAborted = "run-aborted"
    case gatewayRestart = "gateway-restart"
}

public enum PluginApprovalSeverity: String, Codable, Sendable {
    case info = "info"
    case warning = "warning"
    case critical = "critical"
}

public enum ApprovalTerminalReason: String, Codable, Sendable {
    case user = "user"
    case timeout = "timeout"
    case malformedVerdict = "malformed-verdict"
    case noRoute = "no-route"
    case runAborted = "run-aborted"
    case gatewayRestart = "gateway-restart"
    case storageCorrupt = "storage-corrupt"
}

public enum QuestionStatus: String, Codable, Sendable {
    case pending = "pending"
    case answered = "answered"
    case cancelled = "cancelled"
    case expired = "expired"
}

public enum ChatRunStartupPhase: String, Codable, Sendable {
    case preparingWorkspace = "preparing_workspace"
    case provisioningEnvironment = "provisioning_environment"
    case preparingContext = "preparing_context"
    case startingModel = "starting_model"
}

public struct BoardTab: Codable, Sendable {
    public let tabid: String
    public let title: String
    public let position: Int
    public let chatdock: AnyCodable

    public init(
        tabid: String,
        title: String,
        position: Int,
        chatdock: AnyCodable)
    {
        self.tabid = tabid
        self.title = title
        self.position = position
        self.chatdock = chatdock
    }

    private enum CodingKeys: String, CodingKey {
        case tabid = "tabId"
        case title
        case position
        case chatdock = "chatDock"
    }
}

public struct BoardWidget: Codable, Sendable {
    public let name: String
    public let tabid: String
    public let title: String?
    public let contentkind: AnyCodable
    public let pluginkind: String?
    public let props: [String: AnyCodable]?
    public let presentation: AnyCodable?
    public let heightmode: AnyCodable?
    public let sizew: Int
    public let sizeh: Int
    public let position: Int
    public let grantstate: AnyCodable
    public let revision: Int
    public let instanceid: String?
    public let declaredsummary: [String]?
    public let declared: BoardWidgetDeclared?
    public let frameurl: String?
    public let viewticket: String?
    public let viewticketttlms: Int?
    public let viewgeneration: String?
    public let sandboxurl: String?
    public let sandboxport: Int?
    public let sandboxorigin: String?

    public init(
        name: String,
        tabid: String,
        title: String? = nil,
        contentkind: AnyCodable,
        pluginkind: String? = nil,
        props: [String: AnyCodable]? = nil,
        presentation: AnyCodable? = nil,
        heightmode: AnyCodable? = nil,
        sizew: Int,
        sizeh: Int,
        position: Int,
        grantstate: AnyCodable,
        revision: Int,
        instanceid: String? = nil,
        declaredsummary: [String]? = nil,
        declared: BoardWidgetDeclared? = nil,
        frameurl: String? = nil,
        viewticket: String? = nil,
        viewticketttlms: Int? = nil,
        viewgeneration: String? = nil,
        sandboxurl: String? = nil,
        sandboxport: Int? = nil,
        sandboxorigin: String? = nil)
    {
        self.name = name
        self.tabid = tabid
        self.title = title
        self.contentkind = contentkind
        self.pluginkind = pluginkind
        self.props = props
        self.presentation = presentation
        self.heightmode = heightmode
        self.sizew = sizew
        self.sizeh = sizeh
        self.position = position
        self.grantstate = grantstate
        self.revision = revision
        self.instanceid = instanceid
        self.declaredsummary = declaredsummary
        self.declared = declared
        self.frameurl = frameurl
        self.viewticket = viewticket
        self.viewticketttlms = viewticketttlms
        self.viewgeneration = viewgeneration
        self.sandboxurl = sandboxurl
        self.sandboxport = sandboxport
        self.sandboxorigin = sandboxorigin
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case tabid = "tabId"
        case title
        case contentkind = "contentKind"
        case pluginkind = "pluginKind"
        case props
        case presentation
        case heightmode = "heightMode"
        case sizew = "sizeW"
        case sizeh = "sizeH"
        case position
        case grantstate = "grantState"
        case revision
        case instanceid = "instanceId"
        case declaredsummary = "declaredSummary"
        case declared
        case frameurl = "frameUrl"
        case viewticket = "viewTicket"
        case viewticketttlms = "viewTicketTtlMs"
        case viewgeneration = "viewGeneration"
        case sandboxurl = "sandboxUrl"
        case sandboxport = "sandboxPort"
        case sandboxorigin = "sandboxOrigin"
    }
}

public struct BoardWidgetDeclared: Codable, Sendable {
    public let netorigins: [String]?
    public let tools: [String]?

    public init(
        netorigins: [String]? = nil,
        tools: [String]? = nil)
    {
        self.netorigins = netorigins
        self.tools = tools
    }

    private enum CodingKeys: String, CodingKey {
        case netorigins = "netOrigins"
        case tools
    }
}

public struct BoardSnapshot: Codable, Sendable {
    public let sessionkey: String
    public let revision: Int
    public let tabs: [BoardTab]
    public let widgets: [BoardWidget]

    public init(
        sessionkey: String,
        revision: Int,
        tabs: [BoardTab],
        widgets: [BoardWidget])
    {
        self.sessionkey = sessionkey
        self.revision = revision
        self.tabs = tabs
        self.widgets = widgets
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case revision
        case tabs
        case widgets
    }
}

public struct BoardTabCreateOp: Codable, Sendable {
    public let kind: String
    public let tabid: String
    public let title: String
    public let chatdock: AnyCodable?

    public init(
        kind: String,
        tabid: String,
        title: String,
        chatdock: AnyCodable? = nil)
    {
        self.kind = kind
        self.tabid = tabid
        self.title = title
        self.chatdock = chatdock
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case tabid = "tabId"
        case title
        case chatdock = "chatDock"
    }
}

public struct BoardTabUpdateOp: Codable, Sendable {
    public let kind: String
    public let tabid: String
    public let title: String?
    public let chatdock: AnyCodable?
    public let position: Int?

    public init(
        kind: String,
        tabid: String,
        title: String? = nil,
        chatdock: AnyCodable? = nil,
        position: Int? = nil)
    {
        self.kind = kind
        self.tabid = tabid
        self.title = title
        self.chatdock = chatdock
        self.position = position
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case tabid = "tabId"
        case title
        case chatdock = "chatDock"
        case position
    }
}

public struct BoardTabDeleteOp: Codable, Sendable {
    public let kind: String
    public let tabid: String

    public init(
        kind: String,
        tabid: String)
    {
        self.kind = kind
        self.tabid = tabid
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case tabid = "tabId"
    }
}

public struct BoardTabsReorderOp: Codable, Sendable {
    public let kind: String
    public let tabids: [String]

    public init(
        kind: String,
        tabids: [String])
    {
        self.kind = kind
        self.tabids = tabids
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case tabids = "tabIds"
    }
}

public struct BoardWidgetMoveOp: Codable, Sendable {
    public let kind: String
    public let name: String
    public let tabid: String?
    public let position: Int?
    public let after: String?

    public init(
        kind: String,
        name: String,
        tabid: String? = nil,
        position: Int? = nil,
        after: String? = nil)
    {
        self.kind = kind
        self.name = name
        self.tabid = tabid
        self.position = position
        self.after = after
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case name
        case tabid = "tabId"
        case position
        case after
    }
}

public struct BoardWidgetResizeOp: Codable, Sendable {
    public let kind: String
    public let name: String
    public let sizew: Int
    public let sizeh: Int
    public let heightmode: AnyCodable?

    public init(
        kind: String,
        name: String,
        sizew: Int,
        sizeh: Int,
        heightmode: AnyCodable? = nil)
    {
        self.kind = kind
        self.name = name
        self.sizew = sizew
        self.sizeh = sizeh
        self.heightmode = heightmode
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case name
        case sizew = "sizeW"
        case sizeh = "sizeH"
        case heightmode = "heightMode"
    }
}

public struct BoardWidgetRemoveOp: Codable, Sendable {
    public let kind: String
    public let name: String

    public init(
        kind: String,
        name: String)
    {
        self.kind = kind
        self.name = name
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case name
    }
}

public struct BoardMcpAppDescriptor: Codable, Sendable {
    public let servername: String
    public let toolname: String
    public let uiresourceuri: String
    public let toolcallid: String

    public init(
        servername: String,
        toolname: String,
        uiresourceuri: String,
        toolcallid: String)
    {
        self.servername = servername
        self.toolname = toolname
        self.uiresourceuri = uiresourceuri
        self.toolcallid = toolcallid
    }

    private enum CodingKeys: String, CodingKey {
        case servername = "serverName"
        case toolname = "toolName"
        case uiresourceuri = "uiResourceUri"
        case toolcallid = "toolCallId"
    }
}

public struct BoardWidgetHtmlContent: Codable, Sendable {
    public let kind: String
    public let html: String

    public init(
        kind: String,
        html: String)
    {
        self.kind = kind
        self.html = html
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case html
    }
}

public struct BoardWidgetMcpAppContent: Codable, Sendable {
    public let kind: String
    public let descriptor: BoardMcpAppDescriptor

    public init(
        kind: String,
        descriptor: BoardMcpAppDescriptor)
    {
        self.kind = kind
        self.descriptor = descriptor
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case descriptor
    }
}

public struct BoardWidgetMcpAppPutContent: Codable, Sendable {
    public let kind: String
    public let viewid: String

    public init(
        kind: String,
        viewid: String)
    {
        self.kind = kind
        self.viewid = viewid
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case viewid = "viewId"
    }
}

public struct BoardWidgetPluginContent: Codable, Sendable {
    public let kind: String
    public let pluginkind: String
    public let props: [String: AnyCodable]?

    public init(
        kind: String,
        pluginkind: String,
        props: [String: AnyCodable]? = nil)
    {
        self.kind = kind
        self.pluginkind = pluginkind
        self.props = props
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case pluginkind = "pluginKind"
        case props
    }
}

public struct BoardCanvasDocumentSource: Codable, Sendable {
    public let kind: String
    public let docid: String

    public init(
        kind: String,
        docid: String)
    {
        self.kind = kind
        self.docid = docid
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case docid = "docId"
    }
}

public struct BoardGetParams: Codable, Sendable {
    public let sessionkey: String

    public init(
        sessionkey: String)
    {
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
    }
}

public struct BoardUpdateParams: Codable, Sendable {
    public let sessionkey: String
    public let ops: [BoardOp]

    public init(
        sessionkey: String,
        ops: [BoardOp])
    {
        self.sessionkey = sessionkey
        self.ops = ops
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case ops
    }
}

public struct BoardWidgetPutParams: Codable, Sendable {
    public let sessionkey: String
    public let name: String
    public let title: String?
    public let content: BoardWidgetPutContent
    public let presentation: AnyCodable?
    public let heightmode: AnyCodable?
    public let placement: [String: AnyCodable]?
    public let declared: BoardWidgetDeclared?

    public init(
        sessionkey: String,
        name: String,
        title: String? = nil,
        content: BoardWidgetPutContent,
        presentation: AnyCodable? = nil,
        heightmode: AnyCodable? = nil,
        placement: [String: AnyCodable]? = nil,
        declared: BoardWidgetDeclared? = nil)
    {
        self.sessionkey = sessionkey
        self.name = name
        self.title = title
        self.content = content
        self.presentation = presentation
        self.heightmode = heightmode
        self.placement = placement
        self.declared = declared
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case name
        case title
        case content
        case presentation
        case heightmode = "heightMode"
        case placement
        case declared
    }
}

public struct BoardWidgetGrantParams: Codable, Sendable {
    public let sessionkey: String
    public let name: String
    public let decision: AnyCodable
    public let revision: Int
    public let instanceid: String

    public init(
        sessionkey: String,
        name: String,
        decision: AnyCodable,
        revision: Int,
        instanceid: String)
    {
        self.sessionkey = sessionkey
        self.name = name
        self.decision = decision
        self.revision = revision
        self.instanceid = instanceid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case name
        case decision
        case revision
        case instanceid = "instanceId"
    }
}

public struct BoardWidgetAppViewParams: Codable, Sendable {
    public let sessionkey: String
    public let name: String
    public let revision: Int
    public let instanceid: String

    public init(
        sessionkey: String,
        name: String,
        revision: Int,
        instanceid: String)
    {
        self.sessionkey = sessionkey
        self.name = name
        self.revision = revision
        self.instanceid = instanceid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case name
        case revision
        case instanceid = "instanceId"
    }
}

public struct BoardWidgetAppViewResult: Codable, Sendable {
    public let viewid: String
    public let expiresatms: Int

    public init(
        viewid: String,
        expiresatms: Int)
    {
        self.viewid = viewid
        self.expiresatms = expiresatms
    }

    private enum CodingKeys: String, CodingKey {
        case viewid = "viewId"
        case expiresatms = "expiresAtMs"
    }
}

public struct BoardEventParams: Codable, Sendable {
    public let sessionkey: String
    public let widget: String
    public let payload: AnyCodable

    public init(
        sessionkey: String,
        widget: String,
        payload: AnyCodable)
    {
        self.sessionkey = sessionkey
        self.widget = widget
        self.payload = payload
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case widget
        case payload
    }
}

public struct BoardTicketEventParams: Codable, Sendable {
    public let ticket: String
    public let payload: AnyCodable

    public init(
        ticket: String,
        payload: AnyCodable)
    {
        self.ticket = ticket
        self.payload = payload
    }

    private enum CodingKeys: String, CodingKey {
        case ticket
        case payload
    }
}

public struct BoardPromptAuthorizeParams: Codable, Sendable {
    public let ticket: String

    public init(
        ticket: String)
    {
        self.ticket = ticket
    }

    private enum CodingKeys: String, CodingKey {
        case ticket
    }
}

public struct BoardDataReadParams: Codable, Sendable {
    public let ticket: String
    public let bindingid: String
    public let params: [String: AnyCodable]?

    public init(
        ticket: String,
        bindingid: String,
        params: [String: AnyCodable]? = nil)
    {
        self.ticket = ticket
        self.bindingid = bindingid
        self.params = params
    }

    private enum CodingKeys: String, CodingKey {
        case ticket
        case bindingid = "bindingId"
        case params
    }
}

public struct BoardChangedEvent: Codable, Sendable {
    public let sessionkey: String
    public let revision: Int
    public let widget: String?

    public init(
        sessionkey: String,
        revision: Int,
        widget: String? = nil)
    {
        self.sessionkey = sessionkey
        self.revision = revision
        self.widget = widget
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case revision
        case widget
    }
}

public struct BoardFocusTabCommand: Codable, Sendable {
    public let kind: String
    public let tabid: String

    public init(
        kind: String,
        tabid: String)
    {
        self.kind = kind
        self.tabid = tabid
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case tabid = "tabId"
    }
}

public struct BoardSetChatDockCommand: Codable, Sendable {
    public let kind: String
    public let dock: AnyCodable

    public init(
        kind: String,
        dock: AnyCodable)
    {
        self.kind = kind
        self.dock = dock
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case dock
    }
}

public struct BoardCommandEvent: Codable, Sendable {
    public let sessionkey: String
    public let command: BoardCommand

    public init(
        sessionkey: String,
        command: BoardCommand)
    {
        self.sessionkey = sessionkey
        self.command = command
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case command
    }
}

public struct ConnectParams: Codable, Sendable {
    public let minprotocol: Int
    public let maxprotocol: Int
    public let client: [String: AnyCodable]
    public let caps: [String]?
    public let commands: [String]?
    public let permissions: [String: AnyCodable]?
    public let pathenv: String?
    public let role: String?
    public let scopes: [String]?
    public let device: [String: AnyCodable]?
    public let auth: [String: AnyCodable]?
    public let locale: String?
    public let useragent: String?

    public init(
        minprotocol: Int,
        maxprotocol: Int,
        client: [String: AnyCodable],
        caps: [String]? = nil,
        commands: [String]? = nil,
        permissions: [String: AnyCodable]? = nil,
        pathenv: String? = nil,
        role: String? = nil,
        scopes: [String]? = nil,
        device: [String: AnyCodable]? = nil,
        auth: [String: AnyCodable]? = nil,
        locale: String? = nil,
        useragent: String? = nil)
    {
        self.minprotocol = minprotocol
        self.maxprotocol = maxprotocol
        self.client = client
        self.caps = caps
        self.commands = commands
        self.permissions = permissions
        self.pathenv = pathenv
        self.role = role
        self.scopes = scopes
        self.device = device
        self.auth = auth
        self.locale = locale
        self.useragent = useragent
    }

    private enum CodingKeys: String, CodingKey {
        case minprotocol = "minProtocol"
        case maxprotocol = "maxProtocol"
        case client
        case caps
        case commands
        case permissions
        case pathenv = "pathEnv"
        case role
        case scopes
        case device
        case auth
        case locale
        case useragent = "userAgent"
    }
}

public struct WorkerAdmissionHandshake: Codable, Sendable {
    public let bundlehash: String
    public let openclawversion: String
    public let protocolfeatures: [String]

    public init(
        bundlehash: String,
        openclawversion: String,
        protocolfeatures: [String])
    {
        self.bundlehash = bundlehash
        self.openclawversion = openclawversion
        self.protocolfeatures = protocolfeatures
    }

    private enum CodingKeys: String, CodingKey {
        case bundlehash = "bundleHash"
        case openclawversion = "openclawVersion"
        case protocolfeatures = "protocolFeatures"
    }
}

public struct HelloOk: Codable, Sendable {
    public let type: String
    public let _protocol: Int
    public let server: [String: AnyCodable]
    public let features: [String: AnyCodable]
    public let snapshot: Snapshot
    public let controluitabs: [[String: AnyCodable]]?
    public let controluiwidgetkinds: [[String: AnyCodable]]?
    public let pluginsurfaceurls: [String: AnyCodable]?
    public let deviceauthmigration: [String: AnyCodable]?
    public let auth: [String: AnyCodable]
    public let policy: [String: AnyCodable]

    public init(
        type: String,
        _protocol: Int,
        server: [String: AnyCodable],
        features: [String: AnyCodable],
        snapshot: Snapshot,
        controluitabs: [[String: AnyCodable]]? = nil,
        controluiwidgetkinds: [[String: AnyCodable]]? = nil,
        pluginsurfaceurls: [String: AnyCodable]? = nil,
        deviceauthmigration: [String: AnyCodable]? = nil,
        auth: [String: AnyCodable],
        policy: [String: AnyCodable])
    {
        self.type = type
        self._protocol = _protocol
        self.server = server
        self.features = features
        self.snapshot = snapshot
        self.controluitabs = controluitabs
        self.controluiwidgetkinds = controluiwidgetkinds
        self.pluginsurfaceurls = pluginsurfaceurls
        self.deviceauthmigration = deviceauthmigration
        self.auth = auth
        self.policy = policy
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case _protocol = "protocol"
        case server
        case features
        case snapshot
        case controluitabs = "controlUiTabs"
        case controluiwidgetkinds = "controlUiWidgetKinds"
        case pluginsurfaceurls = "pluginSurfaceUrls"
        case deviceauthmigration = "deviceAuthMigration"
        case auth
        case policy
    }
}

public struct RequestFrame: Codable, Sendable {
    public let type: String
    public let id: String
    public let method: String
    public let params: AnyCodable?

    public init(
        type: String,
        id: String,
        method: String,
        params: AnyCodable? = nil)
    {
        self.type = type
        self.id = id
        self.method = method
        self.params = params
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case id
        case method
        case params
    }
}

public struct ResponseFrame: Codable, Sendable {
    public let type: String
    public let id: String
    public let ok: Bool
    public let payload: AnyCodable?
    public let error: ErrorShape?

    public init(
        type: String,
        id: String,
        ok: Bool,
        payload: AnyCodable? = nil,
        error: ErrorShape? = nil)
    {
        self.type = type
        self.id = id
        self.ok = ok
        self.payload = payload
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case id
        case ok
        case payload
        case error
    }
}

public struct EventFrame: Codable, Sendable {
    public let type: String
    public let event: String
    public let payload: AnyCodable?
    public let seq: Int?
    public let stateversion: StateVersion?

    public init(
        type: String,
        event: String,
        payload: AnyCodable? = nil,
        seq: Int? = nil,
        stateversion: StateVersion? = nil)
    {
        self.type = type
        self.event = event
        self.payload = payload
        self.seq = seq
        self.stateversion = stateversion
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case event
        case payload
        case seq
        case stateversion = "stateVersion"
    }
}

public struct PresenceEntry: Codable, Sendable {
    public let host: String?
    public let ip: String?
    public let version: String?
    public let platform: String?
    public let devicefamily: String?
    public let modelidentifier: String?
    public let mode: String?
    public let lastinputseconds: Int?
    public let reason: String?
    public let tags: [String]?
    public let text: String?
    public let ts: Int
    public let deviceid: String?
    public let roles: [String]?
    public let scopes: [String]?
    public let instanceid: String?
    public let user: [String: AnyCodable]?
    public let watchedsessions: [String]?

    public init(
        host: String? = nil,
        ip: String? = nil,
        version: String? = nil,
        platform: String? = nil,
        devicefamily: String? = nil,
        modelidentifier: String? = nil,
        mode: String? = nil,
        lastinputseconds: Int? = nil,
        reason: String? = nil,
        tags: [String]? = nil,
        text: String? = nil,
        ts: Int,
        deviceid: String? = nil,
        roles: [String]? = nil,
        scopes: [String]? = nil,
        instanceid: String? = nil,
        user: [String: AnyCodable]? = nil,
        watchedsessions: [String]? = nil)
    {
        self.host = host
        self.ip = ip
        self.version = version
        self.platform = platform
        self.devicefamily = devicefamily
        self.modelidentifier = modelidentifier
        self.mode = mode
        self.lastinputseconds = lastinputseconds
        self.reason = reason
        self.tags = tags
        self.text = text
        self.ts = ts
        self.deviceid = deviceid
        self.roles = roles
        self.scopes = scopes
        self.instanceid = instanceid
        self.user = user
        self.watchedsessions = watchedsessions
    }

    private enum CodingKeys: String, CodingKey {
        case host
        case ip
        case version
        case platform
        case devicefamily = "deviceFamily"
        case modelidentifier = "modelIdentifier"
        case mode
        case lastinputseconds = "lastInputSeconds"
        case reason
        case tags
        case text
        case ts
        case deviceid = "deviceId"
        case roles
        case scopes
        case instanceid = "instanceId"
        case user
        case watchedsessions = "watchedSessions"
    }
}

public struct StateVersion: Codable, Sendable {
    public let presence: Int
    public let health: Int

    public init(
        presence: Int,
        health: Int)
    {
        self.presence = presence
        self.health = health
    }

    private enum CodingKeys: String, CodingKey {
        case presence
        case health
    }
}

public struct Snapshot: Codable, Sendable {
    public let presence: [PresenceEntry]
    public let health: [String: AnyCodable]
    public let stateversion: StateVersion
    public let uptimems: Int
    public let appliedconfighash: AnyCodable?
    public let configpath: String?
    public let statedir: String?
    public let sessiondefaults: [String: AnyCodable]?
    public let authmode: AnyCodable?
    public let updateavailable: [String: AnyCodable]?

    public init(
        presence: [PresenceEntry],
        health: [String: AnyCodable],
        stateversion: StateVersion,
        uptimems: Int,
        appliedconfighash: AnyCodable? = nil,
        configpath: String? = nil,
        statedir: String? = nil,
        sessiondefaults: [String: AnyCodable]? = nil,
        authmode: AnyCodable? = nil,
        updateavailable: [String: AnyCodable]? = nil)
    {
        self.presence = presence
        self.health = health
        self.stateversion = stateversion
        self.uptimems = uptimems
        self.appliedconfighash = appliedconfighash
        self.configpath = configpath
        self.statedir = statedir
        self.sessiondefaults = sessiondefaults
        self.authmode = authmode
        self.updateavailable = updateavailable
    }

    private enum CodingKeys: String, CodingKey {
        case presence
        case health
        case stateversion = "stateVersion"
        case uptimems = "uptimeMs"
        case appliedconfighash = "appliedConfigHash"
        case configpath = "configPath"
        case statedir = "stateDir"
        case sessiondefaults = "sessionDefaults"
        case authmode = "authMode"
        case updateavailable = "updateAvailable"
    }
}

public struct ErrorShape: Codable, Sendable {
    public let code: String
    public let message: String
    public let details: AnyCodable?
    public let retryable: Bool?
    public let retryafterms: Int?

    public init(
        code: String,
        message: String,
        details: AnyCodable? = nil,
        retryable: Bool? = nil,
        retryafterms: Int? = nil)
    {
        self.code = code
        self.message = message
        self.details = details
        self.retryable = retryable
        self.retryafterms = retryafterms
    }

    private enum CodingKeys: String, CodingKey {
        case code
        case message
        case details
        case retryable
        case retryafterms = "retryAfterMs"
    }
}

public struct MissingScopeErrorDetails: Codable, Sendable {
    public let code: String
    public let missingscope: String
    public let requiredscopes: [String]

    public init(
        code: String,
        missingscope: String,
        requiredscopes: [String])
    {
        self.code = code
        self.missingscope = missingscope
        self.requiredscopes = requiredscopes
    }

    private enum CodingKeys: String, CodingKey {
        case code
        case missingscope = "missingScope"
        case requiredscopes = "requiredScopes"
    }
}

public struct McpAppViewExpiredErrorDetails: Codable, Sendable {
    public let code: String

    public init(
        code: String)
    {
        self.code = code
    }

    private enum CodingKeys: String, CodingKey {
        case code
    }
}

public struct UnknownAgentIdErrorDetails: Codable, Sendable {
    public let code: String
    public let agentid: String

    public init(
        code: String,
        agentid: String)
    {
        self.code = code
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case code
        case agentid = "agentId"
    }
}

public struct WizardNotFoundErrorDetails: Codable, Sendable {
    public let code: String

    public init(
        code: String)
    {
        self.code = code
    }

    private enum CodingKeys: String, CodingKey {
        case code
    }
}

public struct GatewaySuspendTaskBlocker: Codable, Sendable {
    public let taskid: String
    public let status: String
    public let runtime: AnyCodable
    public let runid: String?
    public let label: String?
    public let title: String?

    public init(
        taskid: String,
        status: String,
        runtime: AnyCodable,
        runid: String? = nil,
        label: String? = nil,
        title: String? = nil)
    {
        self.taskid = taskid
        self.status = status
        self.runtime = runtime
        self.runid = runid
        self.label = label
        self.title = title
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case status
        case runtime
        case runid = "runId"
        case label
        case title
    }
}

public struct GatewaySuspendBlocker: Codable, Sendable {
    public let kind: AnyCodable
    public let count: Int
    public let message: String
    public let task: GatewaySuspendTaskBlocker?

    public init(
        kind: AnyCodable,
        count: Int,
        message: String,
        task: GatewaySuspendTaskBlocker? = nil)
    {
        self.kind = kind
        self.count = count
        self.message = message
        self.task = task
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case count
        case message
        case task
    }
}

public struct GatewaySuspendPrepareParams: Codable, Sendable {
    public let requestid: String

    public init(
        requestid: String)
    {
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
    }
}

public struct GatewaySuspendPrepareBusyResult: Codable, Sendable {
    public let status: String
    public let reason: AnyCodable
    public let retryafterms: Int
    public let activecount: Int
    public let blockers: [GatewaySuspendBlocker]

    public init(
        status: String,
        reason: AnyCodable,
        retryafterms: Int,
        activecount: Int,
        blockers: [GatewaySuspendBlocker])
    {
        self.status = status
        self.reason = reason
        self.retryafterms = retryafterms
        self.activecount = activecount
        self.blockers = blockers
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case reason
        case retryafterms = "retryAfterMs"
        case activecount = "activeCount"
        case blockers
    }
}

public struct GatewaySuspendPrepareReadyResult: Codable, Sendable {
    public let status: String
    public let suspensionid: String
    public let expiresatms: Int
    public let activecount: Int
    public let blockers: [GatewaySuspendBlocker]

    public init(
        status: String,
        suspensionid: String,
        expiresatms: Int,
        activecount: Int,
        blockers: [GatewaySuspendBlocker])
    {
        self.status = status
        self.suspensionid = suspensionid
        self.expiresatms = expiresatms
        self.activecount = activecount
        self.blockers = blockers
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case suspensionid = "suspensionId"
        case expiresatms = "expiresAtMs"
        case activecount = "activeCount"
        case blockers
    }
}

public struct GatewaySuspendStatusParams: Codable, Sendable {
    public let suspensionid: String

    public init(
        suspensionid: String)
    {
        self.suspensionid = suspensionid
    }

    private enum CodingKeys: String, CodingKey {
        case suspensionid = "suspensionId"
    }
}

public struct GatewaySuspendStatusRunningResult: Codable, Sendable {
    public let status: String

    public init(
        status: String)
    {
        self.status = status
    }

    private enum CodingKeys: String, CodingKey {
        case status
    }
}

public struct GatewaySuspendStatusReadyResult: Codable, Sendable {
    public let status: String
    public let expiresatms: Int

    public init(
        status: String,
        expiresatms: Int)
    {
        self.status = status
        self.expiresatms = expiresatms
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case expiresatms = "expiresAtMs"
    }
}

public struct GatewaySuspendResumeParams: Codable, Sendable {
    public let suspensionid: String

    public init(
        suspensionid: String)
    {
        self.suspensionid = suspensionid
    }

    private enum CodingKeys: String, CodingKey {
        case suspensionid = "suspensionId"
    }
}

public struct GatewaySuspendResumeResult: Codable, Sendable {
    public let ok: Bool
    public let status: String
    public let resumed: Bool

    public init(
        ok: Bool,
        status: String,
        resumed: Bool)
    {
        self.ok = ok
        self.status = status
        self.resumed = resumed
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case status
        case resumed
    }
}

public struct WorkerEnvironmentMetadata: Codable, Sendable {
    public let providerid: String
    public let leaseid: String?
    public let state: WorkerEnvironmentState
    public let agems: Int
    public let idlems: Int?
    public let attachedsessionids: [String]
    public let tunnelstatus: WorkerTunnelStatus

    public init(
        providerid: String,
        leaseid: String? = nil,
        state: WorkerEnvironmentState,
        agems: Int,
        idlems: Int? = nil,
        attachedsessionids: [String],
        tunnelstatus: WorkerTunnelStatus)
    {
        self.providerid = providerid
        self.leaseid = leaseid
        self.state = state
        self.agems = agems
        self.idlems = idlems
        self.attachedsessionids = attachedsessionids
        self.tunnelstatus = tunnelstatus
    }

    private enum CodingKeys: String, CodingKey {
        case providerid = "providerId"
        case leaseid = "leaseId"
        case state
        case agems = "ageMs"
        case idlems = "idleMs"
        case attachedsessionids = "attachedSessionIds"
        case tunnelstatus = "tunnelStatus"
    }
}

public struct EnvironmentSummary: Codable, Sendable {
    public let id: String
    public let type: String
    public let label: String?
    public let status: EnvironmentStatus
    public let capabilities: [String]?
    public let worker: WorkerEnvironmentMetadata?

    public init(
        id: String,
        type: String,
        label: String? = nil,
        status: EnvironmentStatus,
        capabilities: [String]? = nil,
        worker: WorkerEnvironmentMetadata? = nil)
    {
        self.id = id
        self.type = type
        self.label = label
        self.status = status
        self.capabilities = capabilities
        self.worker = worker
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case label
        case status
        case capabilities
        case worker
    }
}

public struct EnvironmentsCreateParams: Codable, Sendable {
    public let profileid: String
    public let idempotencykey: String

    public init(
        profileid: String,
        idempotencykey: String)
    {
        self.profileid = profileid
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case profileid = "profileId"
        case idempotencykey = "idempotencyKey"
    }
}

public struct EnvironmentsCreateResult: Codable, Sendable {
    public let id: String
    public let type: String
    public let label: String?
    public let status: EnvironmentStatus
    public let capabilities: [String]?
    public let worker: WorkerEnvironmentMetadata?

    public init(
        id: String,
        type: String,
        label: String? = nil,
        status: EnvironmentStatus,
        capabilities: [String]? = nil,
        worker: WorkerEnvironmentMetadata? = nil)
    {
        self.id = id
        self.type = type
        self.label = label
        self.status = status
        self.capabilities = capabilities
        self.worker = worker
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case label
        case status
        case capabilities
        case worker
    }
}

public struct EnvironmentsDestroyParams: Codable, Sendable {
    public let environmentid: String
    public let force: Bool?

    public init(
        environmentid: String,
        force: Bool? = nil)
    {
        self.environmentid = environmentid
        self.force = force
    }

    private enum CodingKeys: String, CodingKey {
        case environmentid = "environmentId"
        case force
    }
}

public struct EnvironmentsDestroyResult: Codable, Sendable {
    public let id: String
    public let type: String
    public let label: String?
    public let status: EnvironmentStatus
    public let capabilities: [String]?
    public let worker: WorkerEnvironmentMetadata?

    public init(
        id: String,
        type: String,
        label: String? = nil,
        status: EnvironmentStatus,
        capabilities: [String]? = nil,
        worker: WorkerEnvironmentMetadata? = nil)
    {
        self.id = id
        self.type = type
        self.label = label
        self.status = status
        self.capabilities = capabilities
        self.worker = worker
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case label
        case status
        case capabilities
        case worker
    }
}

public struct EnvironmentsListParams: Codable, Sendable {}

public struct EnvironmentsListResult: Codable, Sendable {
    public let environments: [EnvironmentSummary]
    public let profiles: [[String: AnyCodable]]?

    public init(
        environments: [EnvironmentSummary],
        profiles: [[String: AnyCodable]]? = nil)
    {
        self.environments = environments
        self.profiles = profiles
    }

    private enum CodingKeys: String, CodingKey {
        case environments
        case profiles
    }
}

public struct EnvironmentsStatusParams: Codable, Sendable {
    public let environmentid: String

    public init(
        environmentid: String)
    {
        self.environmentid = environmentid
    }

    private enum CodingKeys: String, CodingKey {
        case environmentid = "environmentId"
    }
}

public struct EnvironmentsStatusResult: Codable, Sendable {
    public let id: String
    public let type: String
    public let label: String?
    public let status: EnvironmentStatus
    public let capabilities: [String]?
    public let worker: WorkerEnvironmentMetadata?

    public init(
        id: String,
        type: String,
        label: String? = nil,
        status: EnvironmentStatus,
        capabilities: [String]? = nil,
        worker: WorkerEnvironmentMetadata? = nil)
    {
        self.id = id
        self.type = type
        self.label = label
        self.status = status
        self.capabilities = capabilities
        self.worker = worker
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case label
        case status
        case capabilities
        case worker
    }
}

public struct SystemInfoParams: Codable, Sendable {}

public struct SystemInfoResult: Codable, Sendable {
    public let machinename: String
    public let hostname: String
    public let platform: String
    public let release: String
    public let arch: String
    public let oslabel: String
    public let lanaddress: String?
    public let port: Int?
    public let nodeversion: String
    public let pid: Int
    public let processinstanceid: String?
    public let uptimems: Int
    public let cpucount: Int
    public let cpumodel: String?
    public let loadaverage: [AnyCodable]?
    public let memorytotalbytes: Int
    public let memoryfreebytes: Int
    public let disktotalbytes: Int?
    public let diskavailablebytes: Int?
    public let diskpath: String?
    public let defaultagentutilitymodel: AnyCodable?

    public init(
        machinename: String,
        hostname: String,
        platform: String,
        release: String,
        arch: String,
        oslabel: String,
        lanaddress: String? = nil,
        port: Int? = nil,
        nodeversion: String,
        pid: Int,
        processinstanceid: String? = nil,
        uptimems: Int,
        cpucount: Int,
        cpumodel: String? = nil,
        loadaverage: [AnyCodable]? = nil,
        memorytotalbytes: Int,
        memoryfreebytes: Int,
        disktotalbytes: Int? = nil,
        diskavailablebytes: Int? = nil,
        diskpath: String? = nil,
        defaultagentutilitymodel: AnyCodable? = nil)
    {
        self.machinename = machinename
        self.hostname = hostname
        self.platform = platform
        self.release = release
        self.arch = arch
        self.oslabel = oslabel
        self.lanaddress = lanaddress
        self.port = port
        self.nodeversion = nodeversion
        self.pid = pid
        self.processinstanceid = processinstanceid
        self.uptimems = uptimems
        self.cpucount = cpucount
        self.cpumodel = cpumodel
        self.loadaverage = loadaverage
        self.memorytotalbytes = memorytotalbytes
        self.memoryfreebytes = memoryfreebytes
        self.disktotalbytes = disktotalbytes
        self.diskavailablebytes = diskavailablebytes
        self.diskpath = diskpath
        self.defaultagentutilitymodel = defaultagentutilitymodel
    }

    private enum CodingKeys: String, CodingKey {
        case machinename = "machineName"
        case hostname
        case platform
        case release
        case arch
        case oslabel = "osLabel"
        case lanaddress = "lanAddress"
        case port
        case nodeversion = "nodeVersion"
        case pid
        case processinstanceid = "processInstanceId"
        case uptimems = "uptimeMs"
        case cpucount = "cpuCount"
        case cpumodel = "cpuModel"
        case loadaverage = "loadAverage"
        case memorytotalbytes = "memoryTotalBytes"
        case memoryfreebytes = "memoryFreeBytes"
        case disktotalbytes = "diskTotalBytes"
        case diskavailablebytes = "diskAvailableBytes"
        case diskpath = "diskPath"
        case defaultagentutilitymodel = "defaultAgentUtilityModel"
    }
}

public struct AgentEvent: Codable, Sendable {
    public let runid: String
    public let seq: Int
    public let stream: String
    public let ts: Int
    public let spawnedby: String?
    public let isheartbeat: Bool?
    public let data: [String: AnyCodable]

    public init(
        runid: String,
        seq: Int,
        stream: String,
        ts: Int,
        spawnedby: String? = nil,
        isheartbeat: Bool? = nil,
        data: [String: AnyCodable])
    {
        self.runid = runid
        self.seq = seq
        self.stream = stream
        self.ts = ts
        self.spawnedby = spawnedby
        self.isheartbeat = isheartbeat
        self.data = data
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case seq
        case stream
        case ts
        case spawnedby = "spawnedBy"
        case isheartbeat = "isHeartbeat"
        case data
    }
}

public struct ConversationSendParams: Codable, Sendable {
    public let agentid: String
    public let sourcesessionkey: String?
    public let operationid: String
    public let conversationref: String
    public let message: String

    public init(
        agentid: String,
        sourcesessionkey: String? = nil,
        operationid: String,
        conversationref: String,
        message: String)
    {
        self.agentid = agentid
        self.sourcesessionkey = sourcesessionkey
        self.operationid = operationid
        self.conversationref = conversationref
        self.message = message
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sourcesessionkey = "sourceSessionKey"
        case operationid = "operationId"
        case conversationref = "conversationRef"
        case message
    }
}

public struct ConversationSendResult: Codable, Sendable {
    public let status: AnyCodable
    public let conversationref: String
    public let channel: String
    public let messageid: String?
    public let queueid: String?

    public init(
        status: AnyCodable,
        conversationref: String,
        channel: String,
        messageid: String? = nil,
        queueid: String? = nil)
    {
        self.status = status
        self.conversationref = conversationref
        self.channel = channel
        self.messageid = messageid
        self.queueid = queueid
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case conversationref = "conversationRef"
        case channel
        case messageid = "messageId"
        case queueid = "queueId"
    }
}

public struct ConversationListItem: Codable, Sendable {
    public let conversationref: String
    public let channel: String
    public let accountid: String
    public let kind: AnyCodable
    public let target: String
    public let threadid: String?
    public let label: String?
    public let firstseenat: Int
    public let lastseenat: Int

    public init(
        conversationref: String,
        channel: String,
        accountid: String,
        kind: AnyCodable,
        target: String,
        threadid: String? = nil,
        label: String? = nil,
        firstseenat: Int,
        lastseenat: Int)
    {
        self.conversationref = conversationref
        self.channel = channel
        self.accountid = accountid
        self.kind = kind
        self.target = target
        self.threadid = threadid
        self.label = label
        self.firstseenat = firstseenat
        self.lastseenat = lastseenat
    }

    private enum CodingKeys: String, CodingKey {
        case conversationref = "conversationRef"
        case channel
        case accountid = "accountId"
        case kind
        case target
        case threadid = "threadId"
        case label
        case firstseenat = "firstSeenAt"
        case lastseenat = "lastSeenAt"
    }
}

public struct ConversationListParams: Codable, Sendable {
    public let agentid: String
    public let channel: String?
    public let query: String?
    public let limit: Int?

    public init(
        agentid: String,
        channel: String? = nil,
        query: String? = nil,
        limit: Int? = nil)
    {
        self.agentid = agentid
        self.channel = channel
        self.query = query
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case channel
        case query
        case limit
    }
}

public struct ConversationListResult: Codable, Sendable {
    public let conversations: [ConversationListItem]

    public init(
        conversations: [ConversationListItem])
    {
        self.conversations = conversations
    }

    private enum CodingKeys: String, CodingKey {
        case conversations
    }
}

public struct ConversationTurnCancelParams: Codable, Sendable {
    public let agentid: String
    public let turnid: String

    public init(
        agentid: String,
        turnid: String)
    {
        self.agentid = agentid
        self.turnid = turnid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case turnid = "turnId"
    }
}

public struct ConversationTurnCancelResult: Codable, Sendable {
    public let cancelled: Bool

    public init(
        cancelled: Bool)
    {
        self.cancelled = cancelled
    }

    private enum CodingKeys: String, CodingKey {
        case cancelled
    }
}

public struct ConversationTurnParams: Codable, Sendable {
    public let agentid: String
    public let sourcesessionkey: String?
    public let turnid: String
    public let conversationref: String
    public let message: String
    public let timeoutms: Int

    public init(
        agentid: String,
        sourcesessionkey: String? = nil,
        turnid: String,
        conversationref: String,
        message: String,
        timeoutms: Int)
    {
        self.agentid = agentid
        self.sourcesessionkey = sourcesessionkey
        self.turnid = turnid
        self.conversationref = conversationref
        self.message = message
        self.timeoutms = timeoutms
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sourcesessionkey = "sourceSessionKey"
        case turnid = "turnId"
        case conversationref = "conversationRef"
        case message
        case timeoutms = "timeoutMs"
    }
}

public struct ConversationTurnReply: Codable, Sendable {
    public let conversationref: String
    public let messageid: String
    public let replytoid: String?
    public let threadid: String?
    public let text: String
    public let timestamp: Int
    public let transcriptartifactid: String?
    public let transcriptmessageid: String?

    public init(
        conversationref: String,
        messageid: String,
        replytoid: String? = nil,
        threadid: String? = nil,
        text: String,
        timestamp: Int,
        transcriptartifactid: String? = nil,
        transcriptmessageid: String? = nil)
    {
        self.conversationref = conversationref
        self.messageid = messageid
        self.replytoid = replytoid
        self.threadid = threadid
        self.text = text
        self.timestamp = timestamp
        self.transcriptartifactid = transcriptartifactid
        self.transcriptmessageid = transcriptmessageid
    }

    private enum CodingKeys: String, CodingKey {
        case conversationref = "conversationRef"
        case messageid = "messageId"
        case replytoid = "replyToId"
        case threadid = "threadId"
        case text
        case timestamp
        case transcriptartifactid = "transcriptArtifactId"
        case transcriptmessageid = "transcriptMessageId"
    }
}

public struct MessageActionParams: Codable, Sendable {
    public let channel: String
    public let action: String
    public let params: [String: AnyCodable]
    public let accountid: String?
    public let requesteraccountid: String?
    public let requestersenderid: String?
    public let senderisowner: Bool?
    public let sessionkey: String?
    public let sessionid: String?
    public let inboundturnkind: String?
    public let agentid: String?
    public let toolcontext: [String: AnyCodable]?
    public let conversationreadorigin: String?
    public let idempotencykey: String

    public init(
        channel: String,
        action: String,
        params: [String: AnyCodable],
        accountid: String? = nil,
        requesteraccountid: String? = nil,
        requestersenderid: String? = nil,
        senderisowner: Bool? = nil,
        sessionkey: String? = nil,
        sessionid: String? = nil,
        inboundturnkind: String? = nil,
        agentid: String? = nil,
        toolcontext: [String: AnyCodable]? = nil,
        conversationreadorigin: String? = nil,
        idempotencykey: String)
    {
        self.channel = channel
        self.action = action
        self.params = params
        self.accountid = accountid
        self.requesteraccountid = requesteraccountid
        self.requestersenderid = requestersenderid
        self.senderisowner = senderisowner
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.inboundturnkind = inboundturnkind
        self.agentid = agentid
        self.toolcontext = toolcontext
        self.conversationreadorigin = conversationreadorigin
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case action
        case params
        case accountid = "accountId"
        case requesteraccountid = "requesterAccountId"
        case requestersenderid = "requesterSenderId"
        case senderisowner = "senderIsOwner"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case inboundturnkind = "inboundTurnKind"
        case agentid = "agentId"
        case toolcontext = "toolContext"
        case conversationreadorigin = "conversationReadOrigin"
        case idempotencykey = "idempotencyKey"
    }
}

public struct SendParams: Codable, Sendable {
    public let to: String
    public let message: String?
    public let mediaurl: String?
    public let mediaurls: [String]?
    public let buffer: String?
    public let filename: String?
    public let contenttype: String?
    public let asvoice: Bool?
    public let gifplayback: Bool?
    public let channel: String?
    public let accountid: String?
    public let agentid: String?
    public let replytoid: String?
    public let threadid: String?
    public let forcedocument: Bool?
    public let silent: Bool?
    public let parsemode: String?
    public let sessionkey: String?
    public let idempotencykey: String

    public init(
        to: String,
        message: String? = nil,
        mediaurl: String? = nil,
        mediaurls: [String]? = nil,
        buffer: String? = nil,
        filename: String? = nil,
        contenttype: String? = nil,
        asvoice: Bool? = nil,
        gifplayback: Bool? = nil,
        channel: String? = nil,
        accountid: String? = nil,
        agentid: String? = nil,
        replytoid: String? = nil,
        threadid: String? = nil,
        forcedocument: Bool? = nil,
        silent: Bool? = nil,
        parsemode: String? = nil,
        sessionkey: String? = nil,
        idempotencykey: String)
    {
        self.to = to
        self.message = message
        self.mediaurl = mediaurl
        self.mediaurls = mediaurls
        self.buffer = buffer
        self.filename = filename
        self.contenttype = contenttype
        self.asvoice = asvoice
        self.gifplayback = gifplayback
        self.channel = channel
        self.accountid = accountid
        self.agentid = agentid
        self.replytoid = replytoid
        self.threadid = threadid
        self.forcedocument = forcedocument
        self.silent = silent
        self.parsemode = parsemode
        self.sessionkey = sessionkey
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case to
        case message
        case mediaurl = "mediaUrl"
        case mediaurls = "mediaUrls"
        case buffer
        case filename
        case contenttype = "contentType"
        case asvoice = "asVoice"
        case gifplayback = "gifPlayback"
        case channel
        case accountid = "accountId"
        case agentid = "agentId"
        case replytoid = "replyToId"
        case threadid = "threadId"
        case forcedocument = "forceDocument"
        case silent
        case parsemode = "parseMode"
        case sessionkey = "sessionKey"
        case idempotencykey = "idempotencyKey"
    }
}

public struct PollParams: Codable, Sendable {
    public let to: String
    public let question: String
    public let options: [String]
    public let maxselections: Int?
    public let durationseconds: Int?
    public let durationhours: Int?
    public let silent: Bool?
    public let isanonymous: Bool?
    public let threadid: String?
    public let channel: String?
    public let accountid: String?
    public let idempotencykey: String

    public init(
        to: String,
        question: String,
        options: [String],
        maxselections: Int? = nil,
        durationseconds: Int? = nil,
        durationhours: Int? = nil,
        silent: Bool? = nil,
        isanonymous: Bool? = nil,
        threadid: String? = nil,
        channel: String? = nil,
        accountid: String? = nil,
        idempotencykey: String)
    {
        self.to = to
        self.question = question
        self.options = options
        self.maxselections = maxselections
        self.durationseconds = durationseconds
        self.durationhours = durationhours
        self.silent = silent
        self.isanonymous = isanonymous
        self.threadid = threadid
        self.channel = channel
        self.accountid = accountid
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case to
        case question
        case options
        case maxselections = "maxSelections"
        case durationseconds = "durationSeconds"
        case durationhours = "durationHours"
        case silent
        case isanonymous = "isAnonymous"
        case threadid = "threadId"
        case channel
        case accountid = "accountId"
        case idempotencykey = "idempotencyKey"
    }
}

public struct AgentParams: Codable, Sendable {
    public let message: String
    public let agentid: String?
    public let provider: String?
    public let model: String?
    public let to: String?
    public let replyto: String?
    public let sessionid: String?
    public let sessionkey: String?
    public let expectedexistingsessionid: String?
    public let thinking: String?
    public let deliver: Bool?
    public let attachments: [AnyCodable]?
    public let channel: String?
    public let replychannel: String?
    public let accountid: String?
    public let replyaccountid: String?
    public let threadid: String?
    public let groupid: String?
    public let groupchannel: String?
    public let groupspace: String?
    public let timeout: Int?
    public let besteffortdeliver: Bool?
    public let lane: String?
    public let cwd: String?
    public let cleanupbundlemcponrunend: Bool?
    public let modelrun: Bool?
    public let promptmode: AnyCodable?
    public let extrasystemprompt: String?
    public let bootstrapcontextmode: AnyCodable?
    public let bootstrapcontextrunkind: AnyCodable?
    public let acpturnsource: String?
    public let internalruntimehandoffid: String?
    public let execapprovalfollowupexpectedsessionid: String?
    public let internalevents: [[String: AnyCodable]]?
    public let inputprovenance: [String: AnyCodable]?
    public let suppresspromptpersistence: Bool?
    public let sessioneffects: AnyCodable?
    public let sourcereplydeliverymode: AnyCodable?
    public let disablemessagetool: Bool?
    public let swarmcollector: Bool?
    public let swarmoutputschema: [String: AnyCodable]?
    public let forcerestartsafetools: Bool?
    public let voicewaketrigger: String?
    public let idempotencykey: String
    public let label: String?

    public init(
        message: String,
        agentid: String? = nil,
        provider: String? = nil,
        model: String? = nil,
        to: String? = nil,
        replyto: String? = nil,
        sessionid: String? = nil,
        sessionkey: String? = nil,
        expectedexistingsessionid: String? = nil,
        thinking: String? = nil,
        deliver: Bool? = nil,
        attachments: [AnyCodable]? = nil,
        channel: String? = nil,
        replychannel: String? = nil,
        accountid: String? = nil,
        replyaccountid: String? = nil,
        threadid: String? = nil,
        groupid: String? = nil,
        groupchannel: String? = nil,
        groupspace: String? = nil,
        timeout: Int? = nil,
        besteffortdeliver: Bool? = nil,
        lane: String? = nil,
        cwd: String? = nil,
        cleanupbundlemcponrunend: Bool? = nil,
        modelrun: Bool? = nil,
        promptmode: AnyCodable? = nil,
        extrasystemprompt: String? = nil,
        bootstrapcontextmode: AnyCodable? = nil,
        bootstrapcontextrunkind: AnyCodable? = nil,
        acpturnsource: String? = nil,
        internalruntimehandoffid: String? = nil,
        execapprovalfollowupexpectedsessionid: String? = nil,
        internalevents: [[String: AnyCodable]]? = nil,
        inputprovenance: [String: AnyCodable]? = nil,
        suppresspromptpersistence: Bool? = nil,
        sessioneffects: AnyCodable? = nil,
        sourcereplydeliverymode: AnyCodable? = nil,
        disablemessagetool: Bool? = nil,
        swarmcollector: Bool? = nil,
        swarmoutputschema: [String: AnyCodable]? = nil,
        forcerestartsafetools: Bool? = nil,
        voicewaketrigger: String? = nil,
        idempotencykey: String,
        label: String? = nil)
    {
        self.message = message
        self.agentid = agentid
        self.provider = provider
        self.model = model
        self.to = to
        self.replyto = replyto
        self.sessionid = sessionid
        self.sessionkey = sessionkey
        self.expectedexistingsessionid = expectedexistingsessionid
        self.thinking = thinking
        self.deliver = deliver
        self.attachments = attachments
        self.channel = channel
        self.replychannel = replychannel
        self.accountid = accountid
        self.replyaccountid = replyaccountid
        self.threadid = threadid
        self.groupid = groupid
        self.groupchannel = groupchannel
        self.groupspace = groupspace
        self.timeout = timeout
        self.besteffortdeliver = besteffortdeliver
        self.lane = lane
        self.cwd = cwd
        self.cleanupbundlemcponrunend = cleanupbundlemcponrunend
        self.modelrun = modelrun
        self.promptmode = promptmode
        self.extrasystemprompt = extrasystemprompt
        self.bootstrapcontextmode = bootstrapcontextmode
        self.bootstrapcontextrunkind = bootstrapcontextrunkind
        self.acpturnsource = acpturnsource
        self.internalruntimehandoffid = internalruntimehandoffid
        self.execapprovalfollowupexpectedsessionid = execapprovalfollowupexpectedsessionid
        self.internalevents = internalevents
        self.inputprovenance = inputprovenance
        self.suppresspromptpersistence = suppresspromptpersistence
        self.sessioneffects = sessioneffects
        self.sourcereplydeliverymode = sourcereplydeliverymode
        self.disablemessagetool = disablemessagetool
        self.swarmcollector = swarmcollector
        self.swarmoutputschema = swarmoutputschema
        self.forcerestartsafetools = forcerestartsafetools
        self.voicewaketrigger = voicewaketrigger
        self.idempotencykey = idempotencykey
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case message
        case agentid = "agentId"
        case provider
        case model
        case to
        case replyto = "replyTo"
        case sessionid = "sessionId"
        case sessionkey = "sessionKey"
        case expectedexistingsessionid = "expectedExistingSessionId"
        case thinking
        case deliver
        case attachments
        case channel
        case replychannel = "replyChannel"
        case accountid = "accountId"
        case replyaccountid = "replyAccountId"
        case threadid = "threadId"
        case groupid = "groupId"
        case groupchannel = "groupChannel"
        case groupspace = "groupSpace"
        case timeout
        case besteffortdeliver = "bestEffortDeliver"
        case lane
        case cwd
        case cleanupbundlemcponrunend = "cleanupBundleMcpOnRunEnd"
        case modelrun = "modelRun"
        case promptmode = "promptMode"
        case extrasystemprompt = "extraSystemPrompt"
        case bootstrapcontextmode = "bootstrapContextMode"
        case bootstrapcontextrunkind = "bootstrapContextRunKind"
        case acpturnsource = "acpTurnSource"
        case internalruntimehandoffid = "internalRuntimeHandoffId"
        case execapprovalfollowupexpectedsessionid = "execApprovalFollowupExpectedSessionId"
        case internalevents = "internalEvents"
        case inputprovenance = "inputProvenance"
        case suppresspromptpersistence = "suppressPromptPersistence"
        case sessioneffects = "sessionEffects"
        case sourcereplydeliverymode = "sourceReplyDeliveryMode"
        case disablemessagetool = "disableMessageTool"
        case swarmcollector = "swarmCollector"
        case swarmoutputschema = "swarmOutputSchema"
        case forcerestartsafetools = "forceRestartSafeTools"
        case voicewaketrigger = "voiceWakeTrigger"
        case idempotencykey = "idempotencyKey"
        case label
    }
}

public struct AgentIdentityParams: Codable, Sendable {
    public let agentid: String?
    public let sessionkey: String?

    public init(
        agentid: String? = nil,
        sessionkey: String? = nil)
    {
        self.agentid = agentid
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sessionkey = "sessionKey"
    }
}

public struct AgentIdentityResult: Codable, Sendable {
    public let agentid: String
    public let name: String?
    public let avatar: String?
    public let avatarsource: String?
    public let avatarstatus: String?
    public let avatarreason: String?
    public let emoji: String?

    public init(
        agentid: String,
        name: String? = nil,
        avatar: String? = nil,
        avatarsource: String? = nil,
        avatarstatus: String? = nil,
        avatarreason: String? = nil,
        emoji: String? = nil)
    {
        self.agentid = agentid
        self.name = name
        self.avatar = avatar
        self.avatarsource = avatarsource
        self.avatarstatus = avatarstatus
        self.avatarreason = avatarreason
        self.emoji = emoji
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case name
        case avatar
        case avatarsource = "avatarSource"
        case avatarstatus = "avatarStatus"
        case avatarreason = "avatarReason"
        case emoji
    }
}

public struct AgentWaitParams: Codable, Sendable {
    public let runid: String
    public let timeoutms: Int?

    public init(
        runid: String,
        timeoutms: Int? = nil)
    {
        self.runid = runid
        self.timeoutms = timeoutms
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case timeoutms = "timeoutMs"
    }
}

public struct WakeParams: Codable, Sendable {
    public let mode: AnyCodable
    public let text: String
    public let sessionkey: String?
    public let agentid: String?

    public init(
        mode: AnyCodable,
        text: String,
        sessionkey: String? = nil,
        agentid: String? = nil)
    {
        self.mode = mode
        self.text = text
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case mode
        case text
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct WorktreeRecord: Codable, Sendable {
    public let id: String
    public let name: String
    public let repofingerprint: String
    public let reporoot: String
    public let path: String
    public let branch: String
    public let baseref: String
    public let ownerkind: String
    public let ownerid: String?
    public let snapshotref: String?
    public let createdat: Int
    public let lastactiveat: Int
    public let removedat: Int?

    public init(
        id: String,
        name: String,
        repofingerprint: String,
        reporoot: String,
        path: String,
        branch: String,
        baseref: String,
        ownerkind: String,
        ownerid: String? = nil,
        snapshotref: String? = nil,
        createdat: Int,
        lastactiveat: Int,
        removedat: Int? = nil)
    {
        self.id = id
        self.name = name
        self.repofingerprint = repofingerprint
        self.reporoot = reporoot
        self.path = path
        self.branch = branch
        self.baseref = baseref
        self.ownerkind = ownerkind
        self.ownerid = ownerid
        self.snapshotref = snapshotref
        self.createdat = createdat
        self.lastactiveat = lastactiveat
        self.removedat = removedat
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case name
        case repofingerprint = "repoFingerprint"
        case reporoot = "repoRoot"
        case path
        case branch
        case baseref = "baseRef"
        case ownerkind = "ownerKind"
        case ownerid = "ownerId"
        case snapshotref = "snapshotRef"
        case createdat = "createdAt"
        case lastactiveat = "lastActiveAt"
        case removedat = "removedAt"
    }
}

public struct WorktreesListParams: Codable, Sendable {}

public struct WorktreesListResult: Codable, Sendable {
    public let worktrees: [WorktreeRecord]

    public init(
        worktrees: [WorktreeRecord])
    {
        self.worktrees = worktrees
    }

    private enum CodingKeys: String, CodingKey {
        case worktrees
    }
}

public struct WorktreesCreateParams: Codable, Sendable {
    public let reporoot: String
    public let name: String?
    public let baseref: String?

    public init(
        reporoot: String,
        name: String? = nil,
        baseref: String? = nil)
    {
        self.reporoot = reporoot
        self.name = name
        self.baseref = baseref
    }

    private enum CodingKeys: String, CodingKey {
        case reporoot = "repoRoot"
        case name
        case baseref = "baseRef"
    }
}

public struct WorktreesRemoveParams: Codable, Sendable {
    public let id: String
    public let force: Bool?

    public init(
        id: String,
        force: Bool? = nil)
    {
        self.id = id
        self.force = force
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case force
    }
}

public struct WorktreesRemoveResult: Codable, Sendable {
    public let removed: Bool
    public let snapshotref: String?
    public let snapshoterror: String?

    public init(
        removed: Bool,
        snapshotref: String? = nil,
        snapshoterror: String? = nil)
    {
        self.removed = removed
        self.snapshotref = snapshotref
        self.snapshoterror = snapshoterror
    }

    private enum CodingKeys: String, CodingKey {
        case removed
        case snapshotref = "snapshotRef"
        case snapshoterror = "snapshotError"
    }
}

public struct WorktreesRestoreParams: Codable, Sendable {
    public let id: String

    public init(
        id: String)
    {
        self.id = id
    }

    private enum CodingKeys: String, CodingKey {
        case id
    }
}

public struct WorktreesGcParams: Codable, Sendable {}

public struct WorktreesGcResult: Codable, Sendable {
    public let removed: [String]
    public let orphansdeleted: Int
    public let snapshotspruned: Int

    public init(
        removed: [String],
        orphansdeleted: Int,
        snapshotspruned: Int)
    {
        self.removed = removed
        self.orphansdeleted = orphansdeleted
        self.snapshotspruned = snapshotspruned
    }

    private enum CodingKeys: String, CodingKey {
        case removed
        case orphansdeleted = "orphansDeleted"
        case snapshotspruned = "snapshotsPruned"
    }
}

public struct WorktreeBranch: Codable, Sendable {
    public let name: String
    public let kind: AnyCodable

    public init(
        name: String,
        kind: AnyCodable)
    {
        self.name = name
        self.kind = kind
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case kind
    }
}

public struct WorktreesBranchesParams: Codable, Sendable {
    public let reporoot: String
    public let includerepositorystatus: Bool?

    public init(
        reporoot: String,
        includerepositorystatus: Bool? = nil)
    {
        self.reporoot = reporoot
        self.includerepositorystatus = includerepositorystatus
    }

    private enum CodingKeys: String, CodingKey {
        case reporoot = "repoRoot"
        case includerepositorystatus = "includeRepositoryStatus"
    }
}

public struct WorktreesBranchesResult: Codable, Sendable {
    public let branches: [WorktreeBranch]
    public let defaultbranch: String?
    public let headbranch: String?
    public let repositorystatus: WorktreeRepositoryStatus?

    public init(
        branches: [WorktreeBranch],
        defaultbranch: String? = nil,
        headbranch: String? = nil,
        repositorystatus: WorktreeRepositoryStatus? = nil)
    {
        self.branches = branches
        self.defaultbranch = defaultbranch
        self.headbranch = headbranch
        self.repositorystatus = repositorystatus
    }

    private enum CodingKeys: String, CodingKey {
        case branches
        case defaultbranch = "defaultBranch"
        case headbranch = "headBranch"
        case repositorystatus = "repositoryStatus"
    }
}

public struct FsDirEntry: Codable, Sendable {
    public let name: String
    public let path: String
    public let hidden: Bool?

    public init(
        name: String,
        path: String,
        hidden: Bool? = nil)
    {
        self.name = name
        self.path = path
        self.hidden = hidden
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case path
        case hidden
    }
}

public struct FsListDirParams: Codable, Sendable {
    public let path: String?
    public let nodeid: String?

    public init(
        path: String? = nil,
        nodeid: String? = nil)
    {
        self.path = path
        self.nodeid = nodeid
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case nodeid = "nodeId"
    }
}

public struct FsListDirResult: Codable, Sendable {
    public let path: String
    public let parent: String?
    public let home: String
    public let entries: [FsDirEntry]

    public init(
        path: String,
        parent: String? = nil,
        home: String,
        entries: [FsDirEntry])
    {
        self.path = path
        self.parent = parent
        self.home = home
        self.entries = entries
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case parent
        case home
        case entries
    }
}

public struct NodePairListParams: Codable, Sendable {}

public struct NodePairApproveParams: Codable, Sendable {
    public let requestid: String

    public init(
        requestid: String)
    {
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
    }
}

public struct NodePairRejectParams: Codable, Sendable {
    public let requestid: String

    public init(
        requestid: String)
    {
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
    }
}

public struct NodePairRemoveParams: Codable, Sendable {
    public let nodeid: String

    public init(
        nodeid: String)
    {
        self.nodeid = nodeid
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
    }
}

public struct NodeRenameParams: Codable, Sendable {
    public let nodeid: String
    public let displayname: String

    public init(
        nodeid: String,
        displayname: String)
    {
        self.nodeid = nodeid
        self.displayname = displayname
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case displayname = "displayName"
    }
}

public struct NodeListParams: Codable, Sendable {}

public struct NodePluginToolDescriptor: Codable, Sendable {
    public let pluginid: String
    public let name: String
    public let description: String
    public let parameters: [String: AnyCodable]?
    public let command: String?
    public let mcp: [String: AnyCodable]?

    public init(
        pluginid: String,
        name: String,
        description: String,
        parameters: [String: AnyCodable]? = nil,
        command: String? = nil,
        mcp: [String: AnyCodable]? = nil)
    {
        self.pluginid = pluginid
        self.name = name
        self.description = description
        self.parameters = parameters
        self.command = command
        self.mcp = mcp
    }

    private enum CodingKeys: String, CodingKey {
        case pluginid = "pluginId"
        case name
        case description
        case parameters
        case command
        case mcp
    }
}

public struct NodePluginToolsUpdateParams: Codable, Sendable {
    public let tools: [NodePluginToolDescriptor]

    public init(
        tools: [NodePluginToolDescriptor])
    {
        self.tools = tools
    }

    private enum CodingKeys: String, CodingKey {
        case tools
    }
}

public struct NodeSkillDescriptor: Codable, Sendable {
    public let name: String
    public let description: String
    public let content: String

    public init(
        name: String,
        description: String,
        content: String)
    {
        self.name = name
        self.description = description
        self.content = content
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case description
        case content
    }
}

public struct NodeSkillsUpdateParams: Codable, Sendable {
    public let skills: [NodeSkillDescriptor]

    public init(
        skills: [NodeSkillDescriptor])
    {
        self.skills = skills
    }

    private enum CodingKeys: String, CodingKey {
        case skills
    }
}

public struct NodePendingAckParams: Codable, Sendable {
    public let ids: [String]

    public init(
        ids: [String])
    {
        self.ids = ids
    }

    private enum CodingKeys: String, CodingKey {
        case ids
    }
}

public struct NodeDescribeParams: Codable, Sendable {
    public let nodeid: String

    public init(
        nodeid: String)
    {
        self.nodeid = nodeid
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
    }
}

public struct NodeInvokeParams: Codable, Sendable {
    public let nodeid: String
    public let command: String
    public let params: AnyCodable?
    public let timeoutms: Int?
    public let idempotencykey: String
    public let sessionkey: String?
    public let turnsourcechannel: String?
    public let turnsourceto: String?
    public let turnsourceaccountid: String?
    public let turnsourcethreadid: AnyCodable?

    public init(
        nodeid: String,
        command: String,
        params: AnyCodable? = nil,
        timeoutms: Int? = nil,
        idempotencykey: String,
        sessionkey: String? = nil,
        turnsourcechannel: String? = nil,
        turnsourceto: String? = nil,
        turnsourceaccountid: String? = nil,
        turnsourcethreadid: AnyCodable? = nil)
    {
        self.nodeid = nodeid
        self.command = command
        self.params = params
        self.timeoutms = timeoutms
        self.idempotencykey = idempotencykey
        self.sessionkey = sessionkey
        self.turnsourcechannel = turnsourcechannel
        self.turnsourceto = turnsourceto
        self.turnsourceaccountid = turnsourceaccountid
        self.turnsourcethreadid = turnsourcethreadid
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case command
        case params
        case timeoutms = "timeoutMs"
        case idempotencykey = "idempotencyKey"
        case sessionkey = "sessionKey"
        case turnsourcechannel = "turnSourceChannel"
        case turnsourceto = "turnSourceTo"
        case turnsourceaccountid = "turnSourceAccountId"
        case turnsourcethreadid = "turnSourceThreadId"
    }
}

public struct NodeInvokeInputEvent: Codable, Sendable {
    public let id: String
    public let nodeid: String
    public let seq: Int
    public let payloadjson: String

    public init(
        id: String,
        nodeid: String,
        seq: Int,
        payloadjson: String)
    {
        self.id = id
        self.nodeid = nodeid
        self.seq = seq
        self.payloadjson = payloadjson
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case nodeid = "nodeId"
        case seq
        case payloadjson = "payloadJSON"
    }
}

public struct NodeInvokeProgressParams: Codable, Sendable {
    public let invokeid: String
    public let nodeid: String
    public let seq: Int
    public let chunk: String

    public init(
        invokeid: String,
        nodeid: String,
        seq: Int,
        chunk: String)
    {
        self.invokeid = invokeid
        self.nodeid = nodeid
        self.seq = seq
        self.chunk = chunk
    }

    private enum CodingKeys: String, CodingKey {
        case invokeid = "invokeId"
        case nodeid = "nodeId"
        case seq
        case chunk
    }
}

public struct NodeInvokeResultParams: Codable, Sendable {
    public let id: String
    public let nodeid: String
    public let ok: Bool
    public let payload: AnyCodable?
    public let payloadjson: String?
    public let error: [String: AnyCodable]?

    public init(
        id: String,
        nodeid: String,
        ok: Bool,
        payload: AnyCodable? = nil,
        payloadjson: String? = nil,
        error: [String: AnyCodable]? = nil)
    {
        self.id = id
        self.nodeid = nodeid
        self.ok = ok
        self.payload = payload
        self.payloadjson = payloadjson
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case nodeid = "nodeId"
        case ok
        case payload
        case payloadjson = "payloadJSON"
        case error
    }
}

public struct NodeInvokeRequestEvent: Codable, Sendable {
    public let id: String
    public let nodeid: String
    public let command: String
    public let paramsjson: String?
    public let timeoutms: Int?
    public let idempotencykey: String?

    public init(
        id: String,
        nodeid: String,
        command: String,
        paramsjson: String? = nil,
        timeoutms: Int? = nil,
        idempotencykey: String? = nil)
    {
        self.id = id
        self.nodeid = nodeid
        self.command = command
        self.paramsjson = paramsjson
        self.timeoutms = timeoutms
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case nodeid = "nodeId"
        case command
        case paramsjson = "paramsJSON"
        case timeoutms = "timeoutMs"
        case idempotencykey = "idempotencyKey"
    }
}

public struct NodeEventParams: Codable, Sendable {
    public let event: String
    public let payload: AnyCodable?
    public let payloadjson: String?

    public init(
        event: String,
        payload: AnyCodable? = nil,
        payloadjson: String? = nil)
    {
        self.event = event
        self.payload = payload
        self.payloadjson = payloadjson
    }

    private enum CodingKeys: String, CodingKey {
        case event
        case payload
        case payloadjson = "payloadJSON"
    }
}

public struct NodeEventResult: Codable, Sendable {
    public let ok: Bool
    public let event: String
    public let handled: Bool
    public let reason: String?

    public init(
        ok: Bool,
        event: String,
        handled: Bool,
        reason: String? = nil)
    {
        self.ok = ok
        self.event = event
        self.handled = handled
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case event
        case handled
        case reason
    }
}

public struct NodePresenceAlivePayload: Codable, Sendable {
    public let trigger: NodePresenceAliveReason
    public let sentatms: Int?
    public let displayname: String?
    public let version: String?
    public let platform: String?
    public let devicefamily: String?
    public let modelidentifier: String?
    public let pushtransport: String?

    public init(
        trigger: NodePresenceAliveReason,
        sentatms: Int? = nil,
        displayname: String? = nil,
        version: String? = nil,
        platform: String? = nil,
        devicefamily: String? = nil,
        modelidentifier: String? = nil,
        pushtransport: String? = nil)
    {
        self.trigger = trigger
        self.sentatms = sentatms
        self.displayname = displayname
        self.version = version
        self.platform = platform
        self.devicefamily = devicefamily
        self.modelidentifier = modelidentifier
        self.pushtransport = pushtransport
    }

    private enum CodingKeys: String, CodingKey {
        case trigger
        case sentatms = "sentAtMs"
        case displayname = "displayName"
        case version
        case platform
        case devicefamily = "deviceFamily"
        case modelidentifier = "modelIdentifier"
        case pushtransport = "pushTransport"
    }
}

public struct NodePendingDrainParams: Codable, Sendable {
    public let maxitems: Int?

    public init(
        maxitems: Int? = nil)
    {
        self.maxitems = maxitems
    }

    private enum CodingKeys: String, CodingKey {
        case maxitems = "maxItems"
    }
}

public struct NodePendingDrainResult: Codable, Sendable {
    public let nodeid: String
    public let revision: Int
    public let items: [[String: AnyCodable]]
    public let hasmore: Bool

    public init(
        nodeid: String,
        revision: Int,
        items: [[String: AnyCodable]],
        hasmore: Bool)
    {
        self.nodeid = nodeid
        self.revision = revision
        self.items = items
        self.hasmore = hasmore
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case revision
        case items
        case hasmore = "hasMore"
    }
}

public struct NodePendingEnqueueParams: Codable, Sendable {
    public let nodeid: String
    public let type: String
    public let priority: String?
    public let expiresinms: Int?
    public let wake: Bool?

    public init(
        nodeid: String,
        type: String,
        priority: String? = nil,
        expiresinms: Int? = nil,
        wake: Bool? = nil)
    {
        self.nodeid = nodeid
        self.type = type
        self.priority = priority
        self.expiresinms = expiresinms
        self.wake = wake
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case type
        case priority
        case expiresinms = "expiresInMs"
        case wake
    }
}

public struct NodePendingEnqueueResult: Codable, Sendable {
    public let nodeid: String
    public let revision: Int
    public let queued: [String: AnyCodable]
    public let waketriggered: Bool

    public init(
        nodeid: String,
        revision: Int,
        queued: [String: AnyCodable],
        waketriggered: Bool)
    {
        self.nodeid = nodeid
        self.revision = revision
        self.queued = queued
        self.waketriggered = waketriggered
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case revision
        case queued
        case waketriggered = "wakeTriggered"
    }
}

public struct PushTestParams: Codable, Sendable {
    public let nodeid: String
    public let title: String?
    public let body: String?
    public let environment: String?

    public init(
        nodeid: String,
        title: String? = nil,
        body: String? = nil,
        environment: String? = nil)
    {
        self.nodeid = nodeid
        self.title = title
        self.body = body
        self.environment = environment
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case title
        case body
        case environment
    }
}

public struct PushTestResult: Codable, Sendable {
    public let ok: Bool
    public let status: Int
    public let apnsid: String?
    public let reason: String?
    public let tokensuffix: String
    public let topic: String
    public let environment: String
    public let transport: String

    public init(
        ok: Bool,
        status: Int,
        apnsid: String? = nil,
        reason: String? = nil,
        tokensuffix: String,
        topic: String,
        environment: String,
        transport: String)
    {
        self.ok = ok
        self.status = status
        self.apnsid = apnsid
        self.reason = reason
        self.tokensuffix = tokensuffix
        self.topic = topic
        self.environment = environment
        self.transport = transport
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case status
        case apnsid = "apnsId"
        case reason
        case tokensuffix = "tokenSuffix"
        case topic
        case environment
        case transport
    }
}

public struct UiSplitCommand: Codable, Sendable {
    public let kind: String
    public let direction: AnyCodable
    public let sessionkey: String

    public init(
        kind: String,
        direction: AnyCodable,
        sessionkey: String)
    {
        self.kind = kind
        self.direction = direction
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case direction
        case sessionkey = "sessionKey"
    }
}

public struct UiClosePaneCommand: Codable, Sendable {
    public let kind: String
    public let sessionkey: String

    public init(
        kind: String,
        sessionkey: String)
    {
        self.kind = kind
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case sessionkey = "sessionKey"
    }
}

public struct UiFocusCommand: Codable, Sendable {
    public let kind: String
    public let sessionkey: String

    public init(
        kind: String,
        sessionkey: String)
    {
        self.kind = kind
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case sessionkey = "sessionKey"
    }
}

public struct UiSidebarCommand: Codable, Sendable {
    public let kind: String
    public let visible: Bool

    public init(
        kind: String,
        visible: Bool)
    {
        self.kind = kind
        self.visible = visible
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case visible
    }
}

public struct UiPanelCommand: Codable, Sendable {
    public let kind: String
    public let panel: AnyCodable
    public let _open: Bool
    public let dock: AnyCodable?
    public let terminalsessionid: String?

    public init(
        kind: String,
        panel: AnyCodable,
        _open: Bool,
        dock: AnyCodable? = nil,
        terminalsessionid: String? = nil)
    {
        self.kind = kind
        self.panel = panel
        self._open = _open
        self.dock = dock
        self.terminalsessionid = terminalsessionid
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case panel
        case _open = "open"
        case dock
        case terminalsessionid = "terminalSessionId"
    }
}

public struct UiNavigateCommand: Codable, Sendable {
    public let kind: String
    public let sessionkey: String

    public init(
        kind: String,
        sessionkey: String)
    {
        self.kind = kind
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case sessionkey = "sessionKey"
    }
}

public struct UiCommandParams: Codable, Sendable {
    public let command: UiCommand
    public let sessionkey: String?

    public init(
        command: UiCommand,
        sessionkey: String? = nil)
    {
        self.command = command
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case command
        case sessionkey = "sessionKey"
    }
}

public struct UiCommandResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct SecretsReloadParams: Codable, Sendable {}

public struct SecretsResolveParams: Codable, Sendable {
    public let commandname: String
    public let targetids: [String]
    public let allowedpaths: [String]?
    public let forcedactivepaths: [String]?
    public let optionalactivepaths: [String]?
    public let provideroverrides: [String: AnyCodable]?

    public init(
        commandname: String,
        targetids: [String],
        allowedpaths: [String]? = nil,
        forcedactivepaths: [String]? = nil,
        optionalactivepaths: [String]? = nil,
        provideroverrides: [String: AnyCodable]? = nil)
    {
        self.commandname = commandname
        self.targetids = targetids
        self.allowedpaths = allowedpaths
        self.forcedactivepaths = forcedactivepaths
        self.optionalactivepaths = optionalactivepaths
        self.provideroverrides = provideroverrides
    }

    private enum CodingKeys: String, CodingKey {
        case commandname = "commandName"
        case targetids = "targetIds"
        case allowedpaths = "allowedPaths"
        case forcedactivepaths = "forcedActivePaths"
        case optionalactivepaths = "optionalActivePaths"
        case provideroverrides = "providerOverrides"
    }
}

public struct SecretsResolveAssignment: Codable, Sendable {
    public let path: String?
    public let pathsegments: [String]
    public let value: AnyCodable

    public init(
        path: String? = nil,
        pathsegments: [String],
        value: AnyCodable)
    {
        self.path = path
        self.pathsegments = pathsegments
        self.value = value
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case pathsegments = "pathSegments"
        case value
    }
}

public struct SecretsResolveResult: Codable, Sendable {
    public let ok: Bool?
    public let assignments: [SecretsResolveAssignment]?
    public let diagnostics: [String]?
    public let inactiverefpaths: [String]?

    public init(
        ok: Bool? = nil,
        assignments: [SecretsResolveAssignment]? = nil,
        diagnostics: [String]? = nil,
        inactiverefpaths: [String]? = nil)
    {
        self.ok = ok
        self.assignments = assignments
        self.diagnostics = diagnostics
        self.inactiverefpaths = inactiverefpaths
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case assignments
        case diagnostics
        case inactiverefpaths = "inactiveRefPaths"
    }
}

public struct SessionsListParams: Codable, Sendable {
    public let limit: Int?
    public let offset: Int?
    public let activeminutes: Int?
    public let requirelastinteraction: Bool?
    public let sortby: AnyCodable?
    public let includeglobal: Bool?
    public let includeunknown: Bool?
    public let configuredagentsonly: Bool?
    public let includederivedtitles: Bool?
    public let includelastmessage: Bool?
    public let label: String?
    public let creatorid: String?
    public let spawnedby: String?
    public let agentid: String?
    public let search: String?
    public let archived: AnyCodable?

    public init(
        limit: Int? = nil,
        offset: Int? = nil,
        activeminutes: Int? = nil,
        requirelastinteraction: Bool? = nil,
        sortby: AnyCodable? = nil,
        includeglobal: Bool? = nil,
        includeunknown: Bool? = nil,
        configuredagentsonly: Bool? = nil,
        includederivedtitles: Bool? = nil,
        includelastmessage: Bool? = nil,
        label: String? = nil,
        creatorid: String? = nil,
        spawnedby: String? = nil,
        agentid: String? = nil,
        search: String? = nil,
        archived: AnyCodable? = nil)
    {
        self.limit = limit
        self.offset = offset
        self.activeminutes = activeminutes
        self.requirelastinteraction = requirelastinteraction
        self.sortby = sortby
        self.includeglobal = includeglobal
        self.includeunknown = includeunknown
        self.configuredagentsonly = configuredagentsonly
        self.includederivedtitles = includederivedtitles
        self.includelastmessage = includelastmessage
        self.label = label
        self.creatorid = creatorid
        self.spawnedby = spawnedby
        self.agentid = agentid
        self.search = search
        self.archived = archived
    }

    private enum CodingKeys: String, CodingKey {
        case limit
        case offset
        case activeminutes = "activeMinutes"
        case requirelastinteraction = "requireLastInteraction"
        case sortby = "sortBy"
        case includeglobal = "includeGlobal"
        case includeunknown = "includeUnknown"
        case configuredagentsonly = "configuredAgentsOnly"
        case includederivedtitles = "includeDerivedTitles"
        case includelastmessage = "includeLastMessage"
        case label
        case creatorid = "creatorId"
        case spawnedby = "spawnedBy"
        case agentid = "agentId"
        case search
        case archived
    }
}

public struct SessionCatalogCapabilities: Codable, Sendable {
    public let continuesession: Bool
    public let archive: Bool
    public let createsession: [String: AnyCodable]?
    public let openterminal: Bool?

    public init(
        continuesession: Bool,
        archive: Bool,
        createsession: [String: AnyCodable]? = nil,
        openterminal: Bool? = nil)
    {
        self.continuesession = continuesession
        self.archive = archive
        self.createsession = createsession
        self.openterminal = openterminal
    }

    private enum CodingKeys: String, CodingKey {
        case continuesession = "continueSession"
        case archive
        case createsession = "createSession"
        case openterminal = "openTerminal"
    }
}

public struct SessionCatalogDescriptor: Codable, Sendable {
    public let id: String
    public let label: String
    public let capabilities: SessionCatalogCapabilities

    public init(
        id: String,
        label: String,
        capabilities: SessionCatalogCapabilities)
    {
        self.id = id
        self.label = label
        self.capabilities = capabilities
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case capabilities
    }
}

public struct SessionCatalogPullRequestSummary: Codable, Sendable {
    public let numbers: [Int]
    public let state: AnyCodable

    public init(
        numbers: [Int],
        state: AnyCodable)
    {
        self.numbers = numbers
        self.state = state
    }

    private enum CodingKeys: String, CodingKey {
        case numbers
        case state
    }
}

public struct SessionCatalogSession: Codable, Sendable {
    public let threadid: String
    public let name: String?
    public let cwd: String?
    public let status: String
    public let createdat: Double?
    public let updatedat: Double?
    public let recencyat: Double?
    public let source: String?
    public let modelprovider: String?
    public let cliversion: String?
    public let gitbranch: String?
    public let customgroup: String?
    public let pullrequest: SessionCatalogPullRequestSummary?
    public let archived: Bool
    public let sessionkey: String?
    public let createdactor: SessionCreatedActor?
    public let cancontinue: Bool
    public let canarchive: Bool
    public let canopenterminal: Bool?

    public init(
        threadid: String,
        name: String? = nil,
        cwd: String? = nil,
        status: String,
        createdat: Double? = nil,
        updatedat: Double? = nil,
        recencyat: Double? = nil,
        source: String? = nil,
        modelprovider: String? = nil,
        cliversion: String? = nil,
        gitbranch: String? = nil,
        customgroup: String? = nil,
        pullrequest: SessionCatalogPullRequestSummary? = nil,
        archived: Bool,
        sessionkey: String? = nil,
        createdactor: SessionCreatedActor? = nil,
        cancontinue: Bool,
        canarchive: Bool,
        canopenterminal: Bool? = nil)
    {
        self.threadid = threadid
        self.name = name
        self.cwd = cwd
        self.status = status
        self.createdat = createdat
        self.updatedat = updatedat
        self.recencyat = recencyat
        self.source = source
        self.modelprovider = modelprovider
        self.cliversion = cliversion
        self.gitbranch = gitbranch
        self.customgroup = customgroup
        self.pullrequest = pullrequest
        self.archived = archived
        self.sessionkey = sessionkey
        self.createdactor = createdactor
        self.cancontinue = cancontinue
        self.canarchive = canarchive
        self.canopenterminal = canopenterminal
    }

    private enum CodingKeys: String, CodingKey {
        case threadid = "threadId"
        case name
        case cwd
        case status
        case createdat = "createdAt"
        case updatedat = "updatedAt"
        case recencyat = "recencyAt"
        case source
        case modelprovider = "modelProvider"
        case cliversion = "cliVersion"
        case gitbranch = "gitBranch"
        case customgroup = "customGroup"
        case pullrequest = "pullRequest"
        case archived
        case sessionkey = "sessionKey"
        case createdactor = "createdActor"
        case cancontinue = "canContinue"
        case canarchive = "canArchive"
        case canopenterminal = "canOpenTerminal"
    }
}

public struct SessionCatalogHost: Codable, Sendable {
    public let hostid: String
    public let label: String
    public let kind: AnyCodable
    public let connected: Bool
    public let nodeid: String?
    public let sessions: [SessionCatalogSession]
    public let nextcursor: String?
    public let error: [String: AnyCodable]?

    public init(
        hostid: String,
        label: String,
        kind: AnyCodable,
        connected: Bool,
        nodeid: String? = nil,
        sessions: [SessionCatalogSession],
        nextcursor: String? = nil,
        error: [String: AnyCodable]? = nil)
    {
        self.hostid = hostid
        self.label = label
        self.kind = kind
        self.connected = connected
        self.nodeid = nodeid
        self.sessions = sessions
        self.nextcursor = nextcursor
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case hostid = "hostId"
        case label
        case kind
        case connected
        case nodeid = "nodeId"
        case sessions
        case nextcursor = "nextCursor"
        case error
    }
}

public struct SessionCatalog: Codable, Sendable {
    public let id: String
    public let label: String
    public let capabilities: SessionCatalogCapabilities
    public let hosts: [SessionCatalogHost]
    public let error: [String: AnyCodable]?

    public init(
        id: String,
        label: String,
        capabilities: SessionCatalogCapabilities,
        hosts: [SessionCatalogHost],
        error: [String: AnyCodable]? = nil)
    {
        self.id = id
        self.label = label
        self.capabilities = capabilities
        self.hosts = hosts
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case capabilities
        case hosts
        case error
    }
}

public struct SessionCatalogTranscriptItem: Codable, Sendable {
    public let id: String?
    public let type: AnyCodable
    public let text: String?
    public let timestamp: String?
    public let model: String?
    public let truncated: Bool?
    public let raw: AnyCodable?

    public init(
        id: String? = nil,
        type: AnyCodable,
        text: String? = nil,
        timestamp: String? = nil,
        model: String? = nil,
        truncated: Bool? = nil,
        raw: AnyCodable? = nil)
    {
        self.id = id
        self.type = type
        self.text = text
        self.timestamp = timestamp
        self.model = model
        self.truncated = truncated
        self.raw = raw
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case text
        case timestamp
        case model
        case truncated
        case raw
    }
}

public struct SessionsCatalogListParams: Codable, Sendable {
    public let catalogid: String?
    public let cursors: [String: AnyCodable]?
    public let agentid: String?
    public let progressid: String?
    public let search: String?
    public let limitperhost: Int?
    public let hostids: [String]?

    public init(
        catalogid: String? = nil,
        cursors: [String: AnyCodable]? = nil,
        agentid: String? = nil,
        progressid: String? = nil,
        search: String? = nil,
        limitperhost: Int? = nil,
        hostids: [String]? = nil)
    {
        self.catalogid = catalogid
        self.cursors = cursors
        self.agentid = agentid
        self.progressid = progressid
        self.search = search
        self.limitperhost = limitperhost
        self.hostids = hostids
    }

    private enum CodingKeys: String, CodingKey {
        case catalogid = "catalogId"
        case cursors
        case agentid = "agentId"
        case progressid = "progressId"
        case search
        case limitperhost = "limitPerHost"
        case hostids = "hostIds"
    }
}

public struct SessionsCatalogListResult: Codable, Sendable {
    public let catalogs: [SessionCatalog]

    public init(
        catalogs: [SessionCatalog])
    {
        self.catalogs = catalogs
    }

    private enum CodingKeys: String, CodingKey {
        case catalogs
    }
}

public struct SessionsCatalogReadParams: Codable, Sendable {
    public let catalogid: String
    public let hostid: String
    public let threadid: String
    public let limit: Int?
    public let cursor: String?

    public init(
        catalogid: String,
        hostid: String,
        threadid: String,
        limit: Int? = nil,
        cursor: String? = nil)
    {
        self.catalogid = catalogid
        self.hostid = hostid
        self.threadid = threadid
        self.limit = limit
        self.cursor = cursor
    }

    private enum CodingKeys: String, CodingKey {
        case catalogid = "catalogId"
        case hostid = "hostId"
        case threadid = "threadId"
        case limit
        case cursor
    }
}

public struct SessionsCatalogReadResult: Codable, Sendable {
    public let hostid: String
    public let label: String?
    public let threadid: String
    public let items: [SessionCatalogTranscriptItem]
    public let nextcursor: String?

    public init(
        hostid: String,
        label: String? = nil,
        threadid: String,
        items: [SessionCatalogTranscriptItem],
        nextcursor: String? = nil)
    {
        self.hostid = hostid
        self.label = label
        self.threadid = threadid
        self.items = items
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case hostid = "hostId"
        case label
        case threadid = "threadId"
        case items
        case nextcursor = "nextCursor"
    }
}

public struct SessionsCatalogContinueParams: Codable, Sendable {
    public let catalogid: String
    public let hostid: String
    public let threadid: String

    public init(
        catalogid: String,
        hostid: String,
        threadid: String)
    {
        self.catalogid = catalogid
        self.hostid = hostid
        self.threadid = threadid
    }

    private enum CodingKeys: String, CodingKey {
        case catalogid = "catalogId"
        case hostid = "hostId"
        case threadid = "threadId"
    }
}

public struct SessionsCatalogContinueResult: Codable, Sendable {
    public let sessionkey: String

    public init(
        sessionkey: String)
    {
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
    }
}

public struct SessionsCatalogArchiveParams: Codable, Sendable {
    public let catalogid: String
    public let hostid: String
    public let threadid: String
    public let confirmnootherrunner: Bool

    public init(
        catalogid: String,
        hostid: String,
        threadid: String,
        confirmnootherrunner: Bool)
    {
        self.catalogid = catalogid
        self.hostid = hostid
        self.threadid = threadid
        self.confirmnootherrunner = confirmnootherrunner
    }

    private enum CodingKeys: String, CodingKey {
        case catalogid = "catalogId"
        case hostid = "hostId"
        case threadid = "threadId"
        case confirmnootherrunner = "confirmNoOtherRunner"
    }
}

public struct SessionsCatalogArchiveResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct SessionsCleanupParams: Codable, Sendable {
    public let agent: String?
    public let allagents: Bool?
    public let enforce: Bool?
    public let activekey: String?
    public let fixmissing: Bool?
    public let fixdmscope: Bool?

    public init(
        agent: String? = nil,
        allagents: Bool? = nil,
        enforce: Bool? = nil,
        activekey: String? = nil,
        fixmissing: Bool? = nil,
        fixdmscope: Bool? = nil)
    {
        self.agent = agent
        self.allagents = allagents
        self.enforce = enforce
        self.activekey = activekey
        self.fixmissing = fixmissing
        self.fixdmscope = fixdmscope
    }

    private enum CodingKeys: String, CodingKey {
        case agent
        case allagents = "allAgents"
        case enforce
        case activekey = "activeKey"
        case fixmissing = "fixMissing"
        case fixdmscope = "fixDmScope"
    }
}

public struct SessionsPreviewParams: Codable, Sendable {
    public let keys: [String]
    public let limit: Int?
    public let maxchars: Int?

    public init(
        keys: [String],
        limit: Int? = nil,
        maxchars: Int? = nil)
    {
        self.keys = keys
        self.limit = limit
        self.maxchars = maxchars
    }

    private enum CodingKeys: String, CodingKey {
        case keys
        case limit
        case maxchars = "maxChars"
    }
}

public struct SessionsDescribeParams: Codable, Sendable {
    public let key: String
    public let includederivedtitles: Bool?
    public let includelastmessage: Bool?

    public init(
        key: String,
        includederivedtitles: Bool? = nil,
        includelastmessage: Bool? = nil)
    {
        self.key = key
        self.includederivedtitles = includederivedtitles
        self.includelastmessage = includelastmessage
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case includederivedtitles = "includeDerivedTitles"
        case includelastmessage = "includeLastMessage"
    }
}

public struct SessionsResolveParams: Codable, Sendable {
    public let key: String?
    public let sessionid: String?
    public let label: String?
    public let agentid: String?
    public let spawnedby: String?
    public let includeglobal: Bool?
    public let includeunknown: Bool?
    public let allowmissing: Bool?

    public init(
        key: String? = nil,
        sessionid: String? = nil,
        label: String? = nil,
        agentid: String? = nil,
        spawnedby: String? = nil,
        includeglobal: Bool? = nil,
        includeunknown: Bool? = nil,
        allowmissing: Bool? = nil)
    {
        self.key = key
        self.sessionid = sessionid
        self.label = label
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.includeglobal = includeglobal
        self.includeunknown = includeunknown
        self.allowmissing = allowmissing
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case sessionid = "sessionId"
        case label
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case includeglobal = "includeGlobal"
        case includeunknown = "includeUnknown"
        case allowmissing = "allowMissing"
    }
}

public struct SessionsSearchHit: Codable, Sendable {
    public let sessionkey: String
    public let sessionid: String
    public let messageid: String
    public let role: AnyCodable
    public let timestamp: Int
    public let snippet: String
    public let score: Double

    public init(
        sessionkey: String,
        sessionid: String,
        messageid: String,
        role: AnyCodable,
        timestamp: Int,
        snippet: String,
        score: Double)
    {
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.messageid = messageid
        self.role = role
        self.timestamp = timestamp
        self.snippet = snippet
        self.score = score
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case messageid = "messageId"
        case role
        case timestamp
        case snippet
        case score
    }
}

public struct SessionsSearchParams: Codable, Sendable {
    public let agentid: String?
    public let sessionkeys: [String]?
    public let query: String
    public let limit: Int?

    public init(
        agentid: String? = nil,
        sessionkeys: [String]? = nil,
        query: String,
        limit: Int? = nil)
    {
        self.agentid = agentid
        self.sessionkeys = sessionkeys
        self.query = query
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sessionkeys = "sessionKeys"
        case query
        case limit
    }
}

public struct SessionsSearchResult: Codable, Sendable {
    public let results: [SessionsSearchHit]
    public let indexing: Bool?
    public let truncated: Bool?

    public init(
        results: [SessionsSearchHit],
        indexing: Bool? = nil,
        truncated: Bool? = nil)
    {
        self.results = results
        self.indexing = indexing
        self.truncated = truncated
    }

    private enum CodingKeys: String, CodingKey {
        case results
        case indexing
        case truncated
    }
}

public struct SessionCompactionCheckpoint: Codable, Sendable {
    public let checkpointid: String
    public let sessionkey: String
    public let sessionid: String
    public let createdat: Int
    public let reason: AnyCodable
    public let tokensbefore: Int?
    public let tokensafter: Int?
    public let summary: String?
    public let firstkeptentryid: String?
    public let precompaction: [String: AnyCodable]
    public let postcompaction: [String: AnyCodable]

    public init(
        checkpointid: String,
        sessionkey: String,
        sessionid: String,
        createdat: Int,
        reason: AnyCodable,
        tokensbefore: Int? = nil,
        tokensafter: Int? = nil,
        summary: String? = nil,
        firstkeptentryid: String? = nil,
        precompaction: [String: AnyCodable],
        postcompaction: [String: AnyCodable])
    {
        self.checkpointid = checkpointid
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.createdat = createdat
        self.reason = reason
        self.tokensbefore = tokensbefore
        self.tokensafter = tokensafter
        self.summary = summary
        self.firstkeptentryid = firstkeptentryid
        self.precompaction = precompaction
        self.postcompaction = postcompaction
    }

    private enum CodingKeys: String, CodingKey {
        case checkpointid = "checkpointId"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case createdat = "createdAt"
        case reason
        case tokensbefore = "tokensBefore"
        case tokensafter = "tokensAfter"
        case summary
        case firstkeptentryid = "firstKeptEntryId"
        case precompaction = "preCompaction"
        case postcompaction = "postCompaction"
    }
}

public struct SessionOperationEvent: Codable, Sendable {
    public let operationid: String
    public let operation: String
    public let phase: AnyCodable
    public let sessionkey: String
    public let agentid: String?
    public let ts: Int
    public let completed: Bool?
    public let reason: String?

    public init(
        operationid: String,
        operation: String,
        phase: AnyCodable,
        sessionkey: String,
        agentid: String? = nil,
        ts: Int,
        completed: Bool? = nil,
        reason: String? = nil)
    {
        self.operationid = operationid
        self.operation = operation
        self.phase = phase
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.ts = ts
        self.completed = completed
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case operationid = "operationId"
        case operation
        case phase
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case ts
        case completed
        case reason
    }
}

public struct SessionCreatedActor: Codable, Sendable {
    public let type: AnyCodable
    public let id: String?
    public let label: String?

    public init(
        type: AnyCodable,
        id: String? = nil,
        label: String? = nil)
    {
        self.type = type
        self.id = id
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case id
        case label
    }
}

public struct SessionObserverPlanProgress: Codable, Sendable {
    public let completed: Int
    public let total: Int

    public init(
        completed: Int,
        total: Int)
    {
        self.completed = completed
        self.total = total
    }

    private enum CodingKeys: String, CodingKey {
        case completed
        case total
    }
}

public struct SessionObserverDigest: Codable, Sendable {
    public let sessionkey: String
    public let runid: String?
    public let revision: Int
    public let updatedat: Int
    public let headline: String
    public let assessment: String?
    public let health: SessionObserverHealth
    public let planprogress: SessionObserverPlanProgress?

    public init(
        sessionkey: String,
        runid: String? = nil,
        revision: Int,
        updatedat: Int,
        headline: String,
        assessment: String? = nil,
        health: SessionObserverHealth,
        planprogress: SessionObserverPlanProgress? = nil)
    {
        self.sessionkey = sessionkey
        self.runid = runid
        self.revision = revision
        self.updatedat = updatedat
        self.headline = headline
        self.assessment = assessment
        self.health = health
        self.planprogress = planprogress
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case runid = "runId"
        case revision
        case updatedat = "updatedAt"
        case headline
        case assessment
        case health
        case planprogress = "planProgress"
    }
}

public struct SessionRow: Codable, Sendable {
    public let key: String
    public let sessionid: String?
    public let incognito: Bool?
    public let kind: AnyCodable
    public let label: String?
    public let displayname: String?
    public let derivedtitle: String?
    public let lastmessagepreview: String?
    public let channel: String?
    public let chattype: AnyCodable?
    public let updatedat: AnyCodable?
    public let archived: Bool?
    public let archivedat: Double?
    public let archivedby: SessionCreatedActor?
    public let pinned: Bool?
    public let pinnedat: Double?
    public let icon: String?
    public let unread: Bool?
    public let lastreadat: Double?
    public let lastactivityat: Double?
    public let lastinteractionat: Double?
    public let status: AnyCodable?
    public let lastrunerror: String?
    public let activeleafentryid: AnyCodable?
    public let spawnedby: String?
    public let parentsessionkey: String?
    public let controlownersessionkey: String?
    public let childsessions: [String]?
    public let forkedfromparent: Bool?
    public let spawndepth: Double?
    public let subagentrole: AnyCodable?
    public let subagentcontrolscope: AnyCodable?
    public let swarmgroupid: String?
    public let worktree: [String: AnyCodable]?
    public let execnode: String?
    public let execcwd: String?
    public let spawnedworkspacedir: String?
    public let spawnedcwd: String?
    public let createdvia: AnyCodable?
    public let createdactor: SessionCreatedActor?
    public let visibility: SessionVisibility?
    public let sharingrole: SessionSharingRole?
    public let createdat: Double?
    public let forksource: [String: AnyCodable]?
    public let previoussessionid: String?
    public let inputtokens: Double?
    public let outputtokens: Double?
    public let totaltokens: Double?
    public let totaltokensfresh: Bool?
    public let contexttokens: Double?
    public let estimatedcostusd: Double?
    public let model: String?
    public let modelprovider: String?

    public init(
        key: String,
        sessionid: String? = nil,
        incognito: Bool? = nil,
        kind: AnyCodable,
        label: String? = nil,
        displayname: String? = nil,
        derivedtitle: String? = nil,
        lastmessagepreview: String? = nil,
        channel: String? = nil,
        chattype: AnyCodable? = nil,
        updatedat: AnyCodable? = nil,
        archived: Bool? = nil,
        archivedat: Double? = nil,
        archivedby: SessionCreatedActor? = nil,
        pinned: Bool? = nil,
        pinnedat: Double? = nil,
        icon: String? = nil,
        unread: Bool? = nil,
        lastreadat: Double? = nil,
        lastactivityat: Double? = nil,
        lastinteractionat: Double? = nil,
        status: AnyCodable? = nil,
        lastrunerror: String? = nil,
        activeleafentryid: AnyCodable? = nil,
        spawnedby: String? = nil,
        parentsessionkey: String? = nil,
        controlownersessionkey: String? = nil,
        childsessions: [String]? = nil,
        forkedfromparent: Bool? = nil,
        spawndepth: Double? = nil,
        subagentrole: AnyCodable? = nil,
        subagentcontrolscope: AnyCodable? = nil,
        swarmgroupid: String? = nil,
        worktree: [String: AnyCodable]? = nil,
        execnode: String? = nil,
        execcwd: String? = nil,
        spawnedworkspacedir: String? = nil,
        spawnedcwd: String? = nil,
        createdvia: AnyCodable? = nil,
        createdactor: SessionCreatedActor? = nil,
        visibility: SessionVisibility? = nil,
        sharingrole: SessionSharingRole? = nil,
        createdat: Double? = nil,
        forksource: [String: AnyCodable]? = nil,
        previoussessionid: String? = nil,
        inputtokens: Double? = nil,
        outputtokens: Double? = nil,
        totaltokens: Double? = nil,
        totaltokensfresh: Bool? = nil,
        contexttokens: Double? = nil,
        estimatedcostusd: Double? = nil,
        model: String? = nil,
        modelprovider: String? = nil)
    {
        self.key = key
        self.sessionid = sessionid
        self.incognito = incognito
        self.kind = kind
        self.label = label
        self.displayname = displayname
        self.derivedtitle = derivedtitle
        self.lastmessagepreview = lastmessagepreview
        self.channel = channel
        self.chattype = chattype
        self.updatedat = updatedat
        self.archived = archived
        self.archivedat = archivedat
        self.archivedby = archivedby
        self.pinned = pinned
        self.pinnedat = pinnedat
        self.icon = icon
        self.unread = unread
        self.lastreadat = lastreadat
        self.lastactivityat = lastactivityat
        self.lastinteractionat = lastinteractionat
        self.status = status
        self.lastrunerror = lastrunerror
        self.activeleafentryid = activeleafentryid
        self.spawnedby = spawnedby
        self.parentsessionkey = parentsessionkey
        self.controlownersessionkey = controlownersessionkey
        self.childsessions = childsessions
        self.forkedfromparent = forkedfromparent
        self.spawndepth = spawndepth
        self.subagentrole = subagentrole
        self.subagentcontrolscope = subagentcontrolscope
        self.swarmgroupid = swarmgroupid
        self.worktree = worktree
        self.execnode = execnode
        self.execcwd = execcwd
        self.spawnedworkspacedir = spawnedworkspacedir
        self.spawnedcwd = spawnedcwd
        self.createdvia = createdvia
        self.createdactor = createdactor
        self.visibility = visibility
        self.sharingrole = sharingrole
        self.createdat = createdat
        self.forksource = forksource
        self.previoussessionid = previoussessionid
        self.inputtokens = inputtokens
        self.outputtokens = outputtokens
        self.totaltokens = totaltokens
        self.totaltokensfresh = totaltokensfresh
        self.contexttokens = contexttokens
        self.estimatedcostusd = estimatedcostusd
        self.model = model
        self.modelprovider = modelprovider
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case sessionid = "sessionId"
        case incognito
        case kind
        case label
        case displayname = "displayName"
        case derivedtitle = "derivedTitle"
        case lastmessagepreview = "lastMessagePreview"
        case channel
        case chattype = "chatType"
        case updatedat = "updatedAt"
        case archived
        case archivedat = "archivedAt"
        case archivedby = "archivedBy"
        case pinned
        case pinnedat = "pinnedAt"
        case icon
        case unread
        case lastreadat = "lastReadAt"
        case lastactivityat = "lastActivityAt"
        case lastinteractionat = "lastInteractionAt"
        case status
        case lastrunerror = "lastRunError"
        case activeleafentryid = "activeLeafEntryId"
        case spawnedby = "spawnedBy"
        case parentsessionkey = "parentSessionKey"
        case controlownersessionkey = "controlOwnerSessionKey"
        case childsessions = "childSessions"
        case forkedfromparent = "forkedFromParent"
        case spawndepth = "spawnDepth"
        case subagentrole = "subagentRole"
        case subagentcontrolscope = "subagentControlScope"
        case swarmgroupid = "swarmGroupId"
        case worktree
        case execnode = "execNode"
        case execcwd = "execCwd"
        case spawnedworkspacedir = "spawnedWorkspaceDir"
        case spawnedcwd = "spawnedCwd"
        case createdvia = "createdVia"
        case createdactor = "createdActor"
        case visibility
        case sharingrole = "sharingRole"
        case createdat = "createdAt"
        case forksource = "forkSource"
        case previoussessionid = "previousSessionId"
        case inputtokens = "inputTokens"
        case outputtokens = "outputTokens"
        case totaltokens = "totalTokens"
        case totaltokensfresh = "totalTokensFresh"
        case contexttokens = "contextTokens"
        case estimatedcostusd = "estimatedCostUsd"
        case model
        case modelprovider = "modelProvider"
    }
}

public struct SessionsObserverAskParams: Codable, Sendable {
    public let sessionkey: String
    public let question: String

    public init(
        sessionkey: String,
        question: String)
    {
        self.sessionkey = sessionkey
        self.question = question
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case question
    }
}

public struct SessionsObserverAskResult: Codable, Sendable {
    public let answer: String
    public let digestrevision: Int?

    public init(
        answer: String,
        digestrevision: Int? = nil)
    {
        self.answer = answer
        self.digestrevision = digestrevision
    }

    private enum CodingKeys: String, CodingKey {
        case answer
        case digestrevision = "digestRevision"
    }
}

public struct SessionsObserverVisibilityParams: Codable, Sendable {
    public let visible: Bool

    public init(
        visible: Bool)
    {
        self.visible = visible
    }

    private enum CodingKeys: String, CodingKey {
        case visible
    }
}

public struct SessionsObserverVisibilityResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct SessionSharingIdentity: Codable, Sendable {
    public let type: AnyCodable
    public let id: String
    public let label: String?

    public init(
        type: AnyCodable,
        id: String,
        label: String? = nil)
    {
        self.type = type
        self.id = id
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case type
        case id
        case label
    }
}

public struct SessionVisibilitySetParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let visibility: SessionVisibility

    public init(
        sessionkey: String,
        agentid: String? = nil,
        visibility: SessionVisibility)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.visibility = visibility
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case visibility
    }
}

public struct SessionVisibilitySetResult: Codable, Sendable {
    public let ok: Bool
    public let sessionkey: String
    public let visibility: SessionVisibility

    public init(
        ok: Bool,
        sessionkey: String,
        visibility: SessionVisibility)
    {
        self.ok = ok
        self.sessionkey = sessionkey
        self.visibility = visibility
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case sessionkey = "sessionKey"
        case visibility
    }
}

public struct SessionMembersListParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?

    public init(
        sessionkey: String,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct SessionMember: Codable, Sendable {
    public let identityid: String
    public let addedby: String
    public let addedat: Int

    public init(
        identityid: String,
        addedby: String,
        addedat: Int)
    {
        self.identityid = identityid
        self.addedby = addedby
        self.addedat = addedat
    }

    private enum CodingKeys: String, CodingKey {
        case identityid = "identityId"
        case addedby = "addedBy"
        case addedat = "addedAt"
    }
}

public struct SessionMembersListResult: Codable, Sendable {
    public let sessionkey: String
    public let owner: SessionSharingIdentity?
    public let members: [SessionMember]
    public let identities: [SessionSharingIdentity]
    public let role: SessionSharingRole
    public let allowedvisibilities: [SessionVisibility]

    public init(
        sessionkey: String,
        owner: SessionSharingIdentity? = nil,
        members: [SessionMember],
        identities: [SessionSharingIdentity],
        role: SessionSharingRole,
        allowedvisibilities: [SessionVisibility])
    {
        self.sessionkey = sessionkey
        self.owner = owner
        self.members = members
        self.identities = identities
        self.role = role
        self.allowedvisibilities = allowedvisibilities
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case owner
        case members
        case identities
        case role
        case allowedvisibilities = "allowedVisibilities"
    }
}

public struct SessionMemberAddParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let identityid: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        identityid: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.identityid = identityid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case identityid = "identityId"
    }
}

public struct SessionMemberRemoveParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let identityid: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        identityid: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.identityid = identityid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case identityid = "identityId"
    }
}

public struct SessionMemberMutationResult: Codable, Sendable {
    public let ok: Bool
    public let sessionkey: String
    public let identityid: String

    public init(
        ok: Bool,
        sessionkey: String,
        identityid: String)
    {
        self.ok = ok
        self.sessionkey = sessionkey
        self.identityid = identityid
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case sessionkey = "sessionKey"
        case identityid = "identityId"
    }
}

public struct SessionSharingEvent: Codable, Sendable {
    public let action: SessionSharingAction
    public let sessionkey: String
    public let agentid: String
    public let actor: SessionSharingIdentity
    public let visibility: SessionVisibility?
    public let identityid: String?
    public let ts: Int

    public init(
        action: SessionSharingAction,
        sessionkey: String,
        agentid: String,
        actor: SessionSharingIdentity,
        visibility: SessionVisibility? = nil,
        identityid: String? = nil,
        ts: Int)
    {
        self.action = action
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.actor = actor
        self.visibility = visibility
        self.identityid = identityid
        self.ts = ts
    }

    private enum CodingKeys: String, CodingKey {
        case action
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case actor
        case visibility
        case identityid = "identityId"
        case ts
    }
}

public struct SessionSuggestion: Codable, Sendable {
    public let id: String
    public let sessionkey: String
    public let agentid: String
    public let author: SessionSharingIdentity
    public let text: String
    public let createdat: Int
    public let state: SessionSuggestionState

    public init(
        id: String,
        sessionkey: String,
        agentid: String,
        author: SessionSharingIdentity,
        text: String,
        createdat: Int,
        state: SessionSuggestionState)
    {
        self.id = id
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.author = author
        self.text = text
        self.createdat = createdat
        self.state = state
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case author
        case text
        case createdat = "createdAt"
        case state
    }
}

public struct SessionSuggestionsAddParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let text: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        text: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.text = text
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case text
    }
}

public struct SessionSuggestionsAddResult: Codable, Sendable {
    public let suggestion: SessionSuggestion

    public init(
        suggestion: SessionSuggestion)
    {
        self.suggestion = suggestion
    }

    private enum CodingKeys: String, CodingKey {
        case suggestion
    }
}

public struct SessionSuggestionsListParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?

    public init(
        sessionkey: String,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct SessionSuggestionsListResult: Codable, Sendable {
    public let suggestions: [SessionSuggestion]
    public let role: SessionSharingRole

    public init(
        suggestions: [SessionSuggestion],
        role: SessionSharingRole)
    {
        self.suggestions = suggestions
        self.role = role
    }

    private enum CodingKeys: String, CodingKey {
        case suggestions
        case role
    }
}

public struct SessionSuggestionsResolveParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let id: String
    public let resolution: SessionSuggestionResolution

    public init(
        sessionkey: String,
        agentid: String? = nil,
        id: String,
        resolution: SessionSuggestionResolution)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.id = id
        self.resolution = resolution
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case id
        case resolution
    }
}

public struct SessionSuggestionsResolveResult: Codable, Sendable {
    public let suggestion: SessionSuggestion

    public init(
        suggestion: SessionSuggestion)
    {
        self.suggestion = suggestion
    }

    private enum CodingKeys: String, CodingKey {
        case suggestion
    }
}

public struct SessionSuggestionEvent: Codable, Sendable {
    public let action: SessionSuggestionAction
    public let suggestion: SessionSuggestion

    public init(
        action: SessionSuggestionAction,
        suggestion: SessionSuggestion)
    {
        self.action = action
        self.suggestion = suggestion
    }

    private enum CodingKeys: String, CodingKey {
        case action
        case suggestion
    }
}

public struct SessionTypingParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let sessionid: String
    public let typing: Bool

    public init(
        sessionkey: String,
        agentid: String? = nil,
        sessionid: String,
        typing: Bool)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.sessionid = sessionid
        self.typing = typing
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case sessionid = "sessionId"
        case typing
    }
}

public struct SessionTypingResult: Codable, Sendable {
    public let ok: Bool
    public let broadcast: Bool

    public init(
        ok: Bool,
        broadcast: Bool)
    {
        self.ok = ok
        self.broadcast = broadcast
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case broadcast
    }
}

public struct SessionTypingEvent: Codable, Sendable {
    public let sessionkey: String
    public let sessionid: String
    public let agentid: String
    public let actor: SessionSharingIdentity
    public let typing: Bool
    public let ts: Int

    public init(
        sessionkey: String,
        sessionid: String,
        agentid: String,
        actor: SessionSharingIdentity,
        typing: Bool,
        ts: Int)
    {
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.agentid = agentid
        self.actor = actor
        self.typing = typing
        self.ts = ts
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case agentid = "agentId"
        case actor
        case typing
        case ts
    }
}

public struct LocalSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
    }
}

public struct RequestedSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
    }
}

public struct ProvisioningSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String?

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String? = nil)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
    }
}

public struct SyncingSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String
    public let workerbundlehash: String

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String,
        workerbundlehash: String)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.workerbundlehash = workerbundlehash
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case workerbundlehash = "workerBundleHash"
    }
}

public struct StartingSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String
    public let workerbundlehash: String
    public let workspacebasemanifestref: String
    public let remoteworkspacedir: String

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String,
        workerbundlehash: String,
        workspacebasemanifestref: String,
        remoteworkspacedir: String)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.workerbundlehash = workerbundlehash
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case workerbundlehash = "workerBundleHash"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
    }
}

public struct ActiveWorkerSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String
    public let activeownerepoch: Int
    public let workerbundlehash: String
    public let workspacebasemanifestref: String
    public let remoteworkspacedir: String
    public let lasttranscriptackcursor: Int?
    public let lastliveeventackcursor: Int?
    public let workspaceresultconflict: [String: AnyCodable]?

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String,
        activeownerepoch: Int,
        workerbundlehash: String,
        workspacebasemanifestref: String,
        remoteworkspacedir: String,
        lasttranscriptackcursor: Int? = nil,
        lastliveeventackcursor: Int? = nil,
        workspaceresultconflict: [String: AnyCodable]? = nil)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.activeownerepoch = activeownerepoch
        self.workerbundlehash = workerbundlehash
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
        self.lasttranscriptackcursor = lasttranscriptackcursor
        self.lastliveeventackcursor = lastliveeventackcursor
        self.workspaceresultconflict = workspaceresultconflict
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case activeownerepoch = "activeOwnerEpoch"
        case workerbundlehash = "workerBundleHash"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
        case lasttranscriptackcursor = "lastTranscriptAckCursor"
        case lastliveeventackcursor = "lastLiveEventAckCursor"
        case workspaceresultconflict = "workspaceResultConflict"
    }
}

public struct DrainingSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String
    public let activeownerepoch: Int
    public let workerbundlehash: String
    public let workspacebasemanifestref: String
    public let remoteworkspacedir: String
    public let lasttranscriptackcursor: Int?
    public let lastliveeventackcursor: Int?
    public let workspaceresultconflict: [String: AnyCodable]?

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String,
        activeownerepoch: Int,
        workerbundlehash: String,
        workspacebasemanifestref: String,
        remoteworkspacedir: String,
        lasttranscriptackcursor: Int? = nil,
        lastliveeventackcursor: Int? = nil,
        workspaceresultconflict: [String: AnyCodable]? = nil)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.activeownerepoch = activeownerepoch
        self.workerbundlehash = workerbundlehash
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
        self.lasttranscriptackcursor = lasttranscriptackcursor
        self.lastliveeventackcursor = lastliveeventackcursor
        self.workspaceresultconflict = workspaceresultconflict
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case activeownerepoch = "activeOwnerEpoch"
        case workerbundlehash = "workerBundleHash"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
        case lasttranscriptackcursor = "lastTranscriptAckCursor"
        case lastliveeventackcursor = "lastLiveEventAckCursor"
        case workspaceresultconflict = "workspaceResultConflict"
    }
}

public struct ReconcilingSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String
    public let activeownerepoch: Int
    public let workerbundlehash: String
    public let workspacebasemanifestref: String
    public let remoteworkspacedir: String
    public let lasttranscriptackcursor: Int?
    public let lastliveeventackcursor: Int?
    public let workspaceresultconflict: [String: AnyCodable]?

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String,
        activeownerepoch: Int,
        workerbundlehash: String,
        workspacebasemanifestref: String,
        remoteworkspacedir: String,
        lasttranscriptackcursor: Int? = nil,
        lastliveeventackcursor: Int? = nil,
        workspaceresultconflict: [String: AnyCodable]? = nil)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.activeownerepoch = activeownerepoch
        self.workerbundlehash = workerbundlehash
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
        self.lasttranscriptackcursor = lasttranscriptackcursor
        self.lastliveeventackcursor = lastliveeventackcursor
        self.workspaceresultconflict = workspaceresultconflict
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case activeownerepoch = "activeOwnerEpoch"
        case workerbundlehash = "workerBundleHash"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
        case lasttranscriptackcursor = "lastTranscriptAckCursor"
        case lastliveeventackcursor = "lastLiveEventAckCursor"
        case workspaceresultconflict = "workspaceResultConflict"
    }
}

public struct ReclaimedSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String?
    public let activeownerepoch: Int?
    public let workspacebasemanifestref: String?
    public let remoteworkspacedir: String?
    public let workerbundlehash: String?
    public let lasttranscriptackcursor: Int?
    public let lastliveeventackcursor: Int?
    public let workspaceresultconflict: [String: AnyCodable]?

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String? = nil,
        activeownerepoch: Int? = nil,
        workspacebasemanifestref: String? = nil,
        remoteworkspacedir: String? = nil,
        workerbundlehash: String? = nil,
        lasttranscriptackcursor: Int? = nil,
        lastliveeventackcursor: Int? = nil,
        workspaceresultconflict: [String: AnyCodable]? = nil)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.activeownerepoch = activeownerepoch
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
        self.workerbundlehash = workerbundlehash
        self.lasttranscriptackcursor = lasttranscriptackcursor
        self.lastliveeventackcursor = lastliveeventackcursor
        self.workspaceresultconflict = workspaceresultconflict
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case activeownerepoch = "activeOwnerEpoch"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
        case workerbundlehash = "workerBundleHash"
        case lasttranscriptackcursor = "lastTranscriptAckCursor"
        case lastliveeventackcursor = "lastLiveEventAckCursor"
        case workspaceresultconflict = "workspaceResultConflict"
    }
}

public struct FailedSessionPlacement: Codable, Sendable {
    public let state: String
    public let generation: Int
    public let createdatms: Int
    public let updatedatms: Int
    public let statechangedatms: Int
    public let environmentid: String?
    public let activeownerepoch: Int?
    public let workspacebasemanifestref: String?
    public let remoteworkspacedir: String?
    public let workerbundlehash: String?
    public let lasttranscriptackcursor: Int?
    public let lastliveeventackcursor: Int?
    public let workspaceresultconflict: [String: AnyCodable]?
    public let recoveryerror: String

    public init(
        state: String,
        generation: Int,
        createdatms: Int,
        updatedatms: Int,
        statechangedatms: Int,
        environmentid: String? = nil,
        activeownerepoch: Int? = nil,
        workspacebasemanifestref: String? = nil,
        remoteworkspacedir: String? = nil,
        workerbundlehash: String? = nil,
        lasttranscriptackcursor: Int? = nil,
        lastliveeventackcursor: Int? = nil,
        workspaceresultconflict: [String: AnyCodable]? = nil,
        recoveryerror: String)
    {
        self.state = state
        self.generation = generation
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.statechangedatms = statechangedatms
        self.environmentid = environmentid
        self.activeownerepoch = activeownerepoch
        self.workspacebasemanifestref = workspacebasemanifestref
        self.remoteworkspacedir = remoteworkspacedir
        self.workerbundlehash = workerbundlehash
        self.lasttranscriptackcursor = lasttranscriptackcursor
        self.lastliveeventackcursor = lastliveeventackcursor
        self.workspaceresultconflict = workspaceresultconflict
        self.recoveryerror = recoveryerror
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case generation
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case statechangedatms = "stateChangedAtMs"
        case environmentid = "environmentId"
        case activeownerepoch = "activeOwnerEpoch"
        case workspacebasemanifestref = "workspaceBaseManifestRef"
        case remoteworkspacedir = "remoteWorkspaceDir"
        case workerbundlehash = "workerBundleHash"
        case lasttranscriptackcursor = "lastTranscriptAckCursor"
        case lastliveeventackcursor = "lastLiveEventAckCursor"
        case workspaceresultconflict = "workspaceResultConflict"
        case recoveryerror = "recoveryError"
    }
}

public struct SessionsDispatchParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let profileid: String

    public init(
        key: String,
        agentid: String? = nil,
        profileid: String)
    {
        self.key = key
        self.agentid = agentid
        self.profileid = profileid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case profileid = "profileId"
    }
}

public struct SessionsDispatchResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let sessionid: String
    public let placement: ActiveWorkerSessionPlacement

    public init(
        ok: Bool,
        key: String,
        sessionid: String,
        placement: ActiveWorkerSessionPlacement)
    {
        self.ok = ok
        self.key = key
        self.sessionid = sessionid
        self.placement = placement
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case sessionid = "sessionId"
        case placement
    }
}

public struct SessionsReclaimParams: Codable, Sendable {
    public let key: String
    public let agentid: String?

    public init(
        key: String,
        agentid: String? = nil)
    {
        self.key = key
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
    }
}

public struct SessionsReclaimResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let sessionid: String
    public let placement: ReclaimedSessionPlacement

    public init(
        ok: Bool,
        key: String,
        sessionid: String,
        placement: ReclaimedSessionPlacement)
    {
        self.ok = ok
        self.key = key
        self.sessionid = sessionid
        self.placement = placement
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case sessionid = "sessionId"
        case placement
    }
}

public struct SessionDiscussionInfo: Codable, Sendable {
    public let state: SessionDiscussionState
    public let embedurl: String?
    public let openurl: String?

    public init(
        state: SessionDiscussionState,
        embedurl: String? = nil,
        openurl: String? = nil)
    {
        self.state = state
        self.embedurl = embedurl
        self.openurl = openurl
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case embedurl = "embedUrl"
        case openurl = "openUrl"
    }
}

public struct SessionDiscussionInfoParams: Codable, Sendable {
    public let sessionkey: String

    public init(
        sessionkey: String)
    {
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
    }
}

public struct SessionDiscussionInfoResult: Codable, Sendable {
    public let state: SessionDiscussionState
    public let embedurl: String?
    public let openurl: String?

    public init(
        state: SessionDiscussionState,
        embedurl: String? = nil,
        openurl: String? = nil)
    {
        self.state = state
        self.embedurl = embedurl
        self.openurl = openurl
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case embedurl = "embedUrl"
        case openurl = "openUrl"
    }
}

public struct SessionDiscussionOpenParams: Codable, Sendable {
    public let sessionkey: String

    public init(
        sessionkey: String)
    {
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
    }
}

public struct SessionDiscussionOpenResult: Codable, Sendable {
    public let state: SessionDiscussionState
    public let embedurl: String?
    public let openurl: String?

    public init(
        state: SessionDiscussionState,
        embedurl: String? = nil,
        openurl: String? = nil)
    {
        self.state = state
        self.embedurl = embedurl
        self.openurl = openurl
    }

    private enum CodingKeys: String, CodingKey {
        case state
        case embedurl = "embedUrl"
        case openurl = "openUrl"
    }
}

public struct SessionsCompactionListParams: Codable, Sendable {
    public let key: String
    public let agentid: String?

    public init(
        key: String,
        agentid: String? = nil)
    {
        self.key = key
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
    }
}

public struct SessionsCompactionGetParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let checkpointid: String

    public init(
        key: String,
        agentid: String? = nil,
        checkpointid: String)
    {
        self.key = key
        self.agentid = agentid
        self.checkpointid = checkpointid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case checkpointid = "checkpointId"
    }
}

public struct SessionsCompactionBranchParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let checkpointid: String

    public init(
        key: String,
        agentid: String? = nil,
        checkpointid: String)
    {
        self.key = key
        self.agentid = agentid
        self.checkpointid = checkpointid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case checkpointid = "checkpointId"
    }
}

public struct SessionsCompactionRestoreParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let checkpointid: String

    public init(
        key: String,
        agentid: String? = nil,
        checkpointid: String)
    {
        self.key = key
        self.agentid = agentid
        self.checkpointid = checkpointid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case checkpointid = "checkpointId"
    }
}

public struct SessionsCompactionListResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let checkpoints: [SessionCompactionCheckpoint]

    public init(
        ok: Bool,
        key: String,
        checkpoints: [SessionCompactionCheckpoint])
    {
        self.ok = ok
        self.key = key
        self.checkpoints = checkpoints
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case checkpoints
    }
}

public struct SessionsCompactionGetResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let checkpoint: SessionCompactionCheckpoint

    public init(
        ok: Bool,
        key: String,
        checkpoint: SessionCompactionCheckpoint)
    {
        self.ok = ok
        self.key = key
        self.checkpoint = checkpoint
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case checkpoint
    }
}

public struct SessionsCompactionBranchResult: Codable, Sendable {
    public let ok: Bool
    public let sourcekey: String
    public let key: String
    public let sessionid: String
    public let checkpoint: SessionCompactionCheckpoint
    public let entry: [String: AnyCodable]

    public init(
        ok: Bool,
        sourcekey: String,
        key: String,
        sessionid: String,
        checkpoint: SessionCompactionCheckpoint,
        entry: [String: AnyCodable])
    {
        self.ok = ok
        self.sourcekey = sourcekey
        self.key = key
        self.sessionid = sessionid
        self.checkpoint = checkpoint
        self.entry = entry
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case sourcekey = "sourceKey"
        case key
        case sessionid = "sessionId"
        case checkpoint
        case entry
    }
}

public struct SessionsCompactionRestoreResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let sessionid: String
    public let checkpoint: SessionCompactionCheckpoint
    public let entry: [String: AnyCodable]

    public init(
        ok: Bool,
        key: String,
        sessionid: String,
        checkpoint: SessionCompactionCheckpoint,
        entry: [String: AnyCodable])
    {
        self.ok = ok
        self.key = key
        self.sessionid = sessionid
        self.checkpoint = checkpoint
        self.entry = entry
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case sessionid = "sessionId"
        case checkpoint
        case entry
    }
}

public struct SessionsRewindParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let entryid: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        entryid: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.entryid = entryid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case entryid = "entryId"
    }
}

public struct SessionsRewindResult: Codable, Sendable {
    public let editortext: String?

    public init(
        editortext: String? = nil)
    {
        self.editortext = editortext
    }

    private enum CodingKeys: String, CodingKey {
        case editortext = "editorText"
    }
}

public struct SessionsForkParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let entryid: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        entryid: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.entryid = entryid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case entryid = "entryId"
    }
}

public struct SessionsForkResult: Codable, Sendable {
    public let sessionkey: String
    public let editortext: String?

    public init(
        sessionkey: String,
        editortext: String? = nil)
    {
        self.sessionkey = sessionkey
        self.editortext = editortext
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case editortext = "editorText"
    }
}

public struct SessionBranch: Codable, Sendable {
    public let leafentryid: String
    public let headline: String
    public let messagecount: Int
    public let updatedat: String?
    public let active: Bool

    public init(
        leafentryid: String,
        headline: String,
        messagecount: Int,
        updatedat: String? = nil,
        active: Bool)
    {
        self.leafentryid = leafentryid
        self.headline = headline
        self.messagecount = messagecount
        self.updatedat = updatedat
        self.active = active
    }

    private enum CodingKeys: String, CodingKey {
        case leafentryid = "leafEntryId"
        case headline
        case messagecount = "messageCount"
        case updatedat = "updatedAt"
        case active
    }
}

public struct SessionsBranchesListParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?

    public init(
        sessionkey: String,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct SessionsBranchesListResult: Codable, Sendable {
    public let branches: [SessionBranch]

    public init(
        branches: [SessionBranch])
    {
        self.branches = branches
    }

    private enum CodingKeys: String, CodingKey {
        case branches
    }
}

public struct SessionsBranchesSwitchParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let leafentryid: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        leafentryid: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.leafentryid = leafentryid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case leafentryid = "leafEntryId"
    }
}

public struct SessionsBranchesSwitchResult: Codable, Sendable {}

public struct SessionFileBrowserEntry: Codable, Sendable {
    public let path: String
    public let name: String
    public let kind: AnyCodable
    public let sessionkind: SessionFileRelevance?
    public let size: Int?
    public let updatedatms: Int?

    public init(
        path: String,
        name: String,
        kind: AnyCodable,
        sessionkind: SessionFileRelevance? = nil,
        size: Int? = nil,
        updatedatms: Int? = nil)
    {
        self.path = path
        self.name = name
        self.kind = kind
        self.sessionkind = sessionkind
        self.size = size
        self.updatedatms = updatedatms
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case name
        case kind
        case sessionkind = "sessionKind"
        case size
        case updatedatms = "updatedAtMs"
    }
}

public struct SessionFileBrowserResult: Codable, Sendable {
    public let path: String
    public let parentpath: String?
    public let search: String?
    public let entries: [SessionFileBrowserEntry]
    public let truncated: Bool?

    public init(
        path: String,
        parentpath: String? = nil,
        search: String? = nil,
        entries: [SessionFileBrowserEntry],
        truncated: Bool? = nil)
    {
        self.path = path
        self.parentpath = parentpath
        self.search = search
        self.entries = entries
        self.truncated = truncated
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case parentpath = "parentPath"
        case search
        case entries
        case truncated
    }
}

public struct SessionFileEntry: Codable, Sendable {
    public let path: String
    public let workspacepath: String?
    public let name: String
    public let kind: SessionFileKind
    public let missing: Bool
    public let size: Int?
    public let updatedatms: Int?
    public let content: String?
    public let hash: String?

    public init(
        path: String,
        workspacepath: String? = nil,
        name: String,
        kind: SessionFileKind,
        missing: Bool,
        size: Int? = nil,
        updatedatms: Int? = nil,
        content: String? = nil,
        hash: String? = nil)
    {
        self.path = path
        self.workspacepath = workspacepath
        self.name = name
        self.kind = kind
        self.missing = missing
        self.size = size
        self.updatedatms = updatedatms
        self.content = content
        self.hash = hash
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case workspacepath = "workspacePath"
        case name
        case kind
        case missing
        case size
        case updatedatms = "updatedAtMs"
        case content
        case hash
    }
}

public struct SessionsFilesListParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let path: String?
    public let search: String?

    public init(
        sessionkey: String,
        agentid: String? = nil,
        path: String? = nil,
        search: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.path = path
        self.search = search
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case path
        case search
    }
}

public struct SessionsFilesListResult: Codable, Sendable {
    public let sessionkey: String
    public let root: String?
    public let gitcheckout: Bool?
    public let files: [SessionFileEntry]
    public let browser: SessionFileBrowserResult?

    public init(
        sessionkey: String,
        root: String? = nil,
        gitcheckout: Bool? = nil,
        files: [SessionFileEntry],
        browser: SessionFileBrowserResult? = nil)
    {
        self.sessionkey = sessionkey
        self.root = root
        self.gitcheckout = gitcheckout
        self.files = files
        self.browser = browser
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case root
        case gitcheckout = "gitCheckout"
        case files
        case browser
    }
}

public struct SessionsFilesGetParams: Codable, Sendable {
    public let sessionkey: String
    public let path: String
    public let agentid: String?

    public init(
        sessionkey: String,
        path: String,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.path = path
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case path
        case agentid = "agentId"
    }
}

public struct SessionsFilesGetResult: Codable, Sendable {
    public let sessionkey: String
    public let root: String?
    public let file: SessionFileEntry

    public init(
        sessionkey: String,
        root: String? = nil,
        file: SessionFileEntry)
    {
        self.sessionkey = sessionkey
        self.root = root
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case root
        case file
    }
}

public struct SessionsFilesRevealParams: Codable, Sendable {
    public let key: String
    public let agentid: String?

    public init(
        key: String,
        agentid: String? = nil)
    {
        self.key = key
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
    }
}

public struct SessionsFilesRevealResult: Codable, Sendable {
    public let ok: Bool
    public let path: String?
    public let error: String?

    public init(
        ok: Bool,
        path: String? = nil,
        error: String? = nil)
    {
        self.ok = ok
        self.path = path
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case path
        case error
    }
}

public struct SessionsFilesSetParams: Codable, Sendable {
    public let sessionkey: String
    public let path: String
    public let agentid: String?
    public let content: String
    public let expectedhash: String

    public init(
        sessionkey: String,
        path: String,
        agentid: String? = nil,
        content: String,
        expectedhash: String)
    {
        self.sessionkey = sessionkey
        self.path = path
        self.agentid = agentid
        self.content = content
        self.expectedhash = expectedhash
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case path
        case agentid = "agentId"
        case content
        case expectedhash = "expectedHash"
    }
}

public struct SessionsFilesSetResult: Codable, Sendable {
    public let sessionkey: String
    public let root: String?
    public let file: SessionFileEntry

    public init(
        sessionkey: String,
        root: String? = nil,
        file: SessionFileEntry)
    {
        self.sessionkey = sessionkey
        self.root = root
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case root
        case file
    }
}

public struct SessionDiffFile: Codable, Sendable {
    public let path: String
    public let oldpath: String?
    public let status: SessionDiffFileStatus
    public let additions: Int
    public let deletions: Int
    public let binary: Bool?
    public let untracked: Bool?
    public let patch: String?
    public let truncated: Bool?

    public init(
        path: String,
        oldpath: String? = nil,
        status: SessionDiffFileStatus,
        additions: Int,
        deletions: Int,
        binary: Bool? = nil,
        untracked: Bool? = nil,
        patch: String? = nil,
        truncated: Bool? = nil)
    {
        self.path = path
        self.oldpath = oldpath
        self.status = status
        self.additions = additions
        self.deletions = deletions
        self.binary = binary
        self.untracked = untracked
        self.patch = patch
        self.truncated = truncated
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case oldpath = "oldPath"
        case status
        case additions
        case deletions
        case binary
        case untracked
        case patch
        case truncated
    }
}

public struct SessionsDiffParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?

    public init(
        sessionkey: String,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct SessionsDiffResult: Codable, Sendable {
    public let sessionkey: String
    public let root: String?
    public let branch: String?
    public let baseref: String?
    public let files: [SessionDiffFile]
    public let additions: Int
    public let deletions: Int
    public let truncated: Bool?
    public let unavailablereason: AnyCodable?

    public init(
        sessionkey: String,
        root: String? = nil,
        branch: String? = nil,
        baseref: String? = nil,
        files: [SessionDiffFile],
        additions: Int,
        deletions: Int,
        truncated: Bool? = nil,
        unavailablereason: AnyCodable? = nil)
    {
        self.sessionkey = sessionkey
        self.root = root
        self.branch = branch
        self.baseref = baseref
        self.files = files
        self.additions = additions
        self.deletions = deletions
        self.truncated = truncated
        self.unavailablereason = unavailablereason
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case root
        case branch
        case baseref = "baseRef"
        case files
        case additions
        case deletions
        case truncated
        case unavailablereason = "unavailableReason"
    }
}

public struct SessionWorktreeInfo: Codable, Sendable {
    public let id: String
    public let path: String
    public let branch: String

    public init(
        id: String,
        path: String,
        branch: String)
    {
        self.id = id
        self.path = path
        self.branch = branch
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case path
        case branch
    }
}

public struct SessionsCreateParams: Codable, Sendable {
    public let key: String?
    public let agentid: String?
    public let label: String?
    public let model: String?
    public let thinkinglevel: String?
    public let incognito: Bool?
    public let visibility: SessionVisibility?
    public let catalogid: String?
    public let parentsessionkey: String?
    public let spawndepth: Int?
    public let fork: Bool?
    public let emitcommandhooks: Bool?
    public let succeedsparent: Bool?
    public let task: String?
    public let message: String?
    public let attachments: [AnyCodable]?
    public let worktree: Bool?
    public let worktreebaseref: String?
    public let worktreename: String?
    public let execnode: String?
    public let cwd: String?

    public init(
        key: String? = nil,
        agentid: String? = nil,
        label: String? = nil,
        model: String? = nil,
        thinkinglevel: String? = nil,
        incognito: Bool? = nil,
        visibility: SessionVisibility? = nil,
        catalogid: String? = nil,
        parentsessionkey: String? = nil,
        spawndepth: Int? = nil,
        fork: Bool? = nil,
        emitcommandhooks: Bool? = nil,
        succeedsparent: Bool? = nil,
        task: String? = nil,
        message: String? = nil,
        attachments: [AnyCodable]? = nil,
        worktree: Bool? = nil,
        worktreebaseref: String? = nil,
        worktreename: String? = nil,
        execnode: String? = nil,
        cwd: String? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.label = label
        self.model = model
        self.thinkinglevel = thinkinglevel
        self.incognito = incognito
        self.visibility = visibility
        self.catalogid = catalogid
        self.parentsessionkey = parentsessionkey
        self.spawndepth = spawndepth
        self.fork = fork
        self.emitcommandhooks = emitcommandhooks
        self.succeedsparent = succeedsparent
        self.task = task
        self.message = message
        self.attachments = attachments
        self.worktree = worktree
        self.worktreebaseref = worktreebaseref
        self.worktreename = worktreename
        self.execnode = execnode
        self.cwd = cwd
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case label
        case model
        case thinkinglevel = "thinkingLevel"
        case incognito
        case visibility
        case catalogid = "catalogId"
        case parentsessionkey = "parentSessionKey"
        case spawndepth = "spawnDepth"
        case fork
        case emitcommandhooks = "emitCommandHooks"
        case succeedsparent = "succeedsParent"
        case task
        case message
        case attachments
        case worktree
        case worktreebaseref = "worktreeBaseRef"
        case worktreename = "worktreeName"
        case execnode = "execNode"
        case cwd
    }
}

public struct SessionsCreateResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let sessionid: String?
    public let entry: [String: AnyCodable]?
    public let runstarted: Bool?
    public let runid: String?
    public let messageseq: Int?
    public let runerror: ErrorShape?
    public let worktree: SessionWorktreeInfo?

    public init(
        ok: Bool,
        key: String,
        sessionid: String? = nil,
        entry: [String: AnyCodable]? = nil,
        runstarted: Bool? = nil,
        runid: String? = nil,
        messageseq: Int? = nil,
        runerror: ErrorShape? = nil,
        worktree: SessionWorktreeInfo? = nil)
    {
        self.ok = ok
        self.key = key
        self.sessionid = sessionid
        self.entry = entry
        self.runstarted = runstarted
        self.runid = runid
        self.messageseq = messageseq
        self.runerror = runerror
        self.worktree = worktree
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case sessionid = "sessionId"
        case entry
        case runstarted = "runStarted"
        case runid = "runId"
        case messageseq = "messageSeq"
        case runerror = "runError"
        case worktree
    }
}

public struct SessionsSendParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let message: String
    public let thinking: String?
    public let attachments: [AnyCodable]?
    public let timeoutms: Int?
    public let idempotencykey: String?

    public init(
        key: String,
        agentid: String? = nil,
        message: String,
        thinking: String? = nil,
        attachments: [AnyCodable]? = nil,
        timeoutms: Int? = nil,
        idempotencykey: String? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.message = message
        self.thinking = thinking
        self.attachments = attachments
        self.timeoutms = timeoutms
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case message
        case thinking
        case attachments
        case timeoutms = "timeoutMs"
        case idempotencykey = "idempotencyKey"
    }
}

public struct SessionsMessagesSubscribeParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let includeapprovals: Bool?

    public init(
        key: String,
        agentid: String? = nil,
        includeapprovals: Bool? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.includeapprovals = includeapprovals
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case includeapprovals = "includeApprovals"
    }
}

public struct SessionsMessagesUnsubscribeParams: Codable, Sendable {
    public let key: String
    public let agentid: String?

    public init(
        key: String,
        agentid: String? = nil)
    {
        self.key = key
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
    }
}

public struct SessionsAbortParams: Codable, Sendable {
    public let key: String?
    public let runid: String?
    public let agentid: String?
    public let clearqueued: Bool?

    public init(
        key: String? = nil,
        runid: String? = nil,
        agentid: String? = nil,
        clearqueued: Bool? = nil)
    {
        self.key = key
        self.runid = runid
        self.agentid = agentid
        self.clearqueued = clearqueued
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case runid = "runId"
        case agentid = "agentId"
        case clearqueued = "clearQueued"
    }
}

public struct SessionsPatchParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let label: AnyCodable?
    public let category: AnyCodable?
    public let icon: AnyCodable?
    public let statusnote: AnyCodable?
    public let attention: AnyCodable?
    public let ttlminutes: Int?
    public let archived: Bool?
    public let pinned: Bool?
    public let unread: Bool?
    public let thinkinglevel: AnyCodable?
    public let fastmode: AnyCodable?
    public let verboselevel: AnyCodable?
    public let tracelevel: AnyCodable?
    public let reasoninglevel: AnyCodable?
    public let responseusage: AnyCodable?
    public let elevatedlevel: AnyCodable?
    public let exechost: AnyCodable?
    public let execsecurity: AnyCodable?
    public let execask: AnyCodable?
    public let execnode: AnyCodable?
    public let model: AnyCodable?
    public let completionownersessionkey: AnyCodable?
    public let inheritedtoolpolicyversion: AnyCodable?
    public let inheritedtoolallow: AnyCodable?
    public let inheritedtooldeny: AnyCodable?
    public let sendpolicy: AnyCodable?
    public let groupactivation: AnyCodable?

    public init(
        key: String,
        agentid: String? = nil,
        label: AnyCodable? = nil,
        category: AnyCodable? = nil,
        icon: AnyCodable? = nil,
        statusnote: AnyCodable? = nil,
        attention: AnyCodable? = nil,
        ttlminutes: Int? = nil,
        archived: Bool? = nil,
        pinned: Bool? = nil,
        unread: Bool? = nil,
        thinkinglevel: AnyCodable? = nil,
        fastmode: AnyCodable? = nil,
        verboselevel: AnyCodable? = nil,
        tracelevel: AnyCodable? = nil,
        reasoninglevel: AnyCodable? = nil,
        responseusage: AnyCodable? = nil,
        elevatedlevel: AnyCodable? = nil,
        exechost: AnyCodable? = nil,
        execsecurity: AnyCodable? = nil,
        execask: AnyCodable? = nil,
        execnode: AnyCodable? = nil,
        model: AnyCodable? = nil,
        completionownersessionkey: AnyCodable? = nil,
        inheritedtoolpolicyversion: AnyCodable? = nil,
        inheritedtoolallow: AnyCodable? = nil,
        inheritedtooldeny: AnyCodable? = nil,
        sendpolicy: AnyCodable? = nil,
        groupactivation: AnyCodable? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.label = label
        self.category = category
        self.icon = icon
        self.statusnote = statusnote
        self.attention = attention
        self.ttlminutes = ttlminutes
        self.archived = archived
        self.pinned = pinned
        self.unread = unread
        self.thinkinglevel = thinkinglevel
        self.fastmode = fastmode
        self.verboselevel = verboselevel
        self.tracelevel = tracelevel
        self.reasoninglevel = reasoninglevel
        self.responseusage = responseusage
        self.elevatedlevel = elevatedlevel
        self.exechost = exechost
        self.execsecurity = execsecurity
        self.execask = execask
        self.execnode = execnode
        self.model = model
        self.completionownersessionkey = completionownersessionkey
        self.inheritedtoolpolicyversion = inheritedtoolpolicyversion
        self.inheritedtoolallow = inheritedtoolallow
        self.inheritedtooldeny = inheritedtooldeny
        self.sendpolicy = sendpolicy
        self.groupactivation = groupactivation
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case label
        case category
        case icon
        case statusnote = "statusNote"
        case attention
        case ttlminutes = "ttlMinutes"
        case archived
        case pinned
        case unread
        case thinkinglevel = "thinkingLevel"
        case fastmode = "fastMode"
        case verboselevel = "verboseLevel"
        case tracelevel = "traceLevel"
        case reasoninglevel = "reasoningLevel"
        case responseusage = "responseUsage"
        case elevatedlevel = "elevatedLevel"
        case exechost = "execHost"
        case execsecurity = "execSecurity"
        case execask = "execAsk"
        case execnode = "execNode"
        case model
        case completionownersessionkey = "completionOwnerSessionKey"
        case inheritedtoolpolicyversion = "inheritedToolPolicyVersion"
        case inheritedtoolallow = "inheritedToolAllow"
        case inheritedtooldeny = "inheritedToolDeny"
        case sendpolicy = "sendPolicy"
        case groupactivation = "groupActivation"
    }
}

public struct SessionsPluginPatchParams: Codable, Sendable {
    public let key: String
    public let pluginid: String
    public let namespace: String
    public let value: AnyCodable?
    public let unset: Bool?

    public init(
        key: String,
        pluginid: String,
        namespace: String,
        value: AnyCodable? = nil,
        unset: Bool? = nil)
    {
        self.key = key
        self.pluginid = pluginid
        self.namespace = namespace
        self.value = value
        self.unset = unset
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case pluginid = "pluginId"
        case namespace
        case value
        case unset
    }
}

public struct SessionsPluginPatchResult: Codable, Sendable {
    public let ok: Bool
    public let key: String
    public let value: AnyCodable?

    public init(
        ok: Bool,
        key: String,
        value: AnyCodable? = nil)
    {
        self.ok = ok
        self.key = key
        self.value = value
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case key
        case value
    }
}

public struct SessionsResetParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let reason: AnyCodable?

    public init(
        key: String,
        agentid: String? = nil,
        reason: AnyCodable? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case reason
    }
}

public struct SessionsDeleteParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let deletetranscript: Bool?
    public let expectedsessionid: String?
    public let expectedlifecyclerevision: String?
    public let expectedsessionupdatedat: Double?
    public let emitlifecyclehooks: Bool?
    public let archivedonly: Bool?

    public init(
        key: String,
        agentid: String? = nil,
        deletetranscript: Bool? = nil,
        expectedsessionid: String? = nil,
        expectedlifecyclerevision: String? = nil,
        expectedsessionupdatedat: Double? = nil,
        emitlifecyclehooks: Bool? = nil,
        archivedonly: Bool? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.deletetranscript = deletetranscript
        self.expectedsessionid = expectedsessionid
        self.expectedlifecyclerevision = expectedlifecyclerevision
        self.expectedsessionupdatedat = expectedsessionupdatedat
        self.emitlifecyclehooks = emitlifecyclehooks
        self.archivedonly = archivedonly
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case deletetranscript = "deleteTranscript"
        case expectedsessionid = "expectedSessionId"
        case expectedlifecyclerevision = "expectedLifecycleRevision"
        case expectedsessionupdatedat = "expectedSessionUpdatedAt"
        case emitlifecyclehooks = "emitLifecycleHooks"
        case archivedonly = "archivedOnly"
    }
}

public struct SessionGroup: Codable, Sendable {
    public let name: String
    public let position: Int

    public init(
        name: String,
        position: Int)
    {
        self.name = name
        self.position = position
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case position
    }
}

public struct SessionsGroupsListParams: Codable, Sendable {}

public struct SessionsGroupsListResult: Codable, Sendable {
    public let groups: [SessionGroup]

    public init(
        groups: [SessionGroup])
    {
        self.groups = groups
    }

    private enum CodingKeys: String, CodingKey {
        case groups
    }
}

public struct SessionsGroupsPutParams: Codable, Sendable {
    public let names: [String]

    public init(
        names: [String])
    {
        self.names = names
    }

    private enum CodingKeys: String, CodingKey {
        case names
    }
}

public struct SessionsGroupsRenameParams: Codable, Sendable {
    public let name: String
    public let to: String

    public init(
        name: String,
        to: String)
    {
        self.name = name
        self.to = to
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case to
    }
}

public struct SessionsGroupsDeleteParams: Codable, Sendable {
    public let name: String

    public init(
        name: String)
    {
        self.name = name
    }

    private enum CodingKeys: String, CodingKey {
        case name
    }
}

public struct SessionsGroupsMutationResult: Codable, Sendable {
    public let ok: Bool
    public let groups: [SessionGroup]
    public let updatedsessions: Int?

    public init(
        ok: Bool,
        groups: [SessionGroup],
        updatedsessions: Int? = nil)
    {
        self.ok = ok
        self.groups = groups
        self.updatedsessions = updatedsessions
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case groups
        case updatedsessions = "updatedSessions"
    }
}

public struct SessionsCompactParams: Codable, Sendable {
    public let key: String
    public let agentid: String?
    public let maxlines: Int?

    public init(
        key: String,
        agentid: String? = nil,
        maxlines: Int? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.maxlines = maxlines
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case maxlines = "maxLines"
    }
}

public struct SessionsUsageParams: Codable, Sendable {
    public let key: String?
    public let agentid: String?
    public let agentscope: String?
    public let startdate: String?
    public let enddate: String?
    public let mode: AnyCodable?
    public let range: AnyCodable?
    public let groupby: AnyCodable?
    public let includehistorical: Bool?
    public let utcoffset: String?
    public let timezone: String?
    public let limit: Int?
    public let includecontextweight: Bool?

    public init(
        key: String? = nil,
        agentid: String? = nil,
        agentscope: String? = nil,
        startdate: String? = nil,
        enddate: String? = nil,
        mode: AnyCodable? = nil,
        range: AnyCodable? = nil,
        groupby: AnyCodable? = nil,
        includehistorical: Bool? = nil,
        utcoffset: String? = nil,
        timezone: String? = nil,
        limit: Int? = nil,
        includecontextweight: Bool? = nil)
    {
        self.key = key
        self.agentid = agentid
        self.agentscope = agentscope
        self.startdate = startdate
        self.enddate = enddate
        self.mode = mode
        self.range = range
        self.groupby = groupby
        self.includehistorical = includehistorical
        self.utcoffset = utcoffset
        self.timezone = timezone
        self.limit = limit
        self.includecontextweight = includecontextweight
    }

    private enum CodingKeys: String, CodingKey {
        case key
        case agentid = "agentId"
        case agentscope = "agentScope"
        case startdate = "startDate"
        case enddate = "endDate"
        case mode
        case range
        case groupby = "groupBy"
        case includehistorical = "includeHistorical"
        case utcoffset = "utcOffset"
        case timezone = "timeZone"
        case limit
        case includecontextweight = "includeContextWeight"
    }
}

public struct AuditActivityAgentRunV1: Codable, Sendable {
    public let eventtype: String
    public let schemaversion: Int
    public let eventid: String
    public let sequence: Int
    public let sourcesequence: Int
    public let occurredat: Int
    public let redaction: String
    public let actor: [String: AnyCodable]
    public let agentid: String
    public let sessionkey: String?
    public let sessionid: String?
    public let runid: String
    public let kind: String
    public let action: AnyCodable
    public let status: AnyCodable
    public let errorcode: AnyCodable?

    public init(
        eventtype: String,
        schemaversion: Int,
        eventid: String,
        sequence: Int,
        sourcesequence: Int,
        occurredat: Int,
        redaction: String,
        actor: [String: AnyCodable],
        agentid: String,
        sessionkey: String? = nil,
        sessionid: String? = nil,
        runid: String,
        kind: String,
        action: AnyCodable,
        status: AnyCodable,
        errorcode: AnyCodable? = nil)
    {
        self.eventtype = eventtype
        self.schemaversion = schemaversion
        self.eventid = eventid
        self.sequence = sequence
        self.sourcesequence = sourcesequence
        self.occurredat = occurredat
        self.redaction = redaction
        self.actor = actor
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.runid = runid
        self.kind = kind
        self.action = action
        self.status = status
        self.errorcode = errorcode
    }

    private enum CodingKeys: String, CodingKey {
        case eventtype = "eventType"
        case schemaversion = "schemaVersion"
        case eventid = "eventId"
        case sequence
        case sourcesequence = "sourceSequence"
        case occurredat = "occurredAt"
        case redaction
        case actor
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case runid = "runId"
        case kind
        case action
        case status
        case errorcode = "errorCode"
    }
}

public struct AuditActivityToolActionV1: Codable, Sendable {
    public let eventtype: String
    public let schemaversion: Int
    public let eventid: String
    public let sequence: Int
    public let sourcesequence: Int
    public let occurredat: Int
    public let redaction: String
    public let actor: [String: AnyCodable]
    public let agentid: String
    public let sessionkey: String?
    public let sessionid: String?
    public let runid: String
    public let kind: String
    public let toolcallid: String?
    public let toolname: String?
    public let action: AnyCodable
    public let status: AnyCodable
    public let errorcode: AnyCodable?

    public init(
        eventtype: String,
        schemaversion: Int,
        eventid: String,
        sequence: Int,
        sourcesequence: Int,
        occurredat: Int,
        redaction: String,
        actor: [String: AnyCodable],
        agentid: String,
        sessionkey: String? = nil,
        sessionid: String? = nil,
        runid: String,
        kind: String,
        toolcallid: String? = nil,
        toolname: String? = nil,
        action: AnyCodable,
        status: AnyCodable,
        errorcode: AnyCodable? = nil)
    {
        self.eventtype = eventtype
        self.schemaversion = schemaversion
        self.eventid = eventid
        self.sequence = sequence
        self.sourcesequence = sourcesequence
        self.occurredat = occurredat
        self.redaction = redaction
        self.actor = actor
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.runid = runid
        self.kind = kind
        self.toolcallid = toolcallid
        self.toolname = toolname
        self.action = action
        self.status = status
        self.errorcode = errorcode
    }

    private enum CodingKeys: String, CodingKey {
        case eventtype = "eventType"
        case schemaversion = "schemaVersion"
        case eventid = "eventId"
        case sequence
        case sourcesequence = "sourceSequence"
        case occurredat = "occurredAt"
        case redaction
        case actor
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case runid = "runId"
        case kind
        case toolcallid = "toolCallId"
        case toolname = "toolName"
        case action
        case status
        case errorcode = "errorCode"
    }
}

public struct AuditActivityInboundMessageV1: Codable, Sendable {
    public let eventtype: String
    public let schemaversion: Int
    public let eventid: String
    public let sequence: Int
    public let sourcesequence: Int
    public let occurredat: Int
    public let redaction: String
    public let channel: String
    public let conversationkind: AnyCodable
    public let durationms: Int?
    public let resultcount: Int?
    public let agentid: String?
    public let runid: String?
    public let accountref: String?
    public let conversationref: String?
    public let messageref: String?
    public let targetref: String?
    public let kind: String
    public let action: String
    public let direction: String
    public let actor: AnyCodable
    public let status: AnyCodable
    public let outcome: AnyCodable
    public let errorcode: String?
    public let reasoncode: AnyCodable?

    public init(
        eventtype: String,
        schemaversion: Int,
        eventid: String,
        sequence: Int,
        sourcesequence: Int,
        occurredat: Int,
        redaction: String,
        channel: String,
        conversationkind: AnyCodable,
        durationms: Int? = nil,
        resultcount: Int? = nil,
        agentid: String? = nil,
        runid: String? = nil,
        accountref: String? = nil,
        conversationref: String? = nil,
        messageref: String? = nil,
        targetref: String? = nil,
        kind: String,
        action: String,
        direction: String,
        actor: AnyCodable,
        status: AnyCodable,
        outcome: AnyCodable,
        errorcode: String? = nil,
        reasoncode: AnyCodable? = nil)
    {
        self.eventtype = eventtype
        self.schemaversion = schemaversion
        self.eventid = eventid
        self.sequence = sequence
        self.sourcesequence = sourcesequence
        self.occurredat = occurredat
        self.redaction = redaction
        self.channel = channel
        self.conversationkind = conversationkind
        self.durationms = durationms
        self.resultcount = resultcount
        self.agentid = agentid
        self.runid = runid
        self.accountref = accountref
        self.conversationref = conversationref
        self.messageref = messageref
        self.targetref = targetref
        self.kind = kind
        self.action = action
        self.direction = direction
        self.actor = actor
        self.status = status
        self.outcome = outcome
        self.errorcode = errorcode
        self.reasoncode = reasoncode
    }

    private enum CodingKeys: String, CodingKey {
        case eventtype = "eventType"
        case schemaversion = "schemaVersion"
        case eventid = "eventId"
        case sequence
        case sourcesequence = "sourceSequence"
        case occurredat = "occurredAt"
        case redaction
        case channel
        case conversationkind = "conversationKind"
        case durationms = "durationMs"
        case resultcount = "resultCount"
        case agentid = "agentId"
        case runid = "runId"
        case accountref = "accountRef"
        case conversationref = "conversationRef"
        case messageref = "messageRef"
        case targetref = "targetRef"
        case kind
        case action
        case direction
        case actor
        case status
        case outcome
        case errorcode = "errorCode"
        case reasoncode = "reasonCode"
    }
}

public struct AuditActivityOutboundMessageV1: Codable, Sendable {
    public let eventtype: String
    public let schemaversion: Int
    public let eventid: String
    public let sequence: Int
    public let sourcesequence: Int
    public let occurredat: Int
    public let redaction: String
    public let channel: String
    public let conversationkind: AnyCodable
    public let durationms: Int?
    public let resultcount: Int?
    public let agentid: String?
    public let runid: String?
    public let accountref: String?
    public let conversationref: String?
    public let messageref: String?
    public let targetref: String?
    public let kind: String
    public let action: String
    public let direction: String
    public let actor: [String: AnyCodable]
    public let deliverykind: AnyCodable?
    public let status: AnyCodable
    public let outcome: AnyCodable
    public let errorcode: AnyCodable?
    public let reasoncode: AnyCodable?
    public let failurestage: AnyCodable?

    public init(
        eventtype: String,
        schemaversion: Int,
        eventid: String,
        sequence: Int,
        sourcesequence: Int,
        occurredat: Int,
        redaction: String,
        channel: String,
        conversationkind: AnyCodable,
        durationms: Int? = nil,
        resultcount: Int? = nil,
        agentid: String? = nil,
        runid: String? = nil,
        accountref: String? = nil,
        conversationref: String? = nil,
        messageref: String? = nil,
        targetref: String? = nil,
        kind: String,
        action: String,
        direction: String,
        actor: [String: AnyCodable],
        deliverykind: AnyCodable? = nil,
        status: AnyCodable,
        outcome: AnyCodable,
        errorcode: AnyCodable? = nil,
        reasoncode: AnyCodable? = nil,
        failurestage: AnyCodable? = nil)
    {
        self.eventtype = eventtype
        self.schemaversion = schemaversion
        self.eventid = eventid
        self.sequence = sequence
        self.sourcesequence = sourcesequence
        self.occurredat = occurredat
        self.redaction = redaction
        self.channel = channel
        self.conversationkind = conversationkind
        self.durationms = durationms
        self.resultcount = resultcount
        self.agentid = agentid
        self.runid = runid
        self.accountref = accountref
        self.conversationref = conversationref
        self.messageref = messageref
        self.targetref = targetref
        self.kind = kind
        self.action = action
        self.direction = direction
        self.actor = actor
        self.deliverykind = deliverykind
        self.status = status
        self.outcome = outcome
        self.errorcode = errorcode
        self.reasoncode = reasoncode
        self.failurestage = failurestage
    }

    private enum CodingKeys: String, CodingKey {
        case eventtype = "eventType"
        case schemaversion = "schemaVersion"
        case eventid = "eventId"
        case sequence
        case sourcesequence = "sourceSequence"
        case occurredat = "occurredAt"
        case redaction
        case channel
        case conversationkind = "conversationKind"
        case durationms = "durationMs"
        case resultcount = "resultCount"
        case agentid = "agentId"
        case runid = "runId"
        case accountref = "accountRef"
        case conversationref = "conversationRef"
        case messageref = "messageRef"
        case targetref = "targetRef"
        case kind
        case action
        case direction
        case actor
        case deliverykind = "deliveryKind"
        case status
        case outcome
        case errorcode = "errorCode"
        case reasoncode = "reasonCode"
        case failurestage = "failureStage"
    }
}

public struct AuditActivityListParams: Codable, Sendable {
    public let agentid: String?
    public let sessionkey: String?
    public let runid: String?
    public let kind: AnyCodable?
    public let status: AnyCodable?
    public let direction: AnyCodable?
    public let channel: String?
    public let after: Int?
    public let before: Int?
    public let limit: Int?
    public let cursor: String?

    public init(
        agentid: String? = nil,
        sessionkey: String? = nil,
        runid: String? = nil,
        kind: AnyCodable? = nil,
        status: AnyCodable? = nil,
        direction: AnyCodable? = nil,
        channel: String? = nil,
        after: Int? = nil,
        before: Int? = nil,
        limit: Int? = nil,
        cursor: String? = nil)
    {
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.runid = runid
        self.kind = kind
        self.status = status
        self.direction = direction
        self.channel = channel
        self.after = after
        self.before = before
        self.limit = limit
        self.cursor = cursor
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case runid = "runId"
        case kind
        case status
        case direction
        case channel
        case after
        case before
        case limit
        case cursor
    }
}

public struct AuditActivityListResult: Codable, Sendable {
    public let events: [AuditActivityEventV1]
    public let nextcursor: String?

    public init(
        events: [AuditActivityEventV1],
        nextcursor: String? = nil)
    {
        self.events = events
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case events
        case nextcursor = "nextCursor"
    }
}

public struct AuditEvent: Codable, Sendable {
    public let eventid: String
    public let sequence: Int
    public let sourcesequence: Int
    public let occurredat: Int
    public let kind: AnyCodable
    public let action: AnyCodable
    public let status: AnyCodable
    public let errorcode: AnyCodable?
    public let actor: [String: AnyCodable]
    public let agentid: String
    public let sessionkey: String?
    public let sessionid: String?
    public let runid: String
    public let toolcallid: String?
    public let toolname: String?
    public let redaction: String

    public init(
        eventid: String,
        sequence: Int,
        sourcesequence: Int,
        occurredat: Int,
        kind: AnyCodable,
        action: AnyCodable,
        status: AnyCodable,
        errorcode: AnyCodable? = nil,
        actor: [String: AnyCodable],
        agentid: String,
        sessionkey: String? = nil,
        sessionid: String? = nil,
        runid: String,
        toolcallid: String? = nil,
        toolname: String? = nil,
        redaction: String)
    {
        self.eventid = eventid
        self.sequence = sequence
        self.sourcesequence = sourcesequence
        self.occurredat = occurredat
        self.kind = kind
        self.action = action
        self.status = status
        self.errorcode = errorcode
        self.actor = actor
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.runid = runid
        self.toolcallid = toolcallid
        self.toolname = toolname
        self.redaction = redaction
    }

    private enum CodingKeys: String, CodingKey {
        case eventid = "eventId"
        case sequence
        case sourcesequence = "sourceSequence"
        case occurredat = "occurredAt"
        case kind
        case action
        case status
        case errorcode = "errorCode"
        case actor
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case runid = "runId"
        case toolcallid = "toolCallId"
        case toolname = "toolName"
        case redaction
    }
}

public struct AuditListParams: Codable, Sendable {
    public let agentid: String?
    public let sessionkey: String?
    public let runid: String?
    public let kind: AnyCodable?
    public let status: AnyCodable?
    public let after: Int?
    public let before: Int?
    public let limit: Int?
    public let cursor: String?

    public init(
        agentid: String? = nil,
        sessionkey: String? = nil,
        runid: String? = nil,
        kind: AnyCodable? = nil,
        status: AnyCodable? = nil,
        after: Int? = nil,
        before: Int? = nil,
        limit: Int? = nil,
        cursor: String? = nil)
    {
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.runid = runid
        self.kind = kind
        self.status = status
        self.after = after
        self.before = before
        self.limit = limit
        self.cursor = cursor
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case runid = "runId"
        case kind
        case status
        case after
        case before
        case limit
        case cursor
    }
}

public struct AuditListResult: Codable, Sendable {
    public let events: [AuditEvent]
    public let nextcursor: String?

    public init(
        events: [AuditEvent],
        nextcursor: String? = nil)
    {
        self.events = events
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case events
        case nextcursor = "nextCursor"
    }
}

public struct TaskSuggestion: Codable, Sendable {
    public let id: String
    public let title: String
    public let prompt: String
    public let tldr: String
    public let cwd: String
    public let sessionkey: String
    public let agentid: String?
    public let createdat: Int

    public init(
        id: String,
        title: String,
        prompt: String,
        tldr: String,
        cwd: String,
        sessionkey: String,
        agentid: String? = nil,
        createdat: Int)
    {
        self.id = id
        self.title = title
        self.prompt = prompt
        self.tldr = tldr
        self.cwd = cwd
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.createdat = createdat
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case title
        case prompt
        case tldr
        case cwd
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case createdat = "createdAt"
    }
}

public struct TaskSuggestionsAcceptParams: Codable, Sendable {
    public let taskid: String

    public init(
        taskid: String)
    {
        self.taskid = taskid
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
    }
}

public struct TaskSuggestionsAcceptResult: Codable, Sendable {
    public let taskid: String
    public let key: String

    public init(
        taskid: String,
        key: String)
    {
        self.taskid = taskid
        self.key = key
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case key
    }
}

public struct TaskSuggestionsCreateParams: Codable, Sendable {
    public let title: String
    public let prompt: String
    public let tldr: String
    public let cwd: String
    public let sessionkey: String
    public let agentid: String?

    public init(
        title: String,
        prompt: String,
        tldr: String,
        cwd: String,
        sessionkey: String,
        agentid: String? = nil)
    {
        self.title = title
        self.prompt = prompt
        self.tldr = tldr
        self.cwd = cwd
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case title
        case prompt
        case tldr
        case cwd
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct TaskSuggestionsCreateResult: Codable, Sendable {
    public let taskid: String
    public let suggestion: TaskSuggestion

    public init(
        taskid: String,
        suggestion: TaskSuggestion)
    {
        self.taskid = taskid
        self.suggestion = suggestion
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case suggestion
    }
}

public struct TaskSuggestionsDismissParams: Codable, Sendable {
    public let taskid: String
    public let reason: String?

    public init(
        taskid: String,
        reason: String? = nil)
    {
        self.taskid = taskid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case reason
    }
}

public struct TaskSuggestionsDismissResult: Codable, Sendable {
    public let taskid: String
    public let dismissed: Bool

    public init(
        taskid: String,
        dismissed: Bool)
    {
        self.taskid = taskid
        self.dismissed = dismissed
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case dismissed
    }
}

public struct TaskSuggestionsListParams: Codable, Sendable {
    public let sessionkey: String?
    public let agentid: String?

    public init(
        sessionkey: String? = nil,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
    }
}

public struct TaskSuggestionsListResult: Codable, Sendable {
    public let suggestions: [TaskSuggestion]

    public init(
        suggestions: [TaskSuggestion])
    {
        self.suggestions = suggestions
    }

    private enum CodingKeys: String, CodingKey {
        case suggestions
    }
}

public struct TaskSummary: Codable, Sendable {
    public let id: String
    public let kind: String?
    public let runtime: String?
    public let status: AnyCodable
    public let title: String?
    public let agentid: String?
    public let sessionkey: String?
    public let childsessionkey: String?
    public let ownerkey: String?
    public let runid: String?
    public let taskid: String?
    public let flowid: String?
    public let parenttaskid: String?
    public let sourceid: String?
    public let createdat: AnyCodable?
    public let updatedat: AnyCodable?
    public let startedat: AnyCodable?
    public let endedat: AnyCodable?
    public let toolusecount: Int?
    public let lasttoolname: String?
    public let progresssummary: String?
    public let terminalsummary: String?
    public let error: String?
    public let prompt: String?

    public init(
        id: String,
        kind: String? = nil,
        runtime: String? = nil,
        status: AnyCodable,
        title: String? = nil,
        agentid: String? = nil,
        sessionkey: String? = nil,
        childsessionkey: String? = nil,
        ownerkey: String? = nil,
        runid: String? = nil,
        taskid: String? = nil,
        flowid: String? = nil,
        parenttaskid: String? = nil,
        sourceid: String? = nil,
        createdat: AnyCodable? = nil,
        updatedat: AnyCodable? = nil,
        startedat: AnyCodable? = nil,
        endedat: AnyCodable? = nil,
        toolusecount: Int? = nil,
        lasttoolname: String? = nil,
        progresssummary: String? = nil,
        terminalsummary: String? = nil,
        error: String? = nil,
        prompt: String? = nil)
    {
        self.id = id
        self.kind = kind
        self.runtime = runtime
        self.status = status
        self.title = title
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.childsessionkey = childsessionkey
        self.ownerkey = ownerkey
        self.runid = runid
        self.taskid = taskid
        self.flowid = flowid
        self.parenttaskid = parenttaskid
        self.sourceid = sourceid
        self.createdat = createdat
        self.updatedat = updatedat
        self.startedat = startedat
        self.endedat = endedat
        self.toolusecount = toolusecount
        self.lasttoolname = lasttoolname
        self.progresssummary = progresssummary
        self.terminalsummary = terminalsummary
        self.error = error
        self.prompt = prompt
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case kind
        case runtime
        case status
        case title
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case childsessionkey = "childSessionKey"
        case ownerkey = "ownerKey"
        case runid = "runId"
        case taskid = "taskId"
        case flowid = "flowId"
        case parenttaskid = "parentTaskId"
        case sourceid = "sourceId"
        case createdat = "createdAt"
        case updatedat = "updatedAt"
        case startedat = "startedAt"
        case endedat = "endedAt"
        case toolusecount = "toolUseCount"
        case lasttoolname = "lastToolName"
        case progresssummary = "progressSummary"
        case terminalsummary = "terminalSummary"
        case error
        case prompt
    }
}

public struct TasksListParams: Codable, Sendable {
    public let status: AnyCodable?
    public let agentid: String?
    public let sessionkey: String?
    public let limit: Int?
    public let cursor: String?

    public init(
        status: AnyCodable? = nil,
        agentid: String? = nil,
        sessionkey: String? = nil,
        limit: Int? = nil,
        cursor: String? = nil)
    {
        self.status = status
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.limit = limit
        self.cursor = cursor
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case limit
        case cursor
    }
}

public struct TasksListResult: Codable, Sendable {
    public let tasks: [TaskSummary]
    public let nextcursor: String?

    public init(
        tasks: [TaskSummary],
        nextcursor: String? = nil)
    {
        self.tasks = tasks
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case tasks
        case nextcursor = "nextCursor"
    }
}

public struct TasksGetParams: Codable, Sendable {
    public let taskid: String

    public init(
        taskid: String)
    {
        self.taskid = taskid
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
    }
}

public struct TasksGetResult: Codable, Sendable {
    public let task: TaskSummary

    public init(
        task: TaskSummary)
    {
        self.task = task
    }

    private enum CodingKeys: String, CodingKey {
        case task
    }
}

public struct TasksCancelParams: Codable, Sendable {
    public let taskid: String
    public let reason: String?

    public init(
        taskid: String,
        reason: String? = nil)
    {
        self.taskid = taskid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case taskid = "taskId"
        case reason
    }
}

public struct TasksCancelResult: Codable, Sendable {
    public let found: Bool
    public let cancelled: Bool
    public let reason: String?
    public let task: TaskSummary?

    public init(
        found: Bool,
        cancelled: Bool,
        reason: String? = nil,
        task: TaskSummary? = nil)
    {
        self.found = found
        self.cancelled = cancelled
        self.reason = reason
        self.task = task
    }

    private enum CodingKeys: String, CodingKey {
        case found
        case cancelled
        case reason
        case task
    }
}

public struct ConfigGetParams: Codable, Sendable {}

public struct ConfigSetParams: Codable, Sendable {
    public let raw: String
    public let basehash: String?

    public init(
        raw: String,
        basehash: String? = nil)
    {
        self.raw = raw
        self.basehash = basehash
    }

    private enum CodingKeys: String, CodingKey {
        case raw
        case basehash = "baseHash"
    }
}

public struct ConfigApplyParams: Codable, Sendable {
    public let raw: String
    public let basehash: String?
    public let sessionkey: String?
    public let deliverycontext: [String: AnyCodable]?
    public let note: String?
    public let restartdelayms: Int?

    public init(
        raw: String,
        basehash: String? = nil,
        sessionkey: String? = nil,
        deliverycontext: [String: AnyCodable]? = nil,
        note: String? = nil,
        restartdelayms: Int? = nil)
    {
        self.raw = raw
        self.basehash = basehash
        self.sessionkey = sessionkey
        self.deliverycontext = deliverycontext
        self.note = note
        self.restartdelayms = restartdelayms
    }

    private enum CodingKeys: String, CodingKey {
        case raw
        case basehash = "baseHash"
        case sessionkey = "sessionKey"
        case deliverycontext = "deliveryContext"
        case note
        case restartdelayms = "restartDelayMs"
    }
}

public struct ConfigPatchParams: Codable, Sendable {
    public let raw: String
    public let basehash: String?
    public let sessionkey: String?
    public let deliverycontext: [String: AnyCodable]?
    public let note: String?
    public let restartdelayms: Int?
    public let replacepaths: [String]?

    public init(
        raw: String,
        basehash: String? = nil,
        sessionkey: String? = nil,
        deliverycontext: [String: AnyCodable]? = nil,
        note: String? = nil,
        restartdelayms: Int? = nil,
        replacepaths: [String]? = nil)
    {
        self.raw = raw
        self.basehash = basehash
        self.sessionkey = sessionkey
        self.deliverycontext = deliverycontext
        self.note = note
        self.restartdelayms = restartdelayms
        self.replacepaths = replacepaths
    }

    private enum CodingKeys: String, CodingKey {
        case raw
        case basehash = "baseHash"
        case sessionkey = "sessionKey"
        case deliverycontext = "deliveryContext"
        case note
        case restartdelayms = "restartDelayMs"
        case replacepaths = "replacePaths"
    }
}

public struct ConfigSchemaParams: Codable, Sendable {}

public struct ConfigSchemaLookupParams: Codable, Sendable {
    public let path: String

    public init(
        path: String)
    {
        self.path = path
    }

    private enum CodingKeys: String, CodingKey {
        case path
    }
}

public struct ConfigSchemaResponse: Codable, Sendable {
    public let schema: AnyCodable
    public let uihints: [String: AnyCodable]
    public let version: String
    public let generatedat: String

    public init(
        schema: AnyCodable,
        uihints: [String: AnyCodable],
        version: String,
        generatedat: String)
    {
        self.schema = schema
        self.uihints = uihints
        self.version = version
        self.generatedat = generatedat
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case uihints = "uiHints"
        case version
        case generatedat = "generatedAt"
    }
}

public struct ConfigSchemaLookupResult: Codable, Sendable {
    public let path: String
    public let schema: AnyCodable
    public let reloadkind: AnyCodable?
    public let hint: [String: AnyCodable]?
    public let hintpath: String?
    public let children: [[String: AnyCodable]]

    public init(
        path: String,
        schema: AnyCodable,
        reloadkind: AnyCodable? = nil,
        hint: [String: AnyCodable]? = nil,
        hintpath: String? = nil,
        children: [[String: AnyCodable]])
    {
        self.path = path
        self.schema = schema
        self.reloadkind = reloadkind
        self.hint = hint
        self.hintpath = hintpath
        self.children = children
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case schema
        case reloadkind = "reloadKind"
        case hint
        case hintpath = "hintPath"
        case children
    }
}

public struct SystemAgentChatParams: Codable, Sendable {
    public let sessionid: String
    public let message: String?
    public let welcomevariant: AnyCodable?
    public let reset: Bool?
    public let delegation: [String: AnyCodable]?

    public init(
        sessionid: String,
        message: String? = nil,
        welcomevariant: AnyCodable? = nil,
        reset: Bool? = nil,
        delegation: [String: AnyCodable]? = nil)
    {
        self.sessionid = sessionid
        self.message = message
        self.welcomevariant = welcomevariant
        self.reset = reset
        self.delegation = delegation
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case message
        case welcomevariant = "welcomeVariant"
        case reset
        case delegation
    }
}

public struct SystemAgentChatResult: Codable, Sendable {
    public let sessionid: String
    public let reply: String
    public let sensitive: Bool?
    public let wizardinputpending: Bool?
    public let action: AnyCodable
    public let agentdraft: String?
    public let agentid: String?
    public let needsapproval: Bool?
    public let proposalid: String?
    public let question: [String: AnyCodable]?

    public init(
        sessionid: String,
        reply: String,
        sensitive: Bool? = nil,
        wizardinputpending: Bool? = nil,
        action: AnyCodable,
        agentdraft: String? = nil,
        agentid: String? = nil,
        needsapproval: Bool? = nil,
        proposalid: String? = nil,
        question: [String: AnyCodable]? = nil)
    {
        self.sessionid = sessionid
        self.reply = reply
        self.sensitive = sensitive
        self.wizardinputpending = wizardinputpending
        self.action = action
        self.agentdraft = agentdraft
        self.agentid = agentid
        self.needsapproval = needsapproval
        self.proposalid = proposalid
        self.question = question
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case reply
        case sensitive
        case wizardinputpending = "wizardInputPending"
        case action
        case agentdraft = "agentDraft"
        case agentid = "agentId"
        case needsapproval = "needsApproval"
        case proposalid = "proposalId"
        case question
    }
}

public struct SystemAgentChatHistoryParams: Codable, Sendable {
    public let limit: Int?

    public init(
        limit: Int? = nil)
    {
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case limit
    }
}

public struct SystemAgentChatHistoryTurn: Codable, Sendable {
    public let role: AnyCodable
    public let text: String
    public let at: Double

    public init(
        role: AnyCodable,
        text: String,
        at: Double)
    {
        self.role = role
        self.text = text
        self.at = at
    }

    private enum CodingKeys: String, CodingKey {
        case role
        case text
        case at
    }
}

public struct SystemAgentChatHistoryResult: Codable, Sendable {
    public let turns: [SystemAgentChatHistoryTurn]

    public init(
        turns: [SystemAgentChatHistoryTurn])
    {
        self.turns = turns
    }

    private enum CodingKeys: String, CodingKey {
        case turns
    }
}

public struct SystemChangeEntry: Codable, Sendable {
    public let id: String
    public let at: Double
    public let kind: SystemChangeKind
    public let source: SystemChangeSource
    public let summary: String
    public let changedpaths: [String]?
    public let invalid: Bool?
    public let opaquechange: Bool?

    public init(
        id: String,
        at: Double,
        kind: SystemChangeKind,
        source: SystemChangeSource,
        summary: String,
        changedpaths: [String]? = nil,
        invalid: Bool? = nil,
        opaquechange: Bool? = nil)
    {
        self.id = id
        self.at = at
        self.kind = kind
        self.source = source
        self.summary = summary
        self.changedpaths = changedpaths
        self.invalid = invalid
        self.opaquechange = opaquechange
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case at
        case kind
        case source
        case summary
        case changedpaths = "changedPaths"
        case invalid
        case opaquechange = "opaqueChange"
    }
}

public struct SystemChangesListParams: Codable, Sendable {
    public let limit: Int?
    public let beforecursor: String?

    public init(
        limit: Int? = nil,
        beforecursor: String? = nil)
    {
        self.limit = limit
        self.beforecursor = beforecursor
    }

    private enum CodingKeys: String, CodingKey {
        case limit
        case beforecursor = "beforeCursor"
    }
}

public struct SystemChangesListResult: Codable, Sendable {
    public let entries: [SystemChangeEntry]
    public let nextcursor: String?

    public init(
        entries: [SystemChangeEntry],
        nextcursor: String? = nil)
    {
        self.entries = entries
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case entries
        case nextcursor = "nextCursor"
    }
}

public struct SystemAgentSetupDetectParams: Codable, Sendable {}

public struct SystemAgentSetupDetectResult: Codable, Sendable {
    public let candidates: [[String: AnyCodable]]
    public let unavailablecandidates: [[String: AnyCodable]]?
    public let manualproviders: [[String: AnyCodable]]
    public let authoptions: [[String: AnyCodable]]?
    public let recommendedinstalls: [[String: AnyCodable]]?
    public let workspace: String
    public let codexappserverdetected: Bool?
    public let configuredmodel: String?
    public let setupcomplete: Bool

    public init(
        candidates: [[String: AnyCodable]],
        unavailablecandidates: [[String: AnyCodable]]? = nil,
        manualproviders: [[String: AnyCodable]],
        authoptions: [[String: AnyCodable]]? = nil,
        recommendedinstalls: [[String: AnyCodable]]? = nil,
        workspace: String,
        codexappserverdetected: Bool? = nil,
        configuredmodel: String? = nil,
        setupcomplete: Bool)
    {
        self.candidates = candidates
        self.unavailablecandidates = unavailablecandidates
        self.manualproviders = manualproviders
        self.authoptions = authoptions
        self.recommendedinstalls = recommendedinstalls
        self.workspace = workspace
        self.codexappserverdetected = codexappserverdetected
        self.configuredmodel = configuredmodel
        self.setupcomplete = setupcomplete
    }

    private enum CodingKeys: String, CodingKey {
        case candidates
        case unavailablecandidates = "unavailableCandidates"
        case manualproviders = "manualProviders"
        case authoptions = "authOptions"
        case recommendedinstalls = "recommendedInstalls"
        case workspace
        case codexappserverdetected = "codexAppServerDetected"
        case configuredmodel = "configuredModel"
        case setupcomplete = "setupComplete"
    }
}

public struct SystemAgentSetupVerifyParams: Codable, Sendable {}

public struct SystemAgentSetupActivateParams: Codable, Sendable {
    public let kind: AnyCodable
    public let modelref: String?
    public let authchoice: String?
    public let apikey: String?
    public let workspace: String?

    public init(
        kind: AnyCodable,
        modelref: String? = nil,
        authchoice: String? = nil,
        apikey: String? = nil,
        workspace: String? = nil)
    {
        self.kind = kind
        self.modelref = modelref
        self.authchoice = authchoice
        self.apikey = apikey
        self.workspace = workspace
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case modelref = "modelRef"
        case authchoice = "authChoice"
        case apikey = "apiKey"
        case workspace
    }
}

public struct SystemAgentSetupActivateResult: Codable, Sendable {
    public let ok: Bool
    public let modelref: String?
    public let latencyms: Double?
    public let lines: [String]?
    public let status: AnyCodable?
    public let error: String?

    public init(
        ok: Bool,
        modelref: String? = nil,
        latencyms: Double? = nil,
        lines: [String]? = nil,
        status: AnyCodable? = nil,
        error: String? = nil)
    {
        self.ok = ok
        self.modelref = modelref
        self.latencyms = latencyms
        self.lines = lines
        self.status = status
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case modelref = "modelRef"
        case latencyms = "latencyMs"
        case lines
        case status
        case error
    }
}

public struct SystemAgentSetupAuthStartParams: Codable, Sendable {
    public let sessionid: String
    public let authchoice: String
    public let workspace: String?

    public init(
        sessionid: String,
        authchoice: String,
        workspace: String? = nil)
    {
        self.sessionid = sessionid
        self.authchoice = authchoice
        self.workspace = workspace
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case authchoice = "authChoice"
        case workspace
    }
}

public struct SystemAgentSetupAuthStartResult: Codable, Sendable {
    public let sessionid: String
    public let done: Bool
    public let step: WizardStep?
    public let status: AnyCodable?
    public let error: String?
    public let channels: [String]?
    public let accounts: [[String: AnyCodable]]?

    public init(
        sessionid: String,
        done: Bool,
        step: WizardStep? = nil,
        status: AnyCodable? = nil,
        error: String? = nil,
        channels: [String]? = nil,
        accounts: [[String: AnyCodable]]? = nil)
    {
        self.sessionid = sessionid
        self.done = done
        self.step = step
        self.status = status
        self.error = error
        self.channels = channels
        self.accounts = accounts
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case done
        case step
        case status
        case error
        case channels
        case accounts
    }
}

public struct WizardStartParams: Codable, Sendable {
    public let mode: AnyCodable?
    public let workspace: String?
    public let flow: AnyCodable?
    public let channel: String?

    public init(
        mode: AnyCodable? = nil,
        workspace: String? = nil,
        flow: AnyCodable? = nil,
        channel: String? = nil)
    {
        self.mode = mode
        self.workspace = workspace
        self.flow = flow
        self.channel = channel
    }

    private enum CodingKeys: String, CodingKey {
        case mode
        case workspace
        case flow
        case channel
    }
}

public struct WizardNextParams: Codable, Sendable {
    public let sessionid: String
    public let answer: [String: AnyCodable]?

    public init(
        sessionid: String,
        answer: [String: AnyCodable]? = nil)
    {
        self.sessionid = sessionid
        self.answer = answer
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case answer
    }
}

public struct WizardCancelParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct WizardStatusParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct WizardStep: Codable, Sendable {
    public let id: String
    public let type: AnyCodable
    public let title: String?
    public let message: String?
    public let format: AnyCodable?
    public let options: [[String: AnyCodable]]?
    public let initialvalue: AnyCodable?
    public let placeholder: String?
    public let sensitive: Bool?
    public let executor: AnyCodable?
    public let externalurl: String?
    public let devicecode: [String: AnyCodable]?

    public init(
        id: String,
        type: AnyCodable,
        title: String? = nil,
        message: String? = nil,
        format: AnyCodable? = nil,
        options: [[String: AnyCodable]]? = nil,
        initialvalue: AnyCodable? = nil,
        placeholder: String? = nil,
        sensitive: Bool? = nil,
        executor: AnyCodable? = nil,
        externalurl: String? = nil,
        devicecode: [String: AnyCodable]? = nil)
    {
        self.id = id
        self.type = type
        self.title = title
        self.message = message
        self.format = format
        self.options = options
        self.initialvalue = initialvalue
        self.placeholder = placeholder
        self.sensitive = sensitive
        self.executor = executor
        self.externalurl = externalurl
        self.devicecode = devicecode
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case title
        case message
        case format
        case options
        case initialvalue = "initialValue"
        case placeholder
        case sensitive
        case executor
        case externalurl = "externalUrl"
        case devicecode = "deviceCode"
    }
}

public struct WizardNextResult: Codable, Sendable {
    public let done: Bool
    public let step: WizardStep?
    public let status: AnyCodable?
    public let error: String?
    public let channels: [String]?
    public let accounts: [[String: AnyCodable]]?

    public init(
        done: Bool,
        step: WizardStep? = nil,
        status: AnyCodable? = nil,
        error: String? = nil,
        channels: [String]? = nil,
        accounts: [[String: AnyCodable]]? = nil)
    {
        self.done = done
        self.step = step
        self.status = status
        self.error = error
        self.channels = channels
        self.accounts = accounts
    }

    private enum CodingKeys: String, CodingKey {
        case done
        case step
        case status
        case error
        case channels
        case accounts
    }
}

public struct WizardStartResult: Codable, Sendable {
    public let sessionid: String
    public let done: Bool
    public let step: WizardStep?
    public let status: AnyCodable?
    public let error: String?
    public let channels: [String]?
    public let accounts: [[String: AnyCodable]]?

    public init(
        sessionid: String,
        done: Bool,
        step: WizardStep? = nil,
        status: AnyCodable? = nil,
        error: String? = nil,
        channels: [String]? = nil,
        accounts: [[String: AnyCodable]]? = nil)
    {
        self.sessionid = sessionid
        self.done = done
        self.step = step
        self.status = status
        self.error = error
        self.channels = channels
        self.accounts = accounts
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case done
        case step
        case status
        case error
        case channels
        case accounts
    }
}

public struct WizardStatusResult: Codable, Sendable {
    public let status: AnyCodable
    public let error: String?

    public init(
        status: AnyCodable,
        error: String? = nil)
    {
        self.status = status
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case status
        case error
    }
}

public struct TalkModeParams: Codable, Sendable {
    public let enabled: Bool
    public let phase: String?

    public init(
        enabled: Bool,
        phase: String? = nil)
    {
        self.enabled = enabled
        self.phase = phase
    }

    private enum CodingKeys: String, CodingKey {
        case enabled
        case phase
    }
}

public struct TalkEvent: Codable, Sendable {
    public let id: String
    public let type: AnyCodable
    public let sessionid: String
    public let turnid: String?
    public let captureid: String?
    public let seq: Int
    public let timestamp: String
    public let mode: AnyCodable
    public let transport: AnyCodable
    public let brain: AnyCodable
    public let provider: String?
    public let final: Bool?
    public let callid: String?
    public let itemid: String?
    public let parentid: String?
    public let payload: AnyCodable

    public init(
        id: String,
        type: AnyCodable,
        sessionid: String,
        turnid: String? = nil,
        captureid: String? = nil,
        seq: Int,
        timestamp: String,
        mode: AnyCodable,
        transport: AnyCodable,
        brain: AnyCodable,
        provider: String? = nil,
        final: Bool? = nil,
        callid: String? = nil,
        itemid: String? = nil,
        parentid: String? = nil,
        payload: AnyCodable)
    {
        self.id = id
        self.type = type
        self.sessionid = sessionid
        self.turnid = turnid
        self.captureid = captureid
        self.seq = seq
        self.timestamp = timestamp
        self.mode = mode
        self.transport = transport
        self.brain = brain
        self.provider = provider
        self.final = final
        self.callid = callid
        self.itemid = itemid
        self.parentid = parentid
        self.payload = payload
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case sessionid = "sessionId"
        case turnid = "turnId"
        case captureid = "captureId"
        case seq
        case timestamp
        case mode
        case transport
        case brain
        case provider
        case final
        case callid = "callId"
        case itemid = "itemId"
        case parentid = "parentId"
        case payload
    }
}

public struct TalkCatalogParams: Codable, Sendable {}

public struct TalkCatalogResult: Codable, Sendable {
    public let modes: [AnyCodable]
    public let transports: [AnyCodable]
    public let brains: [AnyCodable]
    public let speech: [String: AnyCodable]
    public let transcription: [String: AnyCodable]
    public let realtime: [String: AnyCodable]

    public init(
        modes: [AnyCodable],
        transports: [AnyCodable],
        brains: [AnyCodable],
        speech: [String: AnyCodable],
        transcription: [String: AnyCodable],
        realtime: [String: AnyCodable])
    {
        self.modes = modes
        self.transports = transports
        self.brains = brains
        self.speech = speech
        self.transcription = transcription
        self.realtime = realtime
    }

    private enum CodingKeys: String, CodingKey {
        case modes
        case transports
        case brains
        case speech
        case transcription
        case realtime
    }
}

public struct TalkClientCreateParams: Codable, Sendable {
    public let sessionkey: String?
    public let voicesessionid: String?
    public let provider: String?
    public let model: String?
    public let voice: String?
    public let vadthreshold: Double?
    public let silencedurationms: Int?
    public let prefixpaddingms: Int?
    public let reasoningeffort: String?
    public let mode: AnyCodable?
    public let transport: AnyCodable?
    public let brain: AnyCodable?
    public let capabilities: [AnyCodable]?

    public init(
        sessionkey: String? = nil,
        voicesessionid: String? = nil,
        provider: String? = nil,
        model: String? = nil,
        voice: String? = nil,
        vadthreshold: Double? = nil,
        silencedurationms: Int? = nil,
        prefixpaddingms: Int? = nil,
        reasoningeffort: String? = nil,
        mode: AnyCodable? = nil,
        transport: AnyCodable? = nil,
        brain: AnyCodable? = nil,
        capabilities: [AnyCodable]? = nil)
    {
        self.sessionkey = sessionkey
        self.voicesessionid = voicesessionid
        self.provider = provider
        self.model = model
        self.voice = voice
        self.vadthreshold = vadthreshold
        self.silencedurationms = silencedurationms
        self.prefixpaddingms = prefixpaddingms
        self.reasoningeffort = reasoningeffort
        self.mode = mode
        self.transport = transport
        self.brain = brain
        self.capabilities = capabilities
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case voicesessionid = "voiceSessionId"
        case provider
        case model
        case voice
        case vadthreshold = "vadThreshold"
        case silencedurationms = "silenceDurationMs"
        case prefixpaddingms = "prefixPaddingMs"
        case reasoningeffort = "reasoningEffort"
        case mode
        case transport
        case brain
        case capabilities
    }
}

public struct TalkClientCloseParams: Codable, Sendable {
    public let sessionkey: String
    public let voicesessionid: String

    public init(
        sessionkey: String,
        voicesessionid: String)
    {
        self.sessionkey = sessionkey
        self.voicesessionid = voicesessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case voicesessionid = "voiceSessionId"
    }
}

public struct TalkClientMutationResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct TalkClientSteerParams: Codable, Sendable {
    public let sessionkey: String
    public let text: String
    public let mode: AnyCodable?

    public init(
        sessionkey: String,
        text: String,
        mode: AnyCodable? = nil)
    {
        self.sessionkey = sessionkey
        self.text = text
        self.mode = mode
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case text
        case mode
    }
}

public struct TalkAgentControlResult: Codable, Sendable {
    public let ok: Bool
    public let mode: AnyCodable
    public let sessionkey: String
    public let sessionid: String?
    public let active: Bool
    public let queued: Bool?
    public let aborted: Bool?
    public let target: AnyCodable?
    public let reason: String?
    public let message: String
    public let speak: Bool
    public let show: Bool
    public let suppress: Bool
    public let providerresult: [String: AnyCodable]?
    public let enqueuedatms: Double?
    public let deliveredatms: Double?

    public init(
        ok: Bool,
        mode: AnyCodable,
        sessionkey: String,
        sessionid: String? = nil,
        active: Bool,
        queued: Bool? = nil,
        aborted: Bool? = nil,
        target: AnyCodable? = nil,
        reason: String? = nil,
        message: String,
        speak: Bool,
        show: Bool,
        suppress: Bool,
        providerresult: [String: AnyCodable]? = nil,
        enqueuedatms: Double? = nil,
        deliveredatms: Double? = nil)
    {
        self.ok = ok
        self.mode = mode
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.active = active
        self.queued = queued
        self.aborted = aborted
        self.target = target
        self.reason = reason
        self.message = message
        self.speak = speak
        self.show = show
        self.suppress = suppress
        self.providerresult = providerresult
        self.enqueuedatms = enqueuedatms
        self.deliveredatms = deliveredatms
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case mode
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case active
        case queued
        case aborted
        case target
        case reason
        case message
        case speak
        case show
        case suppress
        case providerresult = "providerResult"
        case enqueuedatms = "enqueuedAtMs"
        case deliveredatms = "deliveredAtMs"
    }
}

public struct TalkClientToolCallParams: Codable, Sendable {
    public let sessionkey: String
    public let voicesessionid: String?
    public let callid: String
    public let name: String
    public let args: AnyCodable?
    public let relaysessionid: String?

    public init(
        sessionkey: String,
        voicesessionid: String? = nil,
        callid: String,
        name: String,
        args: AnyCodable? = nil,
        relaysessionid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.voicesessionid = voicesessionid
        self.callid = callid
        self.name = name
        self.args = args
        self.relaysessionid = relaysessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case voicesessionid = "voiceSessionId"
        case callid = "callId"
        case name
        case args
        case relaysessionid = "relaySessionId"
    }
}

public struct TalkClientToolCallResult: Codable, Sendable {
    public let runid: String
    public let idempotencykey: String

    public init(
        runid: String,
        idempotencykey: String)
    {
        self.runid = runid
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case idempotencykey = "idempotencyKey"
    }
}

public struct TalkClientTranscriptParams: Codable, Sendable {
    public let sessionkey: String
    public let voicesessionid: String
    public let entryid: String
    public let role: AnyCodable
    public let text: String
    public let timestamp: Double?

    public init(
        sessionkey: String,
        voicesessionid: String,
        entryid: String,
        role: AnyCodable,
        text: String,
        timestamp: Double? = nil)
    {
        self.sessionkey = sessionkey
        self.voicesessionid = voicesessionid
        self.entryid = entryid
        self.role = role
        self.text = text
        self.timestamp = timestamp
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case voicesessionid = "voiceSessionId"
        case entryid = "entryId"
        case role
        case text
        case timestamp
    }
}

public struct TalkConfigParams: Codable, Sendable {
    public let includesecrets: Bool?

    public init(
        includesecrets: Bool? = nil)
    {
        self.includesecrets = includesecrets
    }

    private enum CodingKeys: String, CodingKey {
        case includesecrets = "includeSecrets"
    }
}

public struct TalkConfigResult: Codable, Sendable {
    public let config: [String: AnyCodable]

    public init(
        config: [String: AnyCodable])
    {
        self.config = config
    }

    private enum CodingKeys: String, CodingKey {
        case config
    }
}

public struct TalkSessionAppendAudioParams: Codable, Sendable {
    public let sessionid: String
    public let audiobase64: String
    public let timestamp: Double?

    public init(
        sessionid: String,
        audiobase64: String,
        timestamp: Double? = nil)
    {
        self.sessionid = sessionid
        self.audiobase64 = audiobase64
        self.timestamp = timestamp
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case audiobase64 = "audioBase64"
        case timestamp
    }
}

public struct TalkSessionAcknowledgeMarkParams: Codable, Sendable {
    public let sessionid: String
    public let markname: String

    public init(
        sessionid: String,
        markname: String)
    {
        self.sessionid = sessionid
        self.markname = markname
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case markname = "markName"
    }
}

public struct TalkSessionCancelOutputParams: Codable, Sendable {
    public let sessionid: String
    public let turnid: String?
    public let reason: String?

    public init(
        sessionid: String,
        turnid: String? = nil,
        reason: String? = nil)
    {
        self.sessionid = sessionid
        self.turnid = turnid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case turnid = "turnId"
        case reason
    }
}

public struct TalkSessionCancelTurnParams: Codable, Sendable {
    public let sessionid: String
    public let turnid: String?
    public let reason: String?

    public init(
        sessionid: String,
        turnid: String? = nil,
        reason: String? = nil)
    {
        self.sessionid = sessionid
        self.turnid = turnid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case turnid = "turnId"
        case reason
    }
}

public struct TalkSessionCreateParams: Codable, Sendable {
    public let sessionkey: String?
    public let spawnedby: String?
    public let provider: String?
    public let model: String?
    public let voice: String?
    public let language: String?
    public let vadthreshold: Double?
    public let silencedurationms: Int?
    public let prefixpaddingms: Int?
    public let reasoningeffort: String?
    public let mode: AnyCodable?
    public let transport: AnyCodable?
    public let brain: AnyCodable?
    public let ttlms: Int?

    public init(
        sessionkey: String? = nil,
        spawnedby: String? = nil,
        provider: String? = nil,
        model: String? = nil,
        voice: String? = nil,
        language: String? = nil,
        vadthreshold: Double? = nil,
        silencedurationms: Int? = nil,
        prefixpaddingms: Int? = nil,
        reasoningeffort: String? = nil,
        mode: AnyCodable? = nil,
        transport: AnyCodable? = nil,
        brain: AnyCodable? = nil,
        ttlms: Int? = nil)
    {
        self.sessionkey = sessionkey
        self.spawnedby = spawnedby
        self.provider = provider
        self.model = model
        self.voice = voice
        self.language = language
        self.vadthreshold = vadthreshold
        self.silencedurationms = silencedurationms
        self.prefixpaddingms = prefixpaddingms
        self.reasoningeffort = reasoningeffort
        self.mode = mode
        self.transport = transport
        self.brain = brain
        self.ttlms = ttlms
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case spawnedby = "spawnedBy"
        case provider
        case model
        case voice
        case language
        case vadthreshold = "vadThreshold"
        case silencedurationms = "silenceDurationMs"
        case prefixpaddingms = "prefixPaddingMs"
        case reasoningeffort = "reasoningEffort"
        case mode
        case transport
        case brain
        case ttlms = "ttlMs"
    }
}

public struct TalkSessionCreateResult: Codable, Sendable {
    public let sessionid: String
    public let provider: String?
    public let mode: AnyCodable
    public let transport: AnyCodable
    public let brain: AnyCodable
    public let relaysessionid: String?
    public let transcriptionsessionid: String?
    public let handoffid: String?
    public let roomid: String?
    public let roomurl: String?
    public let token: String?
    public let audio: AnyCodable?
    public let model: String?
    public let voice: String?
    public let expiresat: Double?

    public init(
        sessionid: String,
        provider: String? = nil,
        mode: AnyCodable,
        transport: AnyCodable,
        brain: AnyCodable,
        relaysessionid: String? = nil,
        transcriptionsessionid: String? = nil,
        handoffid: String? = nil,
        roomid: String? = nil,
        roomurl: String? = nil,
        token: String? = nil,
        audio: AnyCodable? = nil,
        model: String? = nil,
        voice: String? = nil,
        expiresat: Double? = nil)
    {
        self.sessionid = sessionid
        self.provider = provider
        self.mode = mode
        self.transport = transport
        self.brain = brain
        self.relaysessionid = relaysessionid
        self.transcriptionsessionid = transcriptionsessionid
        self.handoffid = handoffid
        self.roomid = roomid
        self.roomurl = roomurl
        self.token = token
        self.audio = audio
        self.model = model
        self.voice = voice
        self.expiresat = expiresat
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case provider
        case mode
        case transport
        case brain
        case relaysessionid = "relaySessionId"
        case transcriptionsessionid = "transcriptionSessionId"
        case handoffid = "handoffId"
        case roomid = "roomId"
        case roomurl = "roomUrl"
        case token
        case audio
        case model
        case voice
        case expiresat = "expiresAt"
    }
}

public struct TalkSessionJoinParams: Codable, Sendable {
    public let sessionid: String
    public let token: String

    public init(
        sessionid: String,
        token: String)
    {
        self.sessionid = sessionid
        self.token = token
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case token
    }
}

public struct TalkSessionJoinResult: Codable, Sendable {
    public let id: String
    public let roomid: String
    public let roomurl: String
    public let sessionkey: String
    public let sessionid: String?
    public let channel: String?
    public let target: String?
    public let provider: String?
    public let model: String?
    public let voice: String?
    public let mode: AnyCodable
    public let transport: AnyCodable
    public let brain: AnyCodable
    public let createdat: Double
    public let expiresat: Double
    public let room: [String: AnyCodable]

    public init(
        id: String,
        roomid: String,
        roomurl: String,
        sessionkey: String,
        sessionid: String? = nil,
        channel: String? = nil,
        target: String? = nil,
        provider: String? = nil,
        model: String? = nil,
        voice: String? = nil,
        mode: AnyCodable,
        transport: AnyCodable,
        brain: AnyCodable,
        createdat: Double,
        expiresat: Double,
        room: [String: AnyCodable])
    {
        self.id = id
        self.roomid = roomid
        self.roomurl = roomurl
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.channel = channel
        self.target = target
        self.provider = provider
        self.model = model
        self.voice = voice
        self.mode = mode
        self.transport = transport
        self.brain = brain
        self.createdat = createdat
        self.expiresat = expiresat
        self.room = room
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case roomid = "roomId"
        case roomurl = "roomUrl"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case channel
        case target
        case provider
        case model
        case voice
        case mode
        case transport
        case brain
        case createdat = "createdAt"
        case expiresat = "expiresAt"
        case room
    }
}

public struct TalkSessionTurnParams: Codable, Sendable {
    public let sessionid: String
    public let turnid: String?

    public init(
        sessionid: String,
        turnid: String? = nil)
    {
        self.sessionid = sessionid
        self.turnid = turnid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case turnid = "turnId"
    }
}

public struct TalkSessionTurnResult: Codable, Sendable {
    public let ok: Bool
    public let turnid: String?
    public let events: [TalkEvent]?

    public init(
        ok: Bool,
        turnid: String? = nil,
        events: [TalkEvent]? = nil)
    {
        self.ok = ok
        self.turnid = turnid
        self.events = events
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case turnid = "turnId"
        case events
    }
}

public struct TalkSessionSteerParams: Codable, Sendable {
    public let sessionid: String
    public let sessionkey: String?
    public let text: String
    public let mode: AnyCodable?

    public init(
        sessionid: String,
        sessionkey: String? = nil,
        text: String,
        mode: AnyCodable? = nil)
    {
        self.sessionid = sessionid
        self.sessionkey = sessionkey
        self.text = text
        self.mode = mode
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case sessionkey = "sessionKey"
        case text
        case mode
    }
}

public struct TalkSessionSubmitToolResultParams: Codable, Sendable {
    public let sessionid: String
    public let callid: String
    public let result: AnyCodable
    public let options: [String: AnyCodable]?

    public init(
        sessionid: String,
        callid: String,
        result: AnyCodable,
        options: [String: AnyCodable]? = nil)
    {
        self.sessionid = sessionid
        self.callid = callid
        self.result = result
        self.options = options
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case callid = "callId"
        case result
        case options
    }
}

public struct TalkSessionCloseParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct TalkSessionOkResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct TalkSpeakParams: Codable, Sendable {
    public let text: String
    public let voiceid: String?
    public let modelid: String?
    public let outputformat: String?
    public let speed: Double?
    public let ratewpm: Int?
    public let stability: Double?
    public let similarity: Double?
    public let style: Double?
    public let speakerboost: Bool?
    public let seed: Int?
    public let normalize: String?
    public let language: String?
    public let latencytier: Int?

    public init(
        text: String,
        voiceid: String? = nil,
        modelid: String? = nil,
        outputformat: String? = nil,
        speed: Double? = nil,
        ratewpm: Int? = nil,
        stability: Double? = nil,
        similarity: Double? = nil,
        style: Double? = nil,
        speakerboost: Bool? = nil,
        seed: Int? = nil,
        normalize: String? = nil,
        language: String? = nil,
        latencytier: Int? = nil)
    {
        self.text = text
        self.voiceid = voiceid
        self.modelid = modelid
        self.outputformat = outputformat
        self.speed = speed
        self.ratewpm = ratewpm
        self.stability = stability
        self.similarity = similarity
        self.style = style
        self.speakerboost = speakerboost
        self.seed = seed
        self.normalize = normalize
        self.language = language
        self.latencytier = latencytier
    }

    private enum CodingKeys: String, CodingKey {
        case text
        case voiceid = "voiceId"
        case modelid = "modelId"
        case outputformat = "outputFormat"
        case speed
        case ratewpm = "rateWpm"
        case stability
        case similarity
        case style
        case speakerboost = "speakerBoost"
        case seed
        case normalize
        case language
        case latencytier = "latencyTier"
    }
}

public struct TalkSpeakResult: Codable, Sendable {
    public let audiobase64: String
    public let provider: String
    public let outputformat: String?
    public let voicecompatible: Bool?
    public let mimetype: String?
    public let fileextension: String?

    public init(
        audiobase64: String,
        provider: String,
        outputformat: String? = nil,
        voicecompatible: Bool? = nil,
        mimetype: String? = nil,
        fileextension: String? = nil)
    {
        self.audiobase64 = audiobase64
        self.provider = provider
        self.outputformat = outputformat
        self.voicecompatible = voicecompatible
        self.mimetype = mimetype
        self.fileextension = fileextension
    }

    private enum CodingKeys: String, CodingKey {
        case audiobase64 = "audioBase64"
        case provider
        case outputformat = "outputFormat"
        case voicecompatible = "voiceCompatible"
        case mimetype = "mimeType"
        case fileextension = "fileExtension"
    }
}

public struct TtsSpeakParams: Codable, Sendable {
    public let text: String

    public init(
        text: String)
    {
        self.text = text
    }

    private enum CodingKeys: String, CodingKey {
        case text
    }
}

public struct TtsSpeakResult: Codable, Sendable {
    public let audiobase64: String
    public let provider: String
    public let outputformat: String?
    public let mimetype: String?
    public let fileextension: String?

    public init(
        audiobase64: String,
        provider: String,
        outputformat: String? = nil,
        mimetype: String? = nil,
        fileextension: String? = nil)
    {
        self.audiobase64 = audiobase64
        self.provider = provider
        self.outputformat = outputformat
        self.mimetype = mimetype
        self.fileextension = fileextension
    }

    private enum CodingKeys: String, CodingKey {
        case audiobase64 = "audioBase64"
        case provider
        case outputformat = "outputFormat"
        case mimetype = "mimeType"
        case fileextension = "fileExtension"
    }
}

public struct ChannelsStatusParams: Codable, Sendable {
    public let probe: Bool?
    public let timeoutms: Int?
    public let channel: String?

    public init(
        probe: Bool? = nil,
        timeoutms: Int? = nil,
        channel: String? = nil)
    {
        self.probe = probe
        self.timeoutms = timeoutms
        self.channel = channel
    }

    private enum CodingKeys: String, CodingKey {
        case probe
        case timeoutms = "timeoutMs"
        case channel
    }
}

public struct ChannelsStatusResult: Codable, Sendable {
    public let ts: Int
    public let channelorder: [String]
    public let channellabels: [String: AnyCodable]
    public let channeldetaillabels: [String: AnyCodable]?
    public let channelsystemimages: [String: AnyCodable]?
    public let channelmeta: [[String: AnyCodable]]?
    public let channels: [String: AnyCodable]
    public let channelaccounts: [String: AnyCodable]
    public let channeldefaultaccountid: [String: AnyCodable]
    public let eventloop: [String: AnyCodable]?
    public let partial: Bool?
    public let warnings: [String]?

    public init(
        ts: Int,
        channelorder: [String],
        channellabels: [String: AnyCodable],
        channeldetaillabels: [String: AnyCodable]? = nil,
        channelsystemimages: [String: AnyCodable]? = nil,
        channelmeta: [[String: AnyCodable]]? = nil,
        channels: [String: AnyCodable],
        channelaccounts: [String: AnyCodable],
        channeldefaultaccountid: [String: AnyCodable],
        eventloop: [String: AnyCodable]? = nil,
        partial: Bool? = nil,
        warnings: [String]? = nil)
    {
        self.ts = ts
        self.channelorder = channelorder
        self.channellabels = channellabels
        self.channeldetaillabels = channeldetaillabels
        self.channelsystemimages = channelsystemimages
        self.channelmeta = channelmeta
        self.channels = channels
        self.channelaccounts = channelaccounts
        self.channeldefaultaccountid = channeldefaultaccountid
        self.eventloop = eventloop
        self.partial = partial
        self.warnings = warnings
    }

    private enum CodingKeys: String, CodingKey {
        case ts
        case channelorder = "channelOrder"
        case channellabels = "channelLabels"
        case channeldetaillabels = "channelDetailLabels"
        case channelsystemimages = "channelSystemImages"
        case channelmeta = "channelMeta"
        case channels
        case channelaccounts = "channelAccounts"
        case channeldefaultaccountid = "channelDefaultAccountId"
        case eventloop = "eventLoop"
        case partial
        case warnings
    }
}

public struct ChannelsPairingListParams: Codable, Sendable {
    public let channel: String?
    public let accountid: String?

    public init(
        channel: String? = nil,
        accountid: String? = nil)
    {
        self.channel = channel
        self.accountid = accountid
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
    }
}

public struct ChannelsPairingListResult: Codable, Sendable {
    public let accounts: [[String: AnyCodable]]
    public let requests: [[String: AnyCodable]]
    public let commandownerconfigured: Bool
    public let limits: [String: AnyCodable]

    public init(
        accounts: [[String: AnyCodable]],
        requests: [[String: AnyCodable]],
        commandownerconfigured: Bool,
        limits: [String: AnyCodable])
    {
        self.accounts = accounts
        self.requests = requests
        self.commandownerconfigured = commandownerconfigured
        self.limits = limits
    }

    private enum CodingKeys: String, CodingKey {
        case accounts
        case requests
        case commandownerconfigured = "commandOwnerConfigured"
        case limits
    }
}

public struct ChannelsPairingApproveParams: Codable, Sendable {
    public let channel: String
    public let accountid: String
    public let requestid: String
    public let notify: Bool?
    public let bootstrapcommandowner: Bool?

    public init(
        channel: String,
        accountid: String,
        requestid: String,
        notify: Bool? = nil,
        bootstrapcommandowner: Bool? = nil)
    {
        self.channel = channel
        self.accountid = accountid
        self.requestid = requestid
        self.notify = notify
        self.bootstrapcommandowner = bootstrapcommandowner
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
        case requestid = "requestId"
        case notify
        case bootstrapcommandowner = "bootstrapCommandOwner"
    }
}

public struct ChannelsPairingApproveResult: Codable, Sendable {
    public let requestid: String
    public let senderid: String
    public let notification: String
    public let commandownerbootstrap: String

    public init(
        requestid: String,
        senderid: String,
        notification: String,
        commandownerbootstrap: String)
    {
        self.requestid = requestid
        self.senderid = senderid
        self.notification = notification
        self.commandownerbootstrap = commandownerbootstrap
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
        case senderid = "senderId"
        case notification
        case commandownerbootstrap = "commandOwnerBootstrap"
    }
}

public struct ChannelsPairingDismissParams: Codable, Sendable {
    public let channel: String
    public let accountid: String
    public let requestid: String

    public init(
        channel: String,
        accountid: String,
        requestid: String)
    {
        self.channel = channel
        self.accountid = accountid
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
        case requestid = "requestId"
    }
}

public struct ChannelsPairingDismissResult: Codable, Sendable {
    public let requestid: String
    public let senderid: String

    public init(
        requestid: String,
        senderid: String)
    {
        self.requestid = requestid
        self.senderid = senderid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
        case senderid = "senderId"
    }
}

public struct ChannelsStartParams: Codable, Sendable {
    public let channel: String
    public let accountid: String?

    public init(
        channel: String,
        accountid: String? = nil)
    {
        self.channel = channel
        self.accountid = accountid
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
    }
}

public struct ChannelsStopParams: Codable, Sendable {
    public let channel: String
    public let accountid: String?

    public init(
        channel: String,
        accountid: String? = nil)
    {
        self.channel = channel
        self.accountid = accountid
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
    }
}

public struct ChannelsLogoutParams: Codable, Sendable {
    public let channel: String
    public let accountid: String?

    public init(
        channel: String,
        accountid: String? = nil)
    {
        self.channel = channel
        self.accountid = accountid
    }

    private enum CodingKeys: String, CodingKey {
        case channel
        case accountid = "accountId"
    }
}

public struct WebLoginStartParams: Codable, Sendable {
    public let force: Bool?
    public let timeoutms: Int?
    public let verbose: Bool?
    public let accountid: String?

    public init(
        force: Bool? = nil,
        timeoutms: Int? = nil,
        verbose: Bool? = nil,
        accountid: String? = nil)
    {
        self.force = force
        self.timeoutms = timeoutms
        self.verbose = verbose
        self.accountid = accountid
    }

    private enum CodingKeys: String, CodingKey {
        case force
        case timeoutms = "timeoutMs"
        case verbose
        case accountid = "accountId"
    }
}

public struct WebLoginWaitParams: Codable, Sendable {
    public let timeoutms: Int?
    public let accountid: String?
    public let currentqrdataurl: String?

    public init(
        timeoutms: Int? = nil,
        accountid: String? = nil,
        currentqrdataurl: String? = nil)
    {
        self.timeoutms = timeoutms
        self.accountid = accountid
        self.currentqrdataurl = currentqrdataurl
    }

    private enum CodingKeys: String, CodingKey {
        case timeoutms = "timeoutMs"
        case accountid = "accountId"
        case currentqrdataurl = "currentQrDataUrl"
    }
}

public struct AgentSummary: Codable, Sendable {
    public let id: String
    public let kind: AgentKind?
    public let name: String?
    public let identity: [String: AnyCodable]?
    public let workspace: String?
    public let workspacegit: Bool?
    public let model: [String: AnyCodable]?
    public let agentruntime: [String: AnyCodable]?
    public let thinkinglevels: [[String: AnyCodable]]?
    public let thinkingoptions: [String]?
    public let thinkingdefault: String?

    public init(
        id: String,
        kind: AgentKind? = nil,
        name: String? = nil,
        identity: [String: AnyCodable]? = nil,
        workspace: String? = nil,
        workspacegit: Bool? = nil,
        model: [String: AnyCodable]? = nil,
        agentruntime: [String: AnyCodable]? = nil,
        thinkinglevels: [[String: AnyCodable]]? = nil,
        thinkingoptions: [String]? = nil,
        thinkingdefault: String? = nil)
    {
        self.id = id
        self.kind = kind
        self.name = name
        self.identity = identity
        self.workspace = workspace
        self.workspacegit = workspacegit
        self.model = model
        self.agentruntime = agentruntime
        self.thinkinglevels = thinkinglevels
        self.thinkingoptions = thinkingoptions
        self.thinkingdefault = thinkingdefault
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case kind
        case name
        case identity
        case workspace
        case workspacegit = "workspaceGit"
        case model
        case agentruntime = "agentRuntime"
        case thinkinglevels = "thinkingLevels"
        case thinkingoptions = "thinkingOptions"
        case thinkingdefault = "thinkingDefault"
    }
}

public struct AgentsCreateParams: Codable, Sendable {
    public let name: String
    public let workspace: String?
    public let model: String?
    public let emoji: String?
    public let avatar: String?

    public init(
        name: String,
        workspace: String? = nil,
        model: String? = nil,
        emoji: String? = nil,
        avatar: String? = nil)
    {
        self.name = name
        self.workspace = workspace
        self.model = model
        self.emoji = emoji
        self.avatar = avatar
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case workspace
        case model
        case emoji
        case avatar
    }
}

public struct AgentsCreateResult: Codable, Sendable {
    public let ok: Bool
    public let agentid: String
    public let name: String
    public let workspace: String
    public let model: String?

    public init(
        ok: Bool,
        agentid: String,
        name: String,
        workspace: String,
        model: String? = nil)
    {
        self.ok = ok
        self.agentid = agentid
        self.name = name
        self.workspace = workspace
        self.model = model
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case agentid = "agentId"
        case name
        case workspace
        case model
    }
}

public struct AgentsUpdateParams: Codable, Sendable {
    public let agentid: String
    public let name: String?
    public let workspace: String?
    public let modelvalue: AnyCodable?
    public var model: String? { modelvalue?.value as? String }
    public let emoji: String?
    public let avatar: String?

    public init(
        agentid: String,
        name: String? = nil,
        workspace: String? = nil,
        modelvalue: AnyCodable?,
        emoji: String? = nil,
        avatar: String? = nil)
    {
        self.agentid = agentid
        self.name = name
        self.workspace = workspace
        self.modelvalue = modelvalue
        self.emoji = emoji
        self.avatar = avatar
    }

    public init(
        agentid: String,
        name: String? = nil,
        workspace: String? = nil,
        model: String? = nil,
        emoji: String? = nil,
        avatar: String? = nil)
    {
        self.init(
            agentid: agentid,
            name: name,
            workspace: workspace,
            modelvalue: model.map { AnyCodable($0) },
            emoji: emoji,
            avatar: avatar)
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case name
        case workspace
        case modelvalue = "model"
        case emoji
        case avatar
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.agentid = try container.decode(String.self, forKey: .agentid)
        self.name = try container.decodeIfPresent(String.self, forKey: .name)
        self.workspace = try container.decodeIfPresent(String.self, forKey: .workspace)
        self.modelvalue = container.contains(.modelvalue)
            ? try container.decode(AnyCodable.self, forKey: .modelvalue)
            : nil
        self.emoji = try container.decodeIfPresent(String.self, forKey: .emoji)
        self.avatar = try container.decodeIfPresent(String.self, forKey: .avatar)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(agentid, forKey: .agentid)
        try container.encodeIfPresent(name, forKey: .name)
        try container.encodeIfPresent(workspace, forKey: .workspace)
        try container.encodeIfPresent(modelvalue, forKey: .modelvalue)
        try container.encodeIfPresent(emoji, forKey: .emoji)
        try container.encodeIfPresent(avatar, forKey: .avatar)
    }
}

public struct AgentsUpdateResult: Codable, Sendable {
    public let ok: Bool
    public let agentid: String

    public init(
        ok: Bool,
        agentid: String)
    {
        self.ok = ok
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case agentid = "agentId"
    }
}

public struct AgentsDeleteParams: Codable, Sendable {
    public let agentid: String
    public let deletefiles: Bool?

    public init(
        agentid: String,
        deletefiles: Bool? = nil)
    {
        self.agentid = agentid
        self.deletefiles = deletefiles
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case deletefiles = "deleteFiles"
    }
}

public struct AgentsDeleteResult: Codable, Sendable {
    public let ok: Bool
    public let agentid: String
    public let removedbindings: Int
    public let removed: [[String: AnyCodable]]?
    public let failed: [[String: AnyCodable]]?

    public init(
        ok: Bool,
        agentid: String,
        removedbindings: Int,
        removed: [[String: AnyCodable]]? = nil,
        failed: [[String: AnyCodable]]? = nil)
    {
        self.ok = ok
        self.agentid = agentid
        self.removedbindings = removedbindings
        self.removed = removed
        self.failed = failed
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case agentid = "agentId"
        case removedbindings = "removedBindings"
        case removed
        case failed
    }
}

public struct AgentsFileEntry: Codable, Sendable {
    public let name: String
    public let path: String
    public let missing: Bool
    public let size: Int?
    public let updatedatms: Int?
    public let content: String?

    public init(
        name: String,
        path: String,
        missing: Bool,
        size: Int? = nil,
        updatedatms: Int? = nil,
        content: String? = nil)
    {
        self.name = name
        self.path = path
        self.missing = missing
        self.size = size
        self.updatedatms = updatedatms
        self.content = content
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case path
        case missing
        case size
        case updatedatms = "updatedAtMs"
        case content
    }
}

public struct AgentsFilesListParams: Codable, Sendable {
    public let agentid: String

    public init(
        agentid: String)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct AgentsFilesListResult: Codable, Sendable {
    public let agentid: String
    public let workspace: String
    public let files: [AgentsFileEntry]

    public init(
        agentid: String,
        workspace: String,
        files: [AgentsFileEntry])
    {
        self.agentid = agentid
        self.workspace = workspace
        self.files = files
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case workspace
        case files
    }
}

public struct AgentsFilesGetParams: Codable, Sendable {
    public let agentid: String
    public let name: String

    public init(
        agentid: String,
        name: String)
    {
        self.agentid = agentid
        self.name = name
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case name
    }
}

public struct AgentsFilesGetResult: Codable, Sendable {
    public let agentid: String
    public let workspace: String
    public let file: AgentsFileEntry

    public init(
        agentid: String,
        workspace: String,
        file: AgentsFileEntry)
    {
        self.agentid = agentid
        self.workspace = workspace
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case workspace
        case file
    }
}

public struct AgentsFilesSetParams: Codable, Sendable {
    public let agentid: String
    public let name: String
    public let content: String

    public init(
        agentid: String,
        name: String,
        content: String)
    {
        self.agentid = agentid
        self.name = name
        self.content = content
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case name
        case content
    }
}

public struct AgentsFilesSetResult: Codable, Sendable {
    public let ok: Bool
    public let agentid: String
    public let workspace: String
    public let file: AgentsFileEntry

    public init(
        ok: Bool,
        agentid: String,
        workspace: String,
        file: AgentsFileEntry)
    {
        self.ok = ok
        self.agentid = agentid
        self.workspace = workspace
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case agentid = "agentId"
        case workspace
        case file
    }
}

public struct AgentsWorkspaceEntry: Codable, Sendable {
    public let path: String
    public let name: String
    public let kind: AnyCodable
    public let size: Int?
    public let updatedatms: Int?

    public init(
        path: String,
        name: String,
        kind: AnyCodable,
        size: Int? = nil,
        updatedatms: Int? = nil)
    {
        self.path = path
        self.name = name
        self.kind = kind
        self.size = size
        self.updatedatms = updatedatms
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case name
        case kind
        case size
        case updatedatms = "updatedAtMs"
    }
}

public struct AgentsWorkspaceFile: Codable, Sendable {
    public let path: String
    public let name: String
    public let size: Int
    public let updatedatms: Int
    public let mimetype: String
    public let encoding: AnyCodable
    public let content: String

    public init(
        path: String,
        name: String,
        size: Int,
        updatedatms: Int,
        mimetype: String,
        encoding: AnyCodable,
        content: String)
    {
        self.path = path
        self.name = name
        self.size = size
        self.updatedatms = updatedatms
        self.mimetype = mimetype
        self.encoding = encoding
        self.content = content
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case name
        case size
        case updatedatms = "updatedAtMs"
        case mimetype = "mimeType"
        case encoding
        case content
    }
}

public struct AgentsWorkspaceListParams: Codable, Sendable {
    public let agentid: String
    public let path: String?
    public let offset: Int?
    public let limit: Int?

    public init(
        agentid: String,
        path: String? = nil,
        offset: Int? = nil,
        limit: Int? = nil)
    {
        self.agentid = agentid
        self.path = path
        self.offset = offset
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case path
        case offset
        case limit
    }
}

public struct AgentsWorkspaceListResult: Codable, Sendable {
    public let agentid: String
    public let path: String
    public let parentpath: String?
    public let entries: [AgentsWorkspaceEntry]
    public let totalentries: Int
    public let offset: Int

    public init(
        agentid: String,
        path: String,
        parentpath: String? = nil,
        entries: [AgentsWorkspaceEntry],
        totalentries: Int,
        offset: Int)
    {
        self.agentid = agentid
        self.path = path
        self.parentpath = parentpath
        self.entries = entries
        self.totalentries = totalentries
        self.offset = offset
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case path
        case parentpath = "parentPath"
        case entries
        case totalentries = "totalEntries"
        case offset
    }
}

public struct AgentsWorkspaceGetParams: Codable, Sendable {
    public let agentid: String
    public let path: String

    public init(
        agentid: String,
        path: String)
    {
        self.agentid = agentid
        self.path = path
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case path
    }
}

public struct AgentsWorkspaceGetResult: Codable, Sendable {
    public let agentid: String
    public let file: AgentsWorkspaceFile

    public init(
        agentid: String,
        file: AgentsWorkspaceFile)
    {
        self.agentid = agentid
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case file
    }
}

public struct ArtifactSummary: Codable, Sendable {
    public let id: String
    public let type: String
    public let title: String
    public let mimetype: String?
    public let sizebytes: Int?
    public let sessionkey: String?
    public let runid: String?
    public let taskid: String?
    public let messageseq: Int?
    public let source: String?
    public let download: [String: AnyCodable]

    public init(
        id: String,
        type: String,
        title: String,
        mimetype: String? = nil,
        sizebytes: Int? = nil,
        sessionkey: String? = nil,
        runid: String? = nil,
        taskid: String? = nil,
        messageseq: Int? = nil,
        source: String? = nil,
        download: [String: AnyCodable])
    {
        self.id = id
        self.type = type
        self.title = title
        self.mimetype = mimetype
        self.sizebytes = sizebytes
        self.sessionkey = sessionkey
        self.runid = runid
        self.taskid = taskid
        self.messageseq = messageseq
        self.source = source
        self.download = download
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case type
        case title
        case mimetype = "mimeType"
        case sizebytes = "sizeBytes"
        case sessionkey = "sessionKey"
        case runid = "runId"
        case taskid = "taskId"
        case messageseq = "messageSeq"
        case source
        case download
    }
}

public struct ArtifactsListParams: Codable, Sendable {
    public let sessionkey: String?
    public let runid: String?
    public let taskid: String?
    public let agentid: String?

    public init(
        sessionkey: String? = nil,
        runid: String? = nil,
        taskid: String? = nil,
        agentid: String? = nil)
    {
        self.sessionkey = sessionkey
        self.runid = runid
        self.taskid = taskid
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case runid = "runId"
        case taskid = "taskId"
        case agentid = "agentId"
    }
}

public struct ArtifactsListResult: Codable, Sendable {
    public let artifacts: [ArtifactSummary]

    public init(
        artifacts: [ArtifactSummary])
    {
        self.artifacts = artifacts
    }

    private enum CodingKeys: String, CodingKey {
        case artifacts
    }
}

public struct ArtifactsGetParams: Codable, Sendable {
    public let sessionkey: String?
    public let runid: String?
    public let taskid: String?
    public let agentid: String?
    public let artifactid: String

    public init(
        sessionkey: String? = nil,
        runid: String? = nil,
        taskid: String? = nil,
        agentid: String? = nil,
        artifactid: String)
    {
        self.sessionkey = sessionkey
        self.runid = runid
        self.taskid = taskid
        self.agentid = agentid
        self.artifactid = artifactid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case runid = "runId"
        case taskid = "taskId"
        case agentid = "agentId"
        case artifactid = "artifactId"
    }
}

public struct ArtifactsGetResult: Codable, Sendable {
    public let artifact: ArtifactSummary

    public init(
        artifact: ArtifactSummary)
    {
        self.artifact = artifact
    }

    private enum CodingKeys: String, CodingKey {
        case artifact
    }
}

public struct ArtifactsDownloadParams: Codable, Sendable {
    public let sessionkey: String?
    public let runid: String?
    public let taskid: String?
    public let agentid: String?
    public let artifactid: String

    public init(
        sessionkey: String? = nil,
        runid: String? = nil,
        taskid: String? = nil,
        agentid: String? = nil,
        artifactid: String)
    {
        self.sessionkey = sessionkey
        self.runid = runid
        self.taskid = taskid
        self.agentid = agentid
        self.artifactid = artifactid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case runid = "runId"
        case taskid = "taskId"
        case agentid = "agentId"
        case artifactid = "artifactId"
    }
}

public struct ArtifactsDownloadResult: Codable, Sendable {
    public let artifact: ArtifactSummary
    public let encoding: String?
    public let data: String?
    public let url: String?

    public init(
        artifact: ArtifactSummary,
        encoding: String? = nil,
        data: String? = nil,
        url: String? = nil)
    {
        self.artifact = artifact
        self.encoding = encoding
        self.data = data
        self.url = url
    }

    private enum CodingKeys: String, CodingKey {
        case artifact
        case encoding
        case data
        case url
    }
}

public struct AgentsListParams: Codable, Sendable {}

public struct AgentsListResult: Codable, Sendable {
    public let defaultid: String
    public let mainkey: String
    public let scope: AnyCodable
    public let agents: [AgentSummary]

    public init(
        defaultid: String,
        mainkey: String,
        scope: AnyCodable,
        agents: [AgentSummary])
    {
        self.defaultid = defaultid
        self.mainkey = mainkey
        self.scope = scope
        self.agents = agents
    }

    private enum CodingKeys: String, CodingKey {
        case defaultid = "defaultId"
        case mainkey = "mainKey"
        case scope
        case agents
    }
}

public struct ModelChoice: Codable, Sendable {
    public let id: String
    public let name: String
    public let provider: String
    public let alias: String?
    public let available: Bool?
    public let contextwindow: Int?
    public let reasoning: Bool?
    public let agentruntime: [String: AnyCodable]?
    public let apikeysupported: Bool?
    public let input: [AnyCodable]?

    public init(
        id: String,
        name: String,
        provider: String,
        alias: String? = nil,
        available: Bool? = nil,
        contextwindow: Int? = nil,
        reasoning: Bool? = nil,
        agentruntime: [String: AnyCodable]? = nil,
        apikeysupported: Bool? = nil,
        input: [AnyCodable]? = nil)
    {
        self.id = id
        self.name = name
        self.provider = provider
        self.alias = alias
        self.available = available
        self.contextwindow = contextwindow
        self.reasoning = reasoning
        self.agentruntime = agentruntime
        self.apikeysupported = apikeysupported
        self.input = input
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case name
        case provider
        case alias
        case available
        case contextwindow = "contextWindow"
        case reasoning
        case agentruntime = "agentRuntime"
        case apikeysupported = "apiKeySupported"
        case input
    }
}

public struct ModelsAuthLogoutParams: Codable, Sendable {
    public let provider: String
    public let profileids: [String]?
    public let agentid: String?

    public init(
        provider: String,
        profileids: [String]? = nil,
        agentid: String? = nil)
    {
        self.provider = provider
        self.profileids = profileids
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case provider
        case profileids = "profileIds"
        case agentid = "agentId"
    }
}

public struct ModelsAuthStatusParams: Codable, Sendable {
    public let refresh: Bool?
    public let agentid: String?

    public init(
        refresh: Bool? = nil,
        agentid: String? = nil)
    {
        self.refresh = refresh
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case refresh
        case agentid = "agentId"
    }
}

public struct ModelsListParams: Codable, Sendable {
    public let includeprovidercapabilities: Bool?
    public let view: AnyCodable?

    public init(
        includeprovidercapabilities: Bool? = nil,
        view: AnyCodable? = nil)
    {
        self.includeprovidercapabilities = includeprovidercapabilities
        self.view = view
    }

    private enum CodingKeys: String, CodingKey {
        case includeprovidercapabilities = "includeProviderCapabilities"
        case view
    }
}

public struct ModelsListResult: Codable, Sendable {
    public let models: [ModelChoice]

    public init(
        models: [ModelChoice])
    {
        self.models = models
    }

    private enum CodingKeys: String, CodingKey {
        case models
    }
}

public struct ModelsProbeParams: Codable, Sendable {
    public let provider: String
    public let profileid: String?
    public let timeoutms: Int?
    public let agentid: String?

    public init(
        provider: String,
        profileid: String? = nil,
        timeoutms: Int? = nil,
        agentid: String? = nil)
    {
        self.provider = provider
        self.profileid = profileid
        self.timeoutms = timeoutms
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case provider
        case profileid = "profileId"
        case timeoutms = "timeoutMs"
        case agentid = "agentId"
    }
}

public struct ModelsProbeTargetResult: Codable, Sendable {
    public let profileid: String?
    public let label: String
    public let status: AuthProbeStatus
    public let latencyms: Int?
    public let error: String?

    public init(
        profileid: String? = nil,
        label: String,
        status: AuthProbeStatus,
        latencyms: Int? = nil,
        error: String? = nil)
    {
        self.profileid = profileid
        self.label = label
        self.status = status
        self.latencyms = latencyms
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case profileid = "profileId"
        case label
        case status
        case latencyms = "latencyMs"
        case error
    }
}

public struct ModelsProbeResult: Codable, Sendable {
    public let provider: String
    public let status: AuthProbeStatus
    public let latencyms: Int?
    public let error: String?
    public let results: [ModelsProbeTargetResult]

    public init(
        provider: String,
        status: AuthProbeStatus,
        latencyms: Int? = nil,
        error: String? = nil,
        results: [ModelsProbeTargetResult])
    {
        self.provider = provider
        self.status = status
        self.latencyms = latencyms
        self.error = error
        self.results = results
    }

    private enum CodingKeys: String, CodingKey {
        case provider
        case status
        case latencyms = "latencyMs"
        case error
        case results
    }
}

public struct CommandEntry: Codable, Sendable {
    public let name: String
    public let nativename: String?
    public let textaliases: [String]?
    public let description: String
    public let category: AnyCodable?
    public let source: AnyCodable
    public let scope: AnyCodable
    public let acceptsargs: Bool
    public let args: [[String: AnyCodable]]?

    public init(
        name: String,
        nativename: String? = nil,
        textaliases: [String]? = nil,
        description: String,
        category: AnyCodable? = nil,
        source: AnyCodable,
        scope: AnyCodable,
        acceptsargs: Bool,
        args: [[String: AnyCodable]]? = nil)
    {
        self.name = name
        self.nativename = nativename
        self.textaliases = textaliases
        self.description = description
        self.category = category
        self.source = source
        self.scope = scope
        self.acceptsargs = acceptsargs
        self.args = args
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case nativename = "nativeName"
        case textaliases = "textAliases"
        case description
        case category
        case source
        case scope
        case acceptsargs = "acceptsArgs"
        case args
    }
}

public struct CommandsListParams: Codable, Sendable {
    public let agentid: String?
    public let provider: String?
    public let scope: AnyCodable?
    public let includeargs: Bool?

    public init(
        agentid: String? = nil,
        provider: String? = nil,
        scope: AnyCodable? = nil,
        includeargs: Bool? = nil)
    {
        self.agentid = agentid
        self.provider = provider
        self.scope = scope
        self.includeargs = includeargs
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case provider
        case scope
        case includeargs = "includeArgs"
    }
}

public struct CommandsListResult: Codable, Sendable {
    public let commands: [CommandEntry]

    public init(
        commands: [CommandEntry])
    {
        self.commands = commands
    }

    private enum CodingKeys: String, CodingKey {
        case commands
    }
}

public struct SkillsStatusParams: Codable, Sendable {
    public let agentid: String?

    public init(
        agentid: String? = nil)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct ToolsCatalogParams: Codable, Sendable {
    public let agentid: String?
    public let includeplugins: Bool?

    public init(
        agentid: String? = nil,
        includeplugins: Bool? = nil)
    {
        self.agentid = agentid
        self.includeplugins = includeplugins
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case includeplugins = "includePlugins"
    }
}

public struct ToolCatalogProfile: Codable, Sendable {
    public let id: AnyCodable
    public let label: String

    public init(
        id: AnyCodable,
        label: String)
    {
        self.id = id
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
    }
}

public struct ToolCatalogEntry: Codable, Sendable {
    public let id: String
    public let label: String
    public let description: String
    public let source: AnyCodable
    public let pluginid: String?
    public let optional: Bool?
    public let risk: AnyCodable?
    public let tags: [String]?
    public let defaultprofiles: [AnyCodable]

    public init(
        id: String,
        label: String,
        description: String,
        source: AnyCodable,
        pluginid: String? = nil,
        optional: Bool? = nil,
        risk: AnyCodable? = nil,
        tags: [String]? = nil,
        defaultprofiles: [AnyCodable])
    {
        self.id = id
        self.label = label
        self.description = description
        self.source = source
        self.pluginid = pluginid
        self.optional = optional
        self.risk = risk
        self.tags = tags
        self.defaultprofiles = defaultprofiles
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case description
        case source
        case pluginid = "pluginId"
        case optional
        case risk
        case tags
        case defaultprofiles = "defaultProfiles"
    }
}

public struct ToolCatalogGroup: Codable, Sendable {
    public let id: String
    public let label: String
    public let source: AnyCodable
    public let pluginid: String?
    public let tools: [ToolCatalogEntry]

    public init(
        id: String,
        label: String,
        source: AnyCodable,
        pluginid: String? = nil,
        tools: [ToolCatalogEntry])
    {
        self.id = id
        self.label = label
        self.source = source
        self.pluginid = pluginid
        self.tools = tools
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case source
        case pluginid = "pluginId"
        case tools
    }
}

public struct ToolsCatalogResult: Codable, Sendable {
    public let agentid: String
    public let profiles: [ToolCatalogProfile]
    public let groups: [ToolCatalogGroup]

    public init(
        agentid: String,
        profiles: [ToolCatalogProfile],
        groups: [ToolCatalogGroup])
    {
        self.agentid = agentid
        self.profiles = profiles
        self.groups = groups
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case profiles
        case groups
    }
}

public struct ToolsEffectiveParams: Codable, Sendable {
    public let agentid: String?
    public let sessionkey: String

    public init(
        agentid: String? = nil,
        sessionkey: String)
    {
        self.agentid = agentid
        self.sessionkey = sessionkey
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case sessionkey = "sessionKey"
    }
}

public struct ToolsEffectiveEntry: Codable, Sendable {
    public let id: String
    public let label: String
    public let description: String
    public let rawdescription: String
    public let source: AnyCodable
    public let pluginid: String?
    public let channelid: String?
    public let risk: AnyCodable?
    public let tags: [String]?

    public init(
        id: String,
        label: String,
        description: String,
        rawdescription: String,
        source: AnyCodable,
        pluginid: String? = nil,
        channelid: String? = nil,
        risk: AnyCodable? = nil,
        tags: [String]? = nil)
    {
        self.id = id
        self.label = label
        self.description = description
        self.rawdescription = rawdescription
        self.source = source
        self.pluginid = pluginid
        self.channelid = channelid
        self.risk = risk
        self.tags = tags
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case description
        case rawdescription = "rawDescription"
        case source
        case pluginid = "pluginId"
        case channelid = "channelId"
        case risk
        case tags
    }
}

public struct ToolsEffectiveGroup: Codable, Sendable {
    public let id: AnyCodable
    public let label: String
    public let source: AnyCodable
    public let tools: [ToolsEffectiveEntry]

    public init(
        id: AnyCodable,
        label: String,
        source: AnyCodable,
        tools: [ToolsEffectiveEntry])
    {
        self.id = id
        self.label = label
        self.source = source
        self.tools = tools
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case label
        case source
        case tools
    }
}

public struct ToolsEffectiveNotice: Codable, Sendable {
    public let id: String
    public let severity: AnyCodable
    public let message: String

    public init(
        id: String,
        severity: AnyCodable,
        message: String)
    {
        self.id = id
        self.severity = severity
        self.message = message
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case severity
        case message
    }
}

public struct ToolsEffectiveResult: Codable, Sendable {
    public let agentid: String
    public let profile: String
    public let groups: [ToolsEffectiveGroup]
    public let notices: [ToolsEffectiveNotice]?

    public init(
        agentid: String,
        profile: String,
        groups: [ToolsEffectiveGroup],
        notices: [ToolsEffectiveNotice]? = nil)
    {
        self.agentid = agentid
        self.profile = profile
        self.groups = groups
        self.notices = notices
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case profile
        case groups
        case notices
    }
}

public struct ToolsInvokeParams: Codable, Sendable {
    public let name: String
    public let args: [String: AnyCodable]?
    public let sessionkey: String?
    public let agentid: String?
    public let confirm: Bool?
    public let idempotencykey: String?
    public let conversationreadorigin: String?

    public init(
        name: String,
        args: [String: AnyCodable]? = nil,
        sessionkey: String? = nil,
        agentid: String? = nil,
        confirm: Bool? = nil,
        idempotencykey: String? = nil,
        conversationreadorigin: String? = nil)
    {
        self.name = name
        self.args = args
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.confirm = confirm
        self.idempotencykey = idempotencykey
        self.conversationreadorigin = conversationreadorigin
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case args
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case confirm
        case idempotencykey = "idempotencyKey"
        case conversationreadorigin = "conversationReadOrigin"
    }
}

public struct ToolsInvokeError: Codable, Sendable {
    public let code: String
    public let message: String
    public let details: AnyCodable?

    public init(
        code: String,
        message: String,
        details: AnyCodable? = nil)
    {
        self.code = code
        self.message = message
        self.details = details
    }

    private enum CodingKeys: String, CodingKey {
        case code
        case message
        case details
    }
}

public struct ToolsInvokeResult: Codable, Sendable {
    public let ok: Bool
    public let toolname: String
    public let output: AnyCodable?
    public let requiresapproval: Bool?
    public let approvalid: String?
    public let source: AnyCodable?
    public let error: ToolsInvokeError?

    public init(
        ok: Bool,
        toolname: String,
        output: AnyCodable? = nil,
        requiresapproval: Bool? = nil,
        approvalid: String? = nil,
        source: AnyCodable? = nil,
        error: ToolsInvokeError? = nil)
    {
        self.ok = ok
        self.toolname = toolname
        self.output = output
        self.requiresapproval = requiresapproval
        self.approvalid = approvalid
        self.source = source
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case toolname = "toolName"
        case output
        case requiresapproval = "requiresApproval"
        case approvalid = "approvalId"
        case source
        case error
    }
}

public struct SkillsBinsParams: Codable, Sendable {}

public struct SkillsBinsResult: Codable, Sendable {
    public let bins: [String]

    public init(
        bins: [String])
    {
        self.bins = bins
    }

    private enum CodingKeys: String, CodingKey {
        case bins
    }
}

public struct SkillsSearchParams: Codable, Sendable {
    public let query: String?
    public let limit: Int?

    public init(
        query: String? = nil,
        limit: Int? = nil)
    {
        self.query = query
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case query
        case limit
    }
}

public struct SkillsSearchResult: Codable, Sendable {
    public let results: [[String: AnyCodable]]

    public init(
        results: [[String: AnyCodable]])
    {
        self.results = results
    }

    private enum CodingKeys: String, CodingKey {
        case results
    }
}

public struct SkillsDetailParams: Codable, Sendable {
    public let slug: String

    public init(
        slug: String)
    {
        self.slug = slug
    }

    private enum CodingKeys: String, CodingKey {
        case slug
    }
}

public struct SkillsDetailResult: Codable, Sendable {
    public let skill: AnyCodable
    public let latestversion: AnyCodable?
    public let metadata: AnyCodable?
    public let owner: AnyCodable?

    public init(
        skill: AnyCodable,
        latestversion: AnyCodable? = nil,
        metadata: AnyCodable? = nil,
        owner: AnyCodable? = nil)
    {
        self.skill = skill
        self.latestversion = latestversion
        self.metadata = metadata
        self.owner = owner
    }

    private enum CodingKeys: String, CodingKey {
        case skill
        case latestversion = "latestVersion"
        case metadata
        case owner
    }
}

public struct SkillsCuratorActionParams: Codable, Sendable {
    public let skill: String

    public init(
        skill: String)
    {
        self.skill = skill
    }

    private enum CodingKeys: String, CodingKey {
        case skill
    }
}

public struct SkillsCuratorActionResult: Codable, Sendable {
    public let skillfile: String
    public let skillkey: String
    public let skillname: String
    public let state: AnyCodable
    public let pinned: Bool
    public let createdatms: Double
    public let statechangedatms: Double
    public let lastusedatms: AnyCodable
    public let usecount: Double
    public let archivedreason: AnyCodable

    public init(
        skillfile: String,
        skillkey: String,
        skillname: String,
        state: AnyCodable,
        pinned: Bool,
        createdatms: Double,
        statechangedatms: Double,
        lastusedatms: AnyCodable,
        usecount: Double,
        archivedreason: AnyCodable)
    {
        self.skillfile = skillfile
        self.skillkey = skillkey
        self.skillname = skillname
        self.state = state
        self.pinned = pinned
        self.createdatms = createdatms
        self.statechangedatms = statechangedatms
        self.lastusedatms = lastusedatms
        self.usecount = usecount
        self.archivedreason = archivedreason
    }

    private enum CodingKeys: String, CodingKey {
        case skillfile = "skillFile"
        case skillkey = "skillKey"
        case skillname = "skillName"
        case state
        case pinned
        case createdatms = "createdAtMs"
        case statechangedatms = "stateChangedAtMs"
        case lastusedatms = "lastUsedAtMs"
        case usecount = "useCount"
        case archivedreason = "archivedReason"
    }
}

public struct SkillsCuratorStatusParams: Codable, Sendable {}

public struct SkillsCuratorStatusResult: Codable, Sendable {
    public let lastattemptatms: AnyCodable
    public let lastsuccessatms: AnyCodable
    public let lasterror: AnyCodable
    public let counts: [String: AnyCodable]
    public let skills: [SkillsCuratorActionResult]
    public let overlaps: [[String: AnyCodable]]

    public init(
        lastattemptatms: AnyCodable,
        lastsuccessatms: AnyCodable,
        lasterror: AnyCodable,
        counts: [String: AnyCodable],
        skills: [SkillsCuratorActionResult],
        overlaps: [[String: AnyCodable]])
    {
        self.lastattemptatms = lastattemptatms
        self.lastsuccessatms = lastsuccessatms
        self.lasterror = lasterror
        self.counts = counts
        self.skills = skills
        self.overlaps = overlaps
    }

    private enum CodingKeys: String, CodingKey {
        case lastattemptatms = "lastAttemptAtMs"
        case lastsuccessatms = "lastSuccessAtMs"
        case lasterror = "lastError"
        case counts
        case skills
        case overlaps
    }
}

public struct SkillsProposalsListParams: Codable, Sendable {
    public let agentid: String?

    public init(
        agentid: String? = nil)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct SkillsProposalsListResult: Codable, Sendable {
    public let schema: String
    public let updatedat: String
    public let proposals: [[String: AnyCodable]]

    public init(
        schema: String,
        updatedat: String,
        proposals: [[String: AnyCodable]])
    {
        self.schema = schema
        self.updatedat = updatedat
        self.proposals = proposals
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case updatedat = "updatedAt"
        case proposals
    }
}

public struct SkillsProposalHistoryStatusParams: Codable, Sendable {
    public let agentid: String?

    public init(
        agentid: String? = nil)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct SkillsProposalHistoryScanParams: Codable, Sendable {
    public let agentid: String?
    public let direction: AnyCodable?

    public init(
        agentid: String? = nil,
        direction: AnyCodable? = nil)
    {
        self.agentid = agentid
        self.direction = direction
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case direction
    }
}

public struct SkillsProposalHistoryScanResult: Codable, Sendable {
    public let schema: String
    public let hasscanned: Bool
    public let reviewedsessions: Int
    public let ideasfound: Int
    public let hasmore: Bool
    public let lastscanreviewed: Int
    public let lastscanideas: Int
    public let lastscanat: String?
    public let oldestreviewedat: String?
    public let newestreviewedat: String?

    public init(
        schema: String,
        hasscanned: Bool,
        reviewedsessions: Int,
        ideasfound: Int,
        hasmore: Bool,
        lastscanreviewed: Int,
        lastscanideas: Int,
        lastscanat: String? = nil,
        oldestreviewedat: String? = nil,
        newestreviewedat: String? = nil)
    {
        self.schema = schema
        self.hasscanned = hasscanned
        self.reviewedsessions = reviewedsessions
        self.ideasfound = ideasfound
        self.hasmore = hasmore
        self.lastscanreviewed = lastscanreviewed
        self.lastscanideas = lastscanideas
        self.lastscanat = lastscanat
        self.oldestreviewedat = oldestreviewedat
        self.newestreviewedat = newestreviewedat
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case hasscanned = "hasScanned"
        case reviewedsessions = "reviewedSessions"
        case ideasfound = "ideasFound"
        case hasmore = "hasMore"
        case lastscanreviewed = "lastScanReviewed"
        case lastscanideas = "lastScanIdeas"
        case lastscanat = "lastScanAt"
        case oldestreviewedat = "oldestReviewedAt"
        case newestreviewedat = "newestReviewedAt"
    }
}

public struct SkillsProposalInspectParams: Codable, Sendable {
    public let agentid: String?
    public let proposalid: String

    public init(
        agentid: String? = nil,
        proposalid: String)
    {
        self.agentid = agentid
        self.proposalid = proposalid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case proposalid = "proposalId"
    }
}

public struct SkillsProposalInspectResult: Codable, Sendable {
    public let record: SkillsProposalRecordResult
    public let content: String
    public let supportfiles: [[String: AnyCodable]]?

    public init(
        record: SkillsProposalRecordResult,
        content: String,
        supportfiles: [[String: AnyCodable]]? = nil)
    {
        self.record = record
        self.content = content
        self.supportfiles = supportfiles
    }

    private enum CodingKeys: String, CodingKey {
        case record
        case content
        case supportfiles = "supportFiles"
    }
}

public struct SkillsProposalCreateParams: Codable, Sendable {
    public let agentid: String?
    public let name: String
    public let description: String
    public let content: String
    public let supportfiles: [[String: AnyCodable]]?
    public let goal: String?
    public let evidence: String?

    public init(
        agentid: String? = nil,
        name: String,
        description: String,
        content: String,
        supportfiles: [[String: AnyCodable]]? = nil,
        goal: String? = nil,
        evidence: String? = nil)
    {
        self.agentid = agentid
        self.name = name
        self.description = description
        self.content = content
        self.supportfiles = supportfiles
        self.goal = goal
        self.evidence = evidence
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case name
        case description
        case content
        case supportfiles = "supportFiles"
        case goal
        case evidence
    }
}

public struct SkillsProposalUpdateParams: Codable, Sendable {
    public let agentid: String?
    public let skillname: String
    public let description: String?
    public let content: String
    public let supportfiles: [[String: AnyCodable]]?
    public let goal: String?
    public let evidence: String?

    public init(
        agentid: String? = nil,
        skillname: String,
        description: String? = nil,
        content: String,
        supportfiles: [[String: AnyCodable]]? = nil,
        goal: String? = nil,
        evidence: String? = nil)
    {
        self.agentid = agentid
        self.skillname = skillname
        self.description = description
        self.content = content
        self.supportfiles = supportfiles
        self.goal = goal
        self.evidence = evidence
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case skillname = "skillName"
        case description
        case content
        case supportfiles = "supportFiles"
        case goal
        case evidence
    }
}

public struct SkillsProposalReviseParams: Codable, Sendable {
    public let agentid: String?
    public let proposalid: String
    public let content: String
    public let supportfiles: [[String: AnyCodable]]?
    public let description: String?
    public let goal: String?
    public let evidence: String?

    public init(
        agentid: String? = nil,
        proposalid: String,
        content: String,
        supportfiles: [[String: AnyCodable]]? = nil,
        description: String? = nil,
        goal: String? = nil,
        evidence: String? = nil)
    {
        self.agentid = agentid
        self.proposalid = proposalid
        self.content = content
        self.supportfiles = supportfiles
        self.description = description
        self.goal = goal
        self.evidence = evidence
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case proposalid = "proposalId"
        case content
        case supportfiles = "supportFiles"
        case description
        case goal
        case evidence
    }
}

public struct SkillsProposalRequestRevisionParams: Codable, Sendable {
    public let agentid: String?
    public let targetagentid: String?
    public let proposalid: String
    public let instructions: String
    public let sessionkey: String
    public let sessionid: String?
    public let idempotencykey: String

    public init(
        agentid: String? = nil,
        targetagentid: String? = nil,
        proposalid: String,
        instructions: String,
        sessionkey: String,
        sessionid: String? = nil,
        idempotencykey: String)
    {
        self.agentid = agentid
        self.targetagentid = targetagentid
        self.proposalid = proposalid
        self.instructions = instructions
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case targetagentid = "targetAgentId"
        case proposalid = "proposalId"
        case instructions
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case idempotencykey = "idempotencyKey"
    }
}

public struct SkillsProposalRequestRevisionResult: Codable, Sendable {
    public let runid: String
    public let status: AnyCodable

    public init(
        runid: String,
        status: AnyCodable)
    {
        self.runid = runid
        self.status = status
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case status
    }
}

public struct SkillsProposalActionParams: Codable, Sendable {
    public let agentid: String?
    public let proposalid: String
    public let reason: String?

    public init(
        agentid: String? = nil,
        proposalid: String,
        reason: String? = nil)
    {
        self.agentid = agentid
        self.proposalid = proposalid
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case proposalid = "proposalId"
        case reason
    }
}

public struct SkillsProposalApplyResult: Codable, Sendable {
    public let record: SkillsProposalRecordResult
    public let targetskillfile: String

    public init(
        record: SkillsProposalRecordResult,
        targetskillfile: String)
    {
        self.record = record
        self.targetskillfile = targetskillfile
    }

    private enum CodingKeys: String, CodingKey {
        case record
        case targetskillfile = "targetSkillFile"
    }
}

public struct SkillsProposalRecordResult: Codable, Sendable {
    public let schema: String
    public let id: String
    public let kind: AnyCodable
    public let status: AnyCodable
    public let title: String
    public let description: String
    public let createdat: String
    public let updatedat: String
    public let createdby: AnyCodable
    public let origin: [String: AnyCodable]?
    public let proposedversion: String
    public let draftfile: String
    public let drafthash: String
    public let supportfiles: [[String: AnyCodable]]?
    public let target: [String: AnyCodable]
    public let scan: [String: AnyCodable]
    public let goal: String?
    public let evidence: String?
    public let appliedat: String?
    public let rejectedat: String?
    public let quarantinedat: String?
    public let staleat: String?
    public let statusreason: String?

    public init(
        schema: String,
        id: String,
        kind: AnyCodable,
        status: AnyCodable,
        title: String,
        description: String,
        createdat: String,
        updatedat: String,
        createdby: AnyCodable,
        origin: [String: AnyCodable]? = nil,
        proposedversion: String,
        draftfile: String,
        drafthash: String,
        supportfiles: [[String: AnyCodable]]? = nil,
        target: [String: AnyCodable],
        scan: [String: AnyCodable],
        goal: String? = nil,
        evidence: String? = nil,
        appliedat: String? = nil,
        rejectedat: String? = nil,
        quarantinedat: String? = nil,
        staleat: String? = nil,
        statusreason: String? = nil)
    {
        self.schema = schema
        self.id = id
        self.kind = kind
        self.status = status
        self.title = title
        self.description = description
        self.createdat = createdat
        self.updatedat = updatedat
        self.createdby = createdby
        self.origin = origin
        self.proposedversion = proposedversion
        self.draftfile = draftfile
        self.drafthash = drafthash
        self.supportfiles = supportfiles
        self.target = target
        self.scan = scan
        self.goal = goal
        self.evidence = evidence
        self.appliedat = appliedat
        self.rejectedat = rejectedat
        self.quarantinedat = quarantinedat
        self.staleat = staleat
        self.statusreason = statusreason
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case id
        case kind
        case status
        case title
        case description
        case createdat = "createdAt"
        case updatedat = "updatedAt"
        case createdby = "createdBy"
        case origin
        case proposedversion = "proposedVersion"
        case draftfile = "draftFile"
        case drafthash = "draftHash"
        case supportfiles = "supportFiles"
        case target
        case scan
        case goal
        case evidence
        case appliedat = "appliedAt"
        case rejectedat = "rejectedAt"
        case quarantinedat = "quarantinedAt"
        case staleat = "staleAt"
        case statusreason = "statusReason"
    }
}

public struct SkillsSecurityVerdictsParams: Codable, Sendable {
    public let agentid: String?

    public init(
        agentid: String? = nil)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct SkillsSecurityVerdictsResult: Codable, Sendable {
    public let schema: String
    public let items: [[String: AnyCodable]]

    public init(
        schema: String,
        items: [[String: AnyCodable]])
    {
        self.schema = schema
        self.items = items
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case items
    }
}

public struct SkillsSkillCardParams: Codable, Sendable {
    public let agentid: String?
    public let skillkey: String

    public init(
        agentid: String? = nil,
        skillkey: String)
    {
        self.agentid = agentid
        self.skillkey = skillkey
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case skillkey = "skillKey"
    }
}

public struct SkillsSkillCardResult: Codable, Sendable {
    public let schema: String
    public let skillkey: String
    public let path: String
    public let sizebytes: Int
    public let content: String

    public init(
        schema: String,
        skillkey: String,
        path: String,
        sizebytes: Int,
        content: String)
    {
        self.schema = schema
        self.skillkey = skillkey
        self.path = path
        self.sizebytes = sizebytes
        self.content = content
    }

    private enum CodingKeys: String, CodingKey {
        case schema
        case skillkey = "skillKey"
        case path
        case sizebytes = "sizeBytes"
        case content
    }
}

public struct SkillsUploadBeginParams: Codable, Sendable {
    public let kind: String
    public let slug: String
    public let sizebytes: Int
    public let sha256: String?
    public let force: Bool?
    public let idempotencykey: String?

    public init(
        kind: String,
        slug: String,
        sizebytes: Int,
        sha256: String? = nil,
        force: Bool? = nil,
        idempotencykey: String? = nil)
    {
        self.kind = kind
        self.slug = slug
        self.sizebytes = sizebytes
        self.sha256 = sha256
        self.force = force
        self.idempotencykey = idempotencykey
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case slug
        case sizebytes = "sizeBytes"
        case sha256
        case force
        case idempotencykey = "idempotencyKey"
    }
}

public struct SkillsUploadChunkParams: Codable, Sendable {
    public let uploadid: String
    public let offset: Int
    public let database64: String

    public init(
        uploadid: String,
        offset: Int,
        database64: String)
    {
        self.uploadid = uploadid
        self.offset = offset
        self.database64 = database64
    }

    private enum CodingKeys: String, CodingKey {
        case uploadid = "uploadId"
        case offset
        case database64 = "dataBase64"
    }
}

public struct SkillsUploadCommitParams: Codable, Sendable {
    public let uploadid: String
    public let sha256: String?

    public init(
        uploadid: String,
        sha256: String? = nil)
    {
        self.uploadid = uploadid
        self.sha256 = sha256
    }

    private enum CodingKeys: String, CodingKey {
        case uploadid = "uploadId"
        case sha256
    }
}

public struct CronJob: Codable, Sendable {
    public let id: String
    public let declarationkey: String?
    public let displayname: String?
    public let owner: [String: AnyCodable]?
    public let scheduledtoolpolicy: AnyCodable?
    public let agentid: String?
    public let sessionkey: String?
    public let name: String
    public let description: String?
    public let enabled: Bool
    public let deleteafterrun: Bool?
    public let createdatms: Int
    public let updatedatms: Int
    public let configrevision: String?
    public let schedule: AnyCodable
    public let pacing: [String: AnyCodable]?
    public let trigger: [String: AnyCodable]?
    public let sessiontarget: AnyCodable
    public let wakemode: AnyCodable
    public let payload: AnyCodable
    public let delivery: AnyCodable?
    public let failurealert: AnyCodable?
    public let state: [String: AnyCodable]
    public let nextrunatms: Int?
    public let lastrunatms: Int?
    public let lastrunstatus: AnyCodable?
    public let lastrunerror: String?
    public let lastdelivered: Bool?
    public let lastdeliverystatus: AnyCodable?
    public let lastdeliveryerror: String?
    public let lastfailurenotificationdelivered: Bool?
    public let lastfailurenotificationdeliverystatus: AnyCodable?
    public let lastfailurenotificationdeliveryerror: String?

    public init(
        id: String,
        declarationkey: String? = nil,
        displayname: String? = nil,
        owner: [String: AnyCodable]? = nil,
        scheduledtoolpolicy: AnyCodable? = nil,
        agentid: String? = nil,
        sessionkey: String? = nil,
        name: String,
        description: String? = nil,
        enabled: Bool,
        deleteafterrun: Bool? = nil,
        createdatms: Int,
        updatedatms: Int,
        configrevision: String? = nil,
        schedule: AnyCodable,
        pacing: [String: AnyCodable]? = nil,
        trigger: [String: AnyCodable]? = nil,
        sessiontarget: AnyCodable,
        wakemode: AnyCodable,
        payload: AnyCodable,
        delivery: AnyCodable? = nil,
        failurealert: AnyCodable? = nil,
        state: [String: AnyCodable],
        nextrunatms: Int? = nil,
        lastrunatms: Int? = nil,
        lastrunstatus: AnyCodable? = nil,
        lastrunerror: String? = nil,
        lastdelivered: Bool? = nil,
        lastdeliverystatus: AnyCodable? = nil,
        lastdeliveryerror: String? = nil,
        lastfailurenotificationdelivered: Bool? = nil,
        lastfailurenotificationdeliverystatus: AnyCodable? = nil,
        lastfailurenotificationdeliveryerror: String? = nil)
    {
        self.id = id
        self.declarationkey = declarationkey
        self.displayname = displayname
        self.owner = owner
        self.scheduledtoolpolicy = scheduledtoolpolicy
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.name = name
        self.description = description
        self.enabled = enabled
        self.deleteafterrun = deleteafterrun
        self.createdatms = createdatms
        self.updatedatms = updatedatms
        self.configrevision = configrevision
        self.schedule = schedule
        self.pacing = pacing
        self.trigger = trigger
        self.sessiontarget = sessiontarget
        self.wakemode = wakemode
        self.payload = payload
        self.delivery = delivery
        self.failurealert = failurealert
        self.state = state
        self.nextrunatms = nextrunatms
        self.lastrunatms = lastrunatms
        self.lastrunstatus = lastrunstatus
        self.lastrunerror = lastrunerror
        self.lastdelivered = lastdelivered
        self.lastdeliverystatus = lastdeliverystatus
        self.lastdeliveryerror = lastdeliveryerror
        self.lastfailurenotificationdelivered = lastfailurenotificationdelivered
        self.lastfailurenotificationdeliverystatus = lastfailurenotificationdeliverystatus
        self.lastfailurenotificationdeliveryerror = lastfailurenotificationdeliveryerror
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case declarationkey = "declarationKey"
        case displayname = "displayName"
        case owner
        case scheduledtoolpolicy = "scheduledToolPolicy"
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case name
        case description
        case enabled
        case deleteafterrun = "deleteAfterRun"
        case createdatms = "createdAtMs"
        case updatedatms = "updatedAtMs"
        case configrevision = "configRevision"
        case schedule
        case pacing
        case trigger
        case sessiontarget = "sessionTarget"
        case wakemode = "wakeMode"
        case payload
        case delivery
        case failurealert = "failureAlert"
        case state
        case nextrunatms = "nextRunAtMs"
        case lastrunatms = "lastRunAtMs"
        case lastrunstatus = "lastRunStatus"
        case lastrunerror = "lastRunError"
        case lastdelivered = "lastDelivered"
        case lastdeliverystatus = "lastDeliveryStatus"
        case lastdeliveryerror = "lastDeliveryError"
        case lastfailurenotificationdelivered = "lastFailureNotificationDelivered"
        case lastfailurenotificationdeliverystatus = "lastFailureNotificationDeliveryStatus"
        case lastfailurenotificationdeliveryerror = "lastFailureNotificationDeliveryError"
    }
}

public struct CronListParams: Codable, Sendable {
    public let includedisabled: Bool?
    public let limit: Int?
    public let offset: Int?
    public let query: String?
    public let enabled: AnyCodable?
    public let schedulekind: AnyCodable?
    public let lastrunstatus: AnyCodable?
    public let sortby: AnyCodable?
    public let sortdir: AnyCodable?
    public let agentid: String?
    public let compact: Bool?

    public init(
        includedisabled: Bool? = nil,
        limit: Int? = nil,
        offset: Int? = nil,
        query: String? = nil,
        enabled: AnyCodable? = nil,
        schedulekind: AnyCodable? = nil,
        lastrunstatus: AnyCodable? = nil,
        sortby: AnyCodable? = nil,
        sortdir: AnyCodable? = nil,
        agentid: String? = nil,
        compact: Bool? = nil)
    {
        self.includedisabled = includedisabled
        self.limit = limit
        self.offset = offset
        self.query = query
        self.enabled = enabled
        self.schedulekind = schedulekind
        self.lastrunstatus = lastrunstatus
        self.sortby = sortby
        self.sortdir = sortdir
        self.agentid = agentid
        self.compact = compact
    }

    private enum CodingKeys: String, CodingKey {
        case includedisabled = "includeDisabled"
        case limit
        case offset
        case query
        case enabled
        case schedulekind = "scheduleKind"
        case lastrunstatus = "lastRunStatus"
        case sortby = "sortBy"
        case sortdir = "sortDir"
        case agentid = "agentId"
        case compact
    }
}

public struct CronStatusParams: Codable, Sendable {}

public struct CronAddParams: Codable, Sendable {
    public let name: String
    public let declarationkey: String?
    public let displayname: String?
    public let owner: [String: AnyCodable]?
    public let agentid: AnyCodable?
    public let sessionkey: AnyCodable?
    public let description: String?
    public let enabled: Bool?
    public let deleteafterrun: Bool?
    public let schedule: AnyCodable
    public let pacing: [String: AnyCodable]?
    public let trigger: [String: AnyCodable]?
    public let sessiontarget: AnyCodable
    public let wakemode: AnyCodable
    public let payload: AnyCodable
    public let delivery: AnyCodable?
    public let failurealert: AnyCodable?

    public init(
        name: String,
        declarationkey: String? = nil,
        displayname: String? = nil,
        owner: [String: AnyCodable]? = nil,
        agentid: AnyCodable? = nil,
        sessionkey: AnyCodable? = nil,
        description: String? = nil,
        enabled: Bool? = nil,
        deleteafterrun: Bool? = nil,
        schedule: AnyCodable,
        pacing: [String: AnyCodable]? = nil,
        trigger: [String: AnyCodable]? = nil,
        sessiontarget: AnyCodable,
        wakemode: AnyCodable,
        payload: AnyCodable,
        delivery: AnyCodable? = nil,
        failurealert: AnyCodable? = nil)
    {
        self.name = name
        self.declarationkey = declarationkey
        self.displayname = displayname
        self.owner = owner
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.description = description
        self.enabled = enabled
        self.deleteafterrun = deleteafterrun
        self.schedule = schedule
        self.pacing = pacing
        self.trigger = trigger
        self.sessiontarget = sessiontarget
        self.wakemode = wakemode
        self.payload = payload
        self.delivery = delivery
        self.failurealert = failurealert
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case declarationkey = "declarationKey"
        case displayname = "displayName"
        case owner
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case description
        case enabled
        case deleteafterrun = "deleteAfterRun"
        case schedule
        case pacing
        case trigger
        case sessiontarget = "sessionTarget"
        case wakemode = "wakeMode"
        case payload
        case delivery
        case failurealert = "failureAlert"
    }
}

public struct CronDeclarativeAddResult: Codable, Sendable {
    public let created: Bool
    public let updated: Bool?
    public let job: CronJob

    public init(
        created: Bool,
        updated: Bool? = nil,
        job: CronJob)
    {
        self.created = created
        self.updated = updated
        self.job = job
    }

    private enum CodingKeys: String, CodingKey {
        case created
        case updated
        case job
    }
}

public struct CronRunsParams: Codable, Sendable {
    public let agentid: String?
    public let scope: AnyCodable?
    public let id: String?
    public let jobid: String?
    public let runid: String?
    public let limit: Int?
    public let offset: Int?
    public let statuses: [AnyCodable]?
    public let status: AnyCodable?
    public let deliverystatuses: [AnyCodable]?
    public let deliverystatus: AnyCodable?
    public let query: String?
    public let sortdir: AnyCodable?

    public init(
        agentid: String? = nil,
        scope: AnyCodable? = nil,
        id: String? = nil,
        jobid: String? = nil,
        runid: String? = nil,
        limit: Int? = nil,
        offset: Int? = nil,
        statuses: [AnyCodable]? = nil,
        status: AnyCodable? = nil,
        deliverystatuses: [AnyCodable]? = nil,
        deliverystatus: AnyCodable? = nil,
        query: String? = nil,
        sortdir: AnyCodable? = nil)
    {
        self.agentid = agentid
        self.scope = scope
        self.id = id
        self.jobid = jobid
        self.runid = runid
        self.limit = limit
        self.offset = offset
        self.statuses = statuses
        self.status = status
        self.deliverystatuses = deliverystatuses
        self.deliverystatus = deliverystatus
        self.query = query
        self.sortdir = sortdir
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case scope
        case id
        case jobid = "jobId"
        case runid = "runId"
        case limit
        case offset
        case statuses
        case status
        case deliverystatuses = "deliveryStatuses"
        case deliverystatus = "deliveryStatus"
        case query
        case sortdir = "sortDir"
    }
}

public struct CronScratchGetResult: Codable, Sendable {
    public let scratch: AnyCodable
    public let currentrevision: Int
    public let maxbytes: Int

    public init(
        scratch: AnyCodable,
        currentrevision: Int,
        maxbytes: Int)
    {
        self.scratch = scratch
        self.currentrevision = currentrevision
        self.maxbytes = maxbytes
    }

    private enum CodingKeys: String, CodingKey {
        case scratch
        case currentrevision = "currentRevision"
        case maxbytes = "maxBytes"
    }
}

public struct CronRunLogEntry: Codable, Sendable {
    public let ts: Int
    public let jobid: String
    public let action: String
    public let status: AnyCodable?
    public let error: String?
    public let errorreason: AnyCodable?
    public let summary: String?
    public let diagnostics: [String: AnyCodable]?
    public let delivered: Bool?
    public let deliverystatus: AnyCodable?
    public let deliveryerror: String?
    public let failurenotificationdelivery: [String: AnyCodable]?
    public let sessionid: String?
    public let sessionkey: String?
    public let runid: String?
    public let runatms: Int?
    public let durationms: Int?
    public let nextrunatms: Int?
    public let triggerfired: Bool?
    public let model: String?
    public let provider: String?
    public let usage: [String: AnyCodable]?
    public let jobname: String?

    public init(
        ts: Int,
        jobid: String,
        action: String,
        status: AnyCodable? = nil,
        error: String? = nil,
        errorreason: AnyCodable? = nil,
        summary: String? = nil,
        diagnostics: [String: AnyCodable]? = nil,
        delivered: Bool? = nil,
        deliverystatus: AnyCodable? = nil,
        deliveryerror: String? = nil,
        failurenotificationdelivery: [String: AnyCodable]? = nil,
        sessionid: String? = nil,
        sessionkey: String? = nil,
        runid: String? = nil,
        runatms: Int? = nil,
        durationms: Int? = nil,
        nextrunatms: Int? = nil,
        triggerfired: Bool? = nil,
        model: String? = nil,
        provider: String? = nil,
        usage: [String: AnyCodable]? = nil,
        jobname: String? = nil)
    {
        self.ts = ts
        self.jobid = jobid
        self.action = action
        self.status = status
        self.error = error
        self.errorreason = errorreason
        self.summary = summary
        self.diagnostics = diagnostics
        self.delivered = delivered
        self.deliverystatus = deliverystatus
        self.deliveryerror = deliveryerror
        self.failurenotificationdelivery = failurenotificationdelivery
        self.sessionid = sessionid
        self.sessionkey = sessionkey
        self.runid = runid
        self.runatms = runatms
        self.durationms = durationms
        self.nextrunatms = nextrunatms
        self.triggerfired = triggerfired
        self.model = model
        self.provider = provider
        self.usage = usage
        self.jobname = jobname
    }

    private enum CodingKeys: String, CodingKey {
        case ts
        case jobid = "jobId"
        case action
        case status
        case error
        case errorreason = "errorReason"
        case summary
        case diagnostics
        case delivered
        case deliverystatus = "deliveryStatus"
        case deliveryerror = "deliveryError"
        case failurenotificationdelivery = "failureNotificationDelivery"
        case sessionid = "sessionId"
        case sessionkey = "sessionKey"
        case runid = "runId"
        case runatms = "runAtMs"
        case durationms = "durationMs"
        case nextrunatms = "nextRunAtMs"
        case triggerfired = "triggerFired"
        case model
        case provider
        case usage
        case jobname = "jobName"
    }
}

public struct LogsTailParams: Codable, Sendable {
    public let cursor: Int?
    public let limit: Int?
    public let maxbytes: Int?

    public init(
        cursor: Int? = nil,
        limit: Int? = nil,
        maxbytes: Int? = nil)
    {
        self.cursor = cursor
        self.limit = limit
        self.maxbytes = maxbytes
    }

    private enum CodingKeys: String, CodingKey {
        case cursor
        case limit
        case maxbytes = "maxBytes"
    }
}

public struct LogsTailResult: Codable, Sendable {
    public let file: String
    public let cursor: Int
    public let size: Int
    public let lines: [String]
    public let truncated: Bool?
    public let reset: Bool?

    public init(
        file: String,
        cursor: Int,
        size: Int,
        lines: [String],
        truncated: Bool? = nil,
        reset: Bool? = nil)
    {
        self.file = file
        self.cursor = cursor
        self.size = size
        self.lines = lines
        self.truncated = truncated
        self.reset = reset
    }

    private enum CodingKeys: String, CodingKey {
        case file
        case cursor
        case size
        case lines
        case truncated
        case reset
    }
}

public struct MemoryMigrationItem: Codable, Sendable {
    public let id: String
    public let status: MemoryMigrationItemStatus
    public let source: String?
    public let target: String?
    public let message: String?
    public let reason: String?
    public let details: [String: AnyCodable]?

    public init(
        id: String,
        status: MemoryMigrationItemStatus,
        source: String? = nil,
        target: String? = nil,
        message: String? = nil,
        reason: String? = nil,
        details: [String: AnyCodable]? = nil)
    {
        self.id = id
        self.status = status
        self.source = source
        self.target = target
        self.message = message
        self.reason = reason
        self.details = details
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case status
        case source
        case target
        case message
        case reason
        case details
    }
}

public struct MemoryMigrationSummary: Codable, Sendable {
    public let total: Int
    public let planned: Int
    public let migrated: Int
    public let skipped: Int
    public let conflicts: Int
    public let errors: Int
    public let sensitive: Int

    public init(
        total: Int,
        planned: Int,
        migrated: Int,
        skipped: Int,
        conflicts: Int,
        errors: Int,
        sensitive: Int)
    {
        self.total = total
        self.planned = planned
        self.migrated = migrated
        self.skipped = skipped
        self.conflicts = conflicts
        self.errors = errors
        self.sensitive = sensitive
    }

    private enum CodingKeys: String, CodingKey {
        case total
        case planned
        case migrated
        case skipped
        case conflicts
        case errors
        case sensitive
    }
}

public struct MemoryMigrationProviderPlan: Codable, Sendable {
    public let providerid: String
    public let label: String
    public let description: String?
    public let planfingerprint: String?
    public let found: Bool
    public let source: String?
    public let target: String?
    public let confidence: AnyCodable?
    public let message: String?
    public let error: String?
    public let summary: MemoryMigrationSummary
    public let items: [MemoryMigrationItem]
    public let warnings: [String]?

    public init(
        providerid: String,
        label: String,
        description: String? = nil,
        planfingerprint: String? = nil,
        found: Bool,
        source: String? = nil,
        target: String? = nil,
        confidence: AnyCodable? = nil,
        message: String? = nil,
        error: String? = nil,
        summary: MemoryMigrationSummary,
        items: [MemoryMigrationItem],
        warnings: [String]? = nil)
    {
        self.providerid = providerid
        self.label = label
        self.description = description
        self.planfingerprint = planfingerprint
        self.found = found
        self.source = source
        self.target = target
        self.confidence = confidence
        self.message = message
        self.error = error
        self.summary = summary
        self.items = items
        self.warnings = warnings
    }

    private enum CodingKeys: String, CodingKey {
        case providerid = "providerId"
        case label
        case description
        case planfingerprint = "planFingerprint"
        case found
        case source
        case target
        case confidence
        case message
        case error
        case summary
        case items
        case warnings
    }
}

public struct MigrationsMemoryPlanParams: Codable, Sendable {
    public let agentid: String
    public let overwrite: Bool?

    public init(
        agentid: String,
        overwrite: Bool? = nil)
    {
        self.agentid = agentid
        self.overwrite = overwrite
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case overwrite
    }
}

public struct MigrationsMemoryPlanResult: Codable, Sendable {
    public let agentid: String
    public let workspace: String
    public let providers: [MemoryMigrationProviderPlan]

    public init(
        agentid: String,
        workspace: String,
        providers: [MemoryMigrationProviderPlan])
    {
        self.agentid = agentid
        self.workspace = workspace
        self.providers = providers
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case workspace
        case providers
    }
}

public struct MigrationsMemoryApplyParams: Codable, Sendable {
    public let idempotencykey: String
    public let agentid: String
    public let providerid: String
    public let planfingerprint: String
    public let itemids: [String]
    public let overwrite: Bool?

    public init(
        idempotencykey: String,
        agentid: String,
        providerid: String,
        planfingerprint: String,
        itemids: [String],
        overwrite: Bool? = nil)
    {
        self.idempotencykey = idempotencykey
        self.agentid = agentid
        self.providerid = providerid
        self.planfingerprint = planfingerprint
        self.itemids = itemids
        self.overwrite = overwrite
    }

    private enum CodingKeys: String, CodingKey {
        case idempotencykey = "idempotencyKey"
        case agentid = "agentId"
        case providerid = "providerId"
        case planfingerprint = "planFingerprint"
        case itemids = "itemIds"
        case overwrite
    }
}

public struct MigrationsMemoryApplyResult: Codable, Sendable {
    public let providerid: String
    public let source: String
    public let target: String?
    public let summary: MemoryMigrationSummary
    public let items: [MemoryMigrationItem]
    public let warnings: [String]?
    public let backuppath: String?
    public let reportdir: String?

    public init(
        providerid: String,
        source: String,
        target: String? = nil,
        summary: MemoryMigrationSummary,
        items: [MemoryMigrationItem],
        warnings: [String]? = nil,
        backuppath: String? = nil,
        reportdir: String? = nil)
    {
        self.providerid = providerid
        self.source = source
        self.target = target
        self.summary = summary
        self.items = items
        self.warnings = warnings
        self.backuppath = backuppath
        self.reportdir = reportdir
    }

    private enum CodingKeys: String, CodingKey {
        case providerid = "providerId"
        case source
        case target
        case summary
        case items
        case warnings
        case backuppath = "backupPath"
        case reportdir = "reportDir"
    }
}

public struct TerminalOpenParams: Codable, Sendable {
    public let agentid: String?
    public let catalog: SessionsCatalogContinueParams?
    public let cols: Int
    public let rows: Int

    public init(
        agentid: String? = nil,
        catalog: SessionsCatalogContinueParams? = nil,
        cols: Int,
        rows: Int)
    {
        self.agentid = agentid
        self.catalog = catalog
        self.cols = cols
        self.rows = rows
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
        case catalog
        case cols
        case rows
    }
}

public struct TerminalOpenResult: Codable, Sendable {
    public let sessionid: String
    public let agentid: String
    public let shell: String
    public let cwd: String
    public let confined: Bool
    public let title: String?

    public init(
        sessionid: String,
        agentid: String,
        shell: String,
        cwd: String,
        confined: Bool,
        title: String? = nil)
    {
        self.sessionid = sessionid
        self.agentid = agentid
        self.shell = shell
        self.cwd = cwd
        self.confined = confined
        self.title = title
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case agentid = "agentId"
        case shell
        case cwd
        case confined
        case title
    }
}

public struct TerminalInputParams: Codable, Sendable {
    public let sessionid: String
    public let data: String

    public init(
        sessionid: String,
        data: String)
    {
        self.sessionid = sessionid
        self.data = data
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case data
    }
}

public struct TerminalResizeParams: Codable, Sendable {
    public let sessionid: String
    public let cols: Int
    public let rows: Int

    public init(
        sessionid: String,
        cols: Int,
        rows: Int)
    {
        self.sessionid = sessionid
        self.cols = cols
        self.rows = rows
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case cols
        case rows
    }
}

public struct TerminalCloseParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct TerminalAttachParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct TerminalAttachResult: Codable, Sendable {
    public let sessionid: String
    public let agentid: String
    public let shell: String
    public let cwd: String
    public let confined: Bool
    public let buffer: String
    public let seq: Int?

    public init(
        sessionid: String,
        agentid: String,
        shell: String,
        cwd: String,
        confined: Bool,
        buffer: String,
        seq: Int? = nil)
    {
        self.sessionid = sessionid
        self.agentid = agentid
        self.shell = shell
        self.cwd = cwd
        self.confined = confined
        self.buffer = buffer
        self.seq = seq
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case agentid = "agentId"
        case shell
        case cwd
        case confined
        case buffer
        case seq
    }
}

public struct TerminalSessionInfo: Codable, Sendable {
    public let sessionid: String
    public let agentid: String
    public let shell: String
    public let cwd: String
    public let confined: Bool
    public let attached: Bool
    public let owner: AnyCodable?
    public let createdatms: Int

    public init(
        sessionid: String,
        agentid: String,
        shell: String,
        cwd: String,
        confined: Bool,
        attached: Bool,
        owner: AnyCodable? = nil,
        createdatms: Int)
    {
        self.sessionid = sessionid
        self.agentid = agentid
        self.shell = shell
        self.cwd = cwd
        self.confined = confined
        self.attached = attached
        self.owner = owner
        self.createdatms = createdatms
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case agentid = "agentId"
        case shell
        case cwd
        case confined
        case attached
        case owner
        case createdatms = "createdAtMs"
    }
}

public struct TerminalListResult: Codable, Sendable {
    public let sessions: [TerminalSessionInfo]

    public init(
        sessions: [TerminalSessionInfo])
    {
        self.sessions = sessions
    }

    private enum CodingKeys: String, CodingKey {
        case sessions
    }
}

public struct TerminalTextParams: Codable, Sendable {
    public let sessionid: String

    public init(
        sessionid: String)
    {
        self.sessionid = sessionid
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
    }
}

public struct TerminalTextResult: Codable, Sendable {
    public let text: String

    public init(
        text: String)
    {
        self.text = text
    }

    private enum CodingKeys: String, CodingKey {
        case text
    }
}

public struct TerminalUploadParams: Codable, Sendable {
    public let sessionid: String
    public let name: String
    public let contentbase64: String

    public init(
        sessionid: String,
        name: String,
        contentbase64: String)
    {
        self.sessionid = sessionid
        self.name = name
        self.contentbase64 = contentbase64
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case name
        case contentbase64 = "contentBase64"
    }
}

public struct TerminalUploadResult: Codable, Sendable {
    public let path: String
    public let size: Int

    public init(
        path: String,
        size: Int)
    {
        self.path = path
        self.size = size
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case size
    }
}

public struct TerminalAckResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct TerminalDataEvent: Codable, Sendable {
    public let sessionid: String
    public let seq: Int
    public let data: String

    public init(
        sessionid: String,
        seq: Int,
        data: String)
    {
        self.sessionid = sessionid
        self.seq = seq
        self.data = data
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case seq
        case data
    }
}

public struct TerminalExitEvent: Codable, Sendable {
    public let sessionid: String
    public let exitcode: AnyCodable?
    public let signal: AnyCodable?
    public let reason: AnyCodable?
    public let error: String?

    public init(
        sessionid: String,
        exitcode: AnyCodable? = nil,
        signal: AnyCodable? = nil,
        reason: AnyCodable? = nil,
        error: String? = nil)
    {
        self.sessionid = sessionid
        self.exitcode = exitcode
        self.signal = signal
        self.reason = reason
        self.error = error
    }

    private enum CodingKeys: String, CodingKey {
        case sessionid = "sessionId"
        case exitcode = "exitCode"
        case signal
        case reason
        case error
    }
}

public struct ExecApprovalPresentation: Codable, Sendable {
    public let kind: String
    public let commandtext: String
    public let commandpreview: AnyCodable?
    public let warningtext: AnyCodable?
    public let host: AnyCodable?
    public let nodeid: AnyCodable?
    public let agentid: AnyCodable?
    public let alloweddecisions: [ApprovalDecision]

    public init(
        kind: String,
        commandtext: String,
        commandpreview: AnyCodable? = nil,
        warningtext: AnyCodable? = nil,
        host: AnyCodable? = nil,
        nodeid: AnyCodable? = nil,
        agentid: AnyCodable? = nil,
        alloweddecisions: [ApprovalDecision])
    {
        self.kind = kind
        self.commandtext = commandtext
        self.commandpreview = commandpreview
        self.warningtext = warningtext
        self.host = host
        self.nodeid = nodeid
        self.agentid = agentid
        self.alloweddecisions = alloweddecisions
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case commandtext = "commandText"
        case commandpreview = "commandPreview"
        case warningtext = "warningText"
        case host
        case nodeid = "nodeId"
        case agentid = "agentId"
        case alloweddecisions = "allowedDecisions"
    }
}

public struct PluginApprovalPresentation: Codable, Sendable {
    public let kind: String
    public let title: String
    public let description: String
    public let detail: String?
    public let severity: PluginApprovalSeverity
    public let pluginid: AnyCodable?
    public let toolname: AnyCodable?
    public let agentid: AnyCodable?
    public let alloweddecisions: [ApprovalDecision]

    public init(
        kind: String,
        title: String,
        description: String,
        detail: String? = nil,
        severity: PluginApprovalSeverity,
        pluginid: AnyCodable? = nil,
        toolname: AnyCodable? = nil,
        agentid: AnyCodable? = nil,
        alloweddecisions: [ApprovalDecision])
    {
        self.kind = kind
        self.title = title
        self.description = description
        self.detail = detail
        self.severity = severity
        self.pluginid = pluginid
        self.toolname = toolname
        self.agentid = agentid
        self.alloweddecisions = alloweddecisions
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case title
        case description
        case detail
        case severity
        case pluginid = "pluginId"
        case toolname = "toolName"
        case agentid = "agentId"
        case alloweddecisions = "allowedDecisions"
    }
}

public struct SystemAgentApprovalPresentation: Codable, Sendable {
    public let kind: String
    public let title: String
    public let description: String
    public let proposalhash: String
    public let agentid: AnyCodable?
    public let alloweddecisions: [AnyCodable]

    public init(
        kind: String,
        title: String,
        description: String,
        proposalhash: String,
        agentid: AnyCodable? = nil,
        alloweddecisions: [AnyCodable])
    {
        self.kind = kind
        self.title = title
        self.description = description
        self.proposalhash = proposalhash
        self.agentid = agentid
        self.alloweddecisions = alloweddecisions
    }

    private enum CodingKeys: String, CodingKey {
        case kind
        case title
        case description
        case proposalhash = "proposalHash"
        case agentid = "agentId"
        case alloweddecisions = "allowedDecisions"
    }
}

public struct PendingApprovalSnapshot: Codable, Sendable {
    public let id: String
    public let urlpath: String
    public let createdatms: Int
    public let expiresatms: Int
    public let presentation: ApprovalPresentation
    public let status: String

    public init(
        id: String,
        urlpath: String,
        createdatms: Int,
        expiresatms: Int,
        presentation: ApprovalPresentation,
        status: String)
    {
        self.id = id
        self.urlpath = urlpath
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.presentation = presentation
        self.status = status
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case urlpath = "urlPath"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case presentation
        case status
    }
}

public struct AllowedApprovalSnapshot: Codable, Sendable {
    public let id: String
    public let urlpath: String
    public let createdatms: Int
    public let expiresatms: Int
    public let presentation: ApprovalPresentation
    public let resolvedatms: Int
    public let source: [String: AnyCodable]?
    public let resolver: [String: AnyCodable]?
    public let status: String
    public let decision: ApprovalAllowDecision
    public let reason: ApprovalAllowedReason

    public init(
        id: String,
        urlpath: String,
        createdatms: Int,
        expiresatms: Int,
        presentation: ApprovalPresentation,
        resolvedatms: Int,
        source: [String: AnyCodable]? = nil,
        resolver: [String: AnyCodable]? = nil,
        status: String,
        decision: ApprovalAllowDecision,
        reason: ApprovalAllowedReason)
    {
        self.id = id
        self.urlpath = urlpath
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.presentation = presentation
        self.resolvedatms = resolvedatms
        self.source = source
        self.resolver = resolver
        self.status = status
        self.decision = decision
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case urlpath = "urlPath"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case presentation
        case resolvedatms = "resolvedAtMs"
        case source
        case resolver
        case status
        case decision
        case reason
    }
}

public struct DeniedApprovalSnapshot: Codable, Sendable {
    public let id: String
    public let urlpath: String
    public let createdatms: Int
    public let expiresatms: Int
    public let presentation: ApprovalPresentation
    public let resolvedatms: Int
    public let source: [String: AnyCodable]?
    public let resolver: [String: AnyCodable]?
    public let status: String
    public let decision: String
    public let reason: ApprovalDeniedReason

    public init(
        id: String,
        urlpath: String,
        createdatms: Int,
        expiresatms: Int,
        presentation: ApprovalPresentation,
        resolvedatms: Int,
        source: [String: AnyCodable]? = nil,
        resolver: [String: AnyCodable]? = nil,
        status: String,
        decision: String,
        reason: ApprovalDeniedReason)
    {
        self.id = id
        self.urlpath = urlpath
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.presentation = presentation
        self.resolvedatms = resolvedatms
        self.source = source
        self.resolver = resolver
        self.status = status
        self.decision = decision
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case urlpath = "urlPath"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case presentation
        case resolvedatms = "resolvedAtMs"
        case source
        case resolver
        case status
        case decision
        case reason
    }
}

public struct ExpiredApprovalSnapshot: Codable, Sendable {
    public let id: String
    public let urlpath: String
    public let createdatms: Int
    public let expiresatms: Int
    public let presentation: ApprovalPresentation
    public let resolvedatms: Int
    public let source: [String: AnyCodable]?
    public let resolver: [String: AnyCodable]?
    public let status: String
    public let reason: ApprovalExpiredReason

    public init(
        id: String,
        urlpath: String,
        createdatms: Int,
        expiresatms: Int,
        presentation: ApprovalPresentation,
        resolvedatms: Int,
        source: [String: AnyCodable]? = nil,
        resolver: [String: AnyCodable]? = nil,
        status: String,
        reason: ApprovalExpiredReason)
    {
        self.id = id
        self.urlpath = urlpath
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.presentation = presentation
        self.resolvedatms = resolvedatms
        self.source = source
        self.resolver = resolver
        self.status = status
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case urlpath = "urlPath"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case presentation
        case resolvedatms = "resolvedAtMs"
        case source
        case resolver
        case status
        case reason
    }
}

public struct CancelledApprovalSnapshot: Codable, Sendable {
    public let id: String
    public let urlpath: String
    public let createdatms: Int
    public let expiresatms: Int
    public let presentation: ApprovalPresentation
    public let resolvedatms: Int
    public let source: [String: AnyCodable]?
    public let resolver: [String: AnyCodable]?
    public let status: String
    public let reason: ApprovalCancelledReason

    public init(
        id: String,
        urlpath: String,
        createdatms: Int,
        expiresatms: Int,
        presentation: ApprovalPresentation,
        resolvedatms: Int,
        source: [String: AnyCodable]? = nil,
        resolver: [String: AnyCodable]? = nil,
        status: String,
        reason: ApprovalCancelledReason)
    {
        self.id = id
        self.urlpath = urlpath
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.presentation = presentation
        self.resolvedatms = resolvedatms
        self.source = source
        self.resolver = resolver
        self.status = status
        self.reason = reason
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case urlpath = "urlPath"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case presentation
        case resolvedatms = "resolvedAtMs"
        case source
        case resolver
        case status
        case reason
    }
}

public struct ApprovalGetParams: Codable, Sendable {
    public let id: String

    public init(
        id: String)
    {
        self.id = id
    }

    private enum CodingKeys: String, CodingKey {
        case id
    }
}

public struct ApprovalGetResult: Codable, Sendable {
    public let approval: ApprovalSnapshot

    public init(
        approval: ApprovalSnapshot)
    {
        self.approval = approval
    }

    private enum CodingKeys: String, CodingKey {
        case approval
    }
}

public struct ApprovalHistoryParams: Codable, Sendable {
    public let cursor: String?
    public let limit: Int?
    public let kind: ApprovalKind?

    public init(
        cursor: String? = nil,
        limit: Int? = nil,
        kind: ApprovalKind? = nil)
    {
        self.cursor = cursor
        self.limit = limit
        self.kind = kind
    }

    private enum CodingKeys: String, CodingKey {
        case cursor
        case limit
        case kind
    }
}

public struct ApprovalHistoryResult: Codable, Sendable {
    public let items: [TerminalApprovalSnapshot]
    public let nextcursor: String?

    public init(
        items: [TerminalApprovalSnapshot],
        nextcursor: String? = nil)
    {
        self.items = items
        self.nextcursor = nextcursor
    }

    private enum CodingKeys: String, CodingKey {
        case items
        case nextcursor = "nextCursor"
    }
}

public struct ApprovalResolveParams: Codable, Sendable {
    public let id: String
    public let kind: ApprovalKind
    public let decision: ApprovalDecision

    public init(
        id: String,
        kind: ApprovalKind,
        decision: ApprovalDecision)
    {
        self.id = id
        self.kind = kind
        self.decision = decision
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case kind
        case decision
    }
}

public struct ApprovalResolveResult: Codable, Sendable {
    public let applied: Bool
    public let approval: TerminalApprovalSnapshot

    public init(
        applied: Bool,
        approval: TerminalApprovalSnapshot)
    {
        self.applied = applied
        self.approval = approval
    }

    private enum CodingKeys: String, CodingKey {
        case applied
        case approval
    }
}

public struct PendingSessionApprovalEvent: Codable, Sendable {
    public let sessionkey: String
    public let sourcesessionkey: String?
    public let updatedatms: Int
    public let phase: String
    public let approval: PendingApprovalSnapshot

    public init(
        sessionkey: String,
        sourcesessionkey: String? = nil,
        updatedatms: Int,
        phase: String,
        approval: PendingApprovalSnapshot)
    {
        self.sessionkey = sessionkey
        self.sourcesessionkey = sourcesessionkey
        self.updatedatms = updatedatms
        self.phase = phase
        self.approval = approval
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case sourcesessionkey = "sourceSessionKey"
        case updatedatms = "updatedAtMs"
        case phase
        case approval
    }
}

public struct TerminalSessionApprovalEvent: Codable, Sendable {
    public let sessionkey: String
    public let sourcesessionkey: String?
    public let updatedatms: Int
    public let phase: String
    public let approval: TerminalApprovalSnapshot

    public init(
        sessionkey: String,
        sourcesessionkey: String? = nil,
        updatedatms: Int,
        phase: String,
        approval: TerminalApprovalSnapshot)
    {
        self.sessionkey = sessionkey
        self.sourcesessionkey = sourcesessionkey
        self.updatedatms = updatedatms
        self.phase = phase
        self.approval = approval
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case sourcesessionkey = "sourceSessionKey"
        case updatedatms = "updatedAtMs"
        case phase
        case approval
    }
}

public struct SessionApprovalReplay: Codable, Sendable {
    public let sessionkey: String
    public let updatedatms: Int
    public let approvals: [PendingApprovalSnapshot]
    public let truncated: Bool

    public init(
        sessionkey: String,
        updatedatms: Int,
        approvals: [PendingApprovalSnapshot],
        truncated: Bool)
    {
        self.sessionkey = sessionkey
        self.updatedatms = updatedatms
        self.approvals = approvals
        self.truncated = truncated
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case updatedatms = "updatedAtMs"
        case approvals
        case truncated
    }
}

public struct ExecApprovalsGetParams: Codable, Sendable {}

public struct ExecApprovalsSetParams: Codable, Sendable {
    public let file: [String: AnyCodable]
    public let basehash: String?

    public init(
        file: [String: AnyCodable],
        basehash: String? = nil)
    {
        self.file = file
        self.basehash = basehash
    }

    private enum CodingKeys: String, CodingKey {
        case file
        case basehash = "baseHash"
    }
}

public struct ExecApprovalsNodeGetParams: Codable, Sendable {
    public let nodeid: String

    public init(
        nodeid: String)
    {
        self.nodeid = nodeid
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
    }
}

public struct ExecApprovalsNodeSnapshot: Codable, Sendable {
    public let path: String?
    public let exists: Bool?
    public let hash: String?
    public let file: [String: AnyCodable]?
    public let resolveddefaults: [String: AnyCodable]?
    public let enabled: Bool?
    public let basehash: String?
    public let defaultaction: AnyCodable?
    public let rules: [[String: AnyCodable]]?
    public let constraints: [String: AnyCodable]?
    public let message: String?

    public init(
        path: String? = nil,
        exists: Bool? = nil,
        hash: String? = nil,
        file: [String: AnyCodable]? = nil,
        resolveddefaults: [String: AnyCodable]? = nil,
        enabled: Bool? = nil,
        basehash: String? = nil,
        defaultaction: AnyCodable? = nil,
        rules: [[String: AnyCodable]]? = nil,
        constraints: [String: AnyCodable]? = nil,
        message: String? = nil)
    {
        self.path = path
        self.exists = exists
        self.hash = hash
        self.file = file
        self.resolveddefaults = resolveddefaults
        self.enabled = enabled
        self.basehash = basehash
        self.defaultaction = defaultaction
        self.rules = rules
        self.constraints = constraints
        self.message = message
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case exists
        case hash
        case file
        case resolveddefaults = "resolvedDefaults"
        case enabled
        case basehash = "baseHash"
        case defaultaction = "defaultAction"
        case rules
        case constraints
        case message
    }
}

public struct ExecApprovalsNodeSetParams: Codable, Sendable {
    public let nodeid: String
    public let file: [String: AnyCodable]?
    public let native: [String: AnyCodable]?
    public let basehash: String?

    public init(
        nodeid: String,
        file: [String: AnyCodable]? = nil,
        native: [String: AnyCodable]? = nil,
        basehash: String? = nil)
    {
        self.nodeid = nodeid
        self.file = file
        self.native = native
        self.basehash = basehash
    }

    private enum CodingKeys: String, CodingKey {
        case nodeid = "nodeId"
        case file
        case native
        case basehash = "baseHash"
    }
}

public struct ExecApprovalsSnapshot: Codable, Sendable {
    public let path: String
    public let exists: Bool
    public let hash: String
    public let file: [String: AnyCodable]

    public init(
        path: String,
        exists: Bool,
        hash: String,
        file: [String: AnyCodable])
    {
        self.path = path
        self.exists = exists
        self.hash = hash
        self.file = file
    }

    private enum CodingKeys: String, CodingKey {
        case path
        case exists
        case hash
        case file
    }
}

public struct ExecApprovalGetParams: Codable, Sendable {
    public let id: String

    public init(
        id: String)
    {
        self.id = id
    }

    private enum CodingKeys: String, CodingKey {
        case id
    }
}

public struct ExecApprovalRequestParams: Codable, Sendable {
    public let id: String?
    public let command: String?
    public let commandargv: [String]?
    public let systemrunplan: [String: AnyCodable]?
    public let env: [String: AnyCodable]?
    public let cwd: AnyCodable?
    public let nodeid: AnyCodable?
    public let host: AnyCodable?
    public let security: AnyCodable?
    public let ask: AnyCodable?
    public let warningtext: AnyCodable?
    public let unavailabledecisions: [String]?
    public let commandspans: [[String: AnyCodable]]?
    public let agentid: AnyCodable?
    public let resolvedpath: AnyCodable?
    public let sessionkey: AnyCodable?
    public let sessionid: AnyCodable?
    public let runid: AnyCodable?
    public let toolcallid: AnyCodable?
    public let turnsourcechannel: AnyCodable?
    public let turnsourceto: AnyCodable?
    public let turnsourceaccountid: AnyCodable?
    public let turnsourcethreadid: AnyCodable?
    public let approvalreviewerdeviceids: [String]?
    public let requiredeliveryroute: Bool?
    public let suppressdelivery: Bool?
    public let timeoutms: Int?
    public let twophase: Bool?

    public init(
        id: String? = nil,
        command: String? = nil,
        commandargv: [String]? = nil,
        systemrunplan: [String: AnyCodable]? = nil,
        env: [String: AnyCodable]? = nil,
        cwd: AnyCodable? = nil,
        nodeid: AnyCodable? = nil,
        host: AnyCodable? = nil,
        security: AnyCodable? = nil,
        ask: AnyCodable? = nil,
        warningtext: AnyCodable? = nil,
        unavailabledecisions: [String]? = nil,
        commandspans: [[String: AnyCodable]]? = nil,
        agentid: AnyCodable? = nil,
        resolvedpath: AnyCodable? = nil,
        sessionkey: AnyCodable? = nil,
        sessionid: AnyCodable? = nil,
        runid: AnyCodable? = nil,
        toolcallid: AnyCodable? = nil,
        turnsourcechannel: AnyCodable? = nil,
        turnsourceto: AnyCodable? = nil,
        turnsourceaccountid: AnyCodable? = nil,
        turnsourcethreadid: AnyCodable? = nil,
        approvalreviewerdeviceids: [String]? = nil,
        requiredeliveryroute: Bool? = nil,
        suppressdelivery: Bool? = nil,
        timeoutms: Int? = nil,
        twophase: Bool? = nil)
    {
        self.id = id
        self.command = command
        self.commandargv = commandargv
        self.systemrunplan = systemrunplan
        self.env = env
        self.cwd = cwd
        self.nodeid = nodeid
        self.host = host
        self.security = security
        self.ask = ask
        self.warningtext = warningtext
        self.unavailabledecisions = unavailabledecisions
        self.commandspans = commandspans
        self.agentid = agentid
        self.resolvedpath = resolvedpath
        self.sessionkey = sessionkey
        self.sessionid = sessionid
        self.runid = runid
        self.toolcallid = toolcallid
        self.turnsourcechannel = turnsourcechannel
        self.turnsourceto = turnsourceto
        self.turnsourceaccountid = turnsourceaccountid
        self.turnsourcethreadid = turnsourcethreadid
        self.approvalreviewerdeviceids = approvalreviewerdeviceids
        self.requiredeliveryroute = requiredeliveryroute
        self.suppressdelivery = suppressdelivery
        self.timeoutms = timeoutms
        self.twophase = twophase
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case command
        case commandargv = "commandArgv"
        case systemrunplan = "systemRunPlan"
        case env
        case cwd
        case nodeid = "nodeId"
        case host
        case security
        case ask
        case warningtext = "warningText"
        case unavailabledecisions = "unavailableDecisions"
        case commandspans = "commandSpans"
        case agentid = "agentId"
        case resolvedpath = "resolvedPath"
        case sessionkey = "sessionKey"
        case sessionid = "sessionId"
        case runid = "runId"
        case toolcallid = "toolCallId"
        case turnsourcechannel = "turnSourceChannel"
        case turnsourceto = "turnSourceTo"
        case turnsourceaccountid = "turnSourceAccountId"
        case turnsourcethreadid = "turnSourceThreadId"
        case approvalreviewerdeviceids = "approvalReviewerDeviceIds"
        case requiredeliveryroute = "requireDeliveryRoute"
        case suppressdelivery = "suppressDelivery"
        case timeoutms = "timeoutMs"
        case twophase = "twoPhase"
    }
}

public struct ExecApprovalResolveParams: Codable, Sendable {
    public let id: String
    public let decision: String

    public init(
        id: String,
        decision: String)
    {
        self.id = id
        self.decision = decision
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case decision
    }
}

public struct QuestionOption: Codable, Sendable {
    public let label: String
    public let description: String?

    public init(
        label: String,
        description: String? = nil)
    {
        self.label = label
        self.description = description
    }

    private enum CodingKeys: String, CodingKey {
        case label
        case description
    }
}

public struct Question: Codable, Sendable {
    public let questionid: String
    public let header: String
    public let question: String
    public let options: [QuestionOption]
    public let multiselect: Bool?
    public let isother: Bool?
    public let issecret: Bool?

    public init(
        questionid: String,
        header: String,
        question: String,
        options: [QuestionOption],
        multiselect: Bool? = nil,
        isother: Bool? = nil,
        issecret: Bool? = nil)
    {
        self.questionid = questionid
        self.header = header
        self.question = question
        self.options = options
        self.multiselect = multiselect
        self.isother = isother
        self.issecret = issecret
    }

    private enum CodingKeys: String, CodingKey {
        case questionid = "questionId"
        case header
        case question
        case options
        case multiselect = "multiSelect"
        case isother = "isOther"
        case issecret = "isSecret"
    }
}

public struct QuestionRequestQuestion: Codable, Sendable {
    public let questionid: String
    public let header: String
    public let question: String
    public let options: [QuestionOption]
    public let multiselect: Bool?
    public let isother: Bool?
    public let issecret: Bool?

    public init(
        questionid: String,
        header: String,
        question: String,
        options: [QuestionOption],
        multiselect: Bool? = nil,
        isother: Bool? = nil,
        issecret: Bool? = nil)
    {
        self.questionid = questionid
        self.header = header
        self.question = question
        self.options = options
        self.multiselect = multiselect
        self.isother = isother
        self.issecret = issecret
    }

    private enum CodingKeys: String, CodingKey {
        case questionid = "questionId"
        case header
        case question
        case options
        case multiselect = "multiSelect"
        case isother = "isOther"
        case issecret = "isSecret"
    }
}

public struct QuestionAnswers: Codable, Sendable {
    public let answers: [String: AnyCodable]

    public init(
        answers: [String: AnyCodable])
    {
        self.answers = answers
    }

    private enum CodingKeys: String, CodingKey {
        case answers
    }
}

public struct QuestionRecord: Codable, Sendable {
    public let id: String
    public let questions: [Question]
    public let agentid: String?
    public let sessionkey: String?
    public let createdatms: Int
    public let expiresatms: Int
    public let status: QuestionStatus
    public let answers: QuestionAnswers?
    public let resolvedby: String?

    public init(
        id: String,
        questions: [Question],
        agentid: String? = nil,
        sessionkey: String? = nil,
        createdatms: Int,
        expiresatms: Int,
        status: QuestionStatus,
        answers: QuestionAnswers? = nil,
        resolvedby: String? = nil)
    {
        self.id = id
        self.questions = questions
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.createdatms = createdatms
        self.expiresatms = expiresatms
        self.status = status
        self.answers = answers
        self.resolvedby = resolvedby
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case questions
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case createdatms = "createdAtMs"
        case expiresatms = "expiresAtMs"
        case status
        case answers
        case resolvedby = "resolvedBy"
    }
}

public struct QuestionRequestParams: Codable, Sendable {
    public let id: String?
    public let questions: [QuestionRequestQuestion]
    public let agentid: String?
    public let sessionkey: String?
    public let timeoutms: Int?

    public init(
        id: String? = nil,
        questions: [QuestionRequestQuestion],
        agentid: String? = nil,
        sessionkey: String? = nil,
        timeoutms: Int? = nil)
    {
        self.id = id
        self.questions = questions
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.timeoutms = timeoutms
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case questions
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case timeoutms = "timeoutMs"
    }
}

public struct QuestionRequestResult: Codable, Sendable {
    public let id: String
    public let expiresatms: Int

    public init(
        id: String,
        expiresatms: Int)
    {
        self.id = id
        self.expiresatms = expiresatms
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case expiresatms = "expiresAtMs"
    }
}

public struct QuestionWaitAnswerParams: Codable, Sendable {
    public let id: String
    public let timeoutms: Int?

    public init(
        id: String,
        timeoutms: Int? = nil)
    {
        self.id = id
        self.timeoutms = timeoutms
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case timeoutms = "timeoutMs"
    }
}

public struct QuestionGetParams: Codable, Sendable {
    public let id: String

    public init(
        id: String)
    {
        self.id = id
    }

    private enum CodingKeys: String, CodingKey {
        case id
    }
}

public struct QuestionGetResult: Codable, Sendable {
    public let question: QuestionRecord

    public init(
        question: QuestionRecord)
    {
        self.question = question
    }

    private enum CodingKeys: String, CodingKey {
        case question
    }
}

public struct QuestionListParams: Codable, Sendable {}

public struct QuestionListResult: Codable, Sendable {
    public let questions: [QuestionRecord]

    public init(
        questions: [QuestionRecord])
    {
        self.questions = questions
    }

    private enum CodingKeys: String, CodingKey {
        case questions
    }
}

public struct PluginApprovalRequestParams: Codable, Sendable {
    public let pluginid: String?
    public let title: String
    public let description: String
    public let detail: String?
    public let severity: String?
    public let toolname: String?
    public let toolcallid: String?
    public let alloweddecisions: [String]?
    public let agentid: String?
    public let sessionkey: String?
    public let approvalreviewerdeviceids: [String]?
    public let turnsourcechannel: String?
    public let turnsourceto: String?
    public let turnsourceaccountid: String?
    public let turnsourcethreadid: AnyCodable?
    public let timeoutms: Int?
    public let twophase: Bool?

    public init(
        pluginid: String? = nil,
        title: String,
        description: String,
        detail: String? = nil,
        severity: String? = nil,
        toolname: String? = nil,
        toolcallid: String? = nil,
        alloweddecisions: [String]? = nil,
        agentid: String? = nil,
        sessionkey: String? = nil,
        approvalreviewerdeviceids: [String]? = nil,
        turnsourcechannel: String? = nil,
        turnsourceto: String? = nil,
        turnsourceaccountid: String? = nil,
        turnsourcethreadid: AnyCodable? = nil,
        timeoutms: Int? = nil,
        twophase: Bool? = nil)
    {
        self.pluginid = pluginid
        self.title = title
        self.description = description
        self.detail = detail
        self.severity = severity
        self.toolname = toolname
        self.toolcallid = toolcallid
        self.alloweddecisions = alloweddecisions
        self.agentid = agentid
        self.sessionkey = sessionkey
        self.approvalreviewerdeviceids = approvalreviewerdeviceids
        self.turnsourcechannel = turnsourcechannel
        self.turnsourceto = turnsourceto
        self.turnsourceaccountid = turnsourceaccountid
        self.turnsourcethreadid = turnsourcethreadid
        self.timeoutms = timeoutms
        self.twophase = twophase
    }

    private enum CodingKeys: String, CodingKey {
        case pluginid = "pluginId"
        case title
        case description
        case detail
        case severity
        case toolname = "toolName"
        case toolcallid = "toolCallId"
        case alloweddecisions = "allowedDecisions"
        case agentid = "agentId"
        case sessionkey = "sessionKey"
        case approvalreviewerdeviceids = "approvalReviewerDeviceIds"
        case turnsourcechannel = "turnSourceChannel"
        case turnsourceto = "turnSourceTo"
        case turnsourceaccountid = "turnSourceAccountId"
        case turnsourcethreadid = "turnSourceThreadId"
        case timeoutms = "timeoutMs"
        case twophase = "twoPhase"
    }
}

public struct PluginApprovalResolveParams: Codable, Sendable {
    public let id: String
    public let decision: String

    public init(
        id: String,
        decision: String)
    {
        self.id = id
        self.decision = decision
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case decision
    }
}

public struct PluginCatalogClawHubInstall: Codable, Sendable {
    public let source: String
    public let packagename: String

    public init(
        source: String,
        packagename: String)
    {
        self.source = source
        self.packagename = packagename
    }

    private enum CodingKeys: String, CodingKey {
        case source
        case packagename = "packageName"
    }
}

public struct PluginCatalogEntry: Codable, Sendable {
    public let id: String
    public let name: String
    public let packagename: String?
    public let description: String?
    public let version: String?
    public let kind: [String]?
    public let origin: String?
    public let installed: Bool
    public let enabled: Bool
    public let state: AnyCodable
    public let featured: Bool?
    public let featuredat: Int?
    public let order: Double?
    public let hasicon: Bool?
    public let install: PluginCatalogInstallAction?
    public let error: String?
    public let category: String?
    public let removable: Bool?

    public init(
        id: String,
        name: String,
        packagename: String? = nil,
        description: String? = nil,
        version: String? = nil,
        kind: [String]? = nil,
        origin: String? = nil,
        installed: Bool,
        enabled: Bool,
        state: AnyCodable,
        featured: Bool? = nil,
        featuredat: Int? = nil,
        order: Double? = nil,
        hasicon: Bool? = nil,
        install: PluginCatalogInstallAction? = nil,
        error: String? = nil,
        category: String? = nil,
        removable: Bool? = nil)
    {
        self.id = id
        self.name = name
        self.packagename = packagename
        self.description = description
        self.version = version
        self.kind = kind
        self.origin = origin
        self.installed = installed
        self.enabled = enabled
        self.state = state
        self.featured = featured
        self.featuredat = featuredat
        self.order = order
        self.hasicon = hasicon
        self.install = install
        self.error = error
        self.category = category
        self.removable = removable
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case name
        case packagename = "packageName"
        case description
        case version
        case kind
        case origin
        case installed
        case enabled
        case state
        case featured
        case featuredat = "featuredAt"
        case order
        case hasicon = "hasIcon"
        case install
        case error
        case category
        case removable
    }
}

public struct PluginCatalogOfficialInstall: Codable, Sendable {
    public let source: String
    public let pluginid: String

    public init(
        source: String,
        pluginid: String)
    {
        self.source = source
        self.pluginid = pluginid
    }

    private enum CodingKeys: String, CodingKey {
        case source
        case pluginid = "pluginId"
    }
}

public struct PluginControlUiDescriptor: Codable, Sendable {
    public let id: String
    public let pluginid: String
    public let pluginname: String?
    public let surface: AnyCodable
    public let label: String
    public let description: String?
    public let placement: String?
    public let schema: AnyCodable?
    public let requiredscopes: [String]?

    public init(
        id: String,
        pluginid: String,
        pluginname: String? = nil,
        surface: AnyCodable,
        label: String,
        description: String? = nil,
        placement: String? = nil,
        schema: AnyCodable? = nil,
        requiredscopes: [String]? = nil)
    {
        self.id = id
        self.pluginid = pluginid
        self.pluginname = pluginname
        self.surface = surface
        self.label = label
        self.description = description
        self.placement = placement
        self.schema = schema
        self.requiredscopes = requiredscopes
    }

    private enum CodingKeys: String, CodingKey {
        case id
        case pluginid = "pluginId"
        case pluginname = "pluginName"
        case surface
        case label
        case description
        case placement
        case schema
        case requiredscopes = "requiredScopes"
    }
}

public struct PluginSearchPackage: Codable, Sendable {
    public let name: String
    public let displayname: String
    public let family: AnyCodable
    public let channel: AnyCodable
    public let isofficial: Bool
    public let summary: String?
    public let latestversion: String?
    public let runtimeid: String?
    public let downloads: Double?
    public let verificationtier: String?

    public init(
        name: String,
        displayname: String,
        family: AnyCodable,
        channel: AnyCodable,
        isofficial: Bool,
        summary: String? = nil,
        latestversion: String? = nil,
        runtimeid: String? = nil,
        downloads: Double? = nil,
        verificationtier: String? = nil)
    {
        self.name = name
        self.displayname = displayname
        self.family = family
        self.channel = channel
        self.isofficial = isofficial
        self.summary = summary
        self.latestversion = latestversion
        self.runtimeid = runtimeid
        self.downloads = downloads
        self.verificationtier = verificationtier
    }

    private enum CodingKeys: String, CodingKey {
        case name
        case displayname = "displayName"
        case family
        case channel
        case isofficial = "isOfficial"
        case summary
        case latestversion = "latestVersion"
        case runtimeid = "runtimeId"
        case downloads
        case verificationtier = "verificationTier"
    }
}

public struct PluginSearchResultEntry: Codable, Sendable {
    public let score: Double
    public let package: PluginSearchPackage

    public init(
        score: Double,
        package: PluginSearchPackage)
    {
        self.score = score
        self.package = package
    }

    private enum CodingKeys: String, CodingKey {
        case score
        case package
    }
}

public struct PluginsInstallResult: Codable, Sendable {
    public let ok: Bool
    public let plugin: PluginCatalogEntry
    public let restartrequired: Bool
    public let warnings: [String]?

    public init(
        ok: Bool,
        plugin: PluginCatalogEntry,
        restartrequired: Bool,
        warnings: [String]? = nil)
    {
        self.ok = ok
        self.plugin = plugin
        self.restartrequired = restartrequired
        self.warnings = warnings
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case plugin
        case restartrequired = "restartRequired"
        case warnings
    }
}

public struct PluginsListParams: Codable, Sendable {}

public struct PluginsListResult: Codable, Sendable {
    public let plugins: [PluginCatalogEntry]
    public let diagnostics: [AnyCodable]
    public let mutationallowed: Bool

    public init(
        plugins: [PluginCatalogEntry],
        diagnostics: [AnyCodable],
        mutationallowed: Bool)
    {
        self.plugins = plugins
        self.diagnostics = diagnostics
        self.mutationallowed = mutationallowed
    }

    private enum CodingKeys: String, CodingKey {
        case plugins
        case diagnostics
        case mutationallowed = "mutationAllowed"
    }
}

public struct PluginsRefreshParams: Codable, Sendable {}

public struct PluginsRefreshResult: Codable, Sendable {
    public let ok: Bool

    public init(
        ok: Bool)
    {
        self.ok = ok
    }

    private enum CodingKeys: String, CodingKey {
        case ok
    }
}

public struct PluginsSearchParams: Codable, Sendable {
    public let query: String
    public let limit: Int?

    public init(
        query: String,
        limit: Int? = nil)
    {
        self.query = query
        self.limit = limit
    }

    private enum CodingKeys: String, CodingKey {
        case query
        case limit
    }
}

public struct PluginsSearchResult: Codable, Sendable {
    public let results: [PluginSearchResultEntry]

    public init(
        results: [PluginSearchResultEntry])
    {
        self.results = results
    }

    private enum CodingKeys: String, CodingKey {
        case results
    }
}

public struct PluginsSessionActionFailureResult: Codable, Sendable {
    public let ok: Bool
    public let error: String
    public let code: String?
    public let details: AnyCodable?

    public init(
        error: String,
        code: String? = nil,
        details: AnyCodable? = nil
    )
    {
        self.ok = false
        self.error = error
        self.code = code
        self.details = details
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case error
        case code
        case details
    }

    public init(from decoder: Decoder) throws {
        let rawContainer = try decoder.container(keyedBy: GatewayAnyCodingKey.self)
        let unexpectedKeys = rawContainer.allKeys
            .map(\.stringValue)
            .filter { !Set(["ok", "error", "code", "details"]).contains($0) }
        if !unexpectedKeys.isEmpty {
            throw DecodingError.dataCorrupted(
                .init(
                    codingPath: rawContainer.codingPath,
                    debugDescription: "Unexpected keys for PluginsSessionActionFailureResult: \(unexpectedKeys.sorted().joined(separator: ", "))"
                )
            )
        }
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let decodedOk = try container.decode(Bool.self, forKey: .ok)
        guard decodedOk == false else {
            throw DecodingError.dataCorruptedError(
                forKey: .ok,
                in: container,
                debugDescription: "Expected ok to equal false"
            )
        }
        self.ok = false
        self.error = try container.decode(String.self, forKey: .error)
        self.code = try container.decodeIfPresent(String.self, forKey: .code)
        self.details = try container.decodeIfPresent(AnyCodable.self, forKey: .details)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(false, forKey: .ok)
        try container.encode(error, forKey: .error)
        try container.encodeIfPresent(code, forKey: .code)
        try container.encodeIfPresent(details, forKey: .details)
    }
}

public struct PluginsSessionActionParams: Codable, Sendable {
    public let pluginid: String
    public let actionid: String
    public let sessionkey: String?
    public let payload: AnyCodable?

    public init(
        pluginid: String,
        actionid: String,
        sessionkey: String? = nil,
        payload: AnyCodable? = nil)
    {
        self.pluginid = pluginid
        self.actionid = actionid
        self.sessionkey = sessionkey
        self.payload = payload
    }

    private enum CodingKeys: String, CodingKey {
        case pluginid = "pluginId"
        case actionid = "actionId"
        case sessionkey = "sessionKey"
        case payload
    }
}

public struct PluginsSessionActionSuccessResult: Codable, Sendable {
    public let ok: Bool
    public let result: AnyCodable?
    public let continueagent: Bool?
    public let reply: AnyCodable?

    public init(
        result: AnyCodable? = nil,
        continueagent: Bool? = nil,
        reply: AnyCodable? = nil
    )
    {
        self.ok = true
        self.result = result
        self.continueagent = continueagent
        self.reply = reply
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case result
        case continueagent = "continueAgent"
        case reply
    }

    public init(from decoder: Decoder) throws {
        let rawContainer = try decoder.container(keyedBy: GatewayAnyCodingKey.self)
        let unexpectedKeys = rawContainer.allKeys
            .map(\.stringValue)
            .filter { !Set(["ok", "result", "continueAgent", "reply"]).contains($0) }
        if !unexpectedKeys.isEmpty {
            throw DecodingError.dataCorrupted(
                .init(
                    codingPath: rawContainer.codingPath,
                    debugDescription: "Unexpected keys for PluginsSessionActionSuccessResult: \(unexpectedKeys.sorted().joined(separator: ", "))"
                )
            )
        }
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let decodedOk = try container.decode(Bool.self, forKey: .ok)
        guard decodedOk == true else {
            throw DecodingError.dataCorruptedError(
                forKey: .ok,
                in: container,
                debugDescription: "Expected ok to equal true"
            )
        }
        self.ok = true
        self.result = try container.decodeIfPresent(AnyCodable.self, forKey: .result)
        self.continueagent = try container.decodeIfPresent(Bool.self, forKey: .continueagent)
        self.reply = try container.decodeIfPresent(AnyCodable.self, forKey: .reply)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(true, forKey: .ok)
        try container.encodeIfPresent(result, forKey: .result)
        try container.encodeIfPresent(continueagent, forKey: .continueagent)
        try container.encodeIfPresent(reply, forKey: .reply)
    }
}

public struct PluginsSetEnabledParams: Codable, Sendable {
    public let pluginid: String
    public let enabled: Bool

    public init(
        pluginid: String,
        enabled: Bool)
    {
        self.pluginid = pluginid
        self.enabled = enabled
    }

    private enum CodingKeys: String, CodingKey {
        case pluginid = "pluginId"
        case enabled
    }
}

public struct PluginsSetEnabledResult: Codable, Sendable {
    public let ok: Bool
    public let plugin: PluginCatalogEntry
    public let restartrequired: Bool
    public let warnings: [String]?

    public init(
        ok: Bool,
        plugin: PluginCatalogEntry,
        restartrequired: Bool,
        warnings: [String]? = nil)
    {
        self.ok = ok
        self.plugin = plugin
        self.restartrequired = restartrequired
        self.warnings = warnings
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case plugin
        case restartrequired = "restartRequired"
        case warnings
    }
}

public struct PluginsUiDescriptorsParams: Codable, Sendable {}

public struct PluginsUiDescriptorsResult: Codable, Sendable {
    public let ok: Bool
    public let descriptors: [PluginControlUiDescriptor]

    public init(
        ok: Bool,
        descriptors: [PluginControlUiDescriptor])
    {
        self.ok = ok
        self.descriptors = descriptors
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case descriptors
    }
}

public struct PluginsUninstallParams: Codable, Sendable {
    public let pluginid: String

    public init(
        pluginid: String)
    {
        self.pluginid = pluginid
    }

    private enum CodingKeys: String, CodingKey {
        case pluginid = "pluginId"
    }
}

public struct PluginsUninstallResult: Codable, Sendable {
    public let ok: Bool
    public let pluginid: String
    public let restartrequired: Bool
    public let removed: [String]
    public let warnings: [String]?

    public init(
        ok: Bool,
        pluginid: String,
        restartrequired: Bool,
        removed: [String],
        warnings: [String]? = nil)
    {
        self.ok = ok
        self.pluginid = pluginid
        self.restartrequired = restartrequired
        self.removed = removed
        self.warnings = warnings
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case pluginid = "pluginId"
        case restartrequired = "restartRequired"
        case removed
        case warnings
    }
}

public struct DevicePairListParams: Codable, Sendable {}

public struct DevicePairApproveParams: Codable, Sendable {
    public let requestid: String

    public init(
        requestid: String)
    {
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
    }
}

public struct DevicePairRejectParams: Codable, Sendable {
    public let requestid: String

    public init(
        requestid: String)
    {
        self.requestid = requestid
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
    }
}

public struct DevicePairRemoveParams: Codable, Sendable {
    public let deviceid: String

    public init(
        deviceid: String)
    {
        self.deviceid = deviceid
    }

    private enum CodingKeys: String, CodingKey {
        case deviceid = "deviceId"
    }
}

public struct DevicePairSetupCodeParams: Codable, Sendable {
    public let publicurl: String?
    public let preferremoteurl: Bool?
    public let includeqr: Bool?
    public let bootstrapprofile: String?

    public init(
        publicurl: String? = nil,
        preferremoteurl: Bool? = nil,
        includeqr: Bool? = nil,
        bootstrapprofile: String? = nil)
    {
        self.publicurl = publicurl
        self.preferremoteurl = preferremoteurl
        self.includeqr = includeqr
        self.bootstrapprofile = bootstrapprofile
    }

    private enum CodingKeys: String, CodingKey {
        case publicurl = "publicUrl"
        case preferremoteurl = "preferRemoteUrl"
        case includeqr = "includeQr"
        case bootstrapprofile = "bootstrapProfile"
    }
}

public struct DevicePairSetupCodeResult: Codable, Sendable {
    public let setupcode: String
    public let qrdataurl: String?
    public let gatewayurl: String
    public let gatewayurls: [String]?
    public let auth: AnyCodable
    public let urlsource: String
    public let access: AnyCodable?
    public let accessdowngraded: Bool?

    public init(
        setupcode: String,
        qrdataurl: String? = nil,
        gatewayurl: String,
        gatewayurls: [String]? = nil,
        auth: AnyCodable,
        urlsource: String,
        access: AnyCodable? = nil,
        accessdowngraded: Bool? = nil)
    {
        self.setupcode = setupcode
        self.qrdataurl = qrdataurl
        self.gatewayurl = gatewayurl
        self.gatewayurls = gatewayurls
        self.auth = auth
        self.urlsource = urlsource
        self.access = access
        self.accessdowngraded = accessdowngraded
    }

    private enum CodingKeys: String, CodingKey {
        case setupcode = "setupCode"
        case qrdataurl = "qrDataUrl"
        case gatewayurl = "gatewayUrl"
        case gatewayurls = "gatewayUrls"
        case auth
        case urlsource = "urlSource"
        case access
        case accessdowngraded = "accessDowngraded"
    }
}

public struct DevicePairRenameParams: Codable, Sendable {
    public let deviceid: String
    public let label: String

    public init(
        deviceid: String,
        label: String)
    {
        self.deviceid = deviceid
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case deviceid = "deviceId"
        case label
    }
}

public struct DeviceTokenRotateParams: Codable, Sendable {
    public let deviceid: String
    public let role: String
    public let scopes: [String]?

    public init(
        deviceid: String,
        role: String,
        scopes: [String]? = nil)
    {
        self.deviceid = deviceid
        self.role = role
        self.scopes = scopes
    }

    private enum CodingKeys: String, CodingKey {
        case deviceid = "deviceId"
        case role
        case scopes
    }
}

public struct DeviceTokenRevokeParams: Codable, Sendable {
    public let deviceid: String
    public let role: String

    public init(
        deviceid: String,
        role: String)
    {
        self.deviceid = deviceid
        self.role = role
    }

    private enum CodingKeys: String, CodingKey {
        case deviceid = "deviceId"
        case role
    }
}

public struct DevicePairRequestedEvent: Codable, Sendable {
    public let requestid: String
    public let deviceid: String
    public let publickey: String
    public let displayname: String?
    public let platform: String?
    public let devicefamily: String?
    public let clientid: String?
    public let clientmode: String?
    public let browserorigin: String?
    public let role: String?
    public let roles: [String]?
    public let scopes: [String]?
    public let remoteip: String?
    public let silent: Bool?
    public let isrepair: Bool?
    public let ts: Int

    public init(
        requestid: String,
        deviceid: String,
        publickey: String,
        displayname: String? = nil,
        platform: String? = nil,
        devicefamily: String? = nil,
        clientid: String? = nil,
        clientmode: String? = nil,
        browserorigin: String? = nil,
        role: String? = nil,
        roles: [String]? = nil,
        scopes: [String]? = nil,
        remoteip: String? = nil,
        silent: Bool? = nil,
        isrepair: Bool? = nil,
        ts: Int)
    {
        self.requestid = requestid
        self.deviceid = deviceid
        self.publickey = publickey
        self.displayname = displayname
        self.platform = platform
        self.devicefamily = devicefamily
        self.clientid = clientid
        self.clientmode = clientmode
        self.browserorigin = browserorigin
        self.role = role
        self.roles = roles
        self.scopes = scopes
        self.remoteip = remoteip
        self.silent = silent
        self.isrepair = isrepair
        self.ts = ts
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
        case deviceid = "deviceId"
        case publickey = "publicKey"
        case displayname = "displayName"
        case platform
        case devicefamily = "deviceFamily"
        case clientid = "clientId"
        case clientmode = "clientMode"
        case browserorigin = "browserOrigin"
        case role
        case roles
        case scopes
        case remoteip = "remoteIp"
        case silent
        case isrepair = "isRepair"
        case ts
    }
}

public struct DevicePairResolvedEvent: Codable, Sendable {
    public let requestid: String
    public let deviceid: String
    public let decision: String
    public let ts: Int

    public init(
        requestid: String,
        deviceid: String,
        decision: String,
        ts: Int)
    {
        self.requestid = requestid
        self.deviceid = deviceid
        self.decision = decision
        self.ts = ts
    }

    private enum CodingKeys: String, CodingKey {
        case requestid = "requestId"
        case deviceid = "deviceId"
        case decision
        case ts
    }
}

public struct ChatHistoryParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let limit: Int?
    public let offset: Int?
    public let messageid: String?
    public let sessionid: String?
    public let maxchars: Int?

    public init(
        sessionkey: String,
        agentid: String? = nil,
        limit: Int? = nil,
        offset: Int? = nil,
        messageid: String? = nil,
        sessionid: String? = nil,
        maxchars: Int? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.limit = limit
        self.offset = offset
        self.messageid = messageid
        self.sessionid = sessionid
        self.maxchars = maxchars
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case limit
        case offset
        case messageid = "messageId"
        case sessionid = "sessionId"
        case maxchars = "maxChars"
    }
}

public struct ChatMetadataParams: Codable, Sendable {
    public let agentid: String?

    public init(
        agentid: String? = nil)
    {
        self.agentid = agentid
    }

    private enum CodingKeys: String, CodingKey {
        case agentid = "agentId"
    }
}

public struct ChatMessageGetParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let messageid: String
    public let maxchars: Int?

    public init(
        sessionkey: String,
        agentid: String? = nil,
        messageid: String,
        maxchars: Int? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.messageid = messageid
        self.maxchars = maxchars
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case messageid = "messageId"
        case maxchars = "maxChars"
    }
}

public struct ChatMessageGetResult: Codable, Sendable {
    public let ok: Bool
    public let message: AnyCodable?
    public let unavailablereason: AnyCodable?

    public init(
        ok: Bool,
        message: AnyCodable? = nil,
        unavailablereason: AnyCodable? = nil)
    {
        self.ok = ok
        self.message = message
        self.unavailablereason = unavailablereason
    }

    private enum CodingKeys: String, CodingKey {
        case ok
        case message
        case unavailablereason = "unavailableReason"
    }
}

public struct ChatToolTitlesParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let items: [[String: AnyCodable]]

    public init(
        sessionkey: String,
        agentid: String? = nil,
        items: [[String: AnyCodable]])
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.items = items
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case items
    }
}

public struct ChatToolTitlesResult: Codable, Sendable {
    public let titles: [String: AnyCodable]
    public let disabled: Bool?

    public init(
        titles: [String: AnyCodable],
        disabled: Bool? = nil)
    {
        self.titles = titles
        self.disabled = disabled
    }

    private enum CodingKeys: String, CodingKey {
        case titles
        case disabled
    }
}

public struct ChatSendParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let sessionid: String?
    public let message: String
    public let thinking: String?
    public let fastmodevalue: AnyCodable?
    public var fastmode: Bool? { fastmodevalue?.value as? Bool }
    public let fastautoonseconds: Int?
    public let queuemode: String?
    public let deliver: Bool?
    public let originatingchannel: String?
    public let originatingto: String?
    public let originatingaccountid: String?
    public let originatingthreadid: String?
    public let replytoid: String?
    public let attachments: [AnyCodable]?
    public let toolbindings: [String: AnyCodable]?
    public let timeoutms: Int?
    public let systeminputprovenance: [String: AnyCodable]?
    public let systemprovenancereceipt: String?
    public let suppresscommandinterpretation: Bool?
    public let expectedleafentryid: AnyCodable?
    public let expectedsessionroutingcontract: String?
    public let idempotencykey: String

    public init(
        sessionkey: String,
        agentid: String? = nil,
        sessionid: String? = nil,
        message: String,
        thinking: String? = nil,
        fastmodevalue: AnyCodable? = nil,
        fastautoonseconds: Int? = nil,
        queuemode: String? = nil,
        deliver: Bool? = nil,
        originatingchannel: String? = nil,
        originatingto: String? = nil,
        originatingaccountid: String? = nil,
        originatingthreadid: String? = nil,
        replytoid: String? = nil,
        attachments: [AnyCodable]? = nil,
        toolbindings: [String: AnyCodable]? = nil,
        timeoutms: Int? = nil,
        systeminputprovenance: [String: AnyCodable]? = nil,
        systemprovenancereceipt: String? = nil,
        suppresscommandinterpretation: Bool? = nil,
        expectedleafentryid: AnyCodable? = nil,
        expectedsessionroutingcontract: String? = nil,
        idempotencykey: String)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.sessionid = sessionid
        self.message = message
        self.thinking = thinking
        self.fastmodevalue = fastmodevalue
        self.fastautoonseconds = fastautoonseconds
        self.queuemode = queuemode
        self.deliver = deliver
        self.originatingchannel = originatingchannel
        self.originatingto = originatingto
        self.originatingaccountid = originatingaccountid
        self.originatingthreadid = originatingthreadid
        self.replytoid = replytoid
        self.attachments = attachments
        self.toolbindings = toolbindings
        self.timeoutms = timeoutms
        self.systeminputprovenance = systeminputprovenance
        self.systemprovenancereceipt = systemprovenancereceipt
        self.suppresscommandinterpretation = suppresscommandinterpretation
        self.expectedleafentryid = expectedleafentryid
        self.expectedsessionroutingcontract = expectedsessionroutingcontract
        self.idempotencykey = idempotencykey
    }

    public init(
        sessionkey: String,
        agentid: String? = nil,
        sessionid: String? = nil,
        message: String,
        thinking: String? = nil,
        fastmode: Bool?,
        queuemode: String? = nil,
        deliver: Bool? = nil,
        originatingchannel: String? = nil,
        originatingto: String? = nil,
        originatingaccountid: String? = nil,
        originatingthreadid: String? = nil,
        replytoid: String? = nil,
        attachments: [AnyCodable]? = nil,
        toolbindings: [String: AnyCodable]? = nil,
        timeoutms: Int? = nil,
        systeminputprovenance: [String: AnyCodable]? = nil,
        systemprovenancereceipt: String? = nil,
        suppresscommandinterpretation: Bool? = nil,
        expectedleafentryid: AnyCodable? = nil,
        expectedsessionroutingcontract: String? = nil,
        idempotencykey: String)
    {
        self.init(
            sessionkey: sessionkey,
            agentid: agentid,
            sessionid: sessionid,
            message: message,
            thinking: thinking,
            fastmodevalue: fastmode.map { AnyCodable($0) },
            fastautoonseconds: nil,
            queuemode: queuemode,
            deliver: deliver,
            originatingchannel: originatingchannel,
            originatingto: originatingto,
            originatingaccountid: originatingaccountid,
            originatingthreadid: originatingthreadid,
            replytoid: replytoid,
            attachments: attachments,
            toolbindings: toolbindings,
            timeoutms: timeoutms,
            systeminputprovenance: systeminputprovenance,
            systemprovenancereceipt: systemprovenancereceipt,
            suppresscommandinterpretation: suppresscommandinterpretation,
            expectedleafentryid: expectedleafentryid,
            expectedsessionroutingcontract: expectedsessionroutingcontract,
            idempotencykey: idempotencykey)
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case sessionid = "sessionId"
        case message
        case thinking
        case fastmodevalue = "fastMode"
        case fastautoonseconds = "fastAutoOnSeconds"
        case queuemode = "queueMode"
        case deliver
        case originatingchannel = "originatingChannel"
        case originatingto = "originatingTo"
        case originatingaccountid = "originatingAccountId"
        case originatingthreadid = "originatingThreadId"
        case replytoid = "replyToId"
        case attachments
        case toolbindings = "toolBindings"
        case timeoutms = "timeoutMs"
        case systeminputprovenance = "systemInputProvenance"
        case systemprovenancereceipt = "systemProvenanceReceipt"
        case suppresscommandinterpretation = "suppressCommandInterpretation"
        case expectedleafentryid = "expectedLeafEntryId"
        case expectedsessionroutingcontract = "expectedSessionRoutingContract"
        case idempotencykey = "idempotencyKey"
    }
}

public struct ChatAbortParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let runid: String?
    public let preservesideruns: Bool?

    public init(
        sessionkey: String,
        agentid: String? = nil,
        runid: String? = nil,
        preservesideruns: Bool? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.runid = runid
        self.preservesideruns = preservesideruns
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case runid = "runId"
        case preservesideruns = "preserveSideRuns"
    }
}

public struct ChatInjectParams: Codable, Sendable {
    public let sessionkey: String
    public let agentid: String?
    public let message: String
    public let label: String?

    public init(
        sessionkey: String,
        agentid: String? = nil,
        message: String,
        label: String? = nil)
    {
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.message = message
        self.label = label
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case message
        case label
    }
}

public struct ChatStatusEvent: Codable, Sendable {
    public let runid: String
    public let sessionkey: String
    public let agentid: String?
    public let spawnedby: String?
    public let seq: Int
    public let state: String
    public let phase: ChatRunStartupPhase

    public init(
        runid: String,
        sessionkey: String,
        agentid: String? = nil,
        spawnedby: String? = nil,
        seq: Int,
        state: String,
        phase: ChatRunStartupPhase)
    {
        self.runid = runid
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.seq = seq
        self.state = state
        self.phase = phase
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case seq
        case state
        case phase
    }
}

public struct ChatDeltaEvent: Codable, Sendable {
    public let runid: String
    public let sessionkey: String
    public let agentid: String?
    public let spawnedby: String?
    public let seq: Int
    public let state: String
    public let message: AnyCodable?
    public let deltatext: String
    public let replace: Bool?
    public let usage: AnyCodable?

    public init(
        runid: String,
        sessionkey: String,
        agentid: String? = nil,
        spawnedby: String? = nil,
        seq: Int,
        state: String,
        message: AnyCodable? = nil,
        deltatext: String,
        replace: Bool? = nil,
        usage: AnyCodable? = nil)
    {
        self.runid = runid
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.seq = seq
        self.state = state
        self.message = message
        self.deltatext = deltatext
        self.replace = replace
        self.usage = usage
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case seq
        case state
        case message
        case deltatext = "deltaText"
        case replace
        case usage
    }
}

public struct ChatFinalEvent: Codable, Sendable {
    public let runid: String
    public let sessionkey: String
    public let agentid: String?
    public let spawnedby: String?
    public let seq: Int
    public let state: String
    public let message: AnyCodable?
    public let usage: AnyCodable?
    public let stopreason: String?
    public let yielded: Bool?

    public init(
        runid: String,
        sessionkey: String,
        agentid: String? = nil,
        spawnedby: String? = nil,
        seq: Int,
        state: String,
        message: AnyCodable? = nil,
        usage: AnyCodable? = nil,
        stopreason: String? = nil,
        yielded: Bool? = nil)
    {
        self.runid = runid
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.seq = seq
        self.state = state
        self.message = message
        self.usage = usage
        self.stopreason = stopreason
        self.yielded = yielded
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case seq
        case state
        case message
        case usage
        case stopreason = "stopReason"
        case yielded
    }
}

public struct ChatAbortedEvent: Codable, Sendable {
    public let runid: String
    public let sessionkey: String
    public let agentid: String?
    public let spawnedby: String?
    public let seq: Int
    public let state: String
    public let message: AnyCodable?
    public let errormessage: String?
    public let stopreason: String?

    public init(
        runid: String,
        sessionkey: String,
        agentid: String? = nil,
        spawnedby: String? = nil,
        seq: Int,
        state: String,
        message: AnyCodable? = nil,
        errormessage: String? = nil,
        stopreason: String? = nil)
    {
        self.runid = runid
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.seq = seq
        self.state = state
        self.message = message
        self.errormessage = errormessage
        self.stopreason = stopreason
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case seq
        case state
        case message
        case errormessage = "errorMessage"
        case stopreason = "stopReason"
    }
}

public struct ChatErrorEvent: Codable, Sendable {
    public let runid: String
    public let sessionkey: String
    public let agentid: String?
    public let spawnedby: String?
    public let seq: Int
    public let state: String
    public let message: AnyCodable?
    public let errormessage: String?
    public let errorkind: AnyCodable?
    public let usage: AnyCodable?
    public let stopreason: String?

    public init(
        runid: String,
        sessionkey: String,
        agentid: String? = nil,
        spawnedby: String? = nil,
        seq: Int,
        state: String,
        message: AnyCodable? = nil,
        errormessage: String? = nil,
        errorkind: AnyCodable? = nil,
        usage: AnyCodable? = nil,
        stopreason: String? = nil)
    {
        self.runid = runid
        self.sessionkey = sessionkey
        self.agentid = agentid
        self.spawnedby = spawnedby
        self.seq = seq
        self.state = state
        self.message = message
        self.errormessage = errormessage
        self.errorkind = errorkind
        self.usage = usage
        self.stopreason = stopreason
    }

    private enum CodingKeys: String, CodingKey {
        case runid = "runId"
        case sessionkey = "sessionKey"
        case agentid = "agentId"
        case spawnedby = "spawnedBy"
        case seq
        case state
        case message
        case errormessage = "errorMessage"
        case errorkind = "errorKind"
        case usage
        case stopreason = "stopReason"
    }
}

public struct UpdateStatusParams: Codable, Sendable {}

public struct UpdateRunParams: Codable, Sendable {
    public let sessionkey: String?
    public let deliverycontext: [String: AnyCodable]?
    public let note: String?
    public let continuationmessage: String?
    public let restartdelayms: Int?
    public let timeoutms: Int?

    public init(
        sessionkey: String? = nil,
        deliverycontext: [String: AnyCodable]? = nil,
        note: String? = nil,
        continuationmessage: String? = nil,
        restartdelayms: Int? = nil,
        timeoutms: Int? = nil)
    {
        self.sessionkey = sessionkey
        self.deliverycontext = deliverycontext
        self.note = note
        self.continuationmessage = continuationmessage
        self.restartdelayms = restartdelayms
        self.timeoutms = timeoutms
    }

    private enum CodingKeys: String, CodingKey {
        case sessionkey = "sessionKey"
        case deliverycontext = "deliveryContext"
        case note
        case continuationmessage = "continuationMessage"
        case restartdelayms = "restartDelayMs"
        case timeoutms = "timeoutMs"
    }
}

public struct TickEvent: Codable, Sendable {
    public let ts: Int

    public init(
        ts: Int)
    {
        self.ts = ts
    }

    private enum CodingKeys: String, CodingKey {
        case ts
    }
}

public struct ShutdownEvent: Codable, Sendable {
    public let reason: String
    public let restartexpectedms: Int?

    public init(
        reason: String,
        restartexpectedms: Int? = nil)
    {
        self.reason = reason
        self.restartexpectedms = restartexpectedms
    }

    private enum CodingKeys: String, CodingKey {
        case reason
        case restartexpectedms = "restartExpectedMs"
    }
}

public enum BoardOp: Codable, Sendable {
    case tabCreate(BoardTabCreateOp)
    case tabUpdate(BoardTabUpdateOp)
    case tabDelete(BoardTabDeleteOp)
    case tabsReorder(BoardTabsReorderOp)
    case widgetMove(BoardWidgetMoveOp)
    case widgetResize(BoardWidgetResizeOp)
    case widgetRemove(BoardWidgetRemoveOp)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "tab_create": self = try .tabCreate(BoardTabCreateOp(from: decoder))
        case "tab_update": self = try .tabUpdate(BoardTabUpdateOp(from: decoder))
        case "tab_delete": self = try .tabDelete(BoardTabDeleteOp(from: decoder))
        case "tabs_reorder": self = try .tabsReorder(BoardTabsReorderOp(from: decoder))
        case "widget_move": self = try .widgetMove(BoardWidgetMoveOp(from: decoder))
        case "widget_resize": self = try .widgetResize(BoardWidgetResizeOp(from: decoder))
        case "widget_remove": self = try .widgetRemove(BoardWidgetRemoveOp(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown BoardOp discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .tabCreate(let value): try value.encode(to: encoder)
        case .tabUpdate(let value): try value.encode(to: encoder)
        case .tabDelete(let value): try value.encode(to: encoder)
        case .tabsReorder(let value): try value.encode(to: encoder)
        case .widgetMove(let value): try value.encode(to: encoder)
        case .widgetResize(let value): try value.encode(to: encoder)
        case .widgetRemove(let value): try value.encode(to: encoder)
        }
    }
}

public enum BoardWidgetContent: Codable, Sendable {
    case html(BoardWidgetHtmlContent)
    case mcpApp(BoardWidgetMcpAppContent)
    case plugin(BoardWidgetPluginContent)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "html": self = try .html(BoardWidgetHtmlContent(from: decoder))
        case "mcp-app": self = try .mcpApp(BoardWidgetMcpAppContent(from: decoder))
        case "plugin": self = try .plugin(BoardWidgetPluginContent(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown BoardWidgetContent discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .html(let value): try value.encode(to: encoder)
        case .mcpApp(let value): try value.encode(to: encoder)
        case .plugin(let value): try value.encode(to: encoder)
        }
    }
}

public enum BoardWidgetPutContent: Codable, Sendable {
    case html(BoardWidgetHtmlContent)
    case mcpApp(BoardWidgetMcpAppPutContent)
    case plugin(BoardWidgetPluginContent)
    case canvasDoc(BoardCanvasDocumentSource)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "html": self = try .html(BoardWidgetHtmlContent(from: decoder))
        case "mcp-app": self = try .mcpApp(BoardWidgetMcpAppPutContent(from: decoder))
        case "plugin": self = try .plugin(BoardWidgetPluginContent(from: decoder))
        case "canvas-doc": self = try .canvasDoc(BoardCanvasDocumentSource(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown BoardWidgetPutContent discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .html(let value): try value.encode(to: encoder)
        case .mcpApp(let value): try value.encode(to: encoder)
        case .plugin(let value): try value.encode(to: encoder)
        case .canvasDoc(let value): try value.encode(to: encoder)
        }
    }
}

public enum BoardCommand: Codable, Sendable {
    case focusTab(BoardFocusTabCommand)
    case setChatDock(BoardSetChatDockCommand)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "focus_tab": self = try .focusTab(BoardFocusTabCommand(from: decoder))
        case "set_chat_dock": self = try .setChatDock(BoardSetChatDockCommand(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown BoardCommand discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .focusTab(let value): try value.encode(to: encoder)
        case .setChatDock(let value): try value.encode(to: encoder)
        }
    }
}

public enum GatewayErrorDetails: Codable, Sendable {
    case missingScope(MissingScopeErrorDetails)
    case mcpAppViewExpired(McpAppViewExpiredErrorDetails)
    case unknownAgentId(UnknownAgentIdErrorDetails)
    case wizardNotFound(WizardNotFoundErrorDetails)

    public init(code: String, missingscope: String, requiredscopes: [String]) {
        self = .missingScope(
            MissingScopeErrorDetails(
                code: code,
                missingscope: missingscope,
                requiredscopes: requiredscopes
            )
        )
    }

    public var code: String {
        switch self {
        case .missingScope(let value): value.code
        case .mcpAppViewExpired(let value): value.code
        case .unknownAgentId(let value): value.code
        case .wizardNotFound(let value): value.code
        }
    }

    public var missingscope: String {
        if case .missingScope(let value) = self { return value.missingscope }
        return ""
    }

    public var requiredscopes: [String] {
        if case .missingScope(let value) = self { return value.requiredscopes }
        return []
    }

    private enum CodingKeys: String, CodingKey {
        case discriminator = "code"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "MISSING_SCOPE": self = try .missingScope(MissingScopeErrorDetails(from: decoder))
        case "MCP_APP_VIEW_EXPIRED": self = try .mcpAppViewExpired(McpAppViewExpiredErrorDetails(from: decoder))
        case "UNKNOWN_AGENT_ID": self = try .unknownAgentId(UnknownAgentIdErrorDetails(from: decoder))
        case "WIZARD_NOT_FOUND": self = try .wizardNotFound(WizardNotFoundErrorDetails(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown GatewayErrorDetails discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .missingScope(let value): try value.encode(to: encoder)
        case .mcpAppViewExpired(let value): try value.encode(to: encoder)
        case .unknownAgentId(let value): try value.encode(to: encoder)
        case .wizardNotFound(let value): try value.encode(to: encoder)
        }
    }
}

public enum GatewaySuspendPrepareResult: Codable, Sendable {
    case busy(GatewaySuspendPrepareBusyResult)
    case ready(GatewaySuspendPrepareReadyResult)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "status"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "busy": self = try .busy(GatewaySuspendPrepareBusyResult(from: decoder))
        case "ready": self = try .ready(GatewaySuspendPrepareReadyResult(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown GatewaySuspendPrepareResult discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .busy(let value): try value.encode(to: encoder)
        case .ready(let value): try value.encode(to: encoder)
        }
    }
}

public enum GatewaySuspendStatusResult: Codable, Sendable {
    case running(GatewaySuspendStatusRunningResult)
    case ready(GatewaySuspendStatusReadyResult)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "status"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "running": self = try .running(GatewaySuspendStatusRunningResult(from: decoder))
        case "ready": self = try .ready(GatewaySuspendStatusReadyResult(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown GatewaySuspendStatusResult discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .running(let value): try value.encode(to: encoder)
        case .ready(let value): try value.encode(to: encoder)
        }
    }
}

public enum UiCommand: Codable, Sendable {
    case split(UiSplitCommand)
    case closePane(UiClosePaneCommand)
    case focus(UiFocusCommand)
    case sidebar(UiSidebarCommand)
    case panel(UiPanelCommand)
    case navigate(UiNavigateCommand)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "split": self = try .split(UiSplitCommand(from: decoder))
        case "close-pane": self = try .closePane(UiClosePaneCommand(from: decoder))
        case "focus": self = try .focus(UiFocusCommand(from: decoder))
        case "sidebar": self = try .sidebar(UiSidebarCommand(from: decoder))
        case "panel": self = try .panel(UiPanelCommand(from: decoder))
        case "navigate": self = try .navigate(UiNavigateCommand(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown UiCommand discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .split(let value): try value.encode(to: encoder)
        case .closePane(let value): try value.encode(to: encoder)
        case .focus(let value): try value.encode(to: encoder)
        case .sidebar(let value): try value.encode(to: encoder)
        case .panel(let value): try value.encode(to: encoder)
        case .navigate(let value): try value.encode(to: encoder)
        }
    }
}

public enum SessionPlacement: Codable, Sendable {
    case local(LocalSessionPlacement)
    case requested(RequestedSessionPlacement)
    case provisioning(ProvisioningSessionPlacement)
    case syncing(SyncingSessionPlacement)
    case starting(StartingSessionPlacement)
    case active(ActiveWorkerSessionPlacement)
    case draining(DrainingSessionPlacement)
    case reconciling(ReconcilingSessionPlacement)
    case reclaimed(ReclaimedSessionPlacement)
    case failed(FailedSessionPlacement)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "state"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "local": self = try .local(LocalSessionPlacement(from: decoder))
        case "requested": self = try .requested(RequestedSessionPlacement(from: decoder))
        case "provisioning": self = try .provisioning(ProvisioningSessionPlacement(from: decoder))
        case "syncing": self = try .syncing(SyncingSessionPlacement(from: decoder))
        case "starting": self = try .starting(StartingSessionPlacement(from: decoder))
        case "active": self = try .active(ActiveWorkerSessionPlacement(from: decoder))
        case "draining": self = try .draining(DrainingSessionPlacement(from: decoder))
        case "reconciling": self = try .reconciling(ReconcilingSessionPlacement(from: decoder))
        case "reclaimed": self = try .reclaimed(ReclaimedSessionPlacement(from: decoder))
        case "failed": self = try .failed(FailedSessionPlacement(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown SessionPlacement discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .local(let value): try value.encode(to: encoder)
        case .requested(let value): try value.encode(to: encoder)
        case .provisioning(let value): try value.encode(to: encoder)
        case .syncing(let value): try value.encode(to: encoder)
        case .starting(let value): try value.encode(to: encoder)
        case .active(let value): try value.encode(to: encoder)
        case .draining(let value): try value.encode(to: encoder)
        case .reconciling(let value): try value.encode(to: encoder)
        case .reclaimed(let value): try value.encode(to: encoder)
        case .failed(let value): try value.encode(to: encoder)
        }
    }
}

public enum AuditActivityEventV1: Codable, Sendable {
    case agentRun(AuditActivityAgentRunV1)
    case toolAction(AuditActivityToolActionV1)
    case inboundMessage(AuditActivityInboundMessageV1)
    case outboundMessage(AuditActivityOutboundMessageV1)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "eventType"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "agent_run": self = try .agentRun(AuditActivityAgentRunV1(from: decoder))
        case "tool_action": self = try .toolAction(AuditActivityToolActionV1(from: decoder))
        case "inbound_message": self = try .inboundMessage(AuditActivityInboundMessageV1(from: decoder))
        case "outbound_message": self = try .outboundMessage(AuditActivityOutboundMessageV1(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown AuditActivityEventV1 discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .agentRun(let value): try value.encode(to: encoder)
        case .toolAction(let value): try value.encode(to: encoder)
        case .inboundMessage(let value): try value.encode(to: encoder)
        case .outboundMessage(let value): try value.encode(to: encoder)
        }
    }
}

public enum ApprovalPresentation: Codable, Sendable {
    case exec(ExecApprovalPresentation)
    case plugin(PluginApprovalPresentation)
    case systemAgent(SystemAgentApprovalPresentation)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "kind"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "exec": self = try .exec(ExecApprovalPresentation(from: decoder))
        case "plugin": self = try .plugin(PluginApprovalPresentation(from: decoder))
        case "system-agent": self = try .systemAgent(SystemAgentApprovalPresentation(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown ApprovalPresentation discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .exec(let value): try value.encode(to: encoder)
        case .plugin(let value): try value.encode(to: encoder)
        case .systemAgent(let value): try value.encode(to: encoder)
        }
    }
}

public enum ApprovalSnapshot: Codable, Sendable {
    case pending(PendingApprovalSnapshot)
    case allowed(AllowedApprovalSnapshot)
    case denied(DeniedApprovalSnapshot)
    case expired(ExpiredApprovalSnapshot)
    case cancelled(CancelledApprovalSnapshot)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "status"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "pending": self = try .pending(PendingApprovalSnapshot(from: decoder))
        case "allowed": self = try .allowed(AllowedApprovalSnapshot(from: decoder))
        case "denied": self = try .denied(DeniedApprovalSnapshot(from: decoder))
        case "expired": self = try .expired(ExpiredApprovalSnapshot(from: decoder))
        case "cancelled": self = try .cancelled(CancelledApprovalSnapshot(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown ApprovalSnapshot discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .pending(let value): try value.encode(to: encoder)
        case .allowed(let value): try value.encode(to: encoder)
        case .denied(let value): try value.encode(to: encoder)
        case .expired(let value): try value.encode(to: encoder)
        case .cancelled(let value): try value.encode(to: encoder)
        }
    }
}

public enum TerminalApprovalSnapshot: Codable, Sendable {
    case allowed(AllowedApprovalSnapshot)
    case denied(DeniedApprovalSnapshot)
    case expired(ExpiredApprovalSnapshot)
    case cancelled(CancelledApprovalSnapshot)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "status"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "allowed": self = try .allowed(AllowedApprovalSnapshot(from: decoder))
        case "denied": self = try .denied(DeniedApprovalSnapshot(from: decoder))
        case "expired": self = try .expired(ExpiredApprovalSnapshot(from: decoder))
        case "cancelled": self = try .cancelled(CancelledApprovalSnapshot(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown TerminalApprovalSnapshot discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .allowed(let value): try value.encode(to: encoder)
        case .denied(let value): try value.encode(to: encoder)
        case .expired(let value): try value.encode(to: encoder)
        case .cancelled(let value): try value.encode(to: encoder)
        }
    }
}

public enum SessionApprovalEvent: Codable, Sendable {
    case pending(PendingSessionApprovalEvent)
    case terminal(TerminalSessionApprovalEvent)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "phase"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "pending": self = try .pending(PendingSessionApprovalEvent(from: decoder))
        case "terminal": self = try .terminal(TerminalSessionApprovalEvent(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown SessionApprovalEvent discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .pending(let value): try value.encode(to: encoder)
        case .terminal(let value): try value.encode(to: encoder)
        }
    }
}

public enum PluginCatalogInstallAction: Codable, Sendable {
    case clawhub(PluginCatalogClawHubInstall)
    case official(PluginCatalogOfficialInstall)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "source"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "clawhub": self = try .clawhub(PluginCatalogClawHubInstall(from: decoder))
        case "official": self = try .official(PluginCatalogOfficialInstall(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown PluginCatalogInstallAction discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .clawhub(let value): try value.encode(to: encoder)
        case .official(let value): try value.encode(to: encoder)
        }
    }
}

public enum PluginsSessionActionResult: Codable, Sendable {
    case success(PluginsSessionActionSuccessResult)
    case failure(PluginsSessionActionFailureResult)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "ok"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(Bool.self, forKey: .discriminator)
        switch discriminator {
        case true: self = try .success(PluginsSessionActionSuccessResult(from: decoder))
        case false: self = try .failure(PluginsSessionActionFailureResult(from: decoder))
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .success(let value): try value.encode(to: encoder)
        case .failure(let value): try value.encode(to: encoder)
        }
    }
}

public enum ChatEvent: Codable, Sendable {
    case status(ChatStatusEvent)
    case delta(ChatDeltaEvent)
    case final(ChatFinalEvent)
    case aborted(ChatAbortedEvent)
    case error(ChatErrorEvent)

    private enum CodingKeys: String, CodingKey {
        case discriminator = "state"
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let discriminator = try container.decode(String.self, forKey: .discriminator)
        switch discriminator {
        case "status": self = try .status(ChatStatusEvent(from: decoder))
        case "delta": self = try .delta(ChatDeltaEvent(from: decoder))
        case "final": self = try .final(ChatFinalEvent(from: decoder))
        case "aborted": self = try .aborted(ChatAbortedEvent(from: decoder))
        case "error": self = try .error(ChatErrorEvent(from: decoder))
        default:
            throw DecodingError.dataCorruptedError(
                forKey: .discriminator,
                in: container,
                debugDescription: "Unknown ChatEvent discriminator value"
            )
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case .status(let value): try value.encode(to: encoder)
        case .delta(let value): try value.encode(to: encoder)
        case .final(let value): try value.encode(to: encoder)
        case .aborted(let value): try value.encode(to: encoder)
        case .error(let value): try value.encode(to: encoder)
        }
    }
}

public enum GatewayFrame: Codable, Sendable {
    case req(RequestFrame)
    case res(ResponseFrame)
    case event(EventFrame)
    case unknown(type: String, raw: [String: AnyCodable])

    private enum CodingKeys: String, CodingKey {
        case type
    }

    public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        let type = try typeContainer.decode(String.self, forKey: .type)
        switch type {
        case "req":
            self = try .req(RequestFrame(from: decoder))
        case "res":
            self = try .res(ResponseFrame(from: decoder))
        case "event":
            self = try .event(EventFrame(from: decoder))
        default:
            let container = try decoder.singleValueContainer()
            let raw = try container.decode([String: AnyCodable].self)
            self = .unknown(type: type, raw: raw)
        }
    }

    public func encode(to encoder: Encoder) throws {
        switch self {
        case let .req(v):
            try v.encode(to: encoder)
        case let .res(v):
            try v.encode(to: encoder)
        case let .event(v):
            try v.encode(to: encoder)
        case let .unknown(_, raw):
            var container = encoder.singleValueContainer()
            try container.encode(raw)
        }
    }
}
