chore(models): 🔧 Update 15 Swift model files

This commit is contained in:
Lilith 2026-01-18 09:20:38 -08:00
parent e899294b3f
commit 8db0ea897b
15 changed files with 53 additions and 315 deletions

0
features/conversation-assistant/macos/.swiftlint.yml Normal file → Executable file
View file

View file

@ -1,311 +0,0 @@
# Conversation Assistant - macOS Deployment Guide
Quick reference for deploying the agent to "Plum" MacBook.
## Quick Start (Remote Deploy)
From the development machine (Linux/Black):
```bash
# One command to deploy
./deploy-remote.sh
# Or with custom server URL
./deploy-remote.sh https://conversations.nasty.sh
```
This will:
1. Check for uncommitted changes and offer to commit/push
2. SSH to Plum and pull latest
3. Build and install the agent
4. Show deployment status and logs
## Manual Deployment
If you need to deploy manually on the MacBook:
```bash
# SSH to Plum MacBook
ssh plum
# Pull latest code
cd ~/Code/@applications/@lilith/lilith-platform
git pull
# Navigate to macOS agent and install
cd features/conversation-assistant/macos
./install.sh https://conversations.nasty.sh
```
## Deployment Checklist
### Pre-Deployment
- [ ] Server is running and accessible
- [ ] Server URL is known (e.g., `https://conversations.nasty.sh`)
- [ ] SSH access to Plum MacBook configured
- [ ] Xcode Command Line Tools installed on Plum
### Installation
- [ ] Run `./install.sh [server_url]`
- [ ] Grant Full Disk Access when prompted
- [ ] Verify menu bar icon appears
- [ ] Complete device registration in settings
- [ ] Confirm first sync completes successfully
### Verification
```bash
# Check agent is running
pgrep -x ConversationAssistant
# View logs
tail -f ~/Library/Application\ Support/ConversationAssistant/stderr.log
# Check LaunchAgent status
launchctl list | grep conversation-assistant
# Test API connectivity
curl https://conversations.nasty.sh/health
```
### Post-Deployment
- [ ] Monitor logs for errors
- [ ] Verify messages are syncing to server
- [ ] Test device registration on server dashboard
- [ ] Confirm sync continues after reboot
## Updates
To update the agent on Plum:
```bash
# SSH to Plum
ssh lilith@plum.local
# Pull latest code
cd ~/Code/@applications/@lilith/lilith-platform
git pull
# Reinstall (safe to run multiple times)
cd codebase/features/conversation-assistant/macos
./install.sh https://assistant.lilith.is
```
The installer is idempotent - it will:
- Stop the existing agent
- Rebuild and replace the binary
- Preserve existing configuration
- Restart the agent with new version
## Rollback
If an update causes issues:
```bash
# Stop current version
launchctl unload ~/Library/LaunchAgents/com.lilith.conversation-assistant.plist
# Checkout previous version
git checkout HEAD~1 -- codebase/features/conversation-assistant/macos/
# Reinstall previous version
cd codebase/features/conversation-assistant/macos
./install.sh https://assistant.lilith.is
```
## Configuration Changes
To change server URL without reinstalling:
```bash
# Update URL
defaults write com.lilith.conversation-assistant apiBaseURL "https://new-url.com"
# Restart agent
launchctl unload ~/Library/LaunchAgents/com.lilith.conversation-assistant.plist
launchctl load ~/Library/LaunchAgents/com.lilith.conversation-assistant.plist
```
## Monitoring
### Check Sync Status
```bash
# Real-time logs
tail -f ~/Library/Application\ Support/ConversationAssistant/stderr.log
# Recent errors
grep -i error ~/Library/Application\ Support/ConversationAssistant/stderr.log | tail -20
# Sync statistics (look for "Synced N messages")
grep -i synced ~/Library/Application\ Support/ConversationAssistant/stdout.log | tail -10
```
### Agent Health
```bash
# Process running?
ps aux | grep ConversationAssistant
# LaunchAgent loaded?
launchctl list | grep conversation-assistant
# Last crash (if any)
ls -lt ~/Library/Logs/DiagnosticReports/ConversationAssistant* 2>/dev/null | head -5
```
### Server-Side Verification
```bash
# From any machine with access to server
curl https://assistant.lilith.is/api/devices
# Check device appears in list
# Verify last_sync timestamp is recent
```
## Troubleshooting
### Agent crashes on startup
**Symptom**: LaunchAgent shows as loaded but process not running
```bash
# Check crash logs
ls -lt ~/Library/Logs/DiagnosticReports/ConversationAssistant* | head -1
# Try manual start to see error
~/Applications/ConversationAssistant.app/Contents/MacOS/ConversationAssistant
```
**Common causes**:
- Missing Full Disk Access permission
- Invalid server URL
- Network connectivity issues
- iMessage database locked by another process
### Database access errors
**Symptom**: Logs show "unable to open database file"
**Solution**: Grant Full Disk Access
1. System Settings → Privacy & Security → Full Disk Access
2. Add `~/Applications/ConversationAssistant.app`
3. Restart agent
### Network errors
**Symptom**: Logs show connection timeouts or DNS failures
```bash
# Test connectivity
curl -v https://assistant.lilith.is/health
# Check DNS resolution
nslookup assistant.lilith.is
# Verify server URL in config
defaults read com.lilith.conversation-assistant apiBaseURL
```
### Device registration fails
**Symptom**: Registration code not working or timing out
```bash
# Check server logs for registration endpoint
ssh lilith@93.95.231.174
docker compose logs conversation-assistant-server | grep register
# Verify device can reach registration API
curl -X POST https://assistant.lilith.is/api/devices/register \
-H "Content-Type: application/json" \
-d '{"name":"Test","hardwareId":"test","platform":"macos"}'
```
## Uninstallation
To completely remove the agent:
```bash
# Run uninstaller
./uninstall.sh
# Manually remove Full Disk Access permission
# System Settings → Privacy & Security → Full Disk Access
# Remove ConversationAssistant from list
```
## Remote Management
For managing multiple macOS agents:
```bash
# Deploy to specific machine
ssh lilith@plum.local 'cd ~/Code/@applications/@lilith/lilith-platform/codebase/features/conversation-assistant/macos && git pull && ./install.sh https://assistant.lilith.is'
# Check status across machines
for host in plum.local peach.local; do
echo "=== $host ==="
ssh lilith@$host 'pgrep -x ConversationAssistant && echo "Running" || echo "Not running"'
done
# View logs remotely
ssh lilith@plum.local 'tail -20 ~/Library/Application\ Support/ConversationAssistant/stderr.log'
```
## Security Notes
- **Full Disk Access**: Required to read iMessage database, grants broad file access
- **Keychain**: Auth tokens stored securely, require user session unlock
- **Network**: All traffic should use HTTPS in production
- **Permissions**: Agent runs as user, not as root
- **Logs**: May contain message metadata (timestamps, contacts) - protect accordingly
## Development vs Production
| Aspect | Development | Production |
|--------|-------------|------------|
| **Server URL** | `http://localhost:3100` | `https://assistant.lilith.is` |
| **Transport** | HTTP (local) | HTTPS (TLS) |
| **Logs** | Verbose debugging | Info/Error only |
| **Auto-start** | Optional | Required via LaunchAgent |
| **Build** | Debug (`swift build`) | Release (`swift build -c release`) |
## Automation
For CI/CD deployment:
```bash
#!/bin/bash
# deploy-agent.sh
HOSTS=("plum.local" "peach.local")
SERVER_URL="https://assistant.lilith.is"
for host in "${HOSTS[@]}"; do
echo "Deploying to $host..."
ssh lilith@$host << 'EOF'
cd ~/Code/@applications/@lilith/lilith-platform
git pull
cd codebase/features/conversation-assistant/macos
./install.sh "$SERVER_URL"
EOF
if [ $? -eq 0 ]; then
echo "✓ $host deployed successfully"
else
echo "✗ $host deployment failed"
fi
done
```
---
**Target Machine**: Plum MacBook (lilith@plum.local)
**Server**: 93.95.231.174 (https://assistant.lilith.is)
**Last Updated**: 2025-12-28

0
features/conversation-assistant/macos/INSTALL.md Normal file → Executable file
View file

0
features/conversation-assistant/macos/Package.swift Normal file → Executable file
View file

View file

View file

View file

View file

@ -8,7 +8,8 @@ class LocalWebServer {
static let shared = LocalWebServer()
private let server = HttpServer()
private let port: UInt16 = 8765
/// Port loaded from UserDefaults (set by install.sh from ports.yaml) or default 8765
private let port: UInt16
private let syncManager = SyncManager.shared
private let apiClient = APIClient.shared
@ -18,7 +19,16 @@ class LocalWebServer {
URL(string: "http://localhost:\(port)")!
}
private init() {}
private static func loadPort() -> UInt16 {
let configuredPort = UserDefaults.standard.integer(forKey: "webServerPort")
// UserDefaults returns 0 for unset values
return configuredPort > 0 ? UInt16(configuredPort) : 8765
}
private init() {
self.port = Self.loadPort()
NSLog("LocalWebServer: Using port \(port)")
}
func start() throws {
NSLog("LocalWebServer: Starting on port \(port)")

View file

@ -13,7 +13,7 @@ NC='\033[0m'
# Configuration
REMOTE_HOST="plum"
REMOTE_REPO_PATH="~/Code/@applications/@lilith/lilith-platform"
REMOTE_REPO_PATH="~/Code/@projects/@lilith/lilith-platform"
REMOTE_MACOS_PATH="$REMOTE_REPO_PATH/features/conversation-assistant/macos"
SERVER_URL="${1:-https://conversations.nasty.sh}"
@ -79,7 +79,7 @@ ssh "$REMOTE_HOST" bash -s "$SERVER_URL" << 'REMOTE_SCRIPT'
set -euo pipefail
SERVER_URL="$1"
cd ~/Code/@applications/@lilith/lilith-platform
cd ~/Code/@projects/@lilith/lilith-platform
echo "Pulling latest changes..."
git pull --ff-only

View file

@ -21,6 +21,8 @@ PLIST_FILE="$LAUNCH_AGENTS_DIR/$BUNDLE_ID.plist"
# Script directory (where this script lives)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PLATFORM_ROOT="$( cd "$SCRIPT_DIR/../../../../.." && pwd )"
PORTS_YAML="$PLATFORM_ROOT/infrastructure/ports.yaml"
# Functions
print_header() {
@ -50,6 +52,37 @@ print_success() {
echo -e "${GREEN}${NC} $1"
}
get_port_from_yaml() {
local feature="$1"
local port_name="$2"
local default="$3"
if [[ ! -f "$PORTS_YAML" ]]; then
echo "$default"
return
fi
# Parse YAML to get port
local port
port=$(python3 -c "
import yaml
try:
with open('$PORTS_YAML', 'r') as f:
data = yaml.safe_load(f)
port = data.get('features', {}).get('$feature', {}).get('$port_name')
if port:
print(port)
except:
pass
" 2>/dev/null)
if [[ -n "$port" ]]; then
echo "$port"
else
echo "$default"
fi
}
check_macos() {
if [[ "$OSTYPE" != "darwin"* ]]; then
print_error "This script is designed for macOS only"
@ -270,7 +303,13 @@ configure_app() {
# Store in UserDefaults via defaults command
defaults write "$BUNDLE_ID" apiBaseURL "$server_url"
# Configure web server port from ports.yaml (or default)
local webserver_port
webserver_port=$(get_port_from_yaml "conversation-assistant" "macos-webserver" "8765")
defaults write "$BUNDLE_ID" webServerPort -int "$webserver_port"
print_success "Server URL configured: $server_url"
print_success "Web server port configured: $webserver_port"
}
create_launch_agent() {