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