spb/zyquo-atlas Public License
The AI-native macOS web browser — every surface, intelligent.
Swift 75.2%
JavaScript 22%
Shell 2%
Makefile 0.9%
1//2// Message.swift3// Zyquo Atlas4//5// Author: Simon-Pierre Boucher6// Mail: contact@spboucher.ai7//89import Foundation1011/// One turn in a conversation transcript.12struct Message: Codable, Identifiable, Hashable {13 enum Role: String, Codable {14 case system15 case user16 case assistant17 }1819 let id: UUID20 var role: Role21 var text: String22 /// Reasoning/thinking text streamed by reasoning models (collapsible in the UI).23 var reasoning: String?24 /// Image attachments (user messages, vision models).25 var attachments: [Attachment]26 /// Web-search citations (Perplexity).27 var citations: [Citation]28 /// Model that produced this message (assistant turns) or was targeted (user turns).29 var modelID: String?30 var provider: ProviderID?31 var usage: TokenUsage?32 /// Estimated USD cost computed from catalog pricing at receive time.33 var estimatedCost: Double?34 var createdAt: Date35 /// Set while a response is streaming; exactly one message can be streaming at a time.36 var isStreaming: Bool = false37 /// Human-readable error if generation failed mid-message.38 var errorText: String?3940 init(41 id: UUID = UUID(),42 role: Role,43 text: String,44 reasoning: String? = nil,45 attachments: [Attachment] = [],46 citations: [Citation] = [],47 modelID: String? = nil,48 provider: ProviderID? = nil,49 usage: TokenUsage? = nil,50 estimatedCost: Double? = nil,51 createdAt: Date = Date()52 ) {53 self.id = id54 self.role = role55 self.text = text56 self.reasoning = reasoning57 self.attachments = attachments58 self.citations = citations59 self.modelID = modelID60 self.provider = provider61 self.usage = usage62 self.estimatedCost = estimatedCost63 self.createdAt = createdAt64 }65}6667/// A file attached to a user message. Images go to vision models as base64;68/// text files are injected into the prompt.69struct Attachment: Codable, Identifiable, Hashable {70 enum Kind: String, Codable {71 case image72 case textFile73 }7475 let id: UUID76 var kind: Kind77 var fileName: String78 /// image: raw image bytes; textFile: UTF-8 contents.79 var data: Data80 /// MIME type for images (image/png, image/jpeg, image/webp, image/gif).81 var mimeType: String8283 init(id: UUID = UUID(), kind: Kind, fileName: String, data: Data, mimeType: String) {84 self.id = id85 self.kind = kind86 self.fileName = fileName87 self.data = data88 self.mimeType = mimeType89 }90}9192/// A numbered web source backing an assistant answer (Perplexity sonar family).93struct Citation: Codable, Identifiable, Hashable {94 let id: UUID95 var index: Int96 var url: URL97 var title: String?9899 init(id: UUID = UUID(), index: Int, url: URL, title: String? = nil) {100 self.id = id101 self.index = index102 self.url = url103 self.title = title104 }105}106