2025-12-14 00:17:07 +00:00
|
|
|
import Foundation
|
|
|
|
|
|
2026-01-27 12:19:58 +00:00
|
|
|
public enum MoltbotChatTransportEvent: Sendable {
|
2025-12-14 00:17:07 +00:00
|
|
|
case health(ok: Bool)
|
|
|
|
|
case tick
|
2026-01-27 12:19:58 +00:00
|
|
|
case chat(MoltbotChatEventPayload)
|
|
|
|
|
case agent(MoltbotAgentEventPayload)
|
2025-12-14 00:17:07 +00:00
|
|
|
case seqGap
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 12:19:58 +00:00
|
|
|
public protocol MoltbotChatTransport: Sendable {
|
|
|
|
|
func requestHistory(sessionKey: String) async throws -> MoltbotChatHistoryPayload
|
2025-12-14 00:17:07 +00:00
|
|
|
func sendMessage(
|
|
|
|
|
sessionKey: String,
|
|
|
|
|
message: String,
|
|
|
|
|
thinking: String,
|
|
|
|
|
idempotencyKey: String,
|
2026-01-27 12:19:58 +00:00
|
|
|
attachments: [MoltbotChatAttachmentPayload]) async throws -> MoltbotChatSendResponse
|
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-27 12:19:58 +00:00
|
|
|
func listSessions(limit: Int?) async throws -> MoltbotChatSessionsListResponse
|
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-27 12:19:58 +00:00
|
|
|
func events() -> AsyncStream<MoltbotChatTransportEvent>
|
2025-12-14 00:17:07 +00:00
|
|
|
|
|
|
|
|
func setActiveSessionKey(_ sessionKey: String) async throws
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 12:19:58 +00:00
|
|
|
extension MoltbotChatTransport {
|
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-27 12:19:58 +00:00
|
|
|
domain: "MoltbotChatTransport",
|
2025-12-17 15:51:31 +01:00
|
|
|
code: 0,
|
|
|
|
|
userInfo: [NSLocalizedDescriptionKey: "chat.abort not supported by this transport"])
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 12:19:58 +00:00
|
|
|
public func listSessions(limit _: Int?) async throws -> MoltbotChatSessionsListResponse {
|
2025-12-17 15:51:31 +01:00
|
|
|
throw NSError(
|
2026-01-27 12:19:58 +00:00
|
|
|
domain: "MoltbotChatTransport",
|
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
|
|
|
}
|