# Specification: Aether Native V3 Bridge Interface **Namespace:** `window.native_app` **Security:** Context Isolated, Sandboxed IPC ## 1. Device & Identity (`ae_device`) Functions for bootstrapping the app from the `seed.json`. | Method | Type | Description | | --- | --- | --- | | `getSeed()` | `() => Promise` | Returns the local `event_device_id` and `api_base_url`. | | `getDeviceInfo()` | `() => Promise` | Returns OS, Arch, and unique hardware UUID. | | `getPermissions()`| `() => Promise` | Returns status of Mic, Camera, and Accessibility. | | `requestAccess()` | `(type: string) => Promise` | Triggers macOS TCC permission prompts. | ## 2. Sync Engine (`ae_sync`) The Sync Engine manages the "Cold Cache" (`~/Library/Caches/Aether/`). It handles atomic downloads and hash verification. | Method | Type | Description | | --- | --- | --- | | `getCacheStatus()` | `(file_hash: string) => Promise` | Checks if a file exists and is valid. | | `startSync()` | `(task: SyncRequest) => Promise` | Begins background download of a presentation. | | `cancelSync()` | `(file_hash: string) => Promise` | Aborts an active download. | | `clearCache()` | `() => Promise` | Wipes the cold cache (Maintenance). | ### Events (Main -> Renderer) - `sync:progress`: `{ hash, percent, speed, bytesLoaded }` - `sync:complete`: `{ hash, success, error }` ## 3. Launcher (`ae_launcher`) The "Big Red Button" logic. Handles the hand-off to the OS. | Method | Type | Description | | --- | --- | --- | | `launch()` | `(req: LaunchRequest) => Promise` | 1. Moves file to Temp. 2. Opens with default app. 3. Starts slideshow. | | `killApp()` | `(appName: string) => Promise` | Closes PowerPoint/Keynote/Acrobat gracefully. | | `preventSleep()` | `(enable: boolean) => Promise` | Prevents the laptop from sleeping during a session. | ## 4. System Control (`ae_sys`) Low-level macOS/Windows/Linux wrappers. | Method | Type | Description | | --- | --- | --- | | `setVolume()` | `(level: number) => Promise` | Sets system master volume (0-100). | | `checkForUpdates()`| `() => Promise` | Checks the Syncthing share for a newer version. | | `applyUpdate()` | `() => Promise` | Triggers the `update_helper.sh` and exits. | | `execIntent()` | `(intent: string, args: any) => Promise` | Executes a whitelisted command (e.g. `open-logs-folder`). | --- ## 5. TypeScript Interface (Draft) ```typescript export interface AE_Native_Bridge { device: { getSeed: () => Promise<{ device_id: string; api_url: string }>; requestPermissions: () => Promise; }; sync: { getStatus: (hash: string) => Promise<{ exists: boolean; verified: boolean }>; queueDownload: (payload: { url: string; hash: string; jwt: string }) => void; }; launcher: { launch: (file: { hash: string; name: string; type: 'pptx'|'key'|'pdf' }) => Promise; killAll: () => Promise; }; } ``` ## 6. Podium Reliability Protocol To ensure the podium never fails: 1. **Pre-Flight Check:** The SvelteKit UI will call `sync.getStatus` for every file in the session as soon as the page loads. 2. **Auto-Warmup:** If a file is missing, the UI automatically calls `sync.queueDownload` in the background. 3. **Verification:** The `launcher.launch` command will perform a final `sha256` check on the temp file *before* executing `shell.openPath`.