Skip to content

Open source CapCut alternative.

TypeScript

Add Gemini Live smoke coverage

David Le4db6298bd76b
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveHybridSpotifySmokeTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveHybridSpotifySmokeTests.swift
new file mode 100644
index 00000000..5200d432
--- /dev/null
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveHybridSpotifySmokeTests.swift
@@ -0,0 +1,81 @@
+import AppKit
+@testable import Donkey
+import DonkeyAI
+import DonkeyContracts
+import DonkeyRuntime
+import Foundation
+import Testing
+
+/// Live, doubly-gated: the **hybrid** flow through the REAL production controller.
+/// `GeminiLiveVoiceController` runs the fast realtime command session
+/// (`gemini-live-2.5-flash`) with the Command Layer tools plus the `vision_control`
+/// escalation. For "play Coldplay on Spotify" — which `music_play` can't do
+/// (Apple-Music only) — the 2.5 model calls `vision_control`, and the controller
+/// runs the gemini-3.5 `VertexVisionDriver` to operate Spotify. The test only feeds
+/// the controller a text turn and verifies real Coldplay playback.
+///
+/// Behavior probe: both the model's choice to escalate and the vision grounding are
+/// probabilistic — read the printed line (validated: escalates, ~8 vision turns,
+/// Coldplay playing). Gated behind `DONKEY_LIVE_SMOKE=1` and `DONKEY_LIVE_INPUT=1`:
+///
+/// env DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
+/// DONKEY_LIVE_SMOKE=1 DONKEY_LIVE_INPUT=1 DONKEY_WEB_BASE_URL=http://localhost:3000 \
+/// DONKEY_DEV_AUTH_BYPASS=1 swift test --filter GeminiLiveHybridSpotifySmokeTests
+@Suite
+struct GeminiLiveHybridSpotifySmokeTests {
+ @Test
+ @MainActor
+ func commandControllerEscalatesToVisionForSpotify() async throws {
+ let environment = ProcessInfo.processInfo.environment
+ guard environment["DONKEY_LIVE_SMOKE"] == "1", environment["DONKEY_LIVE_INPUT"] == "1",
+ (try? DonkeyBackendInferenceConfiguration.fromEnvironment()) != nil
+ else { return }
+
+ // Seed a known NON-Coldplay track, then pause: Spotify auto-resumes the last
+ // track on focus, so seeding a non-target ensures the goal can only be met by
+ // the vision agent actually searching — not by stale/auto-resumed playback.
+ NSWorkspace.shared.launchApplication("Spotify")
+ try? await Task.sleep(nanoseconds: 2_000_000_000)
+ _ = Self.runScript("tell application \"Spotify\" to play track \"spotify:track:4cOdK2wGLETKBW3PvgPWqT\"") // Rick Astley
+ try? await Task.sleep(nanoseconds: 1_500_000_000)
+ LiveSmokeMusicProbe.pauseAll()
+
+ let controller = GeminiLiveVoiceController()
+ var acted: [String] = []
+ controller.onActed = { acted.append($0) }
+ await controller.start()
+ #expect(controller.isConnected, "Live controller did not connect.")
+ guard controller.isConnected else { await controller.stop(); return }
+
+ let coldplayPlaying: @MainActor () -> Bool = {
+ LiveSmokeMusicProbe.spotifyPlayingArtist().lowercased().contains("coldplay")
+ }
+
+ let start = Date()
+ await controller.sendText("Play Coldplay's most popular song on Spotify.")
+ // The controller's 2.5 model escalates to vision_control and runs the gemini-3.5
+ // driver internally; wait for the real result (Coldplay playing).
+ let played = await liveSmokeWaitUntil(timeout: 120) { await coldplayPlaying() }
+ let total = Date().timeIntervalSince(start)
+ await controller.stop()
+
+ let escalated = acted.contains { $0.lowercased().contains("vision") }
+ print(String(format: "[hybrid smoke] %@ in %.2fs — escalated_to_vision=%@\n acted: %@",
+ played ? "PLAYING-COLDPLAY" : "DID NOT PLAY COLDPLAY", total, escalated ? "yes" : "no",
+ acted.joined(separator: " | ")))
+ if !escalated {
+ print("[hybrid smoke] note: the 2.5 model did not escalate to vision_control this run (model nondeterminism) — re-run.")
+ }
+ // The infra gate is `controller.isConnected` (asserted above); the escalation
+ // and playback outcome are reported (both probabilistic), not hard-gated.
+ _ = (escalated, played)
+ }
+
+ @MainActor
+ @discardableResult
+ private static func runScript(_ source: String) -> String? {
+ var error: NSDictionary?
+ let output = NSAppleScript(source: source)?.executeAndReturnError(&error)
+ return error == nil ? output?.stringValue : nil
+ }
+}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveMusicPlaybackLiveSmokeTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveMusicPlaybackLiveSmokeTests.swift
new file mode 100644
index 00000000..2d1eeea7
--- /dev/null
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveMusicPlaybackLiveSmokeTests.swift
@@ -0,0 +1,52 @@
+import AppKit
+@testable import Donkey
+import DonkeyAI
+import DonkeyContracts
+import DonkeyRuntime
+import Foundation
+import Testing
+
+/// Live, end-to-end smoke test that plays music through the REAL production Live
+/// brain — `GeminiLiveVoiceController` — which owns the Gemini Live session
+/// (`gemini-live-2.5-flash` on Vertex) and the Donkey Command Layer harness
+/// registry. The test only hands the controller a text turn ("play some cold play")
+/// and verifies a music app actually starts playing; the controller does the real
+/// work (model → `music_play` tool → harness execution).
+///
+/// Gated behind `DONKEY_LIVE_SMOKE=1`; no-ops otherwise. To run it live:
+///
+/// env DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
+/// DONKEY_LIVE_SMOKE=1 DONKEY_WEB_BASE_URL=http://localhost:3000 DONKEY_DEV_AUTH_BYPASS=1 \
+/// swift test --filter GeminiLiveMusicPlaybackLiveSmokeTests
+@Suite
+struct GeminiLiveMusicPlaybackLiveSmokeTests {
+ @Test
+ @MainActor
+ func playsMusicThroughTheLiveController() async throws {
+ let environment = ProcessInfo.processInfo.environment
+ guard environment["DONKEY_LIVE_SMOKE"] == "1" else { return }
+ if environment["DONKEY_WEB_BASE_URL"]?.isEmpty != false {
+ Issue.record("DONKEY_LIVE_SMOKE=1 but DONKEY_WEB_BASE_URL is not set; cannot reach a backend.")
+ return
+ }
+
+ LiveSmokeMusicProbe.pauseAll()
+
+ let controller = GeminiLiveVoiceController()
+ var acted: [String] = []
+ controller.onActed = { acted.append($0) }
+ await controller.start()
+ #expect(controller.isConnected, "Live controller did not connect (Vertex gemini-live-2.5-flash).")
+ guard controller.isConnected else { await controller.stop(); return }
+
+ let start = Date()
+ await controller.sendText("play some cold play")
+ let playing = await liveSmokeWaitUntil(timeout: 60) { await LiveSmokeMusicProbe.isAnyMusicPlaying() }
+ let duration = Date().timeIntervalSince(start)
+ await controller.stop()
+
+ print(String(format: "[music smoke] live controller %@ in %.2fs (acted: %@)",
+ playing ? "PLAYING" : "DID NOT PLAY", duration, acted.joined(separator: " | ")))
+ #expect(playing, "Live controller did not start music within 60s. acted=\(acted)")
+ }
+}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveSmokeSupport.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveSmokeSupport.swift
new file mode 100644
index 00000000..a69aa677
--- /dev/null
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveSmokeSupport.swift
@@ -0,0 +1,85 @@
+import AppKit
+import Foundation
+
+/// Shared helpers for the live Gemini smoke tests. The session orchestration and
+/// vision driver now live in production (`GeminiLiveVoiceController`,
+/// `VertexVisionDriver`); these are just test utilities.
+
+/// Poll `condition` until it's true or `timeout` seconds elapse.
+@discardableResult
+func liveSmokeWaitUntil(timeout seconds: Double, _ condition: @Sendable () async -> Bool) async -> Bool {
+ let deadline = Date().addingTimeInterval(seconds)
+ while Date() < deadline {
+ if await condition() { return true }
+ try? await Task.sleep(nanoseconds: 200_000_000)
+ }
+ return await condition()
+}
+
+/// Reads/controls real music-app playback via Automation (NSAppleScript),
+/// independent of the model's claims — so the smoke tests verify music is ACTUALLY
+/// playing (and the RIGHT artist), not just that the model said so.
+enum LiveSmokeMusicProbe {
+ /// True if Spotify or Apple Music reports it is currently playing.
+ @MainActor static func isAnyMusicPlaying() -> Bool {
+ playerState(ofApp: "Spotify") == "playing" || playerState(ofApp: "Music") == "playing"
+ }
+
+ /// Pause both music apps if they are running (no-op if not).
+ @MainActor static func pauseAll() {
+ runIfRunning(app: "Spotify", command: "pause")
+ runIfRunning(app: "Music", command: "pause")
+ }
+
+ /// The currently-playing Spotify track's artist, or "" if not playing / not
+ /// running. Used to verify the RIGHT music is playing — Spotify auto-resumes a
+ /// random track on launch, so "is anything playing" is not enough.
+ @MainActor static func spotifyPlayingArtist() -> String {
+ let source = """
+ tell application "System Events"
+ if not (exists process "Spotify") then return ""
+ end tell
+ tell application "Spotify"
+ if player state is playing then return (artist of current track) as text
+ end tell
+ return ""
+ """
+ return runScript(source) ?? ""
+ }
+
+ /// `"playing"`, `"notplaying"`, `"notrunning"`, or `"unknown"`. Uses System
+ /// Events to check the process first so it never launches a stopped app.
+ @MainActor static func playerState(ofApp app: String) -> String {
+ let source = """
+ tell application "System Events"
+ if not (exists process "\(app)") then return "notrunning"
+ end tell
+ tell application "\(app)"
+ if player state is playing then
+ return "playing"
+ else
+ return "notplaying"
+ end if
+ end tell
+ """
+ return runScript(source) ?? "unknown"
+ }
+
+ @MainActor private static func runIfRunning(app: String, command: String) {
+ let source = """
+ tell application "System Events"
+ if not (exists process "\(app)") then return
+ end tell
+ tell application "\(app)" to \(command)
+ """
+ _ = runScript(source)
+ }
+
+ @MainActor private static func runScript(_ source: String) -> String? {
+ var error: NSDictionary?
+ guard let script = NSAppleScript(source: source) else { return nil }
+ let output = script.executeAndReturnError(&error)
+ if error != nil { return nil }
+ return output.stringValue
+ }
+}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionBoxSpotifySmokeTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionBoxSpotifySmokeTests.swift
new file mode 100644
index 00000000..798a707a
--- /dev/null
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionBoxSpotifySmokeTests.swift
@@ -0,0 +1,75 @@
+import AppKit
+@testable import Donkey
+import DonkeyAI
+import DonkeyContracts
+import DonkeyRuntime
+import Foundation
+import Testing
+
+/// Live, doubly-gated: exercises the box-based vision driver (`VertexVisionBoxDriver`,
+/// the `GEMINI_VISION_BOX=1` escalation path) driving Spotify to play. Each turn it
+/// draws the model's returned bounding box + click points onto the screenshot and
+/// saves it to `/tmp/donkey-vision-boxes/` so the box quality can be checked by eye —
+/// the assertion only confirms the driver actually ran (grounding is probabilistic).
+///
+/// Gated behind `DONKEY_LIVE_SMOKE=1` and `DONKEY_LIVE_INPUT=1`. Run live:
+///
+/// env DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
+/// DONKEY_LIVE_SMOKE=1 DONKEY_LIVE_INPUT=1 GEMINI_VISION_BOX=1 \
+/// DONKEY_WEB_BASE_URL=http://localhost:3000 DONKEY_DEV_AUTH_BYPASS=1 \
+/// swift test --filter GeminiLiveVisionBoxSpotifySmokeTests
+@Suite
+struct GeminiLiveVisionBoxSpotifySmokeTests {
+ @Test
+ @MainActor
+ func boxVisionDriverPlaysSpotify() async throws {
+ let environment = ProcessInfo.processInfo.environment
+ guard environment["DONKEY_LIVE_SMOKE"] == "1", environment["DONKEY_LIVE_INPUT"] == "1",
+ let config = try? DonkeyBackendInferenceConfiguration.fromEnvironment()
+ else { return }
+ let goal = environment["DONKEY_GOAL"] ?? "Search for the artist Coldplay and play their most popular song."
+ let visionModel = GeminiLiveConfiguration.fromEnvironment().visionModel
+
+ let outputDir = URL(fileURLWithPath: "/tmp/donkey-vision-boxes", isDirectory: true)
+ try? FileManager.default.removeItem(at: outputDir)
+ try FileManager.default.createDirectory(at: outputDir, withIntermediateDirectories: true)
+
+ NSWorkspace.shared.launchApplication("Spotify")
+ try? await Task.sleep(nanoseconds: 1_500_000_000)
+ LiveSmokeMusicProbe.pauseAll()
+
+ let auth = try await GeminiVertexVisionPlanner.mintAuth(
+ backend: DonkeyBackendInferenceClient(configuration: config)
+ )
+
+ let start = Date()
+ var saved = 0
+ let outcome = await VertexVisionBoxDriver.drive(
+ appName: "Spotify",
+ bundleIdentifier: "com.spotify.client",
+ goal: goal,
+ auth: auth,
+ model: visionModel,
+ verify: { LiveSmokeMusicProbe.playerState(ofApp: "Spotify") == "playing" },
+ onTurn: { turn, screenshot, action in
+ guard let box = action.box,
+ let png = ScreenshotAnnotation.annotatedPNG(
+ screenshot: screenshot,
+ box: box,
+ label: "\(action.action): \(action.reason ?? "")"
+ )
+ else { return }
+ let url = outputDir.appendingPathComponent(String(format: "turn-%02d.png", turn))
+ try? png.write(to: url)
+ saved += 1
+ }
+ )
+ let total = Date().timeIntervalSince(start)
+
+ print(String(format: "[vision-box smoke / %@] %@ in %.2fs over %d turns — %d annotated frames in %@\n trace: %@",
+ visionModel, outcome.completed ? "PLAYING" : "DID NOT PLAY", total, outcome.turns,
+ saved, outputDir.path, outcome.history.joined(separator: " | ")))
+ // Probe (vision grounding is probabilistic): require the driver actually ran.
+ #expect(outcome.turns > 0, "Box vision driver never took a turn (infra failure).")
+ }
+}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionSpotifyLiveSmokeTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionSpotifyLiveSmokeTests.swift
new file mode 100644
index 00000000..f1801c92
--- /dev/null
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GeminiLiveVisionSpotifyLiveSmokeTests.swift
@@ -0,0 +1,58 @@
+import AppKit
+@testable import Donkey
+import DonkeyAI
+import DonkeyContracts
+import DonkeyRuntime
+import Foundation
+import Testing
+
+/// Live, doubly-gated: exercises the production `VertexVisionDriver` (the
+/// gemini-3.5 screenshot loop the Live controller escalates to) directly, driving
+/// Spotify to play. (For the full hybrid — 2.5 command session escalating to this
+/// via `vision_control` — see `GeminiLiveHybridSpotifySmokeTests`.) Reports total
+/// latency to real playback (verified via Automation).
+///
+/// Gated behind `DONKEY_LIVE_SMOKE=1` and `DONKEY_LIVE_INPUT=1`. Run live:
+///
+/// env DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
+/// DONKEY_LIVE_SMOKE=1 DONKEY_LIVE_INPUT=1 DONKEY_WEB_BASE_URL=http://localhost:3000 \
+/// DONKEY_DEV_AUTH_BYPASS=1 swift test --filter GeminiLiveVisionSpotifyLiveSmokeTests
+@Suite
+struct GeminiLiveVisionSpotifyLiveSmokeTests {
+ @Test
+ @MainActor
+ func visionDriverPlaysSpotify() async throws {
+ let environment = ProcessInfo.processInfo.environment
+ guard environment["DONKEY_LIVE_SMOKE"] == "1", environment["DONKEY_LIVE_INPUT"] == "1",
+ let config = try? DonkeyBackendInferenceConfiguration.fromEnvironment()
+ else { return }
+ let goal = environment["DONKEY_GOAL"] ?? "Search for the artist Coldplay and play their most popular song."
+ let visionModel = GeminiLiveConfiguration.fromEnvironment().visionModel
+
+ NSWorkspace.shared.launchApplication("Spotify")
+ try? await Task.sleep(nanoseconds: 1_500_000_000)
+ LiveSmokeMusicProbe.pauseAll()
+
+ let auth = try await GeminiVertexVisionPlanner.mintAuth(
+ backend: DonkeyBackendInferenceClient(configuration: config)
+ )
+
+ let start = Date()
+ let outcome = await VertexVisionDriver.drive(
+ appName: "Spotify",
+ bundleIdentifier: "com.spotify.client",
+ goal: goal,
+ auth: auth,
+ model: visionModel,
+ verify: { LiveSmokeMusicProbe.playerState(ofApp: "Spotify") == "playing" }
+ )
+ let total = Date().timeIntervalSince(start)
+
+ print(String(format: "[vision smoke / %@] %@ in %.2fs over %d turns (%.2fs/turn)\n trace: %@",
+ visionModel, outcome.completed ? "PLAYING" : "DID NOT PLAY", total, outcome.turns,
+ outcome.turns > 0 ? total / Double(outcome.turns) : total,
+ outcome.history.joined(separator: " | ")))
+ // Probe (vision grounding is probabilistic): require the driver actually ran.
+ #expect(outcome.turns > 0, "Vision driver never took a turn (infra failure).")
+ }
+}
diff --git a/apps/Donkey/docs/fast-command-layer-and-gemini-live.md b/apps/Donkey/docs/fast-command-layer-and-gemini-live.md
index e4cfeb52..b40d6005 100644
--- a/apps/Donkey/docs/fast-command-layer-and-gemini-live.md
+++ b/apps/Donkey/docs/fast-command-layer-and-gemini-live.md
@@ -6,7 +6,10 @@
> directly to the Vertex Live websocket with a Bearer token, text/audio route through the session,
> tool calls execute against the Command Layer, and the mic can stream continuously. Gemini Live is **enabled by default** and takes over once it
> connects; if it can't authenticate it stays disconnected and the existing pipeline runs
-> unchanged. Remaining work is live end-to-end verification with real credentials + mic.
+> unchanged. The text path is verified end-to-end against real Vertex credentials by
+> `GeminiLiveCommandSessionLiveSmokeTests` (mint token → websocket → `setupComplete` → text turn
+> → tool call → Command Layer → result). Remaining work is live verification of the optional
+> microphone/audio input.
## Context
@@ -33,8 +36,8 @@ A deliberately small set:
| Tool | Implementation |
|---|---|
| `shell_exec` | runs a safe, single-line shell command via `/bin/zsh -c` and returns its output — the primary, general-purpose tool |
-| `apps.list` | reuses `MacLocalAppAvailabilityProvider.installedApplications()` (Spotlight-backed, names + bundle ids) + running apps so the model targets exact names instead of guessing |
-| `music.play` | reuses the bundled, pre-validated `music-media` `play-media-by-search.applescript` (a multi-step search→play workflow a one-liner can't reproduce) |
+| `apps_list` | reuses `MacLocalAppAvailabilityProvider.installedApplications()` (Spotlight-backed, names + bundle ids, includes Apple native apps) + running apps so the model targets exact names instead of guessing; the installed list is paginated (`filter`/`offset`/`limit`, with `hasMore`/`nextOffset` in the result) so the full catalog survives the response cap |
+| `music_play` | reuses the bundled, pre-validated `music-media` `play-media-by-search.applescript` (a multi-step search→play workflow a one-liner can't reproduce) |
`shell_exec` is the **primary, general-purpose tool** (the same capability the competitor's
Realtime setup exposes) — listed first and prioritized in the system instruction. It handles most
@@ -42,7 +45,7 @@ requests directly: opening/quitting/controlling apps (`open -a Spotify`, `osascr
changing settings, opening URLs (`open https://…`), and reading system state. Earlier dedicated
tools (`app.open`, `app.quit`, `browser.open_url`, `system.set_volume`) were **removed** as
redundant once `shell_exec` could do them reliably; only the two that earn their keep remain —
-`apps.list` (discovery is awkward via raw shell) and `music.play` (encapsulated workflow). The
+`apps_list` (discovery is awkward via raw shell) and `music_play` (encapsulated workflow). The
model is told to send only safe single-line commands; a backstop guardrail in
`DonkeyCommandBackends` enforces single-line input, a length cap, and a hard ~12s timeout
(SIGTERM→SIGKILL). Unsafe commands are caught by a **command-word** check on each pipeline/segment
@@ -102,18 +105,28 @@ or deterministic prefilter: the Live model chooses a tool call (act now) vs. ask
(visual task) vs. a plain reply. The speedup comes from the model *preferring* a fast tool, not
from bypassing it.
-### Authentication — Vertex OAuth only
-
-The backend authenticates to **Vertex AI with Google Cloud OAuth (service-account) credentials**,
-and the Live client uses the same. There is no client-held API-key path. `GeminiLiveSession`'s
-connection provider calls `DonkeyBackendInferenceClient.mintLiveConnection()` →
-`POST /api/inference/live-token/`. The backend route (`site/src/app/api/inference/live-token/route.ts`)
-uses the shared service-account JWT (`site/src/lib/inference/vertex-live.ts`, `cloud-platform`
-scope) to mint a short-lived access token and returns it with the Vertex Live websocket URL
-(`{location}-aiplatform.googleapis.com`, or `aiplatform.googleapis.com` for `global`) and the
-fully-qualified model path. The client connects with `Authorization: Bearer <token>`; the
-long-lived credential never leaves the backend, and the token is re-minted on every (re)connect so
-it stays fresh. The result is carried in a single `GeminiLiveConnection` (url + bearer + model).
+### Authentication — two paths (`GeminiLiveConnectionFactory`)
+
+`GeminiLiveConnectionFactory.makeProvider` picks the connection path from config:
+
+- **Developer API** (`GEMINI_API_KEY` set): connect directly to
+ `wss://generativelanguage.googleapis.com/ws/...BidiGenerateContent?key=<KEY>` with the
+ client-configured model (`GEMINI_LIVE_MODEL`, default `GeminiLiveConfiguration.defaultModel`). No
+ backend round-trip. **Dev-only** — a client-held key; not for production. The default Dev-API model
+ is **audio-output only**: the session requests `AUDIO` response modality
+ (`GeminiLiveConnection.audioOutput`, controlled by `GEMINI_LIVE_AUDIO_OUTPUT`, default on); tool
+ calls and output transcription still flow, which is all the Command Layer needs. Point
+ `GEMINI_LIVE_MODEL` at a TEXT-capable Live model and set `GEMINI_LIVE_AUDIO_OUTPUT=0` to get TEXT.
+- **Vertex AI** (no key — production): the backend authenticates with Google Cloud OAuth
+ (service-account) credentials. `DonkeyBackendInferenceClient.mintLiveConnection()` →
+ `POST /api/inference/live-token/` (`site/src/app/api/inference/live-token/route.ts` +
+ `site/src/lib/inference/vertex-live.ts`, `cloud-platform` scope) mints a short-lived access token
+ and returns the Vertex Live websocket URL (`{location}-aiplatform.googleapis.com`, or
+ `aiplatform.googleapis.com` for `global`) + fully-qualified model path. The client connects with
+ `Authorization: Bearer <token>`; the long-lived credential never leaves the backend, and the token
+ is re-minted on every (re)connect. TEXT response modality.
+
+Both produce a single `GeminiLiveConnection` (url + optional bearer + model + audioOutput).
### Configuration
@@ -121,10 +134,17 @@ it stays fresh. The result is carried in a single `GeminiLiveConnection` (url +
|---|---|---|
| `GEMINI_LIVE_ENABLED` | client | Always-on Live session. **On by default**; set falsey to opt out. |
| `GEMINI_LIVE_AUDIO` | client | Also stream microphone audio (optional). Off by default. |
-| `GEMINI_LIVE_MODEL` | backend | Live model id (default `gemini-3.1-flash-live-preview`). Owned solely by the backend — the single source of truth. |
+| `GEMINI_API_KEY` | client | **Dev-only.** When set, route the Live session through the Developer-API key path instead of Vertex. Default/production is keyless Vertex. |
+| `GEMINI_LIVE_MODEL` | client (dev) / backend (Vertex) | Realtime command Live model. Vertex default `gemini-live-2.5-flash`; Dev-API default `gemini-2.5-flash-native-audio-preview-09-2025`. |
+| `GEMINI_LIVE_AUDIO_OUTPUT` | client (dev) | Request AUDIO response modality on the Dev-API path. **On by default** (the default Dev-API model is audio-only); set falsey only with a TEXT-capable `GEMINI_LIVE_MODEL`. |
+| `GEMINI_VISION_MODEL` | client | Turn-based **vision** model (default `gemini-3.5-flash`). A stronger, non-Live model used only when a task needs the screen — see below. |
| `GOOGLE_APPLICATION_CREDENTIALS_JSON` | backend | Vertex service-account JSON used to mint tokens. |
| `GEMINI_VERTEX_LOCATION` | backend | Vertex location (default `global`). |
+### Two models: realtime command vs vision
+
+The realtime Live session (`gemini-live-2.5-flash`) is the **command brain** — fast, tool-calling, screen-last. When a task genuinely needs the screen, the **vision** path uses a stronger turn-based model (`gemini-3.5-flash`) via `GeminiVertexVisionPlanner`: it calls Vertex `generateContent` with the window screenshot and returns the single next click/type/key (coordinates in Gemini's 0–1000 space, mapped to the window). `gemini-3.5-flash` isn't a Live/bidi model, so vision is per-turn `generateContent`, not the socket — slower per turn (~7s) but markedly better grounding than the realtime model. Both run on Vertex with backend-minted tokens.
+
## How the overlay is wired
`UserQueryOverlayModel` owns a `GeminiLiveVoiceController`, started on init (gated by
@@ -163,5 +183,22 @@ DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter Gen
(A no-filter full run hangs on a GUI-dependent suite.) Covered today: Command Layer descriptors
surface + input validation (`GenericHarnessTests`), and Gemini Live config parsing, function
-declarations, PCM packing, and frame parsing (`GeminiLiveTests`). `GenericHarnessTests` has 8
-failures that pre-date this work (confirmed via a clean-tree `git stash -u` re-run).
+declarations, PCM packing, frame parsing, and the function-name identifier guard (`GeminiLiveTests`).
+`GenericHarnessTests` has 8 failures that pre-date this work (confirmed via a clean-tree
+`git stash -u` re-run).
+
+For the real round trip, `GeminiLiveCommandSessionLiveSmokeTests` drives the whole text path
+against a live backend + Vertex. It is gated behind `DONKEY_LIVE_SMOKE=1` and no-ops otherwise:
+
+```
+env DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \
+ DONKEY_LIVE_SMOKE=1 DONKEY_WEB_BASE_URL=http://localhost:3000 DONKEY_DEV_AUTH_BYPASS=1 \
+ swift test --filter GeminiLiveCommandSessionLiveSmokeTests
+```
+
+It mints a token, opens the Vertex Live websocket, waits for `setupComplete`, sends a text turn,
+and asserts the model's tool call executes against the Command Layer without a harness-side
+failure. This is what caught two real bugs the unit tests couldn't: the default model id had to be
+a model that exists on Vertex (`gemini-live-2.5-flash`), and tool names must be valid function-call
+identifiers — Gemini normalizes dots, so `apps.list`/`music.play` became unreachable and were
+renamed to `apps_list`/`music_play`.