oficina / memoria Public

Clone
git clone https://amadan.net/oficina/memoria

Plain git — no account needed to clone.

Download

Download this file

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