Files
openclaw/apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift

46 lines
1.5 KiB
Swift
Raw Normal View History

import Foundation
2026-01-30 03:15:10 +01:00
public enum OpenClawChatTransportEvent: Sendable {
case health(ok: Bool)
case tick
2026-01-30 03:15:10 +01:00
case chat(OpenClawChatEventPayload)
case agent(OpenClawAgentEventPayload)
case seqGap
}
2026-01-30 03:15:10 +01:00
public protocol OpenClawChatTransport: Sendable {
func requestHistory(sessionKey: String) async throws -> OpenClawChatHistoryPayload
func sendMessage(
sessionKey: String,
message: String,
thinking: String,
idempotencyKey: String,
2026-01-30 03:15:10 +01:00
attachments: [OpenClawChatAttachmentPayload]) async throws -> OpenClawChatSendResponse
func abortRun(sessionKey: String, runId: String) async throws
2026-01-30 03:15:10 +01:00
func listSessions(limit: Int?) async throws -> OpenClawChatSessionsListResponse
func requestHealth(timeoutMs: Int) async throws -> Bool
2026-01-30 03:15:10 +01:00
func events() -> AsyncStream<OpenClawChatTransportEvent>
func setActiveSessionKey(_ sessionKey: String) async throws
}
2026-01-30 03:15:10 +01:00
extension OpenClawChatTransport {
public func setActiveSessionKey(_: String) async throws {}
public func abortRun(sessionKey _: String, runId _: String) async throws {
throw NSError(
2026-01-30 03:15:10 +01:00
domain: "OpenClawChatTransport",
code: 0,
userInfo: [NSLocalizedDescriptionKey: "chat.abort not supported by this transport"])
}
2026-01-30 03:15:10 +01:00
public func listSessions(limit _: Int?) async throws -> OpenClawChatSessionsListResponse {
throw NSError(
2026-01-30 03:15:10 +01:00
domain: "OpenClawChatTransport",
code: 0,
userInfo: [NSLocalizedDescriptionKey: "sessions.list not supported by this transport"])
}
}