Chapter 13: Bridging Two Worlds
The most used interface on the planet is not a web browser. It is not a mobile app. It is not a terminal.
It is iMessage.
By spring 2026, the author had built a powerful AI infrastructure — local LLMs, security tools, intelligence pipelines, agent frameworks, voice capabilities. But it was locked behind a terminal. To use it, you needed to open a terminal, type commands, parse output. It was powerful, but it was not accessible.
The question was simple: What if you could talk to your AI through the most natural interface you already use?
The Moment of Exclusion
It was 8:15 PM on a Friday. The author’s family group chat was active — photos of the weekend hike, plans for Sunday dinner, a joke about the weather. Then a message appeared: “Hey, can you check if my laptop is secure? I got a weird email.”
The author wanted to help. But to help, they needed to:
- Open a terminal
- Run a security scan
- Parse the results
- Explain the findings in plain language
- Send the response back to iMessage
It was doable. But it was not natural. The family member had asked a simple question through the most natural interface available — iMessage. The author’s response required leaving that interface entirely.
“I built these tools to protect myself,” the author thought. “But my family can’t use them.”
This was the accessibility problem in action. The PAI was powerful, but it was locked behind a terminal. Anyone who wanted to use it needed to understand the CLI, navigate the project structure, remember commands and flags. It was fine for the author — a security architect comfortable with terminals. But it was a barrier for everyone else.
That was the moment the question formed: What if the PAI could talk through iMessage?
The Interface Problem
The PAI was capable but inaccessible. Anyone who wanted to use it needed to:
- Understand the CLI and its commands
- Navigate the project structure to find the right tool
- Remember commands and flags
- Parse structured output (JSON, CSV, plain text)
This was fine for the author — a security architect comfortable with terminals. But it was a barrier for everyone else. Family members who wanted security alerts about their own devices. Colleagues who wanted intelligence briefings without opening a terminal. Friends who wanted to query documents but didn’t know what a CLI was.
Before glass-messages, the author’s approach to accessibility was informal and inconsistent. Family members who wanted security alerts were told to “ask me later.” Colleagues who wanted intelligence briefings were given printed reports. Friends who wanted to query documents were told to “learn the CLI.”
This wasn’t just inconvenient. It was exclusionary. An infrastructure that only the builder can use is not an infrastructure — it’s a toy. The PAI needed interfaces that anyone could use — interfaces that didn’t require technical training, that felt natural, that met users where they already were.
The choice wasn’t between accessible and inaccessible interfaces. It was between accessible interfaces and acceptance of exclusion. And for someone who valued both utility and inclusivity, that was an unsustainable tradeoff.
This realization led to two interface projects: glass-messages (bridging to iMessage) and ARC (the web chat interface). Both were built on the same principle: meet users where they are, not where you wish they would be.
The iMessage Insight
The insight came from an unexpected direction. The author’s family group chat was active daily — photos, plans, questions, jokes. iMessage was where life happened. If the PAI could participate in that conversation, it would be instantly accessible to everyone.
But iMessage is not an open platform. Apple does not provide official APIs for sending or receiving iMessage messages programmatically. The ecosystem is closed, walled, and deliberately restrictive.
For most developers, this would be a dead end. For a security architect, it was a challenge — and challenges are what the PAI was built for.
The Breakthrough
The breakthrough came from understanding the protocol beneath the interface.
iMessage messages are not magic — they are data. They flow through Apple’s servers, encrypted end-to-end, but the encryption is between devices, not between the device and the network. On the device itself, messages are stored in a database, accessible to processes with the right privileges.
The author investigated the iMessage database structure, the message flow, and the available hooks. The result was surprising: while Apple does not provide official APIs, there are undocumented interfaces and third-party frameworks that can interact with iMessage at a low level.
The first attempt at iMessage integration was embarrassingly simple. The author tried to hack Apple’s proprietary protocol — reverse-engineering the message format, intercepting the database, sending messages through undocumented APIs. It worked. For a moment.
Then it broke. Not gradually — all at once. Apple released a macOS update, and the undocumented API changed. The hack stopped working. The author spent three days debugging, only to discover that Apple had patched the vulnerability.
“I built a hack that breaks with every update,” the author noted. “That’s not a bridge. That’s a house of cards.”
The problem wasn’t the iMessage integration — it was the assumption that hacking Apple’s protocol was sustainable. A bridge needs to be maintainable, ethical, and aligned with the sovereignty principle. A hack is fragile, unethical, and dependent on someone else’s whims.
This was the first lesson in bridge architecture: bridges use accessible interfaces; hacks use undocumented ones. Bridges are maintainable; hacks are fragile.
The author chose a different approach — one that was more aligned with the PAI philosophy:
Instead of hacking iMessage, bridge it. Build a service that receives messages from iMessage (via a macOS accessibility feature) and sends messages to iMessage (via the same feature). The service would be a bridge between the PAI and iMessage, not a hack into Apple’s ecosystem.
This approach was more elegant, more maintainable, and more aligned with the sovereignty principle. The PAI would not depend on undocumented Apple APIs — it would use accessible, documented interfaces.
What Was Built
glass-messages became a bridge between the PAI and iMessage. The capabilities that emerged didn’t arrive all at once. They developed gradually, each one responding to a specific limitation that became visible only after the previous capability was in place.
Message ingestion came first — the basic ability to detect and extract iMessage conversations. This was the threshold feature: without it, there was no bridge. But early ingestion was naive — a simple keyword match that triggered on any message containing “@sam”. It worked, but it was rigid. There was no way to specify different triggers for different conversations.
PAI processing emerged from the realization that raw messages needed context. A message like “What’s the security status?” meant nothing without knowing which conversation, which sender, which history. But early processing was simple — a flat prompt with no context loading.
Message delivery came last — the ability to send responses back through the same accessible interface. This required understanding the AppleScript API, the accessibility hooks, and the timing constraints of the iMessage client.
// glass-messages — First iMessage bridge (May 2026)
// Note: This was NOT the final architecture.
// The two-component design came later.
// The trigger detection was added after the first false positive.
// First attempt: Direct database hack
// Failed: Broke with macOS updates
// Unmaintainable, unethical, fragile
async function sendIMessage(conversation: string, text: string) {
// Hack into iMessage database
const db = await openIMessageDB();
await db.insert({ conversation, text, timestamp: Date.now() });
}
// Second attempt: Accessibility API
// Worked: More stable
// Problem: No trigger detection, no context
const app = AXUIElementCreateApplication(getiMessageProcessID());
await typeText(app, text);
await pressKey(app, 'Return');
// Final approach: Two-component bridge
// Required: macOS agent + backend service
// Result: Maintainable, ethical, scalable
class GlassMessagesBridge {
async handleMessage(event: MessageEvent): Promise<void> {
// Validate trigger
if (!this.isTriggered(event.text)) return;
// Extract prompt
const prompt = this.extractPrompt(event.text);
// Load context
const context = await this.loadConversationContext(event.conversation);
// Process through PAI
const response = await this.pai.process(prompt, context);
// Deliver response
await this.deliverResponse(event.conversation, response);
}
}
The Bridge Architecture
glass-messages was built as a two-component system:
macOS Agent. A lightweight macOS application that monitored iMessage conversations using Accessibility API hooks. It detected trigger messages, extracted content, and forwarded events to the backend service.
Backend Service. A Bun-based HTTP service that received events from the macOS agent, processed them through the PAI, and sent responses back to the macOS agent for delivery.
iMessage → macOS Agent → glass-messages API → PAI → glass-messages API → macOS Agent → iMessage
The separation was deliberate. The macOS agent handled the platform-specific iMessage interaction. The backend service handled the PAI integration. Each component could evolve independently.
# Course Corrections — glass-messages Development Timeline
| Date | Commit | What Changed | Why |
|------|--------|-------------|-----|
| 2026-05-08 | `60e3d21` | Initial iMessage bridge | First working prototype |
| 2026-05-09 | `3ee0b8f` | Use pai-glass-messages wrapper | macOS showed "bash" in Login Items instead of service name |
| 2026-05-09 | `43f2740` | Add launch.sh, migrate plist to env-file | Hardcoded paths broke on migration |
| 2026-05-09 | `5b1028c` | Add unread message counts, 300s safety-net poll | Initial poll was too aggressive |
| 2026-05-09 | `4fb7174` | Exclude filtered and empty chats | Chat list was noisy |
| 2026-05-11 | `a961f5b` | Reliable unread badges, clickable files/urls | Badges were unreliable, links didn't work |
| 2026-05-24 | `6a2e8fe` | Refactor applescript, db, and ui modules | Code had grown unmaintainable |
| 2026-09-03 | `6689714` | Update widget URLs to HTTPS | TLS proxy required HTTPS |
The Integration
glass-messages integrated with multiple PAI services:
jay-gentic → Primary processing engine. Messages were routed to jay-gentic for natural language understanding and response generation.
voice-server → Optional voice responses. For certain conversations, responses could be synthesized and sent as voice messages.
awareness → Intelligence context. Responses could include current threat intelligence or security briefings.
cyber-alert-mgr → Alert delivery. Critical security alerts could be delivered directly to iMessage conversations.
This integration meant that the PAI was no longer locked behind a terminal. It was accessible through the most natural interface available — the one the author already used every day.
The Impact
glass-messages was a milestone in the PAI’s evolution from technical tool to accessible infrastructure. It demonstrated that:
Any channel can be an interface. iMessage is not an official AI platform, but it can be bridged. The principle is universal: if people are already using a channel, make your infrastructure accessible through it.
Bridges are better than hacks. Instead of hacking Apple’s proprietary protocol, glass-messages built a bridge using accessible interfaces. This is more maintainable, more ethical, and more aligned with the sovereignty principle.
Accessibility expands utility. An infrastructure that anyone can use is more valuable than one only the builder can use.
Context matters. By loading conversation history and sender context, glass-messages enabled contextual responses — the PAI remembered previous messages in the conversation.
The First Real Bridge Interaction
The first time someone else experienced glass-messages’ iMessage bridge, it was accidental. A family member was visiting, and the author had left a terminal open with the bridge running. The family member sent a message to the group chat: “@sam, is my laptop secure?”
Within seconds, a response appeared in the chat: “Running security scan… Found 3 issues. 1. Outdated macOS. 2. Weak password. 3. Unknown app. Want details?”
“Did you just… reply to me in iMessage?” the family member asked.
“Yes.”
“Locally?”
“Locally. And proactively. It didn’t wait for me to ask.”
The family member watched as the bridge continued — running the scan, generating the report, delivering the response. The entire interaction took about thirty seconds.
“Does it… know what it’s doing?”
“No. It’s following rules. But the rules are mine. The tools are mine. The output is mine.”
The family member didn’t ask to use it. They didn’t need to. The demonstration was sufficient. But the look on their face — the realization that a system could respond through iMessage, that the PAI was accessible through the most natural interface available — was the validation the author hadn’t known they needed.
The Lesson
The most powerful interfaces are the ones people already use. Building new interfaces is hard. Bridging to existing ones is smarter.
The glass-messages project teaches us that:
-
Meet users where they are. iMessage was already part of the author’s daily life. Bridging to it was more effective than building a new app.
-
Bridges over hacks. Use accessible, documented interfaces when possible. Bridges are maintainable; hacks are fragile.
-
Accessibility expands utility. An infrastructure that anyone can use is more valuable than one only the builder can use.
-
Context enables conversation. Loading conversation history enables contextual responses, making the interaction feel natural.
-
Failure is data. The first iMessage hack broke — and that breakage taught the author something essential about sustainable architecture. Every failure is information.
Code Snippets
Message Trigger Detection
// glass-messages — Trigger detection
// Evolution: First version matched any message.
// Second version added @sam trigger.
// Third version added configurable triggers per conversation.
const TRIGGERS = ['@sam', 'pai:', 'security:', 'briefing:'];
function isTriggered(text: string): boolean {
return TRIGGERS.some(trigger => text.toLowerCase().includes(trigger));
}
function extractPrompt(text: string): string {
const trigger = TRIGGERS.find(t => text.toLowerCase().includes(t));
if (!trigger) return text;
const index = text.toLowerCase().indexOf(trigger.toLowerCase());
return text.substring(index + trigger.length).trim();
}
Response Delivery
// glass-messages — iMessage delivery
// First attempt: Direct database write (broke with macOS updates)
// Second attempt: AppleScript (worked but slow)
// Final: Accessibility API with debounce
async function sendiMessage(conversation: string, text: string): Promise<void> {
// Use Accessibility API to send message
const app = AXUIElementCreateApplication(
getiMessageProcessID()
);
// Find conversation window
const window = await findConversationWindow(app, conversation);
// Send message
await typeText(window, text);
await pressKey(window, 'Return');
}
Chapter Closing
The chapters ahead will show you how glass-messages became the foundation for the PAI’s interface architecture — how iMessage bridging, trigger detection, and context loading transformed the infrastructure from terminal-locked to universally accessible. But before that evolution, there was another question forming.
If the PAI can talk through iMessage, what else should it talk through?
The answer would require more than a bridge. It would require a unified interface — a web-based chat application that integrated all PAI services into a single, coherent experience. It would require a face.
The next chapter will explore that question — and the breakthrough that gave the PAI a web presence.
Chapter Summary
Chapter 13 documents the construction of glass-messages, the bridge between the PAI and iMessage — the most used interface on the planet. The breakthrough was recognizing that instead of hacking Apple’s proprietary protocol, the PAI should build a bridge using accessible interfaces: a macOS agent using Accessibility API hooks to monitor and send iMessage conversations, and a Bun backend service for PAI integration. The two-component architecture separated platform-specific interaction (macOS agent) from PAI integration (backend service), allowing each to evolve independently. The chapter establishes that any channel can be an interface — if people are already using it, make your infrastructure accessible through it. Bridges are better than hacks: more maintainable, more ethical, more aligned with sovereignty. The trigger detection system (@sam, pai:, security:, briefing:) enabled natural conversation patterns. Context loading from conversation history enabled contextual responses, making interactions feel natural rather than robotic. The chapter also documents the course corrections taken during development — from the initial database hack that broke with macOS updates, to the wrapper script fix that made macOS display the correct service name, to the refactor that made the codebase maintainable.
Key Technical Facts
| Detail | Value |
|---|---|
| Project | glass-messages |
| First Commit | 2026-05-08 (60e3d21) |
| Binary Created | 2026-05-09 (fd8489c1) |
| Language | TypeScript (backend), AppleScript (macOS agent) |
| Key Innovation | iMessage bridge using Accessibility API |
| Architecture | Two-component: macOS agent + backend service |
| Integration | jay-gentic, voice-server, awareness, cyber-alert-mgr |
| Course Corrections | 8+ commits fixing reliability, UI, and architecture issues |
Narrative Threads to Carry Forward
- Any channel can be an interface
- Bridges over hacks
- Accessibility as requirement
- Context enables conversation
- Failure is data
- The PAI gaining a face