mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 13:55:45 +00:00
* fix(ios): defer QR pairing after scanner dismissal * fix(ios): process QR pairing after scanner dismissal * fix(ios): harden QR scanner handoff * fix(ios): give QR scanner dismissal more time * fix(ios): keep onboarding open for QR trust prompt * fix(ios): keep QR trust prompt owned by onboarding * fix(ios): recover operator pairing after QR bootstrap * fix(ios): cancel stale QR scanner handoffs Co-authored-by: PollyBot13 <pollybot13@gmail.com> * fix(ios): defer QR setup until onboarding closes * fix(ios): keep QR setup links with visible settings * fix(ios): consume setup links during onboarding * fix(ios): handle setup links during onboarding launch * fix(ios): route setup links through active onboarding * fix(ios): harden QR gateway handoff * fix(ios): cancel superseded gateway attempts * fix(ios): serialize scanner result delivery * fix(ios): prevent stale gateway reconnects * fix(ios): serialize gateway target handoff * fix(ios): disable stale gateway relaunch route * fix(ios): await staged bootstrap reset * test(ios): bound gateway reset handoff * fix(ios): preserve explicit gateway handoff * fix(ios): harden gateway lifecycle ownership * chore(ios): sync native i18n inventory * test(ios): align gateway ownership assertions * refactor(ios): remove superseded gateway helpers * fix(ios): keep gateway auth route scoped * fix(ios): restore gateway target review state * fix(protocol): refresh Swift plugin approval model * test(ios): isolate state directory overrides * fix(ios): preserve watch alerts across gateway switches * fix(ios): bind deferred work to gateway ownership * docs(changelog): credit iOS gateway handoff fix * chore(i18n): sync native app inventory * test(ios): remove unused Watch approval hooks --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
423 lines
13 KiB
Swift
423 lines
13 KiB
Swift
import Foundation
|
|
|
|
public enum OpenClawWatchCommand: String, Codable, Sendable {
|
|
case status = "watch.status"
|
|
case notify = "watch.notify"
|
|
}
|
|
|
|
public enum OpenClawWatchPayloadType: String, Codable, Sendable, Equatable {
|
|
case notify = "watch.notify"
|
|
case reply = "watch.reply"
|
|
case appSnapshot = "watch.app.snapshot"
|
|
case appSnapshotRequest = "watch.app.snapshotRequest"
|
|
case appCommand = "watch.app.command"
|
|
case chatCompletion = "watch.chat.completion"
|
|
case execApprovalPrompt = "watch.execApproval.prompt"
|
|
case execApprovalResolve = "watch.execApproval.resolve"
|
|
case execApprovalResolved = "watch.execApproval.resolved"
|
|
case execApprovalExpired = "watch.execApproval.expired"
|
|
case execApprovalSnapshot = "watch.execApproval.snapshot"
|
|
case execApprovalSnapshotRequest = "watch.execApproval.snapshotRequest"
|
|
}
|
|
|
|
public enum OpenClawWatchRisk: String, Codable, Sendable, Equatable {
|
|
case low
|
|
case medium
|
|
case high
|
|
}
|
|
|
|
public enum OpenClawWatchExecApprovalDecision: String, Codable, Sendable, Equatable {
|
|
case allowOnce = "allow-once"
|
|
case deny
|
|
}
|
|
|
|
public enum OpenClawWatchExecApprovalCloseReason: String, Codable, Sendable, Equatable {
|
|
case expired
|
|
case notFound = "not-found"
|
|
case unavailable
|
|
case replaced
|
|
case resolved
|
|
}
|
|
|
|
public struct OpenClawWatchAction: Codable, Sendable, Equatable {
|
|
public var id: String
|
|
public var label: String
|
|
public var style: String?
|
|
|
|
public init(id: String, label: String, style: String? = nil) {
|
|
self.id = id
|
|
self.label = label
|
|
self.style = style
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalItem: Codable, Sendable, Equatable, Identifiable {
|
|
public var id: String
|
|
public var gatewayStableID: String?
|
|
public var commandText: String
|
|
public var commandPreview: String?
|
|
public var host: String?
|
|
public var nodeId: String?
|
|
public var agentId: String?
|
|
public var expiresAtMs: Int?
|
|
public var allowedDecisions: [OpenClawWatchExecApprovalDecision]
|
|
public var risk: OpenClawWatchRisk?
|
|
|
|
public init(
|
|
id: String,
|
|
gatewayStableID: String? = nil,
|
|
commandText: String,
|
|
commandPreview: String? = nil,
|
|
host: String? = nil,
|
|
nodeId: String? = nil,
|
|
agentId: String? = nil,
|
|
expiresAtMs: Int? = nil,
|
|
allowedDecisions: [OpenClawWatchExecApprovalDecision] = [],
|
|
risk: OpenClawWatchRisk? = nil)
|
|
{
|
|
self.id = id
|
|
self.gatewayStableID = gatewayStableID
|
|
self.commandText = commandText
|
|
self.commandPreview = commandPreview
|
|
self.host = host
|
|
self.nodeId = nodeId
|
|
self.agentId = agentId
|
|
self.expiresAtMs = expiresAtMs
|
|
self.allowedDecisions = allowedDecisions
|
|
self.risk = risk
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalPromptMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var approval: OpenClawWatchExecApprovalItem
|
|
public var sentAtMs: Int?
|
|
public var deliveryId: String?
|
|
public var resetResolvingState: Bool?
|
|
|
|
public init(
|
|
approval: OpenClawWatchExecApprovalItem,
|
|
sentAtMs: Int? = nil,
|
|
deliveryId: String? = nil,
|
|
resetResolvingState: Bool? = nil)
|
|
{
|
|
self.type = .execApprovalPrompt
|
|
self.approval = approval
|
|
self.sentAtMs = sentAtMs
|
|
self.deliveryId = deliveryId
|
|
self.resetResolvingState = resetResolvingState
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalResolveMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var approvalId: String
|
|
public var gatewayStableID: String?
|
|
public var decision: OpenClawWatchExecApprovalDecision
|
|
public var replyId: String
|
|
public var sentAtMs: Int?
|
|
|
|
public init(
|
|
approvalId: String,
|
|
gatewayStableID: String? = nil,
|
|
decision: OpenClawWatchExecApprovalDecision,
|
|
replyId: String,
|
|
sentAtMs: Int? = nil)
|
|
{
|
|
self.type = .execApprovalResolve
|
|
self.approvalId = approvalId
|
|
self.gatewayStableID = gatewayStableID
|
|
self.decision = decision
|
|
self.replyId = replyId
|
|
self.sentAtMs = sentAtMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalResolvedMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var approvalId: String
|
|
public var gatewayStableID: String?
|
|
public var decision: OpenClawWatchExecApprovalDecision?
|
|
public var resolvedAtMs: Int?
|
|
public var source: String?
|
|
|
|
public init(
|
|
approvalId: String,
|
|
gatewayStableID: String? = nil,
|
|
decision: OpenClawWatchExecApprovalDecision? = nil,
|
|
resolvedAtMs: Int? = nil,
|
|
source: String? = nil)
|
|
{
|
|
self.type = .execApprovalResolved
|
|
self.approvalId = approvalId
|
|
self.gatewayStableID = gatewayStableID
|
|
self.decision = decision
|
|
self.resolvedAtMs = resolvedAtMs
|
|
self.source = source
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalExpiredMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var approvalId: String
|
|
public var gatewayStableID: String?
|
|
public var reason: OpenClawWatchExecApprovalCloseReason
|
|
public var expiredAtMs: Int?
|
|
|
|
public init(
|
|
approvalId: String,
|
|
gatewayStableID: String? = nil,
|
|
reason: OpenClawWatchExecApprovalCloseReason,
|
|
expiredAtMs: Int? = nil)
|
|
{
|
|
self.type = .execApprovalExpired
|
|
self.approvalId = approvalId
|
|
self.gatewayStableID = gatewayStableID
|
|
self.reason = reason
|
|
self.expiredAtMs = expiredAtMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalSnapshotMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var approvals: [OpenClawWatchExecApprovalItem]
|
|
public var gatewayStableID: String?
|
|
public var sentAtMs: Int?
|
|
public var snapshotId: String?
|
|
|
|
public init(
|
|
approvals: [OpenClawWatchExecApprovalItem],
|
|
gatewayStableID: String? = nil,
|
|
sentAtMs: Int? = nil,
|
|
snapshotId: String? = nil)
|
|
{
|
|
self.type = .execApprovalSnapshot
|
|
self.approvals = approvals
|
|
self.gatewayStableID = gatewayStableID
|
|
self.sentAtMs = sentAtMs
|
|
self.snapshotId = snapshotId
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchExecApprovalSnapshotRequestMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var requestId: String
|
|
public var sentAtMs: Int?
|
|
|
|
public init(requestId: String, sentAtMs: Int? = nil) {
|
|
self.type = .execApprovalSnapshotRequest
|
|
self.requestId = requestId
|
|
self.sentAtMs = sentAtMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchChatItem: Codable, Sendable, Equatable, Identifiable {
|
|
public var id: String
|
|
public var role: String
|
|
public var text: String
|
|
public var timestampMs: Int?
|
|
|
|
public init(
|
|
id: String,
|
|
role: String,
|
|
text: String,
|
|
timestampMs: Int? = nil)
|
|
{
|
|
self.id = id
|
|
self.role = role
|
|
self.text = text
|
|
self.timestampMs = timestampMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchChatCompletionMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var commandId: String
|
|
public var replyText: String
|
|
public var sentAtMs: Int?
|
|
|
|
public init(commandId: String, replyText: String, sentAtMs: Int? = nil) {
|
|
self.type = .chatCompletion
|
|
self.commandId = commandId
|
|
self.replyText = replyText
|
|
self.sentAtMs = sentAtMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchAppSnapshotMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var gatewayStatusText: String
|
|
public var gatewayConnected: Bool
|
|
public var agentName: String
|
|
public var agentAvatarURL: String?
|
|
public var agentAvatarText: String?
|
|
public var sessionKey: String
|
|
public var gatewayStableID: String?
|
|
public var talkStatusText: String
|
|
public var talkEnabled: Bool
|
|
public var talkListening: Bool
|
|
public var talkSpeaking: Bool
|
|
public var pendingApprovalCount: Int
|
|
public var chatItems: [OpenClawWatchChatItem]?
|
|
public var chatStatusText: String?
|
|
public var sentAtMs: Int?
|
|
public var snapshotId: String?
|
|
|
|
public init(
|
|
gatewayStatusText: String,
|
|
gatewayConnected: Bool,
|
|
agentName: String,
|
|
agentAvatarURL: String? = nil,
|
|
agentAvatarText: String? = nil,
|
|
sessionKey: String,
|
|
gatewayStableID: String? = nil,
|
|
talkStatusText: String,
|
|
talkEnabled: Bool,
|
|
talkListening: Bool,
|
|
talkSpeaking: Bool,
|
|
pendingApprovalCount: Int,
|
|
chatItems: [OpenClawWatchChatItem]? = nil,
|
|
chatStatusText: String? = nil,
|
|
sentAtMs: Int? = nil,
|
|
snapshotId: String? = nil)
|
|
{
|
|
self.type = .appSnapshot
|
|
self.gatewayStatusText = gatewayStatusText
|
|
self.gatewayConnected = gatewayConnected
|
|
self.agentName = agentName
|
|
self.agentAvatarURL = agentAvatarURL
|
|
self.agentAvatarText = agentAvatarText
|
|
self.sessionKey = sessionKey
|
|
self.gatewayStableID = gatewayStableID
|
|
self.talkStatusText = talkStatusText
|
|
self.talkEnabled = talkEnabled
|
|
self.talkListening = talkListening
|
|
self.talkSpeaking = talkSpeaking
|
|
self.pendingApprovalCount = pendingApprovalCount
|
|
self.chatItems = chatItems
|
|
self.chatStatusText = chatStatusText
|
|
self.sentAtMs = sentAtMs
|
|
self.snapshotId = snapshotId
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchAppSnapshotRequestMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var requestId: String
|
|
public var sentAtMs: Int?
|
|
|
|
public init(requestId: String, sentAtMs: Int? = nil) {
|
|
self.type = .appSnapshotRequest
|
|
self.requestId = requestId
|
|
self.sentAtMs = sentAtMs
|
|
}
|
|
}
|
|
|
|
public enum OpenClawWatchAppCommand: String, Codable, Sendable, Equatable {
|
|
case refresh
|
|
case openChat = "open-chat"
|
|
case sendChat = "send-chat"
|
|
case startTalk = "start-talk"
|
|
case stopTalk = "stop-talk"
|
|
}
|
|
|
|
public struct OpenClawWatchAppCommandMessage: Codable, Sendable, Equatable {
|
|
public var type: OpenClawWatchPayloadType
|
|
public var command: OpenClawWatchAppCommand
|
|
public var commandId: String
|
|
public var sessionKey: String?
|
|
public var gatewayStableID: String?
|
|
public var text: String?
|
|
public var sentAtMs: Int?
|
|
|
|
public init(
|
|
command: OpenClawWatchAppCommand,
|
|
commandId: String,
|
|
sessionKey: String? = nil,
|
|
gatewayStableID: String? = nil,
|
|
text: String? = nil,
|
|
sentAtMs: Int? = nil)
|
|
{
|
|
self.type = .appCommand
|
|
self.command = command
|
|
self.commandId = commandId
|
|
self.sessionKey = sessionKey
|
|
self.gatewayStableID = gatewayStableID
|
|
self.text = text
|
|
self.sentAtMs = sentAtMs
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchStatusPayload: Codable, Sendable, Equatable {
|
|
public var supported: Bool
|
|
public var paired: Bool
|
|
public var appInstalled: Bool
|
|
public var reachable: Bool
|
|
public var activationState: String
|
|
|
|
public init(
|
|
supported: Bool,
|
|
paired: Bool,
|
|
appInstalled: Bool,
|
|
reachable: Bool,
|
|
activationState: String)
|
|
{
|
|
self.supported = supported
|
|
self.paired = paired
|
|
self.appInstalled = appInstalled
|
|
self.reachable = reachable
|
|
self.activationState = activationState
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchNotifyParams: Codable, Sendable, Equatable {
|
|
public var title: String
|
|
public var body: String
|
|
public var priority: OpenClawNotificationPriority?
|
|
public var promptId: String?
|
|
public var sessionKey: String?
|
|
public var gatewayStableID: String?
|
|
public var kind: String?
|
|
public var details: String?
|
|
public var expiresAtMs: Int?
|
|
public var risk: OpenClawWatchRisk?
|
|
public var actions: [OpenClawWatchAction]?
|
|
|
|
public init(
|
|
title: String,
|
|
body: String,
|
|
priority: OpenClawNotificationPriority? = nil,
|
|
promptId: String? = nil,
|
|
sessionKey: String? = nil,
|
|
gatewayStableID: String? = nil,
|
|
kind: String? = nil,
|
|
details: String? = nil,
|
|
expiresAtMs: Int? = nil,
|
|
risk: OpenClawWatchRisk? = nil,
|
|
actions: [OpenClawWatchAction]? = nil)
|
|
{
|
|
self.title = title
|
|
self.body = body
|
|
self.priority = priority
|
|
self.promptId = promptId
|
|
self.sessionKey = sessionKey
|
|
self.gatewayStableID = gatewayStableID
|
|
self.kind = kind
|
|
self.details = details
|
|
self.expiresAtMs = expiresAtMs
|
|
self.risk = risk
|
|
self.actions = actions
|
|
}
|
|
}
|
|
|
|
public struct OpenClawWatchNotifyPayload: Codable, Sendable, Equatable {
|
|
public var deliveredImmediately: Bool
|
|
public var queuedForDelivery: Bool
|
|
public var transport: String
|
|
|
|
public init(deliveredImmediately: Bool, queuedForDelivery: Bool, transport: String) {
|
|
self.deliveredImmediately = deliveredImmediately
|
|
self.queuedForDelivery = queuedForDelivery
|
|
self.transport = transport
|
|
}
|
|
}
|