// Generated by scripts/protocol-gen-kotlin.ts — do not edit by hand.
package ai.openclaw.app.gateway

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement

const val GATEWAY_PROTOCOL_VERSION = 4
const val GATEWAY_MIN_PROTOCOL_VERSION = 3

@Serializable
data class GatewayProtocolError(
  val code: String,
  val message: String,
  val details: JsonElement? = null,
  val retryable: Boolean? = null,
  val retryAfterMs: Long? = null,
)

@Serializable
data class GatewayRequestFrame(
  val type: String = "req",
  val id: String,
  val method: String,
  val params: JsonElement? = null,
  val traceparent: String? = null,
)

@Serializable
data class GatewayResponseFrame(
  val type: String = "res",
  val id: String,
  val ok: Boolean,
  val payload: JsonElement? = null,
  val error: GatewayProtocolError? = null,
)

@Serializable
data class GatewayEventFrame(
  val type: String = "event",
  val event: String,
  val payload: JsonElement? = null,
  val seq: Long? = null,
  val stateVersion: GatewayEventFrameStateVersion? = null,
)

@Serializable
data class GatewayNodeEventParams(
  val event: String,
  val payload: JsonElement? = null,
  @SerialName("payloadJSON")
  val payloadJson: String? = null,
)

@Serializable
data class GatewayNodeInvokeResultParams(
  val id: String,
  val nodeId: String,
  val ok: Boolean,
  val payload: JsonElement? = null,
  @SerialName("payloadJSON")
  val payloadJson: String? = null,
  val error: GatewayNodeInvokeResultParamsError? = null,
)

@Serializable
data class GatewayNodeInvokeRequest(
  val id: String,
  val nodeId: String,
  val command: String,
  @SerialName("paramsJSON")
  val paramsJson: String? = null,
  val timeoutMs: Long? = null,
  val idempotencyKey: String? = null,
)

@Serializable
data class QuestionOption(
  val label: String,
  val description: String? = null,
)

@Serializable
data class Question(
  val questionId: String,
  val header: String,
  val question: String,
  val options: List<QuestionOption>,
  val multiSelect: Boolean? = null,
  val isOther: Boolean? = null,
  val isSecret: Boolean? = null,
)

@Serializable
data class QuestionAnswers(
  val answers: Map<String, List<String>>,
)

@Serializable
data class QuestionRecord(
  val id: String,
  val questions: List<Question>,
  val agentId: String? = null,
  val sessionKey: String? = null,
  val runId: String? = null,
  val createdAtMs: Long,
  val expiresAtMs: Long,
  val status: String,
  val answers: QuestionAnswers? = null,
  val resolvedBy: String? = null,
)

@Serializable
data class QuestionGetResult(
  val question: QuestionRecord,
)

@Serializable
data class QuestionListResult(
  val questions: List<QuestionRecord>,
)

@Serializable
data class SessionObserverPlanProgress(
  val completed: Long,
  val total: Long,
)

@Serializable
data class SessionObserverDigest(
  val sessionKey: String,
  val agentId: String? = null,
  val runId: String? = null,
  val revision: Long,
  val updatedAt: Long,
  val headline: String,
  val assessment: String? = null,
  val health: String,
  val planProgress: SessionObserverPlanProgress? = null,
)

@Serializable
data class GatewayEventFrameStateVersion(
  val presence: Long,
  val health: Long,
)

@Serializable
data class GatewayNodeInvokeResultParamsError(
  val code: String? = null,
  val message: String? = null,
)

enum class GatewayMethod(
  val rawValue: String,
) {
  Health("health"),
  DiagnosticsStability("diagnostics.stability"),
  DoctorMemoryStatus("doctor.memory.status"),
  DoctorMemoryDreamDiary("doctor.memory.dreamDiary"),
  DoctorMemoryBackfillDreamDiary("doctor.memory.backfillDreamDiary"),
  DoctorMemoryResetDreamDiary("doctor.memory.resetDreamDiary"),
  DoctorMemoryResetGroundedShortTerm("doctor.memory.resetGroundedShortTerm"),
  DoctorMemoryRepairDreamingArtifacts("doctor.memory.repairDreamingArtifacts"),
  DoctorMemoryDedupeDreamDiary("doctor.memory.dedupeDreamDiary"),
  DoctorMemoryRemHarness("doctor.memory.remHarness"),
  LogsTail("logs.tail"),
  ChannelsStatus("channels.status"),
  ChannelsStart("channels.start"),
  ChannelsStop("channels.stop"),
  ChannelsLogout("channels.logout"),
  Status("status"),
  UsageStatus("usage.status"),
  UsageCost("usage.cost"),
  TtsStatus("tts.status"),
  TtsProviders("tts.providers"),
  TtsPersonas("tts.personas"),
  TtsEnable("tts.enable"),
  TtsDisable("tts.disable"),
  TtsConvert("tts.convert"),
  TtsSetProvider("tts.setProvider"),
  TtsSetPersona("tts.setPersona"),
  ConfigGet("config.get"),
  ConfigSet("config.set"),
  ConfigApply("config.apply"),
  ConfigPatch("config.patch"),
  ConfigSchema("config.schema"),
  ConfigSchemaLookup("config.schema.lookup"),
  ExecApprovalsGet("exec.approvals.get"),
  ExecApprovalsSet("exec.approvals.set"),
  ExecApprovalsNodeGet("exec.approvals.node.get"),
  ExecApprovalsNodeSet("exec.approvals.node.set"),
  ExecApprovalGet("exec.approval.get"),
  ExecApprovalList("exec.approval.list"),
  ExecApprovalRequest("exec.approval.request"),
  ExecApprovalWaitDecision("exec.approval.waitDecision"),
  ExecApprovalResolve("exec.approval.resolve"),
  QuestionRequest("question.request"),
  QuestionWaitAnswer("question.waitAnswer"),
  QuestionResolve("question.resolve"),
  QuestionGet("question.get"),
  QuestionList("question.list"),
  PluginApprovalList("plugin.approval.list"),
  PluginApprovalRequest("plugin.approval.request"),
  PluginApprovalWaitDecision("plugin.approval.waitDecision"),
  PluginApprovalResolve("plugin.approval.resolve"),
  PluginsUiDescriptors("plugins.uiDescriptors"),
  PluginsSessionAction("plugins.sessionAction"),
  OpenclawChat("openclaw.chat"),
  OpenclawChatHistory("openclaw.chat.history"),
  OpenclawChangesList("openclaw.changes.list"),
  OpenclawApprovalList("openclaw.approval.list"),
  OpenclawSetupDetect("openclaw.setup.detect"),
  OpenclawSetupActivate("openclaw.setup.activate"),
  OpenclawSetupAuthStart("openclaw.setup.auth.start"),
  OpenclawSetupPrepareStart("openclaw.setup.prepare.start"),
  WizardStart("wizard.start"),
  WizardNext("wizard.next"),
  WizardCancel("wizard.cancel"),
  WizardStatus("wizard.status"),
  TalkCatalog("talk.catalog"),
  TalkConfig("talk.config"),
  TalkClientCreate("talk.client.create"),
  TalkClientTranscript("talk.client.transcript"),
  TalkClientClose("talk.client.close"),
  TalkClientToolCall("talk.client.toolCall"),
  TalkClientSteer("talk.client.steer"),
  TalkSessionCreate("talk.session.create"),
  TalkSessionJoin("talk.session.join"),
  TalkSessionAppendAudio("talk.session.appendAudio"),
  TalkSessionStartTurn("talk.session.startTurn"),
  TalkSessionEndTurn("talk.session.endTurn"),
  TalkSessionCancelTurn("talk.session.cancelTurn"),
  TalkSessionCancelOutput("talk.session.cancelOutput"),
  TalkSessionAcknowledgeMark("talk.session.acknowledgeMark"),
  TalkSessionSubmitToolResult("talk.session.submitToolResult"),
  TalkSessionSteer("talk.session.steer"),
  TalkSessionClose("talk.session.close"),
  TalkSpeak("talk.speak"),
  TalkMode("talk.mode"),
  CommandsList("commands.list"),
  ModelsList("models.list"),
  ModelsAuthStatus("models.authStatus"),
  ModelsAuthLogout("models.authLogout"),
  ToolsCatalog("tools.catalog"),
  ToolsEffective("tools.effective"),
  ToolsInvoke("tools.invoke"),
  McpAppView("mcp.app.view"),
  McpAppListTools("mcp.app.listTools"),
  McpAppListResources("mcp.app.listResources"),
  McpAppListResourceTemplates("mcp.app.listResourceTemplates"),
  McpAppReadResource("mcp.app.readResource"),
  McpAppCallTool("mcp.app.callTool"),
  McpAppUpdateModelContext("mcp.app.updateModelContext"),
  BoardGet("board.get"),
  BoardUpdate("board.update"),
  BoardWidgetPut("board.widget.put"),
  BoardWidgetGrant("board.widget.grant"),
  BoardWidgetAppView("board.widget.appView"),
  BoardEvent("board.event"),
  AuditList("audit.list"),
  AuditActivityList("audit.activity.list"),
  UsersList("users.list"),
  UsersSelf("users.self"),
  UsersLinkEmail("users.linkEmail"),
  UsersSetDisplayName("users.setDisplayName"),
  UsersSetAvatar("users.setAvatar"),
  TasksList("tasks.list"),
  TasksGet("tasks.get"),
  TasksCancel("tasks.cancel"),
  TaskSuggestionsList("taskSuggestions.list"),
  TaskSuggestionsCreate("taskSuggestions.create"),
  TaskSuggestionsAccept("taskSuggestions.accept"),
  TaskSuggestionsDismiss("taskSuggestions.dismiss"),
  EnvironmentsList("environments.list"),
  EnvironmentsStatus("environments.status"),
  WorktreesList("worktrees.list"),
  WorktreesBranches("worktrees.branches"),
  FsListDir("fs.listDir"),
  WorktreesCreate("worktrees.create"),
  WorktreesRemove("worktrees.remove"),
  WorktreesRestore("worktrees.restore"),
  WorktreesGc("worktrees.gc"),
  AgentsList("agents.list"),
  AgentsCreate("agents.create"),
  AgentsUpdate("agents.update"),
  AgentsDelete("agents.delete"),
  AgentsFilesList("agents.files.list"),
  AgentsFilesGet("agents.files.get"),
  AgentsFilesSet("agents.files.set"),
  SessionsFilesList("sessions.files.list"),
  SessionsFilesGet("sessions.files.get"),
  SessionsFilesSet("sessions.files.set"),
  SessionsFilesReveal("sessions.files.reveal"),
  ArtifactsList("artifacts.list"),
  ArtifactsGet("artifacts.get"),
  ArtifactsDownload("artifacts.download"),
  SkillsStatus("skills.status"),
  SkillsSearch("skills.search"),
  SkillsDetail("skills.detail"),
  SkillsSecurityVerdicts("skills.securityVerdicts"),
  SkillsSkillCard("skills.skillCard"),
  SkillsBins("skills.bins"),
  SkillsUploadBegin("skills.upload.begin"),
  SkillsUploadChunk("skills.upload.chunk"),
  SkillsUploadCommit("skills.upload.commit"),
  SkillsInstall("skills.install"),
  SkillsUpdate("skills.update"),
  SkillsCuratorStatus("skills.curator.status"),
  SkillsCuratorPin("skills.curator.pin"),
  SkillsCuratorUnpin("skills.curator.unpin"),
  SkillsCuratorRestore("skills.curator.restore"),
  SkillsProposalsList("skills.proposals.list"),
  SkillsProposalsInspect("skills.proposals.inspect"),
  SkillsProposalsHistoryStatus("skills.proposals.historyStatus"),
  SkillsProposalsHistoryScan("skills.proposals.historyScan"),
  SkillsProposalsCreate("skills.proposals.create"),
  SkillsProposalsUpdate("skills.proposals.update"),
  SkillsProposalsRevise("skills.proposals.revise"),
  SkillsProposalsRequestRevision("skills.proposals.requestRevision"),
  SkillsProposalsApply("skills.proposals.apply"),
  SkillsProposalsReject("skills.proposals.reject"),
  SkillsProposalsQuarantine("skills.proposals.quarantine"),
  UpdateStatus("update.status"),
  UpdateRun("update.run"),
  VoicewakeGet("voicewake.get"),
  VoicewakeSet("voicewake.set"),
  SecretsReload("secrets.reload"),
  SecretsResolve("secrets.resolve"),
  VoicewakeRoutingGet("voicewake.routing.get"),
  VoicewakeRoutingSet("voicewake.routing.set"),
  SessionsList("sessions.list"),
  SessionsSubscribe("sessions.subscribe"),
  SessionsUnsubscribe("sessions.unsubscribe"),
  SessionsMessagesSubscribe("sessions.messages.subscribe"),
  SessionsMessagesUnsubscribe("sessions.messages.unsubscribe"),
  SessionsViewersSet("sessions.viewers.set"),
  SessionsPreview("sessions.preview"),
  SessionsDescribe("sessions.describe"),
  SessionsCompactionList("sessions.compaction.list"),
  SessionsCompactionGet("sessions.compaction.get"),
  SessionsCompactionBranch("sessions.compaction.branch"),
  SessionsCompactionRestore("sessions.compaction.restore"),
  SessionsBranchesList("sessions.branches.list"),
  SessionsBranchesSwitch("sessions.branches.switch"),
  SessionsRewind("sessions.rewind"),
  SessionsFork("sessions.fork"),
  SessionsCreate("sessions.create"),
  SessionsSend("sessions.send"),
  SessionsAbort("sessions.abort"),
  SessionsPatch("sessions.patch"),
  SessionsPluginPatch("sessions.pluginPatch"),
  SessionsCleanup("sessions.cleanup"),
  SessionsReset("sessions.reset"),
  SessionsDelete("sessions.delete"),
  SessionsCompact("sessions.compact"),
  SessionsGroupsList("sessions.groups.list"),
  SessionsGroupsPut("sessions.groups.put"),
  SessionsGroupsRename("sessions.groups.rename"),
  SessionsGroupsDelete("sessions.groups.delete"),
  LastHeartbeat("last-heartbeat"),
  SetHeartbeats("set-heartbeats"),
  Wake("wake"),
  NodePairList("node.pair.list"),
  NodePairApprove("node.pair.approve"),
  NodePairReject("node.pair.reject"),
  NodePairRemove("node.pair.remove"),
  DevicePairList("device.pair.list"),
  DevicePairApprove("device.pair.approve"),
  DevicePairReject("device.pair.reject"),
  DevicePairRemove("device.pair.remove"),
  DevicePairRename("device.pair.rename"),
  DeviceTokenRotate("device.token.rotate"),
  DeviceTokenRevoke("device.token.revoke"),
  DevicePairSetupCode("device.pair.setupCode"),
  NodeRename("node.rename"),
  NodeList("node.list"),
  NodeDescribe("node.describe"),
  NodePluginSurfaceRefresh("node.pluginSurface.refresh"),
  NodePluginToolsUpdate("node.pluginTools.update"),
  NodeSkillsUpdate("node.skills.update"),
  NodePendingDrain("node.pending.drain"),
  NodePendingEnqueue("node.pending.enqueue"),
  NodeInvoke("node.invoke"),
  NodePendingPull("node.pending.pull"),
  NodePendingAck("node.pending.ack"),
  NodeInvokeProgress("node.invoke.progress"),
  NodeInvokeResult("node.invoke.result"),
  NodeEvent("node.event"),
  CronGet("cron.get"),
  CronList("cron.list"),
  CronStatus("cron.status"),
  CronScratchGet("cron.scratch.get"),
  CronScratchSet("cron.scratch.set"),
  CronAdd("cron.add"),
  CronUpdate("cron.update"),
  CronRemove("cron.remove"),
  CronRun("cron.run"),
  CronRuns("cron.runs"),
  GatewayIdentityGet("gateway.identity.get"),
  GatewayRestartPreflight("gateway.restart.preflight"),
  GatewayRestartRequest("gateway.restart.request"),
  SystemPresence("system-presence"),
  SystemEvent("system-event"),
  MessageAction("message.action"),
  ConversationsSend("conversations.send"),
  ConversationsTurn("conversations.turn"),
  ConversationsTurnCancel("conversations.turn.cancel"),
  Send("send"),
  Agent("agent"),
  AgentIdentityGet("agent.identity.get"),
  AgentWait("agent.wait"),
  ChatHistory("chat.history"),
  ChatStartup("chat.startup"),
  ChatMetadata("chat.metadata"),
  ChatMessageGet("chat.message.get"),
  ChatAbort("chat.abort"),
  ChatSend("chat.send"),
  TerminalOpen("terminal.open"),
  TerminalInput("terminal.input"),
  TerminalResize("terminal.resize"),
  TerminalClose("terminal.close"),
  ChannelsPairingList("channels.pairing.list"),
  ChannelsPairingApprove("channels.pairing.approve"),
  ChannelsPairingDismiss("channels.pairing.dismiss"),
  AssistantMediaGet("assistant.media.get"),
  SessionsGet("sessions.get"),
  SessionsResolve("sessions.resolve"),
  SessionsUsage("sessions.usage"),
  SessionsUsageTimeseries("sessions.usage.timeseries"),
  SessionsUsageLogs("sessions.usage.logs"),
  Poll("poll"),
  SessionsSteer("sessions.steer"),
  PushTest("push.test"),
  AttachGrant("attach.grant"),
  AttachRevoke("attach.revoke"),
  PushWebVapidPublicKey("push.web.vapidPublicKey"),
  PushWebSubscribe("push.web.subscribe"),
  PushWebUnsubscribe("push.web.unsubscribe"),
  PushWebTest("push.web.test"),
  ConfigOpenFile("config.openFile"),
  Connect("connect"),
  ChatInject("chat.inject"),
  NativeHookInvoke("nativeHook.invoke"),
  WebLoginStart("web.login.start"),
  WebLoginWait("web.login.wait"),
  TerminalAttach("terminal.attach"),
  TerminalList("terminal.list"),
  TerminalText("terminal.text"),
  ControlUiGithubPreview("controlUi.githubPreview"),
  SystemInfo("system.info"),
  AgentsWorkspaceList("agents.workspace.list"),
  AgentsWorkspaceGet("agents.workspace.get"),
  TtsSpeak("tts.speak"),
  PluginsList("plugins.list"),
  PluginsSearch("plugins.search"),
  PluginsInstall("plugins.install"),
  PluginsSetEnabled("plugins.setEnabled"),
  PluginsUninstall("plugins.uninstall"),
  PluginsRefresh("plugins.refresh"),
  ControlUiSessionPullRequestsSubscribe("controlUi.sessionPullRequests.subscribe"),
  GatewaySuspendPrepare("gateway.suspend.prepare"),
  GatewaySuspendStatus("gateway.suspend.status"),
  GatewaySuspendResume("gateway.suspend.resume"),
  ChatToolTitles("chat.toolTitles"),
  SessionsDiff("sessions.diff"),
  OpenclawSetupVerify("openclaw.setup.verify"),
  EnvironmentsCreate("environments.create"),
  EnvironmentsDestroy("environments.destroy"),
  SessionsCatalogList("sessions.catalog.list"),
  SessionsCatalogRead("sessions.catalog.read"),
  TerminalUpload("terminal.upload"),
  SessionsCatalogContinue("sessions.catalog.continue"),
  SessionsCatalogArchive("sessions.catalog.archive"),
  ApprovalGet("approval.get"),
  ApprovalResolve("approval.resolve"),
  SessionsSearch("sessions.search"),
  SessionsDispatch("sessions.dispatch"),
  SessionsReclaim("sessions.reclaim"),
  ModelsProbe("models.probe"),
  MigrationsMemoryPlan("migrations.memory.plan"),
  MigrationsMemoryApply("migrations.memory.apply"),
  UiCommand("ui.command"),
  ApprovalHistory("approval.history"),
  PluginSurfaceRefresh("plugin.surface.refresh"),
  ConversationsList("conversations.list"),
  SessionDiscussionInfo("session.discussion.info"),
  SessionDiscussionOpen("session.discussion.open"),
  BoardPromptAuthorize("board.prompt.authorize"),
  BoardDataRead("board.data.read"),
  BoardAction("board.action"),
  SessionsObserverVisibility("sessions.observer.visibility"),
  SessionVisibilitySet("session.visibility.set"),
  SessionMembersList("session.members.list"),
  SessionMembersAdd("session.members.add"),
  SessionMembersRemove("session.members.remove"),
  SessionSuggestionsAdd("session.suggestions.add"),
  SessionSuggestionsList("session.suggestions.list"),
  SessionSuggestionsResolve("session.suggestions.resolve"),
  SessionTyping("session.typing"),
  SessionsCompanionAsk("sessions.companion.ask"),
  SessionsCompanionState("sessions.companion.state"),
  SessionsCompanionReset("sessions.companion.reset"),
  MemorySearch("memory.search"),
  SkillsProposalsEventsList("skills.proposals.events.list"),
  SkillsProposalsEvaluate("skills.proposals.evaluate"),
}

enum class GatewayEvent(
  val rawValue: String,
) {
  ConnectChallenge("connect.challenge"),
  Agent("agent"),
  Chat("chat"),
  UiCommand("ui.command"),
  SessionApproval("session.approval"),
  SessionMessage("session.message"),
  SessionObserver("session.observer"),
  SessionOperation("session.operation"),
  SessionSharing("session.sharing"),
  SessionSuggestion("session.suggestion"),
  SessionTyping("session.typing"),
  SessionTool("session.tool"),
  SessionsChanged("sessions.changed"),
  ControlUiSessionPullRequestsChanged("controlUi.sessionPullRequests.changed"),
  Presence("presence"),
  Tick("tick"),
  TalkMode("talk.mode"),
  TalkEvent("talk.event"),
  Shutdown("shutdown"),
  Health("health"),
  Heartbeat("heartbeat"),
  Cron("cron"),
  Task("task"),
  TaskSuggestion("task.suggestion"),
  NodePairRequested("node.pair.requested"),
  NodePairResolved("node.pair.resolved"),
  NodePresence("node.presence"),
  NodeInvokeCancel("node.invoke.cancel"),
  NodeInvokeInput("node.invoke.input"),
  NodeInvokeRequest("node.invoke.request"),
  DevicePairRequested("device.pair.requested"),
  DevicePairResolved("device.pair.resolved"),
  SkillsChanged("skills.changed"),
  VoicewakeChanged("voicewake.changed"),
  VoicewakeRoutingChanged("voicewake.routing.changed"),
  ExecApprovalRequested("exec.approval.requested"),
  ExecApprovalResolved("exec.approval.resolved"),
  QuestionRequested("question.requested"),
  QuestionResolved("question.resolved"),
  PluginApprovalRequested("plugin.approval.requested"),
  PluginApprovalResolved("plugin.approval.resolved"),
  OpenclawApprovalRequested("openclaw.approval.requested"),
  OpenclawApprovalResolved("openclaw.approval.resolved"),
  TerminalData("terminal.data"),
  TerminalExit("terminal.exit"),
  UpdateAvailable("update.available"),
}
