Native macOS counterpart to the web Omega agent, connecting directly to the OpenAI API and TPMJS tool registry (1M+ AI-ready tools). - SwiftUI app targeting macOS 15+ with dark theme - Full agentic loop: auto-discover tools via BM25, stream OpenAI responses, execute tools via remote sandbox, loop up to 10x - SwiftData persistence for conversations, messages, tool runs - Keychain storage for API keys and environment variables - SSE streaming via URLSession.bytes with custom parser - Actor-based services (OpenAIService, TPMJSRegistryService) - NavigationSplitView layout with sidebar + chat detail - MarkdownUI for rendering assistant responses - Settings: API key, model picker, env vars, custom system prompt - Keyboard shortcuts: Cmd+N new chat, Cmd+, settings, Enter send Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
993 B
Swift
41 lines
993 B
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
@Model
|
|
final class Conversation {
|
|
var id: UUID
|
|
var title: String?
|
|
var createdAt: Date
|
|
var updatedAt: Date
|
|
var executionState: String // "idle" | "running"
|
|
var inputTokensTotal: Int
|
|
var outputTokensTotal: Int
|
|
|
|
@Relationship(deleteRule: .cascade, inverse: \Message.conversation)
|
|
var messages: [Message]
|
|
|
|
@Relationship(deleteRule: .cascade, inverse: \ToolCallRecord.conversation)
|
|
var toolRuns: [ToolCallRecord]
|
|
|
|
init(
|
|
title: String? = nil
|
|
) {
|
|
self.id = UUID()
|
|
self.title = title
|
|
self.createdAt = Date()
|
|
self.updatedAt = Date()
|
|
self.executionState = "idle"
|
|
self.inputTokensTotal = 0
|
|
self.outputTokensTotal = 0
|
|
self.messages = []
|
|
self.toolRuns = []
|
|
}
|
|
|
|
var displayTitle: String {
|
|
title ?? "New Conversation"
|
|
}
|
|
|
|
var sortedMessages: [Message] {
|
|
messages.sorted { $0.createdAt < $1.createdAt }
|
|
}
|
|
}
|