diff --git a/specification/bug-classes/interactive-launcher-mode-mismatch.json b/specification/bug-classes/interactive-launcher-mode-mismatch.json new file mode 100644 index 00000000000..258e3318445 --- /dev/null +++ b/specification/bug-classes/interactive-launcher-mode-mismatch.json @@ -0,0 +1,115 @@ +{ + "schemaVersion": 1, + "revision": "0ef98562a1f2342c20a21544a660c8f55f07fa9c", + "bugClass": { + "id": "interactive-launcher-mode-mismatch", + "title": "Interactive sessions launch in one-shot mode", + "cause": "An interactive session is started with a one-shot or print-mode CLI flag, so the process emits a single response and exits instead of remaining available for chat. Similar failures can occur when terminal-delivery gates recognize only a fixed set of agent types and omit another interactive launcher. One-shot batch processes that intentionally return one result and exit are outside scope.", + "criteria": "Classify another site when its interactive session launcher uses a print, one-shot, or otherwise non-interactive mode that exits after one response, or when interactive terminal-delivery routing gates only on a fixed agent allowlist and omits an interactive launcher. Either mechanism is sufficient. Exclude batch task processes designed to produce one result and exit.", + "patterns": [ + { + "kind": "text", + "value": "--print", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt-interactive", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt", + "weight": 2 + }, + { + "kind": "text", + "value": "interactive", + "weight": 2 + }, + { + "kind": "text", + "value": "tmux", + "weight": 2 + }, + { + "kind": "text", + "value": "claude", + "weight": 1 + }, + { + "kind": "text", + "value": "codex", + "weight": 1 + }, + { + "kind": "call", + "value": "spawnSync", + "weight": 2 + }, + { + "kind": "call", + "value": "execFileSync", + "weight": 2 + }, + { + "kind": "call", + "value": "exec", + "weight": 1 + }, + { + "kind": "call", + "value": "spawn", + "weight": 2 + }, + { + "kind": "call", + "value": "includes", + "weight": 1 + } + ], + "contextTerms": ["interactive", "print", "prompt", "tmux", "claude", "codex"], + "pathHints": [ + { + "contains": "src/cli/", + "weight": 5 + }, + { + "contains": "src/commands/", + "weight": 4 + }, + { + "contains": "src/workflows/", + "weight": 3 + }, + { + "contains": "src/services/", + "weight": 2 + }, + { + "contains": "packages/desktop/", + "weight": 1 + }, + { + "contains": "packages/hub/", + "weight": 1 + }, + { + "contains": "test/", + "weight": -3 + }, + { + "contains": "specification/", + "weight": -2 + }, + { + "contains": "worker", + "weight": -2 + }, + { + "contains": "server", + "weight": -2 + } + ] + } +} diff --git a/specification/loops/tracker-gemini-interactive/loop.json b/specification/loops/tracker-gemini-interactive/loop.json new file mode 100644 index 00000000000..57368aee508 --- /dev/null +++ b/specification/loops/tracker-gemini-interactive/loop.json @@ -0,0 +1,67 @@ +{ + "name": "tracker-gemini-interactive", + "goal": "Keep managed Gemini Tracker chats interactive in tmux, deliver Hub messages and replies, and preserve exit diagnostics.", + "createdAt": "2026-11-30T20:30:58.605Z", + "updatedAt": "2026-11-30T20:49:23.505Z", + "template": "bug-fix", + "templateLineage": ["bug-fix"], + "enforceOrder": true, + "regressionCommits": 1, + "steps": [ + { + "id": "spec", + "title": "Identify the failing behavior, expected behavior, and reproduction.", + "status": "complete", + "completedAt": "2026-11-30T20:32:21.905Z", + "evidence": "Tracker runs #1907 #1939 #1944 declared readiness and exited 0; agy help confirms --print exits after one turn and --prompt-interactive continues." + }, + { + "id": "coverage", + "title": "Explain why existing standardized tests missed the bug; name the scenario, fixture, lifecycle or assertion gap and reusable test change.", + "status": "complete", + "completedAt": "2026-11-30T20:32:23.712Z", + "evidence": "Managed Gemini launcher test requires --print and ends on the first response. Change its mock to distinguish persistent interactive launch, terminal exit diagnostics and model preflight. Existing Hub idle composer tests omit Gemini. Unit mocks replace the provider executable, so no subscription request is possible. One live Neon medium round trip should take about 1–3 minutes and use the existing subscription with G1 credits disabled." + }, + { + "id": "red", + "title": "Strengthen the existing standardized test; commit it before repair, run it failing with loop record --phase red, and preserve the assertion.", + "status": "complete", + "completedAt": "2026-11-30T20:44:54.343Z", + "evidence": "Combined frozen fixtures at ed58e4696d fail: --print instead of interactive, Gemini send returns false, and provider composer classification is missing." + }, + { + "id": "implement", + "title": "Implement the smallest repair without weakening the regression test.", + "status": "complete", + "completedAt": "2026-11-30T20:44:56.770Z", + "evidence": "Open interactive agy through the managed worker, reuse guarded tmux send/Enter, respect workspace trust, and classify Gemini exits without storing provider text." + }, + { + "id": "green", + "title": "Rerun the same unchanged regression test at a separate fix commit with loop record --phase green; preserve passing proof.", + "status": "complete", + "completedAt": "2026-11-30T20:47:50.295Z", + "evidence": "Three unchanged fixtures passed in a clean snapshot with the same execution environment." + }, + { + "id": "siblings", + "title": "Run harness loop siblings to record the root cause and evaluate the same pattern across committed source.", + "status": "complete", + "completedAt": "2026-11-30T20:49:23.505Z", + "evidence": "siblings-2a8f8140-530b-496c-91c1-b33fa57111a7.json" + }, + { + "id": "verify", + "title": "Run relevant project checks and affected UI browser flows with fresh inspected screenshots and no unexpected browser errors; preserve diagnostics and keep pending until proof passes.", + "status": "pending" + } + ], + "evaluators": [ + { + "id": "check", + "title": "Run the project check script.", + "command": "bun run check", + "step": "verify" + } + ] +} diff --git a/specification/loops/tracker-gemini-interactive/siblings-2a8f8140-530b-496c-91c1-b33fa57111a7.json b/specification/loops/tracker-gemini-interactive/siblings-2a8f8140-530b-496c-91c1-b33fa57111a7.json new file mode 100644 index 00000000000..ea174088f83 --- /dev/null +++ b/specification/loops/tracker-gemini-interactive/siblings-2a8f8140-530b-496c-91c1-b33fa57111a7.json @@ -0,0 +1,299 @@ +{ + "schemaVersion": 1, + "revision": "0ef98562a1f2342c20a21544a660c8f55f07fa9c", + "bugClass": { + "id": "interactive-launcher-mode-mismatch", + "title": "Interactive sessions launch in one-shot mode", + "cause": "An interactive session is started with a one-shot or print-mode CLI flag, so the process emits a single response and exits instead of remaining available for chat. Similar failures can occur when terminal-delivery gates recognize only a fixed set of agent types and omit another interactive launcher. One-shot batch processes that intentionally return one result and exit are outside scope.", + "criteria": "Classify another site when its interactive session launcher uses a print, one-shot, or otherwise non-interactive mode that exits after one response, or when interactive terminal-delivery routing gates only on a fixed agent allowlist and omits an interactive launcher. Either mechanism is sufficient. Exclude batch task processes designed to produce one result and exit.", + "patterns": [ + { + "kind": "text", + "value": "--print", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt-interactive", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt", + "weight": 2 + }, + { + "kind": "text", + "value": "interactive", + "weight": 2 + }, + { + "kind": "text", + "value": "tmux", + "weight": 2 + }, + { + "kind": "text", + "value": "claude", + "weight": 1 + }, + { + "kind": "text", + "value": "codex", + "weight": 1 + }, + { + "kind": "call", + "value": "spawnSync", + "weight": 2 + }, + { + "kind": "call", + "value": "execFileSync", + "weight": 2 + }, + { + "kind": "call", + "value": "exec", + "weight": 1 + }, + { + "kind": "call", + "value": "spawn", + "weight": 2 + }, + { + "kind": "call", + "value": "includes", + "weight": 1 + } + ], + "contextTerms": ["interactive", "print", "prompt", "tmux", "claude", "codex"], + "pathHints": [ + { + "contains": "src/cli/", + "weight": 5 + }, + { + "contains": "src/commands/", + "weight": 4 + }, + { + "contains": "src/workflows/", + "weight": 3 + }, + { + "contains": "src/services/", + "weight": 2 + }, + { + "contains": "packages/desktop/", + "weight": 1 + }, + { + "contains": "packages/hub/", + "weight": 1 + }, + { + "contains": "test/", + "weight": -3 + }, + { + "contains": "specification/", + "weight": -2 + }, + { + "contains": "worker", + "weight": -2 + }, + { + "contains": "server", + "weight": -2 + } + ] + }, + "model": "gpt-6-luna", + "scannedFiles": 10537, + "skipped": [], + "candidates": [ + { + "id": "772ff43174547f74d880", + "path": "src/commands/projects-sessions/TrackerCosSupervisorCommand.ts", + "line": 14, + "lastLine": 14, + "score": 14, + "matches": [ + { + "kind": "text", + "value": "tmux", + "weight": 2 + }, + { + "kind": "text", + "value": "claude", + "weight": 1 + } + ], + "verdict": "unconfirmed", + "impact": 1, + "evidence": "Lines 14–17 show a COS supervisor command with Claude, tmux, and start/resume prompt options, but no launch mode or terminal-delivery routing implementation. The excerpt does not establish a one-shot interactive launch or an allowlist omission." + }, + { + "id": "2586887d9738c1a4d49d", + "path": "src/adapters/agents-providers/module-task-runner-adapter/taskProcess.ts", + "line": 98, + "lastLine": 104, + "score": 22, + "matches": [ + { + "kind": "text", + "value": "codex", + "weight": 1 + }, + { + "kind": "text", + "value": "claude", + "weight": 1 + }, + { + "kind": "text", + "value": "--print", + "weight": 5 + }, + { + "kind": "call", + "value": "spawn", + "weight": 2 + } + ], + "verdict": "dismissed", + "impact": 0, + "evidence": "Lines 98–104 use `--print` for Gemini inside `runNativeTaskProcess` and pass the result to `collectTaskProcess`. This is a task-process path, which the class excludes; the excerpt does not show an interactive session launcher." + }, + { + "id": "74e741ca4646732272f9", + "path": "src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts", + "line": 29, + "lastLine": 29, + "score": 22, + "matches": [ + { + "kind": "text", + "value": "--prompt-interactive", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt", + "weight": 2 + }, + { + "kind": "text", + "value": "interactive", + "weight": 2 + } + ], + "verdict": "dismissed", + "impact": 0, + "evidence": "Lines 25–29 build the Gemini command with `--prompt-interactive` for the tracker managed session. The visible flag selects interactive mode, so this excerpt does not show a one-shot launch mismatch." + }, + { + "id": "58fdebe17a3d7294f827", + "path": "src/services/projects-sessions/tracker-native-runtime-service/trackerGeminiHardStop.ts", + "line": 11, + "lastLine": 11, + "score": 21, + "matches": [ + { + "kind": "text", + "value": "--print", + "weight": 5 + }, + { + "kind": "text", + "value": "interactive", + "weight": 2 + } + ], + "verdict": "dismissed", + "impact": 0, + "evidence": "Line 11 describes `hardStopGeminiHandoff` as stopping a non-interactive Gemini `--print` run past the hard context cap so Tracker can relaunch it. The excerpt identifies an intentional non-interactive run, outside the class." + }, + { + "id": "74dacb9369ad22c81021", + "path": "src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedWorkerProcess.ts", + "line": 87, + "lastLine": 90, + "score": 20, + "matches": [ + { + "kind": "text", + "value": "tmux", + "weight": 2 + }, + { + "kind": "text", + "value": "--prompt-interactive", + "weight": 5 + }, + { + "kind": "text", + "value": "--prompt", + "weight": 2 + }, + { + "kind": "text", + "value": "interactive", + "weight": 2 + }, + { + "kind": "call", + "value": "includes", + "weight": 1 + } + ], + "verdict": "dismissed", + "impact": 0, + "evidence": "Lines 87–90 detect `--prompt-interactive` and set `HARNESS_TRACKER_GEMINI=1` for the managed worker. This is an interactive-mode marker, not evidence that an interactive session is launched one-shot or excluded by a delivery allowlist." + }, + { + "id": "348e0083d77c3f4edee1", + "path": "src/commands/projects-sessions/TrackerServiceCommand.ts", + "line": 21, + "lastLine": 25, + "score": 14, + "matches": [ + { + "kind": "call", + "value": "spawnSync", + "weight": 2 + }, + { + "kind": "call", + "value": "spawn", + "weight": 2 + } + ], + "verdict": "dismissed", + "impact": 0, + "evidence": "Lines 21–25 use `spawnSync` for tracker service installation operations and `spawn` to start a detached service. This is service management, not an interactive agent session launcher or terminal-delivery gate." + } + ], + "errors": [], + "classPath": "specification/bug-classes/interactive-launcher-mode-mismatch.json", + "candidateCounts": [ + { + "status": "dismissed", + "count": 5 + }, + { + "status": "not-reviewed", + "count": 3618 + }, + { + "status": "unconfirmed", + "count": 1 + } + ], + "fullReportSha256": "39f993d2e79f4c8c9f0fb16d758539dee2342c069d5d2767481bfcedf32d6a0f" +} diff --git a/specification/loops/tracker-gemini-interactive/trace.ndjson b/specification/loops/tracker-gemini-interactive/trace.ndjson new file mode 100644 index 00000000000..7bda1de56c9 --- /dev/null +++ b/specification/loops/tracker-gemini-interactive/trace.ndjson @@ -0,0 +1,7 @@ +{"event":"loop.created","timestamp":"2026-11-30T20:30:58.605Z","name":"tracker-gemini-interactive","goal":"Keep managed Gemini Tracker chats interactive in tmux, deliver Hub messages and replies, and preserve exit diagnostics.","template":"bug-fix","templateLineage":["bug-fix"]} +{"event":"step.completed","timestamp":"2026-11-30T20:32:21.905Z","loop":"tracker-gemini-interactive","step":"spec","evidence":"Tracker runs #1907 #1939 #1944 declared readiness and exited 0; agy help confirms --print exits after one turn and --prompt-interactive continues."} +{"event":"step.completed","timestamp":"2026-11-30T20:32:23.712Z","loop":"tracker-gemini-interactive","step":"coverage","evidence":"Managed Gemini launcher test requires --print and ends on the first response. Change its mock to distinguish persistent interactive launch, terminal exit diagnostics and model preflight. Existing Hub idle composer tests omit Gemini. Unit mocks replace the provider executable, so no subscription request is possible. One live Neon medium round trip should take about 1–3 minutes and use the existing subscription with G1 credits disabled."} +{"event":"step.completed","timestamp":"2026-11-30T20:44:54.343Z","loop":"tracker-gemini-interactive","step":"red","evidence":"Combined frozen fixtures at ed58e4696d fail: --print instead of interactive, Gemini send returns false, and provider composer classification is missing."} +{"event":"step.completed","timestamp":"2026-11-30T20:44:56.770Z","loop":"tracker-gemini-interactive","step":"implement","evidence":"Open interactive agy through the managed worker, reuse guarded tmux send/Enter, respect workspace trust, and classify Gemini exits without storing provider text."} +{"event":"step.completed","timestamp":"2026-11-30T20:47:50.295Z","loop":"tracker-gemini-interactive","step":"green","evidence":"Three unchanged fixtures passed in a clean snapshot with the same execution environment."} +{"event":"step.completed","timestamp":"2026-11-30T20:49:23.505Z","loop":"tracker-gemini-interactive","step":"siblings","evidence":"siblings-2a8f8140-530b-496c-91c1-b33fa57111a7.json"} diff --git a/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-claude-trust.json b/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-claude-trust.json index 829f6f686de..73856a3f916 100644 --- a/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-claude-trust.json +++ b/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-claude-trust.json @@ -4,7 +4,7 @@ "uid": "u_lkvgwgi2xf", "kind": "adapter", "title": "trackerClaudeTrust", - "responsibility": "Recognizes the Claude folder-trust dialog and answers it once for an unattended, launcher-owned checkout of an owned repository.", + "responsibility": "Recognizes folder-trust dialogs and confirms them once for unattended, launcher-owned checkouts of owned repositories.", "responsibilityOrigin": "declared", "status": "active", "owns": { @@ -12,7 +12,12 @@ "src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.ts", "src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.types.ts" ], - "symbols": ["claudeTrustDialog", "confirmOwnedWorktreeTrust", "TrackerClaudeTrustPane"] + "symbols": [ + "claudeTrustDialog", + "confirmOwnedWorktreeTrust", + "TrackerClaudeTrustPane", + "confirmGeminiWorktreeTrust" + ] }, "contract": { "origin": "derived", @@ -36,6 +41,16 @@ "name": "confirmOwnedWorktreeTrust.signal", "type": "AbortSignal", "required": true + }, + { + "name": "confirmGeminiWorktreeTrust.pane", + "type": "TrackerClaudeTrustPane", + "required": true + }, + { + "name": "confirmGeminiWorktreeTrust.signal", + "type": "AbortSignal", + "required": true } ], "outputs": [ @@ -46,10 +61,20 @@ { "name": "confirmOwnedWorktreeTrust", "type": "Promise" + }, + { + "name": "confirmGeminiWorktreeTrust", + "type": "Promise" + } + ], + "errors": [ + { + "name": "Error", + "description": "The start was cancelled, or tmux or the private trust receipt could not be accessed.", + "type": "Error" } ], - "errors": [], - "errorStatus": "unknown", + "errorStatus": "declared", "operations": [ { "name": "claudeTrustDialog", @@ -96,6 +121,35 @@ ], "errors": [], "errorStatus": "unknown" + }, + { + "name": "confirmGeminiWorktreeTrust", + "inputs": [ + { + "name": "confirmGeminiWorktreeTrust.pane", + "type": "TrackerClaudeTrustPane", + "required": true + }, + { + "name": "confirmGeminiWorktreeTrust.signal", + "type": "AbortSignal", + "required": true + } + ], + "outputs": [ + { + "name": "confirmGeminiWorktreeTrust", + "type": "Promise" + } + ], + "errors": [ + { + "name": "Error", + "description": "The start was cancelled, or tmux or the private trust receipt could not be accessed.", + "type": "Error" + } + ], + "errorStatus": "declared" } ], "initialization": [] diff --git a/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-managed-gemini-command.json b/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-managed-gemini-command.json index 38e11171f9d..91a227ac356 100644 --- a/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-managed-gemini-command.json +++ b/specification/units/adapter.projects-sessions-tracker-tmux-adapter-tracker-managed-gemini-command.json @@ -4,14 +4,17 @@ "uid": "u_gfe5ygxpac", "kind": "adapter", "title": "trackerManagedGeminiCommand", - "responsibility": "Builds a managed Antigravity CLI command and checks that the signed-in CLI exposes its exact Gemini model.", + "responsibility": "Builds an interactive Antigravity CLI command and checks that the signed-in CLI exposes its exact Gemini model.", "responsibilityOrigin": "declared", "status": "active", "owns": { "source": [ "src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts" ], - "symbols": ["trackerGeminiCommand", "trackerGeminiModelAvailable"] + "symbols": [ + "trackerGeminiCommand", + "trackerGeminiModelAvailable" + ] }, "contract": { "origin": "declared", diff --git a/specification/units/service.projects-sessions-watchdog-pane.json b/specification/units/service.projects-sessions-watchdog-pane.json index eecda27823c..98df8937a78 100644 --- a/specification/units/service.projects-sessions-watchdog-pane.json +++ b/specification/units/service.projects-sessions-watchdog-pane.json @@ -4,7 +4,7 @@ "uid": "u_dakcgp2ade", "kind": "service", "title": "WatchdogPaneService", - "responsibility": "Interprets verified snapshots of Tracker panes and identifies their live run or manual item.", + "responsibility": "Interprets verified Tracker pane snapshots, resolves their run or item, and recognizes empty provider composers for delivery.", "responsibilityOrigin": "declared", "status": "active", "owns": { @@ -12,6 +12,7 @@ "src/services/projects-sessions/WatchdogPaneService.ts", "src/services/projects-sessions/WatchdogPaneService.types.ts", "src/services/projects-sessions/watchdog-pane-service/codexStartupMenus.ts", + "src/services/projects-sessions/watchdog-pane-service/geminiPaneComposer.ts", "src/services/projects-sessions/watchdog-pane-service/paneBackgroundWork.ts" ], "symbols": [ @@ -33,7 +34,8 @@ "WatchdogRun", "WatchdogScan", "codexStartupMenus", - "paneBackgroundWork" + "paneBackgroundWork", + "WatchdogPaneService.deliveryPrompt" ] }, "contract": { @@ -103,6 +105,11 @@ "name": "paneBackgroundWork.pane", "type": "WatchdogPane", "required": true + }, + { + "name": "WatchdogPaneService.deliveryPrompt.pane", + "type": "WatchdogPane", + "required": true } ], "outputs": [ @@ -135,6 +142,11 @@ "name": "WatchdogPaneService.matchesRun", "type": "boolean", "description": "True for a live pane with the exact run session name on the runner socket." + }, + { + "name": "WatchdogPaneService.deliveryPrompt", + "type": "WatchdogCli | 'gemini' | null", + "description": "Provider of the empty composer eligible for Hub delivery, or null when the pane is busy or unsafe." } ], "errors": [], @@ -314,6 +326,25 @@ ], "errors": [], "errorStatus": "unknown" + }, + { + "name": "WatchdogPaneService.deliveryPrompt", + "inputs": [ + { + "name": "WatchdogPaneService.deliveryPrompt.pane", + "type": "WatchdogPane", + "required": true + } + ], + "outputs": [ + { + "name": "WatchdogPaneService.deliveryPrompt", + "type": "WatchdogCli | 'gemini' | null", + "description": "Provider of the empty composer eligible for Hub delivery, or null when the pane is busy or unsafe." + } + ], + "errors": [], + "errorStatus": "none-found" } ], "initialization": [] @@ -335,7 +366,9 @@ } ] }, - "scenarios": ["tracker-watchdog-parity"], + "scenarios": [ + "tracker-watchdog-parity" + ], "budgets": { "size": "frozen", "complexity": "frozen", diff --git a/src/adapters/projects-sessions/TrackerTmuxAdapter.ts b/src/adapters/projects-sessions/TrackerTmuxAdapter.ts index a38748bc449..83f2b39c010 100644 --- a/src/adapters/projects-sessions/TrackerTmuxAdapter.ts +++ b/src/adapters/projects-sessions/TrackerTmuxAdapter.ts @@ -92,7 +92,7 @@ export class TrackerTmuxAdapter { ); if (!candidate) return false; const observed = await this.capture(candidate, signal); - if (decisions.idlePrompt(observed.pane) !== cli) return false; + if (decisions.deliveryPrompt(observed.pane) !== cli) return false; return sendTrackerTmuxNudge( input, observed, diff --git a/src/adapters/projects-sessions/TrackerTmuxAdapter.types.ts b/src/adapters/projects-sessions/TrackerTmuxAdapter.types.ts index c9663192cf7..90c55dd992a 100644 --- a/src/adapters/projects-sessions/TrackerTmuxAdapter.types.ts +++ b/src/adapters/projects-sessions/TrackerTmuxAdapter.types.ts @@ -18,7 +18,7 @@ export interface TrackerTmuxPane { export interface TrackerTmuxNudge { pane: Pick; - cli: WatchdogCli; + cli: WatchdogCli | 'gemini'; message: string; /** Which sessions may match; defaults to Chief of Staff or Tracker worker names. */ names?: RegExp; diff --git a/src/adapters/projects-sessions/tracker-tmux-adapter/submitClaudeTrackerDraft.ts b/src/adapters/projects-sessions/tracker-tmux-adapter/submitClaudeTrackerDraft.ts index 5280bcf1d9a..e43e96b6c3e 100644 --- a/src/adapters/projects-sessions/tracker-tmux-adapter/submitClaudeTrackerDraft.ts +++ b/src/adapters/projects-sessions/tracker-tmux-adapter/submitClaudeTrackerDraft.ts @@ -2,6 +2,7 @@ import { setTimeout as delay } from 'node:timers/promises'; import type { TrackerTmuxPane } from '../TrackerTmuxAdapter.types'; import type { ClaudeComposer } from './submitClaudeTrackerDraft.types'; +import { geminiPromptPlaceholder } from '../../../services/projects-sessions/watchdog-pane-service/geminiPaneComposer'; const escape = '\u001b'; const control = new RegExp(escape + '\\[[0-9;:]*m', 'g'); @@ -15,7 +16,7 @@ const limitMs = 12_000; const enterLimit = 2; /** - * Submit a message already typed into an empty Claude composer. Claude reads text and an Enter that + * Submit a message already typed into an empty Claude or Antigravity composer. The CLI may read text and Enter that * arrive together as one paste, so Enter goes separately, only once the box shows this message, and * again if it is still there after five seconds. Any other text in the box is never submitted. */ @@ -25,6 +26,7 @@ export async function submitClaudeTrackerDraft( capture: () => Promise; submit: (draft: TrackerTmuxPane) => Promise; working: (pane: TrackerTmuxPane['pane']) => boolean; + gemini?: boolean; }, signal: AbortSignal ): Promise { @@ -35,7 +37,7 @@ export async function submitClaudeTrackerDraft( await delay(pollMs, undefined, { signal }); const current = await effects.capture(); if (!current) return false; - const composer = claudeComposer(current.pane, message); + const composer = boxedComposer(current.pane, message, effects.gemini === true); if (enters && accepted(composer, () => effects.working(current.pane))) return true; if (composer !== 'ours' || !enterDue(enters, enteredAt)) continue; // A pane that changed since this capture refuses the key; the next poll looks again. @@ -56,25 +58,39 @@ function enterDue(enters: number, enteredAt: number): boolean { } /** Find the lines between the two rules around the cursor. */ -function composerBox(lines: readonly string[], y: number) { +function composerBox(lines: readonly string[], y: number, prompt: string) { let top = Math.min(y, lines.length - 1); - while (top > 0 && !(lines[top].startsWith('❯') && rule.test(lines[top - 1]))) top--; + while (top > 0 && !(lines[top].startsWith(prompt) && rule.test(lines[top - 1]))) top--; const bottom = lines.findIndex((line, index) => index > top && rule.test(line)); return top > 0 && bottom > y ? { top, bottom } : null; } -function claudeComposer( - { screen, x, y }: TrackerTmuxPane['pane'], - message: string +function boxedComposer( + pane: TrackerTmuxPane['pane'], + message: string, + gemini: boolean ): ClaudeComposer { + const { screen, y } = pane; const lines = screen?.replace(control, '').split('\n') ?? []; - const box = composerBox(lines, y); + const box = composerBox(lines, y, gemini ? '>' : '❯'); if (!box) return 'unknown'; const { top, bottom } = box; - // An empty box keeps the cursor at its start, even while it shows a suggestion. - if (x === 2 && y === top && bottom === top + 1) return 'empty'; + if (emptyComposer(pane, box, lines[top], gemini)) return 'empty'; const draft = unspaced(lines.slice(top, bottom).join('').slice(1)); - return holdsOnly(draft, unspaced(message)) ? 'ours' : 'other'; + const expected = unspaced(message); + return (gemini ? draft === expected : holdsOnly(draft, expected)) ? 'ours' : 'other'; +} + +/** An empty box keeps the cursor at its start, even while it shows a suggestion. */ +function emptyComposer( + { x, y }: TrackerTmuxPane['pane'], + { top, bottom }: { top: number; bottom: number }, + firstLine: string, + gemini: boolean +) { + return ( + x === 2 && y === top && bottom === top + 1 && (!gemini || geminiPromptPlaceholder(firstLine)) + ); } /** The box shows the whole message, or pastes with any typed remainder taken from it in order. */ diff --git a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.ts b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.ts index b3a4de3c4ae..b39fc7aed5f 100644 --- a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.ts +++ b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerClaudeTrust.ts @@ -1,12 +1,15 @@ // @harness-uid u_lkvgwgi2xf import { realpathSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; +import { setTimeout as delay } from 'node:timers/promises'; import { runTrackerHostCommand } from '../tracker-host-process-adapter/trackerHostCommand'; import type { TrackerClaudeTrustPane } from './trackerClaudeTrust.types'; const dialog = /^\s*Accessing workspace:\s*$[\s\S]*^\s*Quick safety check: Is this a project you created or one you trust\?[\s\S]*Enter to confirm\s*·\s*Esc to cancel\s*$/m; const noSelected = /^\s*❯\s+No, exit\s*\n\s*Yes, I trust this folder\s*$/m; +const geminiTrust = + /^Accessing workspace:\s*$[\s\S]*^Do you trust the contents of this project\?\s*$[\s\S]*^> Yes, I trust this folder[ \t]*\n[ \t]+No, exit[ \t]*$/m; const ownedOrigin = /^(?:(?:https:\/\/|ssh:\/\/git@)github\.com\/|git@github\.com:)dafuga\/[a-z0-9_.-]+$/i; @@ -24,13 +27,40 @@ export async function confirmOwnedWorktreeTrust( signal: AbortSignal ): Promise { if (!noSelected.test(screen) || !(await ownedWorktree(pane, signal))) return false; + return sendTrustKeys(pane, 'Down Enter', signal); +} + +/** Wait briefly for Antigravity’s trust dialog in a launcher-owned checkout. */ +export async function confirmGeminiWorktreeTrust( + pane: TrackerClaudeTrustPane, + signal: AbortSignal +) { + if (!(await ownedWorktree(pane, signal))) return; + const { tmux, socket, name } = pane; + for (let attempt = 0; attempt < 8; attempt++) { + const screen = await runTrackerHostCommand( + tmux, + ['-L', socket, 'capture-pane', '-p', '-t', `=${name}:`], + signal + ); + if (screen.code !== 0 || /^\? for shortcuts\s+.*· Gemini\b/mu.test(screen.stdout)) return; + if (geminiTrust.test(screen.stdout)) { + await sendTrustKeys(pane, 'Enter', signal); + return; + } + await delay(400, undefined, { signal }); + } +} + +async function sendTrustKeys(pane: TrackerClaudeTrustPane, keys: string, signal: AbortSignal) { // Claim before sending keys so one launch is never approved twice. writeFileSync(join(pane.directory, 'trust-confirmed'), '', { mode: 0o600, flag: 'wx' }); const { tmux, socket, name, token } = pane; - const guard = `#{&&:#{==:#{HARNESS_TRACKER_ATTEMPT},${token}},#{==:#{session_attached},0}}`; + const detached = `#{&&:#{==:#{HARNESS_TRACKER_ATTEMPT},${token}},#{==:#{session_attached},0}}`; + const guard = keys === 'Enter' ? `#{&&:${detached},#{==:#{HARNESS_TRACKER_GEMINI},1}}` : detached; const sent = await runTrackerHostCommand( tmux, - ['-L', socket, 'if-shell', '-F', '-t', `=${name}:`, guard, `send-keys -t =${name}: Down Enter`], + ['-L', socket, 'if-shell', '-F', '-t', `=${name}:`, guard, `send-keys -t =${name}: ${keys}`], signal ); return sent.code === 0; diff --git a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts index ac20f287520..e0b8e3495e9 100644 --- a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts +++ b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedGeminiCommand.ts @@ -26,7 +26,7 @@ export function trackerGeminiCommand( `${model}-${intelligence || 'medium'}`, '--settings', JSON.stringify({ useG1Credits: false, modelProvider: '' }), - '--print', + '--prompt-interactive', prompt ] }; diff --git a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedWorkerProcess.ts b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedWorkerProcess.ts index 2fbe2b6859d..0cd6f7f31cb 100644 --- a/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedWorkerProcess.ts +++ b/src/adapters/projects-sessions/tracker-tmux-adapter/trackerManagedWorkerProcess.ts @@ -22,6 +22,7 @@ import { managedTmuxEnvironment, missingTmuxSession } from './trackerTmuxClose'; import { trackerManagedProviderEnvironment } from './trackerManagedProviderCommands'; import { trackerCpuBudgetEnvironment } from '../../../utils/projects-sessions/trackerCpuBudget'; import { trackerStartupCause } from './trackerStartupCause'; +import { confirmGeminiWorktreeTrust } from './trackerClaudeTrust'; export const workerScript = `#!/bin/sh set -u @@ -41,11 +42,28 @@ began=$(/bin/date +%s) "$@" result=$? remove_guest_auth -# A launch that dies within a minute leaves its cause only on the pane, which is about to close. -if [ "$result" -ne 0 ] && [ -n "\${HARNESS_TRACKER_PANE:-}" ] && [ "$(($(/bin/date +%s) - began))" -le 60 ]; then - "$HARNESS_TRACKER_TMUX" -L "$HARNESS_TRACKER_SOCKET" capture-pane -p -J -S -16 -t "=$HARNESS_TRACKER_PANE:" 2>/dev/null | - /usr/bin/grep -iE '^[[:space:]]*(error|fatal):[[:space:]]' | /usr/bin/tail -n 1 | - /usr/bin/head -c 500 > "$run_dir/startup-error" +capture_pane() { + "$HARNESS_TRACKER_TMUX" -L "$HARNESS_TRACKER_SOCKET" capture-pane -p -J -S -16 -t "=$HARNESS_TRACKER_PANE:" 2>/dev/null +} +if [ "$result" -ne 0 ] && [ -n "\${HARNESS_TRACKER_PANE:-}" ]; then + if [ "\${HARNESS_TRACKER_GEMINI:-}" = 1 ]; then + # Retain fixed diagnostics only. Provider error text can contain request data. + capture_pane | /usr/bin/awk ' + { line = tolower($0) } + line ~ /^[[:space:]]*(error:|fatal:|✖|✕)/ { + if (line ~ /resource_exhausted|http[[:space:]]+429|quota (reached|exhausted|exceeded)|exhausted your capacity/) { + cause = "Error: Gemini baseline quota exhausted" + } else { + cause = "Error: Gemini reported a provider failure" + } + } + END { if (cause != "") print cause } + ' > "$run_dir/startup-error" + elif [ "$(($(/bin/date +%s) - began))" -le 60 ]; then + # Other providers retain their existing startup-only diagnostic. + capture_pane | /usr/bin/grep -iE '^[[:space:]]*(error|fatal):[[:space:]]' | /usr/bin/tail -n 1 | + /usr/bin/head -c 500 > "$run_dir/startup-error" + fi fi printf '%s\\n' "$result" > "$run_dir/exit.tmp" /bin/mv "$run_dir/exit.tmp" "$run_dir/exit" @@ -69,12 +87,14 @@ function launchEnvironment( `HARNESS_TRACKER_TMUX=${tmux}`, `HARNESS_TRACKER_SOCKET=${trackerSocket(node, socket)}`, `HARNESS_TRACKER_PANE=${pane}`, + ...(command.argv.includes('--prompt-interactive') ? ['HARNESS_TRACKER_GEMINI=1'] : []), ...(command.image ? [`HARNESS_TASK_DOCKER_IMAGE=${command.image}`] : []), ...(command.image && guestAuthFile ? [`HARNESS_TRACKER_GUEST_AUTH_FILE=${guestAuthFile}`] : []), ...(cpuBudget ? trackerCpuBudgetEnvironment(cpuBudget) : []) ]; } +/** Start a detached worker. Outside the home project, lower priority lets Harbor win contention. */ export async function launchTmux( target: TrackerManagedTarget, receipt: TrackerManagedReceipt, @@ -85,8 +105,7 @@ export async function launchTmux( const { node, socket, token } = receipt; const { script, command, cpuBudget } = execution; const environment = launchEnvironment(target, receipt, execution); - // Outside the home project, lower priority lets Harbor win contention. - const priority = cpuBudget ? ['/usr/bin/nice', '-n', '10'] : []; + const gemini = environment.includes('HARNESS_TRACKER_GEMINI=1'); const created = await runTrackerHostCommand( tmux, [ @@ -101,6 +120,7 @@ export async function launchTmux( ...(windowName ? ['-n', windowName] : []), '-e', `HARNESS_TRACKER_ATTEMPT=${token}`, + ...(gemini ? ['-e', 'HARNESS_TRACKER_GEMINI=1'] : []), '-c', worktree, '/usr/bin/env', @@ -110,14 +130,25 @@ export async function launchTmux( script, dirname(script), token, - ...priority, + ...(cpuBudget ? ['/usr/bin/nice', '-n', '10'] : []), ...command.argv ], signal ); - return created.code === 0 - ? undefined - : trackerStartupCause(`tmux could not start the session: ${created.stderr}`); + if (created.code !== 0) + return trackerStartupCause(`tmux could not start the session: ${created.stderr}`); + if (gemini) + await confirmGeminiWorktreeTrust( + { + tmux, + socket: trackerSocket(node, socket), + name: receipt.tmux, + token, + directory: dirname(script) + }, + signal + ); + return undefined; } export function trackerSocket(node: string, socket?: TrackerManagedReceipt['socket']): string { diff --git a/src/adapters/projects-sessions/tracker-tmux-adapter/verifyTrackerTmuxSubmission.ts b/src/adapters/projects-sessions/tracker-tmux-adapter/verifyTrackerTmuxSubmission.ts index a286bf8366f..35926892f7a 100644 --- a/src/adapters/projects-sessions/tracker-tmux-adapter/verifyTrackerTmuxSubmission.ts +++ b/src/adapters/projects-sessions/tracker-tmux-adapter/verifyTrackerTmuxSubmission.ts @@ -81,14 +81,18 @@ export async function sendTrackerTmuxNudge( ]); return result.code === 0 && result.stdout.trim() === 'tracker-watchdog-sent'; }; - const claude = input.cli === 'claude'; - if (!(await send(raw, trackerTmuxKeys(id, input.message, !claude)))) return false; + const boxed = input.cli !== 'codex'; + if (!(await send(raw, trackerTmuxKeys(id, input.message, !boxed)))) return false; const submit = (draft: TrackerTmuxPane) => send(draft.raw, trackerTmuxKeys(id)); const { capture } = effects; - if (!claude) return verifyTrackerTmuxSubmission(input, { capture, submit }, signal); + if (!boxed) return verifyTrackerTmuxSubmission(input, { capture, submit }, signal); const working = ({ y, screen }: TrackerTmuxPane['pane']) => isWorking(y, screen?.replace(control, '') ?? '', 'claude'); - return submitClaudeTrackerDraft(input.message, { capture, submit, working }, signal); + return submitClaudeTrackerDraft( + input.message, + { capture, submit, working, gemini: input.cli === 'gemini' }, + signal + ); } export async function trackerTmuxCwd( diff --git a/src/services/projects-sessions/WatchdogPaneService.ts b/src/services/projects-sessions/WatchdogPaneService.ts index 64444047175..f5f41d8b6ef 100644 --- a/src/services/projects-sessions/WatchdogPaneService.ts +++ b/src/services/projects-sessions/WatchdogPaneService.ts @@ -7,8 +7,8 @@ import type { WatchdogPane, WatchdogRun } from './WatchdogPaneService.types'; - import { codexStartupMenus } from './watchdog-pane-service/codexStartupMenus'; +import { geminiPaneComposer } from './watchdog-pane-service/geminiPaneComposer'; const escape = '\u001b'; const controls = new RegExp(escape + '\\[[0-9;:]*m', 'g'); @@ -158,6 +158,10 @@ export class WatchdogPaneService { return composerProvider(plain, y); } + deliveryPrompt(pane: WatchdogPane): WatchdogCli | 'gemini' | null { + return geminiPaneComposer(pane, controls, busy) ?? this.idlePrompt(pane); + } + isManual(pane: WatchdogPane): boolean { return watchdogManualPrefix(pane.name) !== undefined; } diff --git a/src/services/projects-sessions/tracker-native-runtime-service/trackerWatchdogPort.ts b/src/services/projects-sessions/tracker-native-runtime-service/trackerWatchdogPort.ts index c2d9a59ffac..a32d6b2c43d 100644 --- a/src/services/projects-sessions/tracker-native-runtime-service/trackerWatchdogPort.ts +++ b/src/services/projects-sessions/tracker-native-runtime-service/trackerWatchdogPort.ts @@ -192,7 +192,7 @@ async function deliverToSession( const found = await tmux.scan(signal, names); const [pane] = found; if (found.length !== 1 || !matchesAnswerPane(pane, expected)) return 'missing'; - const cli = panes.idlePrompt(pane); + const cli = panes.deliveryPrompt(pane); if (!cli || (expected && expected.cli !== cli)) return 'busy'; return (await tmux.nudge({ pane, cli, message, names }, signal)) ? 'delivered' : 'busy'; } diff --git a/src/services/projects-sessions/watchdog-pane-service/geminiPaneComposer.ts b/src/services/projects-sessions/watchdog-pane-service/geminiPaneComposer.ts new file mode 100644 index 00000000000..65966209810 --- /dev/null +++ b/src/services/projects-sessions/watchdog-pane-service/geminiPaneComposer.ts @@ -0,0 +1,30 @@ +// @harness-uid u_dakcgp2ade +import type { WatchdogPane } from '../WatchdogPaneService.types'; + +const rule = /^─{8}/u; +const footer = /^\? for shortcuts\s+.*· Gemini\b/u; + +export function geminiPromptPlaceholder(line: string | undefined) { + return /^> (?:Auto|Plan|Accept Edits) mode:.*\(shift\+tab to cycle\)[ \t]*$/i.test(line ?? ''); +} + +export function geminiPaneComposer( + pane: WatchdogPane, + controls: RegExp, + busy: RegExp +): 'gemini' | null { + const { x, y, ready, readable, live, screen } = pane; + if (x !== 2 || !ready || !readable || !live || !screen) return null; + const lines = screen.replace(controls, '').split('\n'); + if (!visibleGeminiComposer(lines, y)) return null; + return busy.test(lines.slice(Math.max(0, y - 5)).join('\n')) ? null : 'gemini'; +} + +function visibleGeminiComposer(lines: string[], y: number) { + return ( + geminiPromptPlaceholder(lines[y]) && + rule.test(lines[y - 1] ?? '') && + rule.test(lines[y + 1] ?? '') && + footer.test(lines[y + 2] ?? '') + ); +} diff --git a/test/adapters/projects-sessions/tracker-managed-host-launcher-gemini.test.ts b/test/adapters/projects-sessions/tracker-managed-host-launcher-gemini.test.ts index bf215f0c1ec..801adf35abf 100644 --- a/test/adapters/projects-sessions/tracker-managed-host-launcher-gemini.test.ts +++ b/test/adapters/projects-sessions/tracker-managed-host-launcher-gemini.test.ts @@ -54,7 +54,7 @@ test('runs the mock Antigravity executable in a managed tmux attempt and seals i 'gemini-4-hydrogen-low', '--settings', '{"useG1Credits":false,"modelProvider":""}', - '--print' + '--prompt-interactive' ]); expect(result.args[6]).toContain('Your tracker item is gemini0001.'); await expectUnavailableModelRejected(launcher, input, signal); diff --git a/test/adapters/projects-sessions/tracker-tmux.test.ts b/test/adapters/projects-sessions/tracker-tmux.test.ts index 313202f05b3..42f5a6b9566 100644 --- a/test/adapters/projects-sessions/tracker-tmux.test.ts +++ b/test/adapters/projects-sessions/tracker-tmux.test.ts @@ -53,6 +53,20 @@ async function proveTmuxPaneIdentity(root: string) { expect(keys[7]).toContain("Don'\\''t send; run this"); expect(keys[7]).toContain('send-keys -t %9 Enter'); expect(readFileSync(join(root, 'submitted'), 'utf8')).toBe('2'); + await proveGeminiChat(tmux, root, signal); +} + +async function proveGeminiChat(tmux: TrackerTmuxAdapter, root: string, signal: AbortSignal) { + const layout = join(root, 'layout-tracker-claude-aqua'); + writeFileSync(layout, readFileSync(layout, 'utf8').replace(/claude$/, 'bash')); + writeFileSync(join(root, 'submitted'), '0'); + const [, pane] = await tmux.scan(signal); + expect(await tmux.nudge({ pane, cli: 'gemini', message: 'MOCK Hub check' }, signal)).toBe(true); + const keys = JSON.parse(readFileSync(join(root, 'keys.json'), 'utf8')); + expect(keys[1]).toBe('tracker-claude-aqua'); + expect(keys[7]).toContain("send-keys -t %9 -l 'MOCK Hub check'"); + expect(keys[7]).not.toContain('Enter'); + expect(readFileSync(join(root, 'submitted'), 'utf8')).toBe('2'); } const tmuxFixture = ` @@ -72,7 +86,11 @@ const count = existsSync(submitted) ? Number(readFileSync(submitted, 'utf8')) : switch (args[2]) { case 'list-panes': case 'display-message': process.stdout.write(raw + '\\n'); break; case 'capture-pane': - if (count === 1) process.stdout.write("fixture\\n\\n› Don't send; run this\\n\\n100% context left\\n"); + if (raw.endsWith('|bash')) { + const input = count === 1 ? 'MOCK Hub check' : 'Auto mode: edits & safe commands auto-approved (shift+tab to cycle)'; + process.stdout.write('MOCK Antigravity CLI\\n──────────────\\n> ' + input + '\\n──────────────\\n? for shortcuts auto · Gemini 4 Neon · medium\\n'); + } + else if (count === 1) process.stdout.write("fixture\\n\\n› Don't send; run this\\n\\n100% context left\\n"); else if (count === 2) process.stdout.write('fixture\\n\\n• Working (0s · esc to interrupt)\\n'); else process.stdout.write('fixture\\n\\n› \\n\\n100% context left\\n'); break; diff --git a/test/services/projects-sessions/watchdog-pane.test.ts b/test/services/projects-sessions/watchdog-pane.test.ts index 411dcbd2366..7f04637926b 100644 --- a/test/services/projects-sessions/watchdog-pane.test.ts +++ b/test/services/projects-sessions/watchdog-pane.test.ts @@ -33,6 +33,17 @@ test('idlePrompt rejects typed text, busy output, other cursors and unsafe captu pane({ screen: codexTrust, y: 6 }) ]; expect(captures.map((capture) => service.idlePrompt(capture))).toEqual(captures.map(() => null)); + const gemini = + 'Antigravity CLI\n──────────────\n> Auto mode: edits & safe commands auto-approved (shift+tab to cycle)\n──────────────\n? for shortcuts auto · Gemini 4 Neon · medium'; + const active = pane({ currentCommand: 'bash', screen: gemini }); + expect(service.deliveryPrompt(active)).toBe('gemini'); + for (const screen of [ + gemini.replace(/> Auto mode:.*\n/, '> draft text\n'), + gemini.replace('Antigravity CLI', 'Working · Esc to cancel'), + gemini.replace('Gemini 4 Neon', 'unknown'), + 'Accessing workspace:\n\n> Yes, I trust this folder' + ]) + expect(service.deliveryPrompt({ ...active, screen })).toBeNull(); }); test('startupPrompt recognizes the active provider menu and only confirms selected detached trust dialogs', () => {