// Test-only executable. Receives an isolated fixture credential over stdin. import AppKit import SwiftUI import RastrilloApple import MemoriaKit struct Input: Decodable { let origin: URL; let credential: NativeSession; let output: String } @main struct Review { @MainActor static func main() async throws { let input = try JSONDecoder().decode(Input.self, from: FileHandle.standardInput.readDataToEndOfFile()) guard input.origin.host == "127.0.0.1" else { fatalError("Review accepts only an isolated loopback fixture") } let app = NSApplication.shared app.setActivationPolicy(.accessory) let client = NativeHTTP(origin: input.origin, credential: input.credential) let model = MemoriaModel() model.query = "nebula"; await model.search(client) if model.localModelAvailable { await model.makeAnswer(client); guard !model.answer.isEmpty else { fatalError("On-device generation failed: " + model.error) } } guard model.error.isEmpty else { fatalError("Fixture failed: " + model.error) } let view = NSHostingView(rootView: MemoriaWorkspace(client: client, model: model, signOut: {}).preferredColorScheme(.light).tint(Color(red: 0.48, green: 0.32, blue: 0.68))) let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1100, height: 800), styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false) window.appearance = NSAppearance(named: .aqua) window.contentView = view window.center() window.orderFrontRegardless() try await Task.sleep(for: .seconds(2)) let capture = Process() capture.executableURL = URL(fileURLWithPath: "/usr/sbin/screencapture") capture.arguments = ["-x", "-o", "-l", String(window.windowNumber), input.output] try capture.run() capture.waitUntilExit() guard capture.terminationStatus == 0 else { fatalError("Window capture failed") } } }