Skip to content

Add a secure bidirectional FaceTime Realtime voice bridge - #4

Merged
omarshahine merged 17 commits into
mainfrom
agent/paired-audio-bridge
Jul 27, 2026
Merged

omarshahine merged 17 commits into
mainfrom
agent/paired-audio-bridge

Conversation

@omarshahine

@omarshahine omarshahine commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Paired core change: openclaw/openclaw#114163

This PR turns the FaceTime plugin into a working bidirectional voice carrier for OpenClaw on a dedicated, signed-in Mac.

The complete route is:

caller
  → FaceTime Audio or FaceTime video call
  → ScreenCaptureKit process audio capture
  → OpenAI Realtime
  → paired OpenClaw Core Audio driver
  → FaceTime or Phone microphone input
  → caller

The Mac remains the call endpoint, but OpenClaw hears the caller and the caller hears OpenClaw. The call app's own output is suppressed at the process tap, so the unattended Mac does not speak the conversation through its physical speakers.

This branch also adds authenticated owner identity, same-agent workspace and tool delegation, a bundled agent tool and skill, secure inbound and outbound call control, persistent helper supervision, an idempotent driver installer, guided readiness diagnostics, and live acceptance tooling. The default Realtime model is gpt-realtime-2.1, now validated both directly and through live FaceTime Audio calls. Current scope: 71 changed files, 9,872 additions, and 3,790 deletions.

Why

The original bridge could capture some call audio, but the return path and unattended lifecycle were not reliable:

  • assistant speech often played from the MacBook speaker instead of reaching the caller;
  • FaceTime Audio and video calls use different macOS apps on current macOS;
  • injected helpers disappeared when FaceTime or Phone restarted;
  • driver installation and audio routing had too many manual foot guns;
  • stale gateway processes and helper builds could produce misleading partial success;
  • inbound calls could be filtered by Focus or display-sharing notification policy before the helper ever observed them;
  • setup did not distinguish safe automatic repair from security-sensitive macOS changes.

This change makes those states explicit and gives the gateway one lifecycle owner for the whole bridge.

What changed

Paired realtime audio path

  • Replaced the fragile output-device-only route with a paired OpenClaw-Feed and OpenClaw-Mic Core Audio driver.
  • Captures caller audio with a per-process ScreenCaptureKit tap.
  • Sends PCM16 audio to the configured OpenAI Realtime provider and writes assistant audio into the call app's microphone route.
  • Verifies both process input and process-output suppression before declaring the route ready.
  • Adds buffering, playback clocking, gain handling, underrun recovery, and macOS audio-handoff tolerance.
  • Keeps the Mac's physical output selected while suppressing only the FaceTime or Phone process. Global mute and unrelated system audio are untouched.

Inbound and outbound calls

  • Supports incoming FaceTime calls from configured owner handles.
  • Supports secure outbound dialing and exact call correlation.
  • Uses Phone for FaceTime Audio and FaceTime for video on current macOS.
  • Preserves native video when the call is a video call. The AI bridge itself remains audio-only.
  • Adds idempotent answer, mute, and hang-up behavior.
  • If carrier hang-up fails, the runtime keeps the process tap active, safety-mutes both directions, and retries instead of exposing audio from a still-connected call.

Authenticated owner identity and same-agent delegation

  • Treats every whitelistHandles entry as an authenticated owner identity, not as a lower-privilege guest. The README calls out this security contract explicitly.
  • Canonicalizes the exact matched FaceTime handle into senderId and carries senderIsOwner: true from inbound admission or approved outbound dialing through active call state and the delegated agent turn.
  • Requires the paired OpenClaw sender-auth capability (REALTIME_VOICE_AGENT_CONSULT_SENDER_AUTH_VERSION === 1) before answering. Older hosts fail closed instead of silently dropping the owner fields.
  • Loads the configured agent's IDENTITY.md, USER.md, and SOUL.md into the Realtime bootstrap context, then delegates substantive work into that same agent's normal workspace, memory, tools, and approval policy.
  • Removes hardcoded runtime assumptions about the agent or user's name. The authenticated caller is bound to the configured workspace user, so the agent can greet the owner by name and answer identity questions from workspace context.
  • Uses one canonical per-call agent session, forked from the configured main session. FaceTime remains the carrier, while the internal webchat provider keeps approval follow-ups attached to a registered OpenClaw session.
  • Makes the Realtime model the voice surface of the same configured OpenClaw agent. It delegates substantive requests through openclaw_agent_consult and presents confirmed results as its own work, without inventing a separate assistant or supervisor.
  • Supports owner, safe-read-only, and none consult tool policies. owner is the default for allowlisted private calls.
  • Cancels superseded agent consults on caller barge-in, suppresses stale late results, and prevents repeated or unverified retry claims.

Authenticated helper control

  • Adds authenticated helper IPC with per-session validation and HMAC-protected commands.
  • Replaces the ignored CocoaPods socket dependency with a bounded Foundation stream client.
  • Builds the signed macabi helper from packaged source when it is missing or stale.
  • Launches and injects both FaceTime and Phone, serializes LLDB attachment, waits for authenticated connection, and retries disconnects with bounded backoff.
  • Detects a stale helper already loaded into an app and requests a real app restart instead of trusting or reinjecting it.
  • Makes the existing OpenClaw gateway the sole lifecycle owner. No extra LaunchAgent or persistent sidecar is installed.

Driver installation

  • Adds facetime.installDriver and facetime.driverStatus.
  • Builds the pinned paired driver locally, asks for administrator authorization only when installation is needed, records recipe metadata, and verifies the installed result.
  • Acknowledges the RPC immediately while installation continues in the background, avoiding gateway timeouts while the macOS authorization prompt is open.
  • Exposes driverInstall.phase through facetime.status.
  • Restarts Core Audio only after a changed installation and blocks installation while a call is active or pending.
  • Stops the installer process tree if the plugin runtime shuts down.

The GPL-licensed BlackHole source and binary are not distributed in this package. The installer fetches and builds the pinned source locally, preserving the licensing boundary.

Guided setup

Adds:

openclaw gateway call facetime.setup --json

The report combines:

  • Xcode command line tools;
  • Developer Tools access;
  • SIP debugging-restriction state;
  • owner handle allowlist;
  • gateway/runtime ownership;
  • FaceTime and Phone helper state;
  • paired-driver version and loopback;
  • SoX and native capture artifacts;
  • Screen & System Audio Recording/process-tap access;
  • OpenAI Realtime provider readiness;
  • Focus state;
  • notification policy while mirroring or sharing the display;
  • FaceTime sign-in and live audio-route checks that can only be proven during a call.

Each check is classified as ready, repairing, action-required, verify-on-call, or recommended. Safe runtime repairs remain automatic. Authentication, TCC consent, administrator authorization, Recovery changes, and System Settings changes remain explicit operator actions.

Runtime status is refreshed after the concurrent preflight so a helper that authenticates during setup is not incorrectly reported as still repairing.

Config, packaging, and diagnostics

  • Updates the plugin manifest, config schema, package contents, TypeScript build, and native build scripts.
  • Defaults the OpenAI Realtime provider to gpt-realtime-2.1 with the marin voice.
  • Adds doctor compatibility handling for the retired unsupported FaceTime audio config block.
  • Removes obsolete UI/audio-routing paths now replaced by the paired transport.
  • Adds live smoke and acceptance coverage plus detailed phase-one verification notes.
  • Keeps WORKLOG.md untracked and excluded from the public repository.

Agent tool and bundled skill

  • Registers the facetime_call agent tool with get_status, check_readiness, initiate_call, and end_call actions.
  • Bundles a facetime skill that teaches the configured agent to use the typed tool, check readiness, default to audio, avoid duplicate calls, distinguish pending from active calls, and report failures accurately.
  • Requires gateway-owned, one-shot user approval before an agent can place an outbound call. Only allow-once and deny are available. Persistent approval is intentionally unavailable, and the model cannot approve its own call.
  • Restricts dialing to the configured owner allowlist. Driver installation, SIP changes, TCC permissions, FaceTime sign-in, allowlist edits, and System Settings changes remain operator-only.
  • Exposes call state needed for trustworthy agent reporting, including helper health, pending dials, audioReady, realtimeActive, input verification, output suppression, routing errors, and carrier hang-up state.

Realtime model and voice path

  • Defaults to OpenAI gpt-realtime-2.1 with the marin voice.
  • Uses OpenAI Realtime audio end to end for speech generation. The plugin does not call or configure ElevenLabs.
  • Resolves the OpenAI Platform API credential through OpenClaw's secret-input runtime. ChatGPT subscriptions and Codex OAuth are not substitutes for Platform Realtime API access.
  • Retains explicit configuration for another registered Realtime provider or model. GPT Live support is tracked separately until those model IDs are exposed through the required API transport.

Security model and macOS requirements

The helper accepts calls and call-control commands only for configured owner handles. Helper connections are authenticated, outbound calls are correlated to the exact request, and fail-safe audio suppression remains active until a call is known to be closed.

The current call-control architecture injects a helper into Apple's protected FaceTime and Phone apps with LLDB. Apple SIP runtime protections block that attachment, even for root. This therefore requires disabling only SIP debugging restrictions from macOS Recovery:

csrutil enable --without debug

The plugin detects this prerequisite but never changes SIP itself. Other SIP protections remain enabled, but allowing debugger attachment still weakens the machine's security. The README recommends a dedicated, patched, physically controlled OpenClaw Mac. Replacing LLDB injection with a supported helper-free call-control path is a tracked follow-up.

Validation

Proof Result
TypeScript typecheck Passed
GitHub Actions at d938063 Passed, workflow run 30217793178
Publish build Passed
Automated tests 18 files, 114 tests passed
Helper macabi build and signing Passed
Native ScreenCaptureKit capture build Passed
Pinned paired-driver build and signing Passed
Shell and AppleScript syntax Passed
Package dry run and license exclusions Passed
Cold gateway helper supervision FaceTime and Phone both authenticated
Driver installation Background install reached succeeded; installed recipe reported current
Audio preflight Process tap, physical output, paired loopback, and Realtime provider passed
gpt-realtime-2.1 direct provider probe Authenticated, session.updated, 124,800 PCM16 output bytes, exact transcript, and response.done
gpt-realtime-2.1 guided setup All required checks ready; provider openai:gpt-realtime-2.1; paired loopback RMS 0.115210
Outbound FaceTime Audio Live two-way audio passed with gpt-realtime-2.1
Inbound FaceTime Audio Live ring, auto-answer, and two-way audio passed
Mac speaker suppression Runtime verified process output suppression; remote caller heard assistant audio
Owner identity and Calendar delegation Authenticated caller was greeted by name from workspace context; owner-authorized Calendar request returned the correct spoken result
Fresh structured autoreview Passed after all actionable findings were resolved
PR security checks Socket project report passed; alert check completed neutral

gpt-realtime-2.1 model proof

The exact model ID and Realtime/tool-use capabilities were confirmed against the official OpenAI model documentation.

A credential-safe direct probe used the same plugin-scoped OpenAI Platform credential resolution and PCM16 WebSocket provider as the FaceTime bridge. The model completed session.created and session.updated, returned the exact requested transcript, emitted 124,800 bytes of assistant audio, and completed with response.done.

The MacBook Air was then switched from gpt-realtime-2 to gpt-realtime-2.1, the gateway was restarted, and facetime.setup passed every required check. Both FaceTime and Phone helpers authenticated, the installed paired driver reported current, the process tap passed, and the paired-driver loopback measured RMS 0.115210.

Final live acceptance used outbound FaceTime Audio call 9FD8360B-7B00-41A3-8965-3DE0BF5D4703:

  • audioReady: true;
  • realtimeActive: true;
  • processInputVerified: true;
  • processOutputSuppressed: true;
  • caller speech was transcribed;
  • assistant PCM audio was generated;
  • Realtime responses completed with response.done;
  • the remote caller confirmed hearing and conversing with Lobster;
  • the session and carrier call closed cleanly.

The production test Mac remains configured for gpt-realtime-2.1.

Owner identity and tool-access proof

Final owner-auth acceptance on 2026-07-26 used a fresh outbound FaceTime Audio call with the paired OpenClaw core change and openai:gpt-realtime-2.1:

  • the exact configured handle was admitted through the owner allowlist;
  • the call created a fresh delegated agent consult carrying the canonical sender id and senderIsOwner: true;
  • the Realtime proxy and delegated agent bound the authenticated caller to the configured user described by workspace profile context, without hardcoded names;
  • the caller was greeted by name;
  • the caller requested Calendar data and heard the correct tool-backed result;
  • runtime status reported audioReady: true, realtimeActive: true, processInputVerified: true, and processOutputSuppressed: true;
  • the phone number and Calendar contents were intentionally omitted from public proof.

The remote caller confirmed both the personalized identity behavior and successful Calendar access. This exercises the same owner-aware agent/tool boundary covered by paired core PR openclaw/openclaw#114163.

Inbound-call environment finding

The inbound failure encountered during testing was traced outside the plugin: macOS DND filtering rejected the invitation before either helper could observe it while the display was remotely shared. Enabling notifications while mirroring or sharing allowed the next inbound call to ring and auto-answer. Setup now detects and explains that condition.

Known limitations and follow-ups

  • FaceTime Audio is live-confirmed in both directions. Video dialing and native video preservation are implemented, but the final post-fix live FaceTime video acceptance pass remains open. The AI processes audio only.
  • FaceTime account sign-in and the final per-app call route have no supported macOS readiness API, so setup marks them verify-on-call.
  • The current architecture requires SIP debugging restrictions to remain disabled.
  • A supported helper-free call-control path should replace LLDB injection.
  • gpt-realtime-2.1 is the tested default. Automatic fallback to gpt-realtime-2 is not implemented in this PR; users can still configure that older model explicitly.
  • Codex OAuth GPT Live support remains separate from the Platform API Realtime bridge used here.
  • Repeated native active/close status events can still produce duplicate diagnostic log lines. Runtime behavior is correct; log deduplication remains a follow-up.

Reviewer notes

This is a deliberately broad draft because the audio transport, helper lifecycle, call control, setup contract, packaging, and security requirements must agree as one system. The commits are separated by concern, but the branch should be reviewed as a complete carrier implementation.

omarshahine and others added 7 commits June 10, 2026 08:33
- FaceTimeHelper: call setIsSendingAudio:YES on unmute so the local
  participant actually transmits; surface is_sending_audio_set in result
- inject-helper: copy the dylib to a unique timestamped path per run to
  avoid reusing a stale/locked injected dylib
- audio-pump: drop `gain -n` normalization on output gain (was rescaling
  to peak); apply the configured gain directly
- preflight: lower synth test-tone volume (0.9 -> 0.2) and use `gain 1`
  instead of `gain -n 3` to avoid normalized clipping in the probes

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@omarshahine

Copy link
Copy Markdown
Collaborator Author

Live gpt-realtime-2.1 acceptance is complete and the PR description now contains the full evidence.

Highlights:

  • direct authenticated PCM16 WebSocket probe passed with 124,800 output bytes and response.done;
  • facetime.setup passed every required check with openai:gpt-realtime-2.1;
  • both FaceTime and Phone helpers authenticated;
  • paired-driver loopback measured RMS 0.115210;
  • outbound FaceTime Audio call 9FD8360B-7B00-41A3-8965-3DE0BF5D4703 reported audioReady, realtimeActive, verified caller input, and process-output suppression;
  • caller speech was transcribed and assistant audio responses completed;
  • Omar confirmed hearing and conversing with Lobster on the remote phone;
  • the call closed cleanly.

The test Mac remains on gpt-realtime-2.1. Automatic fallback to gpt-realtime-2 remains explicit follow-up work and is not claimed by this PR.

@omarshahine
omarshahine marked this pull request as ready for review July 26, 2026 12:00

Copy link
Copy Markdown
Collaborator Author

ClawSweeper review follow-up

Offline ClawSweeper review was run against the evolving PR head, including exact committed heads 1b5ac0e and 9211612, followed by fresh full-patch autoreview. The current head is cf137e90c724d525fbb894296fb0408a72b81a16.

Findings addressed

  • Raised the public host compatibility floor to the paired sender-auth capability release and kept runtime fail-closed when that capability is absent.
  • Fixed runtime lifecycle ownership so a runtime is retained when safety-preserving shutdown fails.
  • Reworked driver installation provenance. The privileged installer is hash-pinned, fetches BlackHole 0.7.1 itself, verifies the source archive, builds inside the privileged boundary, and validates metadata, signatures, and symlink-free payloads before HAL installation.
  • Removed IPC credentials from compiler argv. Helper keys now use a restricted generated header with explicit cleanup.
  • Added session-bound HMAC authentication for helper actions, replay rejection, reconnect invalidation, and native behavioral coverage.
  • Removed raw helper frame logging.
  • Resolved SecretRefs before reporting the Realtime provider ready.
  • Corrected helper shutdown ordering so supervision remains active until retained audio-safety cleanup completes.
  • Aborted pending agent consults on hangup and suppressed stale late results.
  • Made native-test cleanup work on macOS 15, where /usr/bin/trash is unavailable.
  • Detached the consult-abort retry loop with unrefed exponential-backoff timers, while preserving unbounded discovery so a late session registration cannot escape cancellation.
  • Removed production-specific agent and owner names from runtime prompts.

Findings reviewed and consciously not changed

  • Allowlist migration: this plugin has not shipped a release, and whitelistHandles is intentionally an owner-only trust boundary. There is no guest privilege tier to preserve.
  • SIP debugging restriction: this is a documented dedicated-Mac beta boundary, consistent with the private-API posture of imsg. The plugin detects and explains it but never changes SIP.
  • Published OpenClaw dependency: the package still builds against the latest published 2026.7.2-beta.3; the required sender-auth contract is in paired core PR fix(talk): preserve owner authorization in realtime consults openclaw#114163. The plugin's public runtime floor is beta.4 and it fails closed on older hosts.
  • Internal webchat consultation provider: retained intentionally so approval follow-ups attach to a registered OpenClaw session while FaceTime remains the carrier. Canonical sender identity and senderIsOwner: true are forwarded explicitly.
  • Retired config compatibility: the plugin is unreleased, so runtime shims were not added. Compatibility repair remains owned by the doctor/migration contract.
  • All-helper call-control fanout: retained because safe mute and hangup require every authenticated helper target, not first-success behavior.
  • Autoreview shutdown deadlock claim: rejected after source inspection because close() invokes abort cleanup without awaiting the detached poll. The focused regression test passes.

Proof completed

  • Full local suite: 21 test files, 123 tests passed.
  • TypeScript typecheck and production build passed.
  • Shell syntax and AppleScript compilation passed.
  • Native helper built in an isolated HOME.
  • Paired BlackHole-derived driver built in isolation with signature, metadata, and symlink checks.
  • Package inventory includes the privileged installer and native action-authentication sources.
  • Fresh full-patch autoreview returned no actionable findings.
  • Live FaceTime Audio, owner identity, workspace context, Calendar delegation, Realtime audio, and speaker-suppression proof are recorded in the PR description.

Current CI note

GitHub Actions run 30221886765 passed typecheck, then timed out at 5 seconds in tests/helper-action-authentication.test.ts after 20 files and 122 tests had passed. The native test passed locally, but the current PR head is not CI-green until that runner timeout is resolved or proven transient.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedopenclaw@​2026.7.2-beta.33810010098100

View full report

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Includes npm shrinkwrap: npm @openclaw/ai

Location: Package overview

From: pnpm-lock.yaml → npm/[email protected] → npm/@openclaw/[email protected]

ℹ Read more on: This package | This alert | What is a shrinkwrap file?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should never use npm shrinkwrap files due to the dangers they pose.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@openclaw/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm execa is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: pnpm-lock.yaml → npm/[email protected] → npm/[email protected]

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Includes npm shrinkwrap: npm openclaw

Location: Package overview

From: package.json → npm/[email protected]

ℹ Read more on: This package | This alert | What is a shrinkwrap file?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should never use npm shrinkwrap files due to the dangers they pose.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@omarshahine
omarshahine merged commit 45017e1 into main Jul 27, 2026
3 checks passed

Copy link
Copy Markdown
Collaborator Author

Merged via squash at 45017e1.

Final source head: a8b060c0d0e774c908b56d57f70a799c6c9cb0a3

Final landing proof:

  • GitHub Actions CI run 30227698105 passed on the exact source head
  • pnpm typecheck passed
  • full pnpm test suite passed
  • shell syntax checks passed
  • pnpm build passed
  • fresh structured autoreview reported no accepted/actionable findings
  • no unresolved review threads remained

The last change gave the native Objective-C authentication harness a test-local timeout for cold macOS toolchain startup. It does not weaken or skip any authentication assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant