Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(antigravity): full agent parity (context links, canvas control, models, permissions, usage, chat, handoff, recent)

Fabricio Casali92cca13cf51a
diff --git a/src/core/antigravity-chat.ts b/src/core/antigravity-chat.ts
new file mode 100644
index 000000000..0eb4f8599
--- /dev/null
+++ b/src/core/antigravity-chat.ts
@@ -0,0 +1,169 @@
+// Antigravity's (`agy`) transcript file (`~/.gemini/antigravity-cli/brain/<id>/.system_generated/
+// logs/transcript_full.jsonl`) as the ⌘M panel's structured messages — and, through the relay's
+// `chat.page`, the phone's.
+//
+// MEASURED against real `agy` 1.2.7 sessions (Windows 11, 2026-10-14):
+// - `USER_INPUT`: user prompt wrapped in `<USER_REQUEST>...</USER_REQUEST>`, followed by
+// `<ADDITIONAL_METADATA>` and `<USER_SETTINGS_CHANGE>` (`Model Selection`).
+// - `PLANNER_RESPONSE`: model text (`content`) and `tool_calls[]` (`{ id, name, args }`).
+// - `GENERIC`: tool execution output (`content` or `error`), emitted in call order after the
+// preceding `PLANNER_RESPONSE.tool_calls`.
+// - `ERROR_MESSAGE`: turn/API error (`error`).
+// - `SYSTEM_MESSAGE` / `CHECKPOINT`: harness-internal system or compaction steps (omitted).
+//
+// Because steps are updated in place as their status changes (`RUNNING` → `DONE`) and tool outputs
+// attach to the preceding `PLANNER_RESPONSE`, this reader uses the same capped whole-file read as
+// `gemini-chat.ts` and `grok-chat.ts` (`readCappedTail`, `olderCursor: null`).
+import type { ChatMessage, ChatPart, ChatTranscriptResult } from '../shared/types'
+import type { ChatTranscriptPage } from '../shared/chat-page'
+import { CHAT_TOOL_ARG_MAX } from '../shared/chat-command'
+import {
+ antigravityParse,
+ extractAntigravityModelSelection,
+ extractAntigravityToolArg,
+ extractAntigravityUserText,
+ type AntigravityChatLine
+} from './context-link-render'
+import { locateAntigravity } from './handoff/locate'
+import { readCappedTail } from './transcript-reader'
+
+const TOOL_RESULT_LINES = 3
+const TOOL_RESULT_MAX = 500
+const CHAT_META_MAX_CHARS = 100
+
+type ToolPart = Extract<ChatPart, { kind: 'tool' }>
+
+export interface AntigravityChat {
+ messages: ChatMessage[]
+ model?: string
+ skipped: number
+}
+
+function summarize(s: string): string {
+ return s.split('\n').slice(0, TOOL_RESULT_LINES).join(' ').slice(0, TOOL_RESULT_MAX).trim()
+}
+
+function lineTime(raw: unknown): number | undefined {
+ if (typeof raw !== 'string' || !raw) return undefined
+ const ms = Date.parse(raw)
+ return Number.isFinite(ms) ? ms : undefined
+}
+
+export function chatFromAntigravity(buf: string): AntigravityChat {
+ const { lines, skipped: parseSkipped } = antigravityParse(buf)
+ let skipped = parseSkipped
+ const messages: ChatMessage[] = []
+ let pendingTools: ToolPart[] = []
+ let model: string | undefined
+
+ const push = (role: ChatMessage['role'], parts: ChatPart[], rec: AntigravityChatLine): void => {
+ if (!parts.length) return
+ const at = lineTime(rec.created_at)
+ messages.push(at === undefined ? { role, parts } : { role, parts, at })
+ }
+
+ for (const rec of lines) {
+ const rawRec = rec as Record<string, unknown>
+ const inlineModel =
+ typeof rawRec.modelName === 'string'
+ ? rawRec.modelName.trim()
+ : typeof rawRec.model === 'string'
+ ? rawRec.model.trim()
+ : ''
+ if (inlineModel && inlineModel.length <= CHAT_META_MAX_CHARS) {
+ model = inlineModel
+ }
+
+ switch (rec.type) {
+ case 'USER_INPUT': {
+ pendingTools = []
+ const selected = extractAntigravityModelSelection(rec.content)
+ if (selected && selected.length <= CHAT_META_MAX_CHARS) {
+ model = selected
+ }
+ const text = extractAntigravityUserText(rec.content)
+ if (text) push('user', [{ kind: 'text', text }], rec)
+ break
+ }
+ case 'PLANNER_RESPONSE': {
+ pendingTools = []
+ const parts: ChatPart[] = []
+ const text = typeof rec.content === 'string' ? rec.content.trim() : ''
+ if (text) parts.push({ kind: 'text', text })
+ if (Array.isArray(rec.tool_calls)) {
+ for (const c of rec.tool_calls) {
+ if (!c || typeof c !== 'object' || Array.isArray(c)) {
+ skipped++
+ continue
+ }
+ const part: ToolPart = {
+ kind: 'tool',
+ name: typeof c.name === 'string' && c.name ? c.name : 'tool',
+ arg: extractAntigravityToolArg(c.args, CHAT_TOOL_ARG_MAX)
+ }
+ parts.push(part)
+ pendingTools.push(part)
+ }
+ }
+ push('assistant', parts, rec)
+ break
+ }
+ case 'GENERIC': {
+ const tool = pendingTools.shift()
+ const raw =
+ typeof rec.content === 'string' && rec.content
+ ? rec.content
+ : typeof rec.error === 'string'
+ ? rec.error
+ : ''
+ if (tool && tool.result === undefined && raw) {
+ const s = summarize(raw)
+ if (s) tool.result = s
+ }
+ break
+ }
+ case 'ERROR_MESSAGE': {
+ const err = typeof rec.error === 'string' ? rec.error.trim() : ''
+ if (err) push('assistant', [{ kind: 'text', text: `[error] ${err}` }], rec)
+ break
+ }
+ case 'SYSTEM_MESSAGE':
+ case 'CHECKPOINT':
+ break
+ default:
+ skipped++
+ }
+ }
+
+ const out: AntigravityChat = { messages, skipped }
+ if (model !== undefined) out.model = model
+ return out
+}
+
+/**
+ * The antigravity leg of `chat:read-transcript` (routed in transcript-ipc.ts BEFORE anything
+ * claude-shaped runs). Local only (`CHAT_LOCAL_ONLY`): a remote node's session lives on its host
+ * and there is no remote reader for it, so `remoteOnly` answers `unreadable` (paged) / not-found
+ * (legacy) without touching this machine's disk.
+ *
+ * Located strictly by conversation id (`locateAntigravity`) with no cwd fallback.
+ */
+export async function readAntigravityChatTranscript(
+ q: { sessionId?: string; remoteOnly?: boolean },
+ page: ChatTranscriptPage | null
+): Promise<ChatTranscriptResult> {
+ const paging = page ? { olderCursor: null, unmatchedResults: [] } : {}
+ if (q.remoteOnly) {
+ return page ? { messages: [], found: false, ...paging, unreadable: true } : { messages: [], found: false }
+ }
+ const p = q.sessionId ? await locateAntigravity(q.sessionId) : undefined
+ const buf = p ? await readCappedTail(p) : undefined
+ if (buf === undefined) return { messages: [], found: false, ...paging }
+ const chat = chatFromAntigravity(buf)
+ return {
+ messages: chat.messages,
+ found: true,
+ ...paging,
+ ...(page && chat.model !== undefined ? { model: chat.model } : {})
+ }
+}
diff --git a/src/core/antigravity-session.ts b/src/core/antigravity-session.ts
new file mode 100644
index 000000000..dc4d2f3c7
--- /dev/null
+++ b/src/core/antigravity-session.ts
@@ -0,0 +1,90 @@
+// Pure parsers for Antigravity's (`agy`) session JSONL (`~/.gemini/antigravity-cli/brain/<id>/
+// .system_generated/logs/transcript_full.jsonl`).
+//
+// MEASURED against real `agy` 1.2.7 transcripts (Windows 11, 2026-10-14):
+// - Every `PLANNER_RESPONSE` record carries `input_tokens: number`, optional
+// `cache_read_tokens: number`, and `output_tokens: number`.
+// - The prompt context size on a step is `input_tokens + (cache_read_tokens ?? 0)`.
+// - At turn 0 (`step_index: 0`), `USER_INPUT.content` includes
+// `<USER_SETTINGS_CHANGE>\nThe user changed setting \`Model Selection\` from None to <Display Name>.`
+// and hook payloads also carry `modelName` (e.g. `gemini-4-argon-medium`).
+// `antigravityWindowFor` maps both spellings to the context window and returns `null` when
+// unknown.
+import { antigravityParse, extractAntigravityModelSelection } from './context-link-render'
+import { antigravityWindowFor } from './model-window'
+
+export interface AntigravityTokens {
+ usedTokens: number
+ model: string | null
+}
+
+let lastHookModel: string | null = null
+
+/** Record the latest model id reported by an Antigravity hook payload (`payload.modelName`). */
+export function rememberAntigravityModel(model: string | null | undefined): void {
+ const m = typeof model === 'string' ? model.trim() : ''
+ if (m) lastHookModel = m
+}
+
+/**
+ * Scan an Antigravity transcript buffer for the last `PLANNER_RESPONSE` token usage and the latest
+ * known model name (`fallbackModel` wins when provided, else the transcript's `Model Selection`,
+ * else the last hook-reported `modelName`).
+ */
+export function pickAntigravityTokens(
+ text: string | string[],
+ fallbackModel?: string | null
+): AntigravityTokens | null {
+ const buf = Array.isArray(text) ? text.join('\n') : text
+ let usedTokens: number | null = null
+ let transcriptModel: string | null = null
+
+ for (const rec of antigravityParse(buf).lines) {
+ const rawRec = rec as Record<string, unknown>
+ const inlineModel =
+ typeof rawRec.modelName === 'string'
+ ? rawRec.modelName.trim()
+ : typeof rawRec.model === 'string'
+ ? rawRec.model.trim()
+ : ''
+ if (inlineModel) transcriptModel = inlineModel
+
+ if (rec.type === 'USER_INPUT') {
+ const selected = extractAntigravityModelSelection(rec.content)
+ if (selected) transcriptModel = selected
+ } else if (rec.type === 'PLANNER_RESPONSE') {
+ const input =
+ typeof rec.input_tokens === 'number' && Number.isFinite(rec.input_tokens)
+ ? rec.input_tokens
+ : null
+ const cached =
+ typeof rec.cache_read_tokens === 'number' && Number.isFinite(rec.cache_read_tokens)
+ ? rec.cache_read_tokens
+ : 0
+ if (input !== null && input >= 0 && cached >= 0 && input + cached > 0) {
+ usedTokens = input + cached
+ }
+ }
+ }
+
+ if (usedTokens === null) return null
+ const model = fallbackModel?.trim() || transcriptModel || lastHookModel
+ return { usedTokens, model: model || null }
+}
+
+/**
+ * `ContextTail`'s `parse` callback for Antigravity transcripts (plus direct calculation when a
+ * caller passes `fallbackModel`).
+ */
+export function antigravityContextParse(
+ text: string | string[],
+ fallbackModel?: string | null
+): { used: number; window: number | null; model: string | null } | null {
+ const tok = pickAntigravityTokens(text, fallbackModel)
+ if (!tok) return null
+ return {
+ used: tok.usedTokens,
+ window: antigravityWindowFor(tok.model),
+ model: tok.model
+ }
+}
diff --git a/src/core/antigravity.test.ts b/src/core/antigravity.test.ts
new file mode 100644
index 000000000..c8edc2b6e
--- /dev/null
+++ b/src/core/antigravity.test.ts
@@ -0,0 +1,211 @@
+import fs from 'node:fs'
+import os from 'node:os'
+import path from 'node:path'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import {
+ antigravityParse,
+ extractAntigravityModelSelection,
+ extractAntigravityUserText,
+ linesFromAntigravity,
+ renderTranscriptLines
+} from './context-link-render'
+import { antigravityWindowFor } from './model-window'
+import {
+ antigravityContextParse,
+ pickAntigravityTokens,
+ rememberAntigravityModel
+} from './antigravity-session'
+import { chatFromAntigravity, readAntigravityChatTranscript } from './antigravity-chat'
+import { locateAntigravity } from './handoff/locate'
+import { listRecentConversations, resetRecentConversationsCacheForTests, type RecentRoots } from './recent-conversations'
+
+const SESSION_ID = '6a7d832d-57cf-4620-882b-bdab326e9101'
+
+const SAMPLE_TRANSCRIPT = [
+ JSON.stringify({
+ step_index: 0,
+ type: 'USER_INPUT',
+ status: 'DONE',
+ content:
+ '<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to Gemini 4 Argon (Medium).\n</USER_SETTINGS_CHANGE>\n<USER_REQUEST>\nFix the context link bug in NodeTerm\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\ntime\n</ADDITIONAL_METADATA>'
+ }),
+ JSON.stringify({
+ step_index: 1,
+ type: 'PLANNER_RESPONSE',
+ status: 'DONE',
+ thinking: 'Let us inspect config.ts first.',
+ content: 'I will inspect `config.ts` now.',
+ tool_calls: [
+ {
+ id: 'tc-1',
+ name: 'view_file',
+ args: { AbsolutePath: 'C:/Desenv/particular/nodeterm/src/shared/agents/config.ts' }
+ }
+ ],
+ input_tokens: 12400,
+ cache_read_tokens: 8000,
+ output_tokens: 150
+ }),
+ JSON.stringify({
+ step_index: 2,
+ type: 'SYSTEM_MESSAGE',
+ status: 'DONE',
+ content: 'System reminder'
+ }),
+ JSON.stringify({
+ step_index: 3,
+ type: 'CHECKPOINT',
+ status: 'DONE',
+ content: 'Compacted summary'
+ }),
+ JSON.stringify({
+ step_index: 4,
+ type: 'PLANNER_RESPONSE',
+ status: 'DONE',
+ content: 'All capabilities are now wired.',
+ input_tokens: 25000,
+ cache_read_tokens: 15000,
+ output_tokens: 210
+ })
+].join('\n')
+
+describe('Antigravity transcript parsing & context-link rendering', () => {
+ it('extracts user request text and model selection from USER_INPUT', () => {
+ const raw =
+ '<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to Gemini 4 Argon (High).\n</USER_SETTINGS_CHANGE>\n<USER_REQUEST>\nHello Argon\n</USER_REQUEST>'
+ expect(extractAntigravityModelSelection(raw)).toBe('Gemini 4 Argon (High)')
+ expect(extractAntigravityUserText(raw)).toBe('Hello Argon')
+ })
+
+ it('parses human, assistant, and tool call lines while skipping SYSTEM_MESSAGE and CHECKPOINT without counting them as errors', () => {
+ const parsed = antigravityParse(SAMPLE_TRANSCRIPT)
+ expect(parsed.skipped).toBe(0)
+ expect(parsed.lines).toHaveLength(5)
+
+ const lines = linesFromAntigravity(SAMPLE_TRANSCRIPT)
+ expect(lines).toEqual([
+ 'user: Fix the context link bug in NodeTerm',
+ 'assistant: I will inspect `config.ts` now.',
+ ' $ view_file C:/Desenv/particular/nodeterm/src/shared/agents/config.ts',
+ 'assistant: All capabilities are now wired.'
+ ])
+ expect(renderTranscriptLines('antigravity', SAMPLE_TRANSCRIPT)).toEqual(lines)
+ })
+})
+
+describe('Antigravity context window & token usage', () => {
+ it('maps Gemini/Argon/Claude 4.6 models to 1M and GPT-OSS models to 128k', () => {
+ expect(antigravityWindowFor('gemini-4-argon-medium')).toBe(1_000_000)
+ expect(antigravityWindowFor('Gemini 4 Argon (High)')).toBe(1_000_000)
+ expect(antigravityWindowFor('gemini-3.1-pro-high')).toBe(1_000_000)
+ expect(antigravityWindowFor('claude-opus-4-6-thinking')).toBe(1_000_000)
+ expect(antigravityWindowFor('Claude Sonnet 4.6 (Thinking)')).toBe(1_000_000)
+ expect(antigravityWindowFor('gpt-oss-120b-medium')).toBe(128_000)
+ expect(antigravityWindowFor(null)).toBeNull()
+ })
+
+ it('computes used tokens as input_tokens + cache_read_tokens from the latest PLANNER_RESPONSE', () => {
+ const tok = pickAntigravityTokens(SAMPLE_TRANSCRIPT)
+ expect(tok).toEqual({
+ usedTokens: 40_000,
+ model: 'Gemini 4 Argon (Medium)'
+ })
+ expect(antigravityContextParse(SAMPLE_TRANSCRIPT)).toEqual({
+ used: 40_000,
+ window: 1_000_000,
+ model: 'Gemini 4 Argon (Medium)'
+ })
+ })
+
+ it('falls back to the last hook-reported model when the transcript chunk has no USER_SETTINGS_CHANGE', () => {
+ rememberAntigravityModel('gpt-oss-120b-medium')
+ const partial = JSON.stringify({
+ step_index: 5,
+ type: 'PLANNER_RESPONSE',
+ content: 'Done.',
+ input_tokens: 10_000,
+ cache_read_tokens: 5_000
+ })
+ expect(antigravityContextParse(partial)).toEqual({
+ used: 15_000,
+ window: 128_000,
+ model: 'gpt-oss-120b-medium'
+ })
+ })
+})
+
+describe('Antigravity chat view, locator, and recent conversations', () => {
+ let home: string
+
+ beforeEach(() => {
+ resetRecentConversationsCacheForTests()
+ home = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-agy-test-'))
+ vi.spyOn(os, 'homedir').mockReturnValue(home)
+ })
+
+ afterEach(() => {
+ vi.restoreAllMocks()
+ fs.rmSync(home, { recursive: true, force: true })
+ })
+
+ it('converts an Antigravity transcript into ChatMessages for ⌘M', () => {
+ const chat = chatFromAntigravity(SAMPLE_TRANSCRIPT)
+ expect(chat.skipped).toBe(0)
+ expect(chat.messages).toHaveLength(3)
+ expect(chat.messages[0]).toEqual({
+ role: 'user',
+ parts: [{ kind: 'text', text: 'Fix the context link bug in NodeTerm' }]
+ })
+ expect(chat.messages[1].role).toBe('assistant')
+ expect(chat.messages[1].parts).toEqual([
+ { kind: 'text', text: 'I will inspect `config.ts` now.' },
+ {
+ kind: 'tool',
+ name: 'view_file',
+ arg: 'C:/Desenv/particular/nodeterm/src/shared/agents/config.ts'
+ }
+ ])
+ })
+
+ it('locates transcript_full.jsonl on disk, reads paged chat transcripts, and lists recent conversations with cwd from history.jsonl', async () => {
+ const agyRoot = path.join(home, '.gemini', 'antigravity-cli')
+ const logsDir = path.join(agyRoot, 'brain', SESSION_ID, '.system_generated', 'logs')
+ fs.mkdirSync(logsDir, { recursive: true })
+ const tf = path.join(logsDir, 'transcript_full.jsonl')
+ fs.writeFileSync(tf, SAMPLE_TRANSCRIPT + '\n')
+ fs.writeFileSync(
+ path.join(agyRoot, 'history.jsonl'),
+ JSON.stringify({
+ display: 'Fix the context link bug in NodeTerm',
+ timestamp: 1760444000000,
+ workspace: '/srv/nodeterm',
+ conversationId: SESSION_ID
+ }) + '\n'
+ )
+
+ expect(await locateAntigravity(SESSION_ID)).toBe(tf)
+ expect(await locateAntigravity('../escape')).toBeUndefined()
+
+ const readRes = await readAntigravityChatTranscript({ sessionId: SESSION_ID }, null)
+ expect(readRes.found).toBe(true)
+ expect(readRes.messages).toHaveLength(3)
+
+ const roots: RecentRoots = {
+ claude: [],
+ codex: [],
+ geminiTmp: null,
+ grokSessions: null,
+ copilot: [],
+ antigravity: agyRoot
+ }
+ const recent = await listRecentConversations(roots)
+ expect(recent).toHaveLength(1)
+ expect(recent[0]).toMatchObject({
+ agentId: 'antigravity',
+ sessionId: SESSION_ID,
+ cwd: '/srv/nodeterm',
+ title: 'Fix the context link bug in NodeTerm',
+ titleSource: 'prompt'
+ })
+ })
+})
diff --git a/src/core/claude-accounts-core.ts b/src/core/claude-accounts-core.ts
index 6d91ed2a4..da9862698 100644
--- a/src/core/claude-accounts-core.ts
+++ b/src/core/claude-accounts-core.ts
@@ -331,6 +331,8 @@ export function isSafeLocalTranscriptPath(
// read at `~/.ssh/id_rsa`, and a home-wide allowance would hand that straight back.
const geminiRoot = path.join(homeDir, '.gemini', 'tmp')
if (abs === geminiRoot || abs.startsWith(geminiRoot + path.sep)) return true
+ const antigravityRoot = path.join(homeDir, '.gemini', 'antigravity-cli', 'brain')
+ if (abs === antigravityRoot || abs.startsWith(antigravityRoot + path.sep)) return true
const codexRoot = path.join(codexHomeDir || path.join(homeDir, '.codex'), 'sessions')
if (abs === codexRoot || abs.startsWith(codexRoot + path.sep)) return true
// grok: `$GROK_HOME/sessions/<url-encoded cwd>/<sessionId>/`. `sessions` and not `$GROK_HOME`,
diff --git a/src/core/context-ensure.test.ts b/src/core/context-ensure.test.ts
index b25afabf3..f29e98cd2 100644
--- a/src/core/context-ensure.test.ts
+++ b/src/core/context-ensure.test.ts
@@ -37,6 +37,7 @@ let f: ReturnType<typeof fakePlatform>
let claude: ReturnType<typeof fakeTail>
let codex: ReturnType<typeof fakeTail>
let gemini: ReturnType<typeof fakeTail>
+let antigravity: ReturnType<typeof fakeTail>
// The registered listener is async; `CorePlatform.on` types its return as void (a cast is
// fire-and-forget on the wire), so awaiting it here — which is what lets these tests assert on the
@@ -59,6 +60,8 @@ const tailFor = (agentId: string | undefined): ContextTail | undefined => {
return codex
case 'gemini':
return gemini
+ case 'antigravity':
+ return antigravity
default:
return undefined
}
@@ -81,6 +84,7 @@ beforeEach(() => {
claude = fakeTail()
codex = fakeTail()
gemini = fakeTail()
+ antigravity = fakeTail()
})
afterEach(() => {
vi.restoreAllMocks()
@@ -135,6 +139,17 @@ describe('local rehydration, per agent', () => {
expect(claude.tracked).toEqual([])
})
+ it('rehydrates an antigravity node from its own brain transcript, never claude’s', async () => {
+ const logs = path.join(home, '.gemini', 'antigravity-cli', 'brain', SID, '.system_generated', 'logs')
+ fs.mkdirSync(logs, { recursive: true })
+ const tf = path.join(logs, 'transcript_full.jsonl')
+ fs.writeFileSync(tf, '{}\n')
+ registerContextEnsureIpc({ tailFor })
+ await ensure({ agentId: 'antigravity' })
+ expect(antigravity.tracked).toEqual([[SID, tf]])
+ expect(claude.tracked).toEqual([])
+ })
+
/**
* THE regression this routing exists to prevent, and the reason the renderer gate could move.
*
diff --git a/src/core/context-ensure.ts b/src/core/context-ensure.ts
index 45e2a34ae..0ba3a059b 100644
--- a/src/core/context-ensure.ts
+++ b/src/core/context-ensure.ts
@@ -26,7 +26,7 @@
import { IPC } from '../shared/ipc'
import { platform } from './platform'
import type { ContextTail } from './context-tail'
-import { locateCodex, locateGemini } from './handoff/locate'
+import { locateAntigravity, locateCodex, locateGemini } from './handoff/locate'
import { locateCursorChat } from './cursor-chat'
import { resolveTranscript } from './transcript-ipc'
import { SESSION_ID_RE } from './transcript-reader'
@@ -83,8 +83,8 @@ export interface ContextEnsureDeps {
* - **claude** — `resolveTranscript`, including its `accountId`-scoped cwd fallback (correct here:
* the file genuinely is claude's, and the account scoping is what keeps a managed-account node
* off the system root).
- * - **codex / gemini** — `locateCodex` / `locateGemini`, keyed STRICTLY by session id with no cwd
- * fallback, so neither can adopt a session that is not its own.
+ * - **codex / gemini / antigravity** — `locateCodex` / `locateGemini` / `locateAntigravity`, keyed
+ * STRICTLY by session id with no cwd fallback, so none can adopt a session that is not its own.
* - **grok** — none, and that is by construction rather than an omission. Grok's meter reads
* `signals.json` out of a session directory learned from a hook event (`grokSessionDirFor`),
* which is empty after a restart; `locateGrok` resolves a different file entirely
@@ -111,6 +111,8 @@ function localTranscriptFor(
// search, let alone stand in for the id). A remote node never gets here: `ensureRemote` is terminal.
case 'cursor':
return locateCursorChat(q.sessionId)
+ case 'antigravity':
+ return locateAntigravity(q.sessionId)
default:
return Promise.resolve(undefined)
}
diff --git a/src/core/context-link-core.ts b/src/core/context-link-core.ts
index 18a3e4c11..5bdd4d24d 100644
--- a/src/core/context-link-core.ts
+++ b/src/core/context-link-core.ts
@@ -49,7 +49,7 @@ export async function resolveLinkTranscript(
): Promise<string> {
if (link.note != null) return ''
const agent = link.agentId ?? 'claude'
- if (agent === 'claude') {
+ if (agent === 'claude' || agent === 'antigravity') {
const hooked = deps.hooked(link.id)
if (hooked) return hooked
}
diff --git a/src/core/context-link-render.ts b/src/core/context-link-render.ts
index 3e92f424a..2047c242b 100644
--- a/src/core/context-link-render.ts
+++ b/src/core/context-link-render.ts
@@ -309,6 +309,147 @@ export function linesFromGrok(buf: string): string[] {
/** How many lines of this buffer could not be parsed. Skipped, but never in silence. */
linesFromGrok.skipped = (buf: string): number => grokParse(buf).skipped
+export interface AntigravityToolCall {
+ id?: string
+ name?: string
+ args?: Record<string, unknown> | string
+}
+
+export interface AntigravityChatLine {
+ step_index?: number
+ source?: string
+ type?: string
+ status?: string
+ created_at?: string
+ content?: string
+ thinking?: string
+ error?: string
+ input_tokens?: number
+ cache_read_tokens?: number
+ output_tokens?: number
+ tool_calls?: AntigravityToolCall[]
+}
+
+const ANTIGRAVITY_TOOL_ARG_KEYS = [
+ 'CommandLine',
+ 'AbsolutePath',
+ 'TargetFile',
+ 'query',
+ 'Url',
+ 'command',
+ 'file_path',
+ 'path',
+ 'pattern',
+ 'toolSummary'
+] as const
+
+/**
+ * Extract the human-typed prompt from an Antigravity `USER_INPUT` step's `content`.
+ *
+ * MEASURED on `agy` 1.2.7 (`transcript_full.jsonl`): `USER_INPUT.content` wraps what the person
+ * typed inside `<USER_REQUEST>\n...\n</USER_REQUEST>`, followed by `<ADDITIONAL_METADATA>...` and
+ * `<USER_SETTINGS_CHANGE>...` blocks. Only the `<USER_REQUEST>` body (or the text outside injected
+ * metadata blocks when unwrapped) is what the user actually said.
+ */
+export function extractAntigravityUserText(raw: string | undefined): string {
+ if (typeof raw !== 'string' || !raw) return ''
+ const reqMatch = /<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/.exec(raw)
+ if (reqMatch) return reqMatch[1].trim()
+ return raw
+ .replace(/<ADDITIONAL_METADATA>[\s\S]*?<\/ADDITIONAL_METADATA>/g, '')
+ .replace(/<USER_SETTINGS_CHANGE>[\s\S]*?<\/USER_SETTINGS_CHANGE>/g, '')
+ .replace(/<CONTEXT_SUMMARY>[\s\S]*?<\/CONTEXT_SUMMARY>/g, '')
+ .trim()
+}
+
+/** Extract the `Model Selection` display name from a `USER_INPUT` step's `<USER_SETTINGS_CHANGE>`. */
+export function extractAntigravityModelSelection(raw: string | undefined): string | undefined {
+ if (typeof raw !== 'string' || !raw) return undefined
+ const m = /setting `Model Selection` from [^\n]+? to ([^\n.]+)\./.exec(raw)
+ return m?.[1]?.trim() || undefined
+}
+
+export function extractAntigravityToolArg(
+ args: Record<string, unknown> | string | undefined,
+ maxLen: number = TOOL_ARG_MAX
+): string {
+ if (!args) return ''
+ if (typeof args === 'string') return args.slice(0, maxLen)
+ if (typeof args === 'object' && !Array.isArray(args)) {
+ for (const k of ANTIGRAVITY_TOOL_ARG_KEYS) {
+ const v = args[k]
+ if (typeof v === 'string' && v.trim()) return v.trim().slice(0, maxLen)
+ }
+ return JSON.stringify(args).slice(0, maxLen)
+ }
+ return ''
+}
+
+export function antigravityParse(buf: string): { lines: AntigravityChatLine[]; skipped: number } {
+ const lines: AntigravityChatLine[] = []
+ let skipped = 0
+ for (const raw of buf.split('\n')) {
+ const t = raw.trim()
+ if (!t) continue
+ const o = parseJson(t) as AntigravityChatLine | undefined
+ if (!o || typeof o !== 'object' || Array.isArray(o)) {
+ skipped++
+ continue
+ }
+ lines.push(o)
+ }
+ return { lines, skipped }
+}
+
+/**
+ * One whole Antigravity `transcript_full.jsonl` (or `transcript.jsonl`) -> display strings.
+ *
+ * MEASURED on `agy` 1.2.7 (Windows 11, 2026-10-14):
+ * - `USER_INPUT`: user prompt wrapped in `<USER_REQUEST>...</USER_REQUEST>` plus metadata tags
+ * - `PLANNER_RESPONSE`: assistant `content` and `tool_calls[]` (`{ id, name, args }`)
+ * - `GENERIC`: tool execution output (`content` or `error`) emitted after `PLANNER_RESPONSE`
+ * - `ERROR_MESSAGE`: turn/API error (`error`)
+ * - `SYSTEM_MESSAGE` / `CHECKPOINT`: harness-internal system or compaction step (omitted)
+ */
+export function linesFromAntigravity(buf: string): string[] {
+ const res: string[] = []
+ for (const o of antigravityParse(buf).lines) {
+ switch (o.type) {
+ case 'USER_INPUT': {
+ const t = extractAntigravityUserText(o.content)
+ if (t) res.push(`user: ${t}`)
+ break
+ }
+ case 'PLANNER_RESPONSE': {
+ const t = typeof o.content === 'string' ? o.content.trim() : ''
+ if (t) res.push(`assistant: ${t}`)
+ for (const c of o.tool_calls ?? []) {
+ if (!c || typeof c !== 'object') continue
+ const arg = extractAntigravityToolArg(c.args, TOOL_ARG_MAX)
+ res.push(` $ ${c.name || 'tool'}${arg ? ` ${arg}` : ''}`)
+ }
+ break
+ }
+ case 'GENERIC': {
+ const raw = typeof o.content === 'string' && o.content ? o.content : typeof o.error === 'string' ? o.error : ''
+ const s = raw.split('\n').slice(0, 3).join(' ').slice(0, TOOL_RESULT_MAX).trim()
+ if (s) res.push(` = ${s}`)
+ break
+ }
+ case 'ERROR_MESSAGE': {
+ const e = typeof o.error === 'string' ? o.error.trim() : ''
+ if (e) res.push(`assistant: [error] ${e}`)
+ break
+ }
+ default:
+ break
+ }
+ }
+ return res
+}
+
+linesFromAntigravity.skipped = (buf: string): number => antigravityParse(buf).skipped
+
/** Parse a whole transcript buffer with the parser its agent's format needs. */
export function renderTranscriptLines(agent: string | undefined, buf: string): string[] {
if (agent === 'gemini') return linesFromGemini(buf)
@@ -316,6 +457,7 @@ export function renderTranscriptLines(agent: string | undefined, buf: string): s
// cursor's transcript text is newline-delimited message JSON built from its SQLite store
// (`cursorTranscriptText`), not a file on disk.
if (agent === 'cursor') return linesFromCursor(buf)
+ if (agent === 'antigravity') return linesFromAntigravity(buf)
const parse = agent === 'codex' ? linesFromCodex : linesFromClaude
const lines: string[] = []
for (const raw of buf.split('\n')) {
diff --git a/src/core/context-link.ts b/src/core/context-link.ts
index ed211023e..2045ab2d5 100644
--- a/src/core/context-link.ts
+++ b/src/core/context-link.ts
@@ -40,7 +40,13 @@ import {
type ContextLinkVerb
} from './context-link-render'
import { hookServer } from './agents/hook-server'
-import { locateClaude, locateCodex, locateGemini, locateGrok } from './handoff/locate'
+import {
+ locateAntigravity,
+ locateClaude,
+ locateCodex,
+ locateGemini,
+ locateGrok
+} from './handoff/locate'
import { cursorTranscriptText, locateCursorChat } from './cursor-chat'
export { setNodeTranscript } from './context-link-core'
@@ -105,6 +111,7 @@ const LINK_LOCATORS = {
codex: locateCodex,
gemini: locateGemini,
grok: locateGrok,
+ antigravity: locateAntigravity,
cursor: (sessionId: string) => locateCursorChat(sessionId)
}
diff --git a/src/core/handoff/locate.ts b/src/core/handoff/locate.ts
index e0c8dda3d..5bfcc264c 100644
--- a/src/core/handoff/locate.ts
+++ b/src/core/handoff/locate.ts
@@ -123,3 +123,34 @@ export async function locateGemini(sessionId: string): Promise<string | undefine
}
return undefined
}
+
+export const ANTIGRAVITY_SESSION_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/
+
+/**
+ * antigravity (`agy`): `<home>/.gemini/antigravity-cli/brain/<sessionId>/.system_generated/logs/
+ * transcript_full.jsonl` (falling back to `transcript.jsonl`).
+ *
+ * Keyed strictly by `sessionId` (`conversationId` in hook payloads and `agy --conversation=<id>`)
+ * with no newest-file fallback: `brain/` holds every conversation on the machine, so a scan would
+ * hand back a stranger's session.
+ */
+export async function locateAntigravity(sessionId: string): Promise<string | undefined> {
+ if (!sessionId || !ANTIGRAVITY_SESSION_ID_RE.test(sessionId) || sessionId.includes('..')) {
+ return undefined
+ }
+ const brain = path.resolve(os.homedir(), '.gemini', 'antigravity-cli', 'brain')
+ const logsDir = path.resolve(brain, sessionId, '.system_generated', 'logs')
+ const rel = path.relative(brain, logsDir)
+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return undefined
+ for (const file of ['transcript_full.jsonl', 'transcript.jsonl']) {
+ const candidate = path.join(logsDir, file)
+ try {
+ const st = await fs.promises.lstat(candidate)
+ if (st.isFile()) return candidate
+ } catch {
+ /* try next */
+ }
+ }
+ return undefined
+}
+
diff --git a/src/core/model-window.ts b/src/core/model-window.ts
index c63acb2de..8b73aeda1 100644
--- a/src/core/model-window.ts
+++ b/src/core/model-window.ts
@@ -69,3 +69,23 @@ export function geminiWindowFor(model: string | null): number | null {
if (!model) return null
return GEMMA_4_MODELS.has(model) ? GEMINI_GEMMA_4_TOKEN_LIMIT : GEMINI_DEFAULT_TOKEN_LIMIT
}
+
+/**
+ * Context window for an Antigravity (`agy`) model id or display name (`modelName` in hook payloads
+ * or `Model Selection` in `USER_INPUT` steps).
+ *
+ * MEASURED catalogue (`agy models`, 1.2.7):
+ * - `gemini-4-argon-*`, `gemini-3.8-flash-*` ("Gemini 4 Argon ...", "Gemini 3.8 Flash ...") → 1M
+ * - `claude-opus-*`, `claude-sonnet-*` ("Claude Opus ...", "Claude Sonnet ...") → `staticWindowFor`
+ * - `gpt-oss-120b-*` ("GPT-OSS 120B ...") → 128k
+ * - Unknown or empty → `null` (never guess a denominator).
+ */
+export function antigravityWindowFor(model: string | null | undefined): number | null {
+ const m = model?.trim()
+ if (!m) return null
+ if (/^gemini\b|^gemini-/i.test(m)) return LARGE_WINDOW
+ if (/^claude\b|^claude-/i.test(m)) return staticWindowFor(m)
+ if (/^gpt-oss-120b\b|^gpt-oss-120b-/i.test(m)) return 128_000
+ return null
+}
+
diff --git a/src/core/recent-conversations.ts b/src/core/recent-conversations.ts
index e09002e0c..22d856276 100644
--- a/src/core/recent-conversations.ts
+++ b/src/core/recent-conversations.ts
@@ -48,6 +48,8 @@ import {
isSafeGrokSessionId
} from './agents/grok-paths'
import { chatMessagesFromCopilot, COPILOT_EVENTS_FILE, copilotSessionStateRoots } from './copilot-chat'
+import { chatFromAntigravity } from './antigravity-chat'
+import { ANTIGRAVITY_SESSION_ID_RE } from './handoff/locate'
import { untrustedLine } from './github/control-read'
/** Candidates opened per root (newest by mtime). A root with thousands of old transcripts costs a
@@ -75,6 +77,7 @@ export interface RecentRoots {
geminiTmp: string | null
grokSessions: string | null
copilot: string[]
+ antigravity?: string | null
}
type Parsed = Omit<RecentConversation, 'lastActiveAt' | 'accountId'> | null
@@ -119,7 +122,8 @@ export function defaultRecentRoots(req: RecentConversationsRequest = {}): Recent
codex,
geminiTmp: path.join(geminiHome, '.gemini', 'tmp'),
grokSessions: grokSessionsDir(),
- copilot: copilotSessionStateRoots()
+ copilot: copilotSessionStateRoots(),
+ antigravity: path.join(os.homedir(), '.gemini', 'antigravity-cli')
}
}
@@ -342,6 +346,15 @@ async function parseCopilot(c: Candidate, dirId: string): Promise<Parsed> {
return { agentId: 'copilot', sessionId: dirId, cwd, ...t }
}
+async function parseAntigravity(c: Candidate, sessionId: string, cwd: string | null): Promise<Parsed> {
+ if (!ANTIGRAVITY_SESSION_ID_RE.test(sessionId) || !validId(sessionId)) return null
+ const lines = await headLines(c)
+ const prompt = firstPrompt(chatFromAntigravity(lines.join('\n')).messages)
+ const t = titled(null, prompt)
+ if (t.titleSource === 'none') return null
+ return { agentId: 'antigravity', sessionId, cwd, ...t }
+}
+
async function cached(c: Candidate, parse: () => Promise<Parsed>): Promise<Parsed> {
const hit = cache.get(c.file)
if (hit && hit.size === c.size && hit.mtimeMs === c.mtimeMs) return hit.parsed
@@ -477,6 +490,47 @@ async function copilotRows(root: string): Promise<Row[]> {
return out
}
+async function antigravityRows(root: string): Promise<Row[]> {
+ const brain = path.join(root, 'brain')
+ const ids = (await listDirs(brain)).filter((id) => ANTIGRAVITY_SESSION_ID_RE.test(id) && validId(id))
+ if (!ids.length) return []
+ const cwdBySession = new Map<string, string>()
+ const histCand = await statCandidate(path.join(root, 'history.jsonl'))
+ if (histCand && histCand.size > 0) {
+ try {
+ const text = await tailText(histCand, HEAD_BYTES)
+ for (const line of text.split('\n')) {
+ const o = parseJson(line)
+ if (!o || typeof o.conversationId !== 'string') continue
+ const cwd = safeCwd(o.workspace)
+ if (cwd) cwdBySession.set(o.conversationId, cwd)
+ }
+ } catch {
+ /* unreadable history.jsonl leaves cwd null */
+ }
+ }
+ const cands = await mapLimit(ids, STAT_CONCURRENCY, async (id) => {
+ const logs = path.join(brain, id, '.system_generated', 'logs')
+ return (
+ (await statCandidate(path.join(logs, 'transcript_full.jsonl'))) ??
+ (await statCandidate(path.join(logs, 'transcript.jsonl')))
+ )
+ })
+ const idByFile = new Map<string, string>()
+ ids.forEach((id, i) => {
+ const c = cands[i]
+ if (c) idByFile.set(c.file, id)
+ })
+ const out: Row[] = []
+ for (const c of newest(cands)) {
+ const id = idByFile.get(c.file)!
+ const cwd = cwdBySession.get(id) ?? null
+ const r = row(await cached(c, () => parseAntigravity(c, id, cwd)), c)
+ if (r) out.push(r)
+ }
+ return out
+}
+
/** Newest first; the same (agent, session) seen twice keeps its NEWEST sighting. A tie — a codex
* rollout HARDLINKED into a second home by "Switch Codex account" is one inode, so both sightings
* carry the same mtime — goes to the MANAGED account's copy: that is the account the conversation
@@ -513,7 +567,8 @@ export async function listRecentConversations(
...roots.codex.map((r) => codexRows(r.home, r.accountId)),
...(roots.geminiTmp ? [geminiRows(roots.geminiTmp)] : []),
...(roots.grokSessions ? [grokRows(roots.grokSessions)] : []),
- ...roots.copilot.map((r) => copilotRows(r))
+ ...roots.copilot.map((r) => copilotRows(r)),
+ ...(roots.antigravity ? [antigravityRows(roots.antigravity)] : [])
]
const settled = await Promise.allSettled(jobs)
const rows = settled.flatMap((s) => (s.status === 'fulfilled' ? s.value : []))
diff --git a/src/core/transcript-ipc.ts b/src/core/transcript-ipc.ts
index 4fb365c17..273badfed 100644
--- a/src/core/transcript-ipc.ts
+++ b/src/core/transcript-ipc.ts
@@ -22,6 +22,7 @@ import { platform } from './platform'
import { parseGrokChat } from './grok-chat'
import type { RemoteGrokChat } from './remote-grok-chat'
import { readGeminiChatTranscript } from './gemini-chat'
+import { readAntigravityChatTranscript } from './antigravity-chat'
import { chatMessagesFromCodex, locateCodexRollout, parseCodexChatWindow } from './codex-chat'
import { chatMessagesFromCopilot, locateCopilotTranscript, parseCopilotChatWindow } from './copilot-chat'
import { readOpencodeChat, type OpencodeExportRun } from './opencode-chat'
@@ -392,6 +393,9 @@ export async function readChatTranscript(
// reads gemini's file too. Its own locator, keyed strictly on the session id in the file header —
// never claude's resolver, never a cwd — and local-only (`CHAT_LOCAL_ONLY`).
if (agentId && capabilityAgentId(agentId) === 'gemini') return readGeminiChatTranscript({ sessionId, remoteOnly }, page)
+ if (agentId && capabilityAgentId(agentId) === 'antigravity') {
+ return readAntigravityChatTranscript({ sessionId, remoteOnly }, page)
+ }
// Codex — the builtin or a custom agent whose base harness it is — is routed BEFORE the claude
// path for the same reason as grok: a codex thread id never resolves under claude's tree, and the
// cwd fallback would then answer with somebody else's claude session.
diff --git a/src/main/handoff/index.ts b/src/main/handoff/index.ts
index 499f800bb..5e3636219 100644
--- a/src/main/handoff/index.ts
+++ b/src/main/handoff/index.ts
@@ -17,8 +17,15 @@ import { renderClaudeTranscript } from './render-claude'
import { renderCodexTranscript } from './render-codex'
import { renderGeminiTranscript } from './render-gemini'
import { renderGrokTranscript } from './render-grok'
+import { renderAntigravityTranscript } from './render-antigravity'
import { budgetHandoff } from './budget'
-import { locateClaude, locateCodex, locateGemini, locateGrok } from '../../core/handoff/locate'
+import {
+ locateAntigravity,
+ locateClaude,
+ locateCodex,
+ locateGemini,
+ locateGrok
+} from '../../core/handoff/locate'
import { cursorTranscriptText, locateCursorChat } from '../../core/cursor-chat'
import { renderCursorTranscript } from './render-cursor'
import { capabilityAgentId } from '../../shared/agents/config'
@@ -33,7 +40,8 @@ const RENDERERS: Record<string, Renderer> = {
codex: renderCodexTranscript,
gemini: renderGeminiTranscript,
grok: renderGrokTranscript,
- cursor: renderCursorTranscript
+ cursor: renderCursorTranscript,
+ antigravity: renderAntigravityTranscript
}
const LOCATORS: Record<string, Locator> = {
@@ -42,7 +50,8 @@ const LOCATORS: Record<string, Locator> = {
gemini: locateGemini,
grok: locateGrok,
// (id, accountId?) is the shared shape; cursor's second parameter is a cwd, so it is not passed.
- cursor: (sessionId) => locateCursorChat(sessionId)
+ cursor: (sessionId) => locateCursorChat(sessionId),
+ antigravity: locateAntigravity
}
/** Filesystem-safe handoff filename for a node + ISO-ish timestamp. Node ids are
diff --git a/src/main/handoff/render-antigravity.test.ts b/src/main/handoff/render-antigravity.test.ts
new file mode 100644
index 000000000..9892cf446
--- /dev/null
+++ b/src/main/handoff/render-antigravity.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, it } from 'vitest'
+import { renderAntigravityTranscript } from './render-antigravity'
+
+const SAMPLE_TRANSCRIPT = [
+ JSON.stringify({
+ step_index: 0,
+ type: 'USER_INPUT',
+ status: 'DONE',
+ content:
+ '<USER_SETTINGS_CHANGE>\nThe user changed setting `Model Selection` from None to Gemini 4 Argon (Medium).\n</USER_SETTINGS_CHANGE>\n<USER_REQUEST>\nFix the context link bug in NodeTerm\n</USER_REQUEST>\n<ADDITIONAL_METADATA>\ntime\n</ADDITIONAL_METADATA>'
+ }),
+ JSON.stringify({
+ step_index: 1,
+ type: 'PLANNER_RESPONSE',
+ status: 'DONE',
+ thinking: 'Let us inspect config.ts first.',
+ content: 'I will inspect `config.ts` now.',
+ tool_calls: [
+ {
+ id: 'tc-1',
+ name: 'view_file',
+ args: { AbsolutePath: 'C:/Desenv/particular/nodeterm/src/shared/agents/config.ts' }
+ }
+ ]
+ }),
+ JSON.stringify({
+ step_index: 2,
+ type: 'SYSTEM_MESSAGE',
+ status: 'DONE',
+ content: 'System reminder'
+ }),
+ JSON.stringify({
+ step_index: 3,
+ type: 'CHECKPOINT',
+ status: 'DONE',
+ content: 'Compacted summary'
+ }),
+ JSON.stringify({
+ step_index: 4,
+ type: 'PLANNER_RESPONSE',
+ status: 'DONE',
+ content: 'All capabilities are now wired.'
+ })
+].join('\n')
+
+describe('renderAntigravityTranscript', () => {
+ it('renders user and assistant turns to Markdown while omitting harness metadata and checkpoints', () => {
+ const md = renderAntigravityTranscript(SAMPLE_TRANSCRIPT)
+ expect(md).toContain('## User\n\nFix the context link bug in NodeTerm')
+ expect(md).toContain('## Assistant\n\nI will inspect `config.ts` now.')
+ expect(md).toContain('$ view_file C:/Desenv/particular/nodeterm/src/shared/agents/config.ts')
+ expect(md).toContain('## Assistant\n\nAll capabilities are now wired.')
+ expect(md).not.toContain('USER_SETTINGS_CHANGE')
+ expect(md).not.toContain('System reminder')
+ expect(md).not.toContain('Compacted summary')
+ })
+})
diff --git a/src/main/handoff/render-antigravity.ts b/src/main/handoff/render-antigravity.ts
new file mode 100644
index 000000000..b8ee82f70
--- /dev/null
+++ b/src/main/handoff/render-antigravity.ts
@@ -0,0 +1,33 @@
+// Renders an Antigravity (`agy`) transcript (`~/.gemini/antigravity-cli/brain/<id>/
+// .system_generated/logs/transcript_full.jsonl`) to full Markdown for cross-agent handoff.
+//
+// Shape knowledge lives in `linesFromAntigravity` (`core/context-link-render.ts`), which strips
+// injected `<ADDITIONAL_METADATA>` / `<USER_SETTINGS_CHANGE>` tags from `USER_INPUT` and omits
+// harness-internal `SYSTEM_MESSAGE` / `CHECKPOINT` steps so tooling prose is never attributed to
+// the human speaker.
+import { linesFromAntigravity } from '../../core/context-link-render'
+
+const ROLE_RE = /^(\w+): ([\s\S]*)$/
+
+const HEADINGS: Record<string, string> = {
+ user: 'User',
+ assistant: 'Assistant'
+}
+
+export function renderAntigravityTranscript(raw: string): string {
+ const out: string[] = []
+ for (const line of linesFromAntigravity(raw)) {
+ if (line.startsWith(' ')) {
+ out.push(line.trim())
+ continue
+ }
+ const m = ROLE_RE.exec(line)
+ if (!m) {
+ out.push(line)
+ continue
+ }
+ const [, role, text] = m
+ out.push(`## ${HEADINGS[role] ?? role}\n\n${text}`)
+ }
+ return out.join('\n\n')
+}
diff --git a/src/main/index.ts b/src/main/index.ts
index ed32569f5..d8348a63c 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -290,6 +290,7 @@ import { applyCursorRaw, cursorContextParse, readCursorContextSource, releaseCur
import { GROK_CHAT_HISTORY_FILE } from '../core/agents/grok-paths'
import { createGrokSubagentFormatter } from '../core/grok-subagent-format'
import { geminiContextParse } from '../core/gemini-session'
+import { antigravityContextParse, rememberAntigravityModel } from '../core/antigravity-session'
import { codexContextParse, codexContextModel } from '../core/codex-session'
import { createCodexSubagentFormatter } from '../core/codex-subagent-format'
import { codexHome } from '../core/usage/codex-usage'
@@ -3038,6 +3039,10 @@ app.whenReady().then(async () => {
parse: cursorContextParse,
readSource: readCursorContextSource
})
+ const antigravityContextTail = createContextTail(pushContextUpdate, {
+ parse: antigravityContextParse,
+ wholeFile: true
+ })
// Remote (SSH-project) counterparts: a node whose pty runs on a remote host has its Claude
// transcript on that host, so its meter / subagent transcript / search must read over the
// project's ControlMaster. One RemoteFile bound to the SSH-project manager's own ssh runner
@@ -3347,6 +3352,8 @@ app.whenReady().then(async () => {
return geminiContextTail
case 'cursor':
return cursorContextTail
+ case 'antigravity':
+ return antigravityContextTail
default:
return undefined
}
@@ -3938,6 +3945,23 @@ app.whenReady().then(async () => {
if (p.hook_event_name === 'SessionEnd' && p.session_id) tail.untrack(p.session_id)
return
}
+ if (agentId === 'antigravity') {
+ const p = payload as {
+ conversationId?: string
+ transcriptPath?: string
+ modelName?: string
+ }
+ rememberAntigravityModel(p.modelName)
+ const transcriptPath = safeTranscriptPath(p.transcriptPath)
+ if (p.conversationId && transcriptPath) {
+ antigravityContextTail.track(p.conversationId, transcriptPath)
+ }
+ if (nodeId && p.conversationId) nodeContextSession.set(nodeId, p.conversationId)
+ if (nodeId && p.conversationId && transcriptPath) {
+ setNodeTranscript(nodeId, p.conversationId, transcriptPath)
+ }
+ return
+ }
if (agentId !== 'claude') return
// Mirror the per-node "what it's doing now" activity line for the phone (mobile-usage-inbox).
// Runs BEFORE the local/remote split so it covers remote (SSH) nodes too — it needs only
@@ -4116,6 +4140,7 @@ app.whenReady().then(async () => {
codexContextTail.untrack(sessionId)
grokContextTail.untrack(sessionId)
cursorContextTail.untrack(sessionId)
+ antigravityContextTail.untrack(sessionId)
remoteContextTail.untrack(sessionId)
remoteTranscriptBySession.delete(sessionId)
locatedTranscriptSessions.delete(sessionId)
diff --git a/src/main/remote/host-chat.test.ts b/src/main/remote/host-chat.test.ts
index 2e47cc036..a6839ce6e 100644
--- a/src/main/remote/host-chat.test.ts
+++ b/src/main/remote/host-chat.test.ts
@@ -68,7 +68,7 @@ describe('host-chat page', () => {
await expect(createHostChat(d).page('n1', {})).rejects.toThrow()
})
it('serves only chat-capable agents (resolved through the base harness), and reads nothing otherwise', async () => {
- for (const agentId of ['antigravity', undefined]) {
+ for (const agentId of ['custom:unbased', undefined]) {
const d = deps({ lookupNode: () => ({ agentId, sessionId: 'sid-1' }) })
expect(await createHostChat(d).page('n1', {})).toBe('unsupported')
expect(d.readTranscript).not.toHaveBeenCalled()
@@ -81,10 +81,12 @@ describe('host-chat page', () => {
setCustomAgentBaseResolver(null)
}
})
- it('serves gemini, handing its OWN agent id to the reader (which routes it off claude\'s resolver)', async () => {
- const d = deps({ lookupNode: () => ({ agentId: 'gemini', sessionId: 'sid-1' }) })
- expect(await createHostChat(d).page('n1', {})).toMatchObject({ version: 1 })
- expect(d.readTranscript).toHaveBeenCalledWith(expect.objectContaining({ agentId: 'gemini', sessionId: 'sid-1' }), {})
+ it('serves gemini and antigravity, handing each its OWN agent id to the reader (which routes it off claude\'s resolver)', async () => {
+ for (const agentId of ['gemini', 'antigravity'] as const) {
+ const d = deps({ lookupNode: () => ({ agentId, sessionId: 'sid-1' }) })
+ expect(await createHostChat(d).page('n1', {})).toMatchObject({ version: 1 })
+ expect(d.readTranscript).toHaveBeenCalledWith(expect.objectContaining({ agentId, sessionId: 'sid-1' }), {})
+ }
})
it('serves a codex node, passing its own agent id so core routes it to the codex reader', async () => {
const d = deps({ lookupNode: () => ({ cwd: '/srv/app', agentId: 'codex', sessionId: 'sid-1', remote: true }) })
diff --git a/src/renderer/lib/controlRouting.test.ts b/src/renderer/lib/controlRouting.test.ts
index ca2745b45..db8176fc4 100644
--- a/src/renderer/lib/controlRouting.test.ts
+++ b/src/renderer/lib/controlRouting.test.ts
@@ -239,13 +239,13 @@ describe('sourceIsControlCapable', () => {
})
it('accepts every canvas-control-capable agent', () => {
- for (const id of ['claude', 'codex', 'gemini', 'opencode', 'grok', 'cursor']) {
+ for (const id of ['claude', 'codex', 'gemini', 'opencode', 'grok', 'cursor', 'antigravity']) {
expect(sourceIsControlCapable(id)).toBe(true)
}
})
it('rejects an agent that never gets NODETERM_CANVAS_CONTROL', () => {
- expect(sourceIsControlCapable('antigravity')).toBe(false)
+ expect(sourceIsControlCapable('custom:unbased')).toBe(false)
})
})
@@ -322,7 +322,7 @@ describe('answerBrowserResolve — the renderer answers ONLY what it alone knows
})
it('a non-control-capable source is reported as such (main turns it into the refusal)', () => {
- const p = proj({ nodes: [{ id: 'x-1', agentId: 'antigravity' }], agentBrowserControl: true, capabilityAck: { agentBrowserControl: 'kept' } })
+ const p = proj({ nodes: [{ id: 'x-1', agentId: 'custom:unbased' }], agentBrowserControl: true, capabilityAck: { agentBrowserControl: 'kept' } })
expect(answerBrowserResolve(p, 'x-1')).toMatchObject({ ok: true, sourceControlCapable: false })
})
})
diff --git a/src/server/agent-status.ts b/src/server/agent-status.ts
index 67d13e3a6..316b8a448 100644
--- a/src/server/agent-status.ts
+++ b/src/server/agent-status.ts
@@ -20,6 +20,7 @@ import { ClaudeSubagentLifecycle } from '../core/claude-subagent-lifecycle'
import { claudeSubagentTranscriptPath, isClaudeAgentId } from '../shared/agents/claude-subagents'
import { createContextTail, type ContextTail, type TaskNotification } from '../core/context-tail'
import { geminiContextParse } from '../core/gemini-session'
+import { antigravityContextParse, rememberAntigravityModel } from '../core/antigravity-session'
import { codexContextParse } from '../core/codex-session'
import { grokContextParse, GROK_SIGNALS_FILE } from '../core/grok-signals'
import { applyCursorRaw, cursorContextParse, readCursorContextSource, releaseCursorRaw } from '../core/cursor-chat'
@@ -75,7 +76,13 @@ export interface WireAgentStatusOptions {
export function wireAgentStatus(
platform: ServerPlatform,
opts: WireAgentStatusOptions = {}
-): { contextTail: ContextTail; geminiContextTail: ContextTail; codexContextTail: ContextTail; cursorContextTail: ContextTail } {
+): {
+ contextTail: ContextTail
+ geminiContextTail: ContextTail
+ codexContextTail: ContextTail
+ cursorContextTail: ContextTail
+ antigravityContextTail: ContextTail
+} {
const hooks = opts.hooks ?? hookServer
// nodeId → the agent session id of whichever hook-capable CLI runs in that node (claude's, and
// since the grok branch below, grok's)
@@ -190,6 +197,10 @@ export function wireAgentStatus(
parse: cursorContextParse,
readSource: readCursorContextSource
})
+ const antigravityContextTail = createContextTail(pushContextUpdate, {
+ parse: antigravityContextParse,
+ wholeFile: true
+ })
const emit = (e: NormalizedAgentEvent): void => {
// Claude subagent events first become one card per child (claudeSubagents above); every other
@@ -398,6 +409,23 @@ export function wireAgentStatus(
if (p.hook_event_name === 'SessionEnd' && p.session_id) tail.untrack(p.session_id)
return
}
+ if (agentId === 'antigravity') {
+ const p = payload as {
+ conversationId?: string
+ transcriptPath?: string
+ modelName?: string
+ }
+ rememberAntigravityModel(p.modelName)
+ const transcriptPath = safeTranscriptPath(p.transcriptPath)
+ if (p.conversationId && transcriptPath) {
+ antigravityContextTail.track(p.conversationId, transcriptPath)
+ }
+ if (nodeId && p.conversationId) nodeContextSession.set(nodeId, p.conversationId)
+ if (nodeId && p.conversationId && transcriptPath) {
+ setNodeTranscript(nodeId, p.conversationId, transcriptPath)
+ }
+ return
+ }
if (agentId !== 'claude') return
// Mirror the per-node "what it's doing now" activity line for the phone (mobile-usage-inbox).
// Independent of the transcript-tailing below (no path needed), so it runs first.
@@ -489,6 +517,7 @@ export function wireAgentStatus(
codexContextTail.untrack(sessionId)
grokContextTail.untrack(sessionId)
cursorContextTail.untrack(sessionId)
+ antigravityContextTail.untrack(sessionId)
nodeContextSession.delete(nodeId)
}
const subs = nodeSubagents.get(nodeId)
@@ -500,8 +529,15 @@ export function wireAgentStatus(
platform.on(IPC.ptyDestroy, (nodeId: string) => releaseNodeTails(nodeId))
platform.on(IPC.ptyRecycle, (nodeId: string) => releaseNodeTails(nodeId))
- // `codexContextTail` joins the two already returned so `src/server/index.ts` can register the
- // context-meter rehydration over all three. Keeping a tail private here would mean a second
- // instance somewhere else metering the same sessions twice.
- return { contextTail, geminiContextTail, codexContextTail, cursorContextTail }
+ // `codexContextTail`, `cursorContextTail` and `antigravityContextTail` join the two already
+ // returned so `src/server/index.ts` can register the context-meter rehydration over all five.
+ // Keeping a tail private here would mean a second instance somewhere else metering the same
+ // sessions twice.
+ return {
+ contextTail,
+ geminiContextTail,
+ codexContextTail,
+ cursorContextTail,
+ antigravityContextTail
+ }
}
diff --git a/src/server/headless-node-factory.test.ts b/src/server/headless-node-factory.test.ts
index 3bb0bd4fe..a581ccc88 100644
--- a/src/server/headless-node-factory.test.ts
+++ b/src/server/headless-node-factory.test.ts
@@ -11,6 +11,7 @@ import { initPlatform, resetPlatformForTests } from '../core/platform'
import { WorkspaceStore } from '../core/workspace-store'
import { createCanvasAuthority } from '../core/canvas-authority'
import { initCanvasSync, publishCanvasMutation, setReflectedListener } from '../core/canvas-sync'
+import { AGENT_HOOK_TARGETS } from '../shared/agents/config'
import type { AgentState } from '../shared/agents/normalize'
import { MAX_LAUNCH_LINE_BYTES } from '../shared/canonical-line'
import { RUN_NOW_AFTER_REFUSAL } from '../shared/control-verbs'
@@ -1446,16 +1447,21 @@ describe('HeadlessNodeFactory', () => {
it('refuses a station that could never report, and --run-now, before creating anything', async () => {
const ws = await store.load({ sideline: false })
- ws.projects[0].nodes.push({ ...terminal('term-agy', 'Agy'), agentId: 'antigravity' })
+ ws.projects[0].nodes.push({ ...terminal('term-hook-only', 'HookOnly'), agentId: 'custom:hook-only' })
await store.save(ws)
- ownership.record('term-agy', { sourceNodeId: 'term-source', projectId: 'project-1' })
+ ownership.record('term-hook-only', { sourceNodeId: 'term-source', projectId: 'project-1' })
const before = (await store.load({ sideline: false })).projects[0].nodes.length
- const r = await factory.openAgent(
- 'term-source',
- { agent: 'claude', prompt: 'x', 'after-success': 'term-agy' },
- true
- )
- expect(r).toMatchObject({ ok: false, error: expect.stringContaining('cannot report an outcome') })
+ ;(AGENT_HOOK_TARGETS as unknown as string[]).push('custom:hook-only')
+ try {
+ const r = await factory.openAgent(
+ 'term-source',
+ { agent: 'claude', prompt: 'x', 'after-success': 'term-hook-only' },
+ true
+ )
+ expect(r).toMatchObject({ ok: false, error: expect.stringContaining('cannot report an outcome') })
+ } finally {
+ ;(AGENT_HOOK_TARGETS as unknown as string[]).pop()
+ }
await expect(
factory.openAgent(
'term-source',
diff --git a/src/server/index.ts b/src/server/index.ts
index 8124d26cb..3e732ebfe 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -560,7 +560,13 @@ export async function startServer(
// rather than an unknown channel when canvas control is off.
registerStationOutcomeIpc(platform, () => canvasControl?.stationOutcomes ?? null)
registerStationHandoverIpc(platform, () => canvasControl?.stationHandovers ?? null)
- const { contextTail, geminiContextTail, codexContextTail, cursorContextTail } = wireAgentStatus(platform, {
+ const {
+ contextTail,
+ geminiContextTail,
+ codexContextTail,
+ cursorContextTail,
+ antigravityContextTail
+ } = wireAgentStatus(platform, {
onEvent: (event) => canvasControl?.onAgentEvent(event)
})
// Cursor NEEDS YOU, same seam as the desktop (core/agents/cursor-approval.ts).
@@ -610,6 +616,8 @@ export async function startServer(
return geminiContextTail
case 'cursor':
return cursorContextTail
+ case 'antigravity':
+ return antigravityContextTail
default:
return undefined
}
diff --git a/src/shared/agents/approval-mode.test.ts b/src/shared/agents/approval-mode.test.ts
index acc31822e..0093c2724 100644
--- a/src/shared/agents/approval-mode.test.ts
+++ b/src/shared/agents/approval-mode.test.ts
@@ -261,6 +261,14 @@ describe('approvalFlags: cursor', () => {
})
describe('approvalFlags — an agent with no permission mode', () => {
+ it('maps antigravity modes onto --mode and --dangerously-skip-permissions', () => {
+ expect(approvalFlags('antigravity', 'manual')).toEqual([])
+ expect(approvalFlags('antigravity', 'plan')).toEqual(['--mode', 'plan'])
+ expect(approvalFlags('antigravity', 'acceptEdits')).toEqual(['--mode', 'accept-edits'])
+ expect(approvalFlags('antigravity', 'auto')).toEqual(['--mode', 'auto'])
+ expect(approvalFlags('antigravity', 'bypassPermissions')).toEqual(['--dangerously-skip-permissions'])
+ })
+
it('emits nothing for opencode and for a custom agent', () => {
for (const id of ['opencode', 'custom:abc']) {
for (const m of ALL_PERMISSION_MODES)
@@ -276,7 +284,7 @@ describe('approvalFlags — an agent with no permission mode', () => {
describe('UI copy derived from the mapping', () => {
it('names every agent whose start-up mode we can set', () => {
const label = permissionModeAgentsLabel()
- for (const name of ['Claude Code', 'Grok', 'Gemini', 'Codex', 'Cursor'])
+ for (const name of ['Claude Code', 'Grok', 'Gemini', 'Codex', 'Cursor', 'Antigravity'])
expect(label).toContain(name)
expect(label).not.toContain('opencode')
})
@@ -286,7 +294,7 @@ describe('UI copy derived from the mapping', () => {
// the same drift the label helper exists to prevent, one level down. The ids are exported so the
// caller can agree with them; this pins that they describe the SAME set the label does.
const ids = permissionModeAgentIds({ exclude: ['claude'] })
- expect(ids).toEqual(['grok', 'gemini', 'codex', 'cursor'])
+ expect(ids).toEqual(['grok', 'gemini', 'codex', 'cursor', 'antigravity'])
const label = permissionModeAgentsLabel({ exclude: ['claude'] })
for (const id of ids) expect(label.toLowerCase()).toContain(id)
expect(label).not.toContain('Claude')
diff --git a/src/shared/agents/approval-mode.ts b/src/shared/agents/approval-mode.ts
index 7defb13c6..c94259363 100644
--- a/src/shared/agents/approval-mode.ts
+++ b/src/shared/agents/approval-mode.ts
@@ -81,6 +81,11 @@ const CODEX_APPROVAL_BASELINE: readonly string[] = ['on-request', 'never']
interface ApprovalDialect {
flag: string
modes: Partial<Record<AgentPermissionMode, string>>
+ /**
+ * Optional boolean switch emitted instead of `[flag, value]` for modes that use a standalone flag
+ * (antigravity's `--dangerously-skip-permissions` alongside `--mode accept-edits|auto|plan`).
+ */
+ standaloneFlags?: Partial<Record<AgentPermissionMode, string>>
/**
* Does this CLI's OWN default already prompt before every action?
*
@@ -122,6 +127,15 @@ const GEMINI_MODES: Partial<Record<AgentPermissionMode, string>> = {
// answer and reproduces the pre-branch launch exactly. See `unsupportedModesNote`.
}
+const ANTIGRAVITY_MODES: Partial<Record<AgentPermissionMode, string>> = {
+ plan: 'plan',
+ acceptEdits: 'accept-edits',
+ auto: 'auto'
+ // `manual` → agy's own default (no flag).
+ // `bypassPermissions` uses the standalone switch `--dangerously-skip-permissions`
+ // (`standaloneFlags` below), measured on `agy --help` (1.2.7).
+}
+
const CODEX_MODES: Partial<Record<AgentPermissionMode, string>> = {
// codex is the FIRST agent where `manual` emits a flag, and — where the CLI still has the value
// — it has to. For every other agent `manual` = no flag = a default that already prompts
@@ -196,6 +210,12 @@ const CURSOR_MODES: Partial<Record<AgentPermissionMode, string>> = {
*/
const APPROVAL_DIALECTS: Partial<Record<AgentId, ApprovalDialect>> = {
gemini: { flag: '--approval-mode', modes: GEMINI_MODES, manualIsDefault: true },
+ antigravity: {
+ flag: '--mode',
+ modes: ANTIGRAVITY_MODES,
+ standaloneFlags: { bypassPermissions: '--dangerously-skip-permissions' },
+ manualIsDefault: true
+ },
codex: {
flag: '--ask-for-approval',
modes: CODEX_MODES,
@@ -235,6 +255,15 @@ function emittableValue(
return dialect.vocabulary(caps).includes(value) ? value : undefined
}
+function standaloneFlag(
+ dialect: ApprovalDialect,
+ mode: AgentPermissionMode
+): string | undefined {
+ return dialect.standaloneFlags && Object.hasOwn(dialect.standaloneFlags, mode)
+ ? dialect.standaloneFlags[mode]
+ : undefined
+}
+
const dialectFor = (agentId: AgentId): ApprovalDialect | null =>
Object.hasOwn(APPROVAL_DIALECTS, agentId) ? APPROVAL_DIALECTS[agentId] ?? null : null
@@ -251,12 +280,13 @@ export function modeSupported(
if (!dialect) return hasPermissionMode(agentId)
// `manual` — "ask each time" — is reached two different ways, which is why the table alone is
// not its authority: by emitting NO flag on a CLI whose own default already prompts
- // (`manualIsDefault`: claude, grok, gemini), or by emitting a value that means it (codex's
- // `untrusted`). An agent that can do NEITHER cannot keep the promise, and this is where that is
- // admitted — codex >= 0.149.0 is exactly that case, and it is why this early return stopped
- // being an unconditional `true`.
+ // (`manualIsDefault`: claude, grok, gemini, antigravity), or by emitting a value that means it
+ // (codex's `untrusted`). An agent that can do NEITHER cannot keep the promise, and this is where
+ // that is admitted — codex >= 0.149.0 is exactly that case, and it is why this early return
+ // stopped being an unconditional `true`.
if (mode === 'manual')
return dialect.manualIsDefault || emittableValue(dialect, 'manual', caps) !== undefined
+ if (standaloneFlag(dialect, mode) !== undefined) return true
return emittableValue(dialect, mode, caps) !== undefined
}
@@ -277,6 +307,8 @@ export function approvalFlags(
if (!isPermissionMode(mode)) return []
const dialect = dialectFor(agentId)
if (dialect) {
+ const sw = standaloneFlag(dialect, mode)
+ if (sw) return [sw]
const value = emittableValue(dialect, mode, caps)
return value ? (dialect.spell?.(value) ?? [dialect.flag, value]) : []
}
@@ -289,9 +321,9 @@ export function approvalFlags(
* CLI launch path (new node, cold-restore resume, branch, handoff, canvas control).
*
* WHERE the flag lands is decided one layer up, by `createAgentNode`: with no `argvPromptSeparator`
- * (claude, gemini, codex) it goes LAST, keeping those command lines byte-identical; with one
- * (grok's `--`, cursor's `agent`) it must go BEFORE the separator: `--` is end-of-options, and
- * cursor's flags are root options that the `agent` subcommand reads (measured, see CURSOR_MODES).
+ * (claude, gemini, codex, antigravity) it goes LAST, keeping those command lines byte-identical;
+ * with one (grok's `--`, cursor's `agent`) it must go BEFORE the separator: `--` is end-of-options,
+ * and cursor's flags are root options that the `agent` subcommand reads (measured, see CURSOR_MODES).
*
* **A flag the command already carries is left alone (issue #601).** `cmd` is not always ours:
* `settings.agentLaunchCommands` lets the user replace the program part with a wrapper, and a
@@ -322,7 +354,13 @@ export function withPermissionMode(
): string {
const flags = approvalFlags(id, mode, caps)
if (!flags.length) return cmd
- if (argvHasFlag(cmd, flags[0])) return cmd
+ const dialect = dialectFor(id)
+ if (dialect) {
+ const knownFlags = [flags[0], dialect.flag, ...Object.values(dialect.standaloneFlags ?? {})]
+ if (knownFlags.some((f) => f && argvHasFlag(cmd, f))) return cmd
+ } else if (argvHasFlag(cmd, flags[0])) {
+ return cmd
+ }
return `${cmd} ${flags.join(' ')}`
}
diff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.ts
index 96181d196..6e374ecb7 100644
--- a/src/shared/agents/config.capabilities.test.ts
+++ b/src/shared/agents/config.capabilities.test.ts
@@ -65,8 +65,10 @@ describe('MODEL_SWITCH_CAPABLE', () => {
// cursor: `--model <id>` (a root option, measured before and after `agent`). Its models are its
// own catalogue, so it joins the list WITHOUT the gateway's models (OWN_MODEL_CATALOGUE).
expect(canSwitchModel('cursor')).toBe(true)
+ expect(canSwitchModel('antigravity')).toBe(true)
expect(hasGatewayModels('cursor')).toBe(false)
expect(hasGatewayModels('grok')).toBe(false)
+ expect(hasGatewayModels('antigravity')).toBe(false)
for (const id of ['claude', 'codex', 'copilot'] as const)
expect(hasGatewayModels(id), id).toBe(true)
for (const id of ['gemini', 'opencode', 'custom:plain'] as const) {
@@ -361,21 +363,20 @@ describe('antigravity capabilities', () => {
expect(hasHooks('antigravity')).toBe(true)
})
+ it('joins the measured transcript, context-link, canvas-control, model-switch, and permission-mode capabilities without joining claude-transcript readers', () => {
+ expect(hasUsage('antigravity')).toBe(true)
+ expect(canChat('antigravity')).toBe(true)
+ expect(readsClaudeShapedTranscript('antigravity')).toBe(false)
+ expect(canTransferFrom('antigravity')).toBe(true)
+ expect(canContextLink('antigravity')).toBe(true)
+ expect(canControlCanvas('antigravity')).toBe(true)
+ expect(hasPermissionMode('antigravity')).toBe(true)
+ expect(canSwitchModel('antigravity')).toBe(true)
+ })
+
it('does not claim the capabilities whose per-agent leaf is unwritten', () => {
// No SessionEnd-shaped event exists among agy's five, so a DROPPED chip would be a coin flip.
expect(reportsSessionEnd('antigravity')).toBe(false)
- // No token count and no stated window anywhere measured (the TUI's "1.1k tokens" is per
- // thought block, not context use) — rule 6: no trustworthy denominator, no meter. Joining would
- // also switch on context.ensure and the find-bar index.
- expect(hasUsage('antigravity')).toBe(false)
- // No transcript parser or locator yet. The location is measured (the payload's transcriptPath,
- // `brain/<conversationId>/…/transcript_full.jsonl`); the record shapes are only vendor prose,
- // never captured. Joining CHAT_CAPABLE before that capture would render a guess on ⌘M and on
- // the phone's Chat screen: docs/antigravity-agent.md §7.1 and §8.1.
- expect(canChat('antigravity')).toBe(false)
- expect(readsClaudeShapedTranscript('antigravity')).toBe(false)
- expect(canTransferFrom('antigravity')).toBe(false)
- expect(canContextLink('antigravity')).toBe(false)
// `agy --conversation=<id>` resumes; the id is validated at the interpolation site
// (SAFE_SESSION_ID) and a dead one is ignored by agy itself (it starts fresh). Not minted.
expect(canResume('antigravity')).toBe(true)
@@ -388,12 +389,6 @@ describe('antigravity capabilities', () => {
expect(canSubagent('antigravity')).toBe(false)
expect(canRecur('antigravity')).toBe(false)
expect(canBranch('antigravity')).toBe(false)
- // Canvas control needs a shim + a discovery file; none is installed for agy.
- expect(canControlCanvas('antigravity')).toBe(false)
- // Permission flags exist (--mode, --dangerously-skip-permissions) but the approval-mode table
- // has no antigravity row yet; model switching has no gateway mapping.
- expect(hasPermissionMode('antigravity')).toBe(false)
- expect(canSwitchModel('antigravity')).toBe(false)
// Title lives in SQLite (unmeasured) and there is no rename command; read ⊇ write holds.
expect(canReadTitle('antigravity')).toBe(false)
expect(canRename('antigravity')).toBe(false)
diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.ts
index 79f54d3ab..419a90ee2 100644
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@ -310,7 +310,15 @@ export const BRANCH_CAPABLE = ['claude'] as const
// in the `<agent_skills>` block of a real chat's own context (measured in its store.db), i.e. it reads
// `~/.claude/skills` like grok. Its transcript is a SQLite store read by `core/cursor-chat.ts`.
// UNVERIFIED: a user setting that switches that Claude-compat scan off.
-export const CONTEXT_LINK_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'grok', 'cursor'] as const
+export const CONTEXT_LINK_CAPABLE = [
+ 'claude',
+ 'codex',
+ 'gemini',
+ 'opencode',
+ 'grok',
+ 'cursor',
+ 'antigravity'
+] as const
// Agents whose per-node context meter we can fill. Each needs BOTH numbers: a used count and a
// TRUSTWORTHY window.
// - claude: used from its transcript's assistant usage, window INFERRED from the model family
@@ -325,6 +333,11 @@ export const CONTEXT_LINK_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'g
// grok has already computed. MEASURED on 22 real sessions (1.0.13, 2026-09-02): all three present
// in all 22, and the stated percentage agrees with used/window in all 22. So the window is read,
// never inferred from the model id, which puts grok with codex rather than with gemini.
+// - antigravity: states `input_tokens` and `cache_read_tokens` on every `PLANNER_RESPONSE` in
+// `~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl` (core/
+// antigravity-session.ts), and `antigravityWindowFor` (core/model-window.ts) maps its model
+// family (`gemini-4-argon-*`, `gemini-3.8-flash-*`, `claude-*`, `gpt-oss-120b-*`) to the known
+// context window, returning null for unknown models.
//
// Until 2026-09 this comment explained grok's absence by pointing at a missing parser for the wrong
// file, and concluding there was no used count to divide. Both halves were false, and the first is
@@ -344,7 +357,7 @@ export const CONTEXT_LINK_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'g
// It joins the meter ONLY: its ids are not in CLAUDE_TRANSCRIPT_READABLE, so the find bar's index and
// cold-resume stay off claude's cwd-fallback resolver, and `context.ensure` locates a cursor chat by id.
// Account plan limits (CLI `/usage`) are a different, credentialed number and are not read.
-export const USAGE_CAPABLE = ['claude', 'codex', 'gemini', 'grok', 'cursor'] as const
+export const USAGE_CAPABLE = ['claude', 'codex', 'gemini', 'grok', 'cursor', 'antigravity'] as const
// Agents whose structured transcript we can render as a chat panel (Cmd+M chat mode).
//
// SPLIT from CLAUDE_TRANSCRIPT_READABLE below on 2026-09-02, when grok joined. Until then this one
@@ -369,7 +382,19 @@ export const USAGE_CAPABLE = ['claude', 'codex', 'gemini', 'grok', 'cursor'] as
// read through `opencode export <id>` (core/opencode-chat.ts) and it stays out of the list below.
// cursor joined with `core/cursor-chat.ts`: a read-only `node:sqlite` read of its chat store, located
// strictly by the whole-UUID chat id and routed before anything claude-shaped. Not in the list below.
-export const CHAT_CAPABLE = ['claude', 'grok', 'gemini', 'codex', 'copilot', 'opencode', 'cursor'] as const
+// antigravity joined 2026-10 with its own reader (`core/antigravity-chat.ts`), reading
+// `~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl` strictly by
+// conversation id (`locateAntigravity`).
+export const CHAT_CAPABLE = [
+ 'claude',
+ 'grok',
+ 'gemini',
+ 'codex',
+ 'copilot',
+ 'opencode',
+ 'cursor',
+ 'antigravity'
+] as const
// CHAT_CAPABLE agents whose reader has NO remote leg: a remote (SSH) node's session lives on its
// host, so core answers `unreadable` before touching anything — and the local reader never sets that
// flag (copilot maps a failed local read to not-found for exactly this reason). So an unreadable read
@@ -378,7 +403,7 @@ export const CHAT_CAPABLE = ['claude', 'grok', 'gemini', 'codex', 'copilot', 'op
// remote nodes are read on the host (`core/remote-grok-chat.ts`, `main/remote-codex-chat-page.ts`).
// opencode has no remote leg either but is NOT here: its `unreadable` also means a failed LOCAL
// `opencode export`, which Retry heals — the panel gives it its own copy (`exportError`) instead.
-export const CHAT_LOCAL_ONLY = ['gemini', 'copilot', 'cursor'] as const
+export const CHAT_LOCAL_ONLY = ['gemini', 'copilot', 'cursor', 'antigravity'] as const
// CHAT_CAPABLE agents whose chat-view prompts are TYPED as keystrokes instead of pasted
// (core/typed-input.ts): a multi-line paste is recorded by Claude Code as <pasted_content>, content
// its model is told may not be the user's own words. The typed path puts a line break in as tmux's
@@ -410,7 +435,14 @@ export const SCREEN_DIALOG_READABLE = ['claude'] as const
// a new user turn). Every other chat-capable agent is unmeasured and keeps "wait for the reply".
export const INPUT_QUEUE_CAPABLE = ['claude'] as const
// Agents whose native transcript we can read + render for cross-agent transfer.
-export const TRANSFER_SOURCE_CAPABLE = ['claude', 'codex', 'gemini', 'grok', 'cursor'] as const
+export const TRANSFER_SOURCE_CAPABLE = [
+ 'claude',
+ 'codex',
+ 'gemini',
+ 'grok',
+ 'cursor',
+ 'antigravity'
+] as const
// Agents whose hooks announce that a session ENDED — i.e. whose orderly `/exit` we will hear about.
//
// Derived by reading `normalize.ts`, not by intent: exactly four normalizers map an event to
@@ -482,8 +514,9 @@ export const TITLE_READ_CAPABLE = ['claude', 'codex', 'grok', 'gemini', 'cursor'
export const SHARED_IDENTITY_CAPABLE = ['codex'] as const
// Agents allowed to drive the canvas via the `nodeterm` CLI (open/show/write/close).
// Discovery differs per agent: claude gets the manage-nodeterm-canvas skill; codex/gemini/
-// opencode a marker block in ~/.codex/AGENTS.md / ~/.gemini/GEMINI.md /
-// ~/.config/opencode/AGENTS.md (see canvas-control.ts).
+// antigravity/opencode a marker block in ~/.codex/AGENTS.md / ~/.gemini/GEMINI.md /
+// ~/.config/opencode/AGENTS.md (see canvas-control.ts — agy loads ~/.gemini/GEMINI.md as
+// <RULE[user_global]>).
//
// grok needs NO new installer: it scans `~/.claude/skills` by default for Claude Code
// compatibility (its shipped docs, user-guide/08-skills.md; switched off only by
@@ -497,7 +530,16 @@ export const SHARED_IDENTITY_CAPABLE = ['codex'] as const
// third-party skills (gated by its `thirdPartyExtensibility` setting, default on in the CLI), and
// MEASURED on 2026.10.01 its interactive session listed `~/.claude/skills/manage-nodeterm-canvas`
// right after its own built-ins, ahead of the tail it truncates when the skill list is long.
-export const CANVAS_CONTROL_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'grok', 'copilot', 'cursor'] as const
+export const CANVAS_CONTROL_CAPABLE = [
+ 'claude',
+ 'codex',
+ 'gemini',
+ 'opencode',
+ 'grok',
+ 'copilot',
+ 'cursor',
+ 'antigravity'
+] as const
// Agents whose TOOL shell on Windows is POSIX: Claude Code runs its Bash tool (and its hooks)
// through Git Bash, so `sh "<shim>.sh"` works there exactly as on macOS/Linux. Every other agent
// runs tools in PowerShell (codex, gemini, copilot — measured in their sources) or cmd.exe, where
@@ -507,9 +549,10 @@ export const POSIX_TOOL_SHELL_ON_WINDOWS = ['claude'] as const
// Agents whose session start-up permission mode we can set (see AgentPermissionMode below).
// claude and grok share the flag SPELLING and the value vocabulary
// (`--permission-mode auto|plan|acceptEdits|bypassPermissions`; our `manual` = no flag = grok's own
-// `default`). gemini (`--approval-mode default|auto_edit|yolo|plan`) and codex
-// (`--ask-for-approval untrusted|on-request|never`) each spell it their own way, so membership here
-// is only half the story — the translation lives in ./approval-mode.ts.
+// `default`). gemini (`--approval-mode default|auto_edit|yolo|plan`), codex
+// (`--ask-for-approval untrusted|on-request|never`), and antigravity
+// (`--mode accept-edits|auto|plan` plus `--dangerously-skip-permissions`) each spell it their own
+// way, so membership here is only half the story — the translation lives in ./approval-mode.ts.
//
// Membership does NOT mean every mode applies: BOTH new vocabularies are narrower than ours — codex
// has no plan and no edit-specific mode, and gemini has nothing meaning "approve most things but not
@@ -521,25 +564,39 @@ export const POSIX_TOOL_SHELL_ON_WINDOWS = ['claude'] as const
//
// NOTE: the `auto` VERSION GATE is claude's alone — see activePermissionMode in
// renderer/state/permissionMode.ts. grok has accepted every mode we emit since 1.0.0, its first
-// release, and gemini/codex accept theirs on the versions we measured, so none of them may inherit
-// a gate fed by a `claude --version` probe.
+// release, and gemini/codex/antigravity accept theirs on the versions we measured, so none of them
+// may inherit a gate fed by a `claude --version` probe.
//
// cursor emits `--auto-review` for `auto` (a server classifier auto-runs safe calls, claude's `auto`
// shape), `--mode plan` and `--force`; `manual` and `acceptEdits` emit no flag (its bare launch is
// `approvalMode: allowlist`). See CURSOR_MODES in approval-mode.ts. `auto` is the DEFAULT mode, which
// widened no existing node only because cursor shipped in the same change.
-export const PERMISSION_MODE_CAPABLE = ['claude', 'grok', 'gemini', 'codex', 'cursor'] as const
+export const PERMISSION_MODE_CAPABLE = [
+ 'claude',
+ 'grok',
+ 'gemini',
+ 'codex',
+ 'cursor',
+ 'antigravity'
+] as const
// Agents whose harness accepts a per-launch model override and whose gateway protocol we know how
// to configure. Custom agents inherit this through `capabilityAgentId`, like every other harness
// capability — the renderer never maintains its own Claude/Codex/Copilot allowlist.
-export const MODEL_SWITCH_CAPABLE = ['claude', 'codex', 'copilot', 'grok', 'cursor'] as const
+export const MODEL_SWITCH_CAPABLE = [
+ 'claude',
+ 'codex',
+ 'copilot',
+ 'grok',
+ 'cursor',
+ 'antigravity'
+] as const
// Members of MODEL_SWITCH_CAPABLE whose models are their OWN CLI's catalogue and can never be
-// routed through the model gateway: grok (custom models live in ~/.grok/config.toml) and cursor
-// (`cursor-agent models` lists ~250 account-scoped ids; the gateway's ids are not among them).
+// routed through the model gateway: grok (custom models live in ~/.grok/config.toml), cursor
+// (`cursor-agent models` lists ~250 account-scoped ids), and antigravity (`agy models`).
// Offering or defaulting a gateway id to one of these puts a `--model` on the line that names a
-// model outside its own catalogue (what cursor does with an unknown id is UNMEASURED), so every place
-// that hands out GATEWAY models asks `hasGatewayModels`, not `canSwitchModel`.
-export const OWN_MODEL_CATALOGUE = ['grok', 'cursor'] as const
+// model outside its own catalogue, so every place that hands out GATEWAY models asks
+// `hasGatewayModels`, not `canSwitchModel`.
+export const OWN_MODEL_CATALOGUE = ['grok', 'cursor', 'antigravity'] as const
// Agents whose own CLI already tells the user when it copies, so nodeterm must not say it again.
// Claude Code captures the mouse itself and prints its own line — "copied N chars to tmux buffer ·
// paste with prefix + ]" — which makes our copy pill a second message for one gesture. Membership
diff --git a/src/shared/agents/launch.test.ts b/src/shared/agents/launch.test.ts
index 1dfd6f15f..b47ddaf9c 100644
--- a/src/shared/agents/launch.test.ts
+++ b/src/shared/agents/launch.test.ts
@@ -150,13 +150,19 @@ describe('assembleLaunchCommand — builtins (byte-identical to the historical p
assembleLaunchCommand({ agentId: 'antigravity', initialPrompt: 'fix it\nnow' }, ENV).command
).toBe("agy --prompt-interactive 'fix it now'")
expect(assembleLaunchCommand({ agentId: 'antigravity' }, ENV).command).toBe('agy')
- // No minted id and no permission flag: antigravity is in neither list yet.
+ // No minted id (antigravity does not mint session ids at launch), but permission and model flags apply.
expect(
assembleLaunchCommand(
- { agentId: 'antigravity', sessionId: 'abc-123', sessionIdFlagSupported: true, permissionMode: 'plan' },
+ {
+ agentId: 'antigravity',
+ sessionId: 'abc-123',
+ sessionIdFlagSupported: true,
+ permissionMode: 'plan',
+ model: 'gemini-4-argon-medium'
+ },
ENV
).command
- ).toBe('agy')
+ ).toBe("agy --mode plan --model 'gemini-4-argon-medium'")
})
it('a custom agent built on Antigravity inherits its prompt flag', () => {
setCustomAgentBaseResolver((id) => (id === 'custom:agy' ? 'antigravity' : undefined))
diff --git a/src/shared/agents/model-gateway.test.ts b/src/shared/agents/model-gateway.test.ts
index dd4d43c81..00e51e5ee 100644
--- a/src/shared/agents/model-gateway.test.ts
+++ b/src/shared/agents/model-gateway.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
import { readFileSync } from 'fs'
import path from 'path'
import {
+ antigravityModelsFrom,
grokModelsFrom,
cursorModelsFrom,
normalizedAgentModel,
@@ -412,3 +413,31 @@ describe('cursorModelsFrom', () => {
expect(cursorModelsFrom('a - One\na - Two')).toEqual([{ id: 'a', name: 'One' }])
})
})
+
+describe('antigravityModelsFrom — TSV discovery from `agy models`', () => {
+ const REAL = [
+ 'gemini-4-argon-high\tGemini 4 Argon (High)',
+ 'gemini-4-argon-medium\tGemini 4 Argon (Medium)',
+ 'gemini-3.1-pro-high\tGemini 3.1 Pro (High)',
+ 'claude-opus-4-6-thinking\tClaude Opus 4.6 (Thinking)'
+ ].join('\n')
+
+ it('parses tab-separated id and display name rows', () => {
+ expect(antigravityModelsFrom(REAL)).toEqual([
+ { id: 'gemini-4-argon-high', name: 'Gemini 4 Argon (High)' },
+ { id: 'gemini-4-argon-medium', name: 'Gemini 4 Argon (Medium)' },
+ { id: 'gemini-3.1-pro-high', name: 'Gemini 3.1 Pro (High)' },
+ { id: 'claude-opus-4-6-thinking', name: 'Claude Opus 4.6 (Thinking)' }
+ ])
+ })
+
+ it('routes antigravity to its own catalogue and appends --model', () => {
+ const GATEWAY = [{ id: 'anthropic/claude-x' }]
+ const AGY = antigravityModelsFrom(REAL)
+ expect(modelsForAgent(GATEWAY, 'antigravity', [], [], AGY)).toEqual(AGY)
+ expect(modelsForAgent(GATEWAY, 'antigravity')).toEqual([])
+ expect(withAgentModel('agy', 'antigravity', 'gemini-4-argon-medium')).toBe(
+ "agy --model 'gemini-4-argon-medium'"
+ )
+ })
+})
diff --git a/src/shared/agents/model-gateway.ts b/src/shared/agents/model-gateway.ts
index ce66f2c4f..6af610fcb 100644
--- a/src/shared/agents/model-gateway.ts
+++ b/src/shared/agents/model-gateway.ts
@@ -191,18 +191,18 @@ export function modelsForAgent(
models: GatewayModel[],
agentId: AgentId,
grokModels: readonly GatewayModel[] = [],
- cursorModels: readonly GatewayModel[] = []
+ cursorModels: readonly GatewayModel[] = [],
+ antigravityModels: readonly GatewayModel[] = []
): GatewayModel[] {
if (!canSwitchModel(agentId)) return []
- // grok is offered ITS OWN models, never the gateway's, and this is a correctness rule rather than
- // a preference: grok cannot be routed through the gateway at all (see `modelGatewayEnv` below —
- // its custom models live in `~/.grok/config.toml`, not in environment variables). Handing it the
- // gateway catalogue would put ids on the menu that its CLI rejects at launch: a picker that looks
- // like it worked and kills the node.
- if (capabilityAgentId(agentId) === 'grok') return [...grokModels]
- // cursor: same rule. Its list is `cursor-agent models` (account-scoped, network-backed, ~250 ids);
- // the gateway's ids are not among them, so it is offered only its own, [] when the probe failed.
- if (capabilityAgentId(agentId) === 'cursor') return [...cursorModels]
+ // grok, cursor and antigravity are offered THEIR OWN models, never the gateway's, and this is a
+ // correctness rule rather than a preference: none can be routed through the gateway env (see
+ // `modelGatewayEnv` below). Handing them the gateway catalogue would put ids on the menu that
+ // their CLIs reject at launch: a picker that looks like it worked and kills the node.
+ const capId = capabilityAgentId(agentId)
+ if (capId === 'grok') return [...grokModels]
+ if (capId === 'cursor') return [...cursorModels]
+ if (capId === 'antigravity') return [...antigravityModels]
if (!hasGatewayModels(agentId)) return []
return models
}
@@ -273,6 +273,39 @@ export function cursorModelsFrom(stdout: string | null | undefined): GatewayMode
return [...byId.values()]
}
+/**
+ * Parse `agy models` — Antigravity's own model list (`<id>\t<Display Name>` rows after the
+ * `Fetching available models...` header).
+ *
+ * MEASURED output (1.2.7, Windows 11, 2026-10-14):
+ *
+ * Fetching available models...
+ * gemini-4-argon-medium Gemini 4 Argon (Medium)
+ * gemini-4-argon-high Gemini 4 Argon (High)
+ * gemini-4-argon-low Gemini 4 Argon (Low)
+ * gemini-3.8-flash-high Gemini 3.8 Flash (High)
+ * claude-opus-5-5-high Claude Opus 5.5 (High)
+ * gpt-oss-120b-medium GPT-OSS 120B (Medium)
+ *
+ * Only tab-separated `<id>\t<label>` lines are accepted, with `id` validated by the same charset
+ * rule as `grokModelsFrom`. Prose banners or error lines without a tab are ignored.
+ */
+export function antigravityModelsFrom(stdout: string | null | undefined): GatewayModel[] {
+ const text = stdout ?? ''
+ const byId = new Map<string, GatewayModel>()
+ for (const raw of text.split(/\r?\n/)) {
+ const tab = raw.indexOf('\t')
+ if (tab <= 0) continue
+ const id = raw.slice(0, tab).trim()
+ const name = raw.slice(tab + 1).trim()
+ if (!/^[A-Za-z0-9][A-Za-z0-9._:\/-]*$/.test(id)) continue
+ if (!byId.has(id)) {
+ byId.set(id, name ? { id, name } : { id })
+ }
+ }
+ return [...byId.values()]
+}
+
/**
* Environment applied to a terminal session before custom-agent env (custom values still win).
* Claude/Codex model selection stays a quoted CLI flag. Copilot's BYOK protocol instead carries
diff --git a/src/shared/agents/normalize.antigravity.test.ts b/src/shared/agents/normalize.antigravity.test.ts
index 93d2f42ee..ad406e3ac 100644
--- a/src/shared/agents/normalize.antigravity.test.ts
+++ b/src/shared/agents/normalize.antigravity.test.ts
@@ -112,14 +112,17 @@ describe('normalizeAntigravity over captured agy 1.2.3 payloads', () => {
expect(run(pick('PostInvocation'))).toBeNull()
})
- it('Stop with fullyIdle:false is NOT terminal → working', () => {
- expect(run(pick('Stop', (p) => p.fullyIdle === false))?.state).toBe('working')
+ it('Stop with fullyIdle:false → done with backgroundTaskIds (never sticks on RUNNING)', () => {
+ const out = run(pick('Stop', (p) => p.fullyIdle === false))
+ expect(out?.state).toBe('done')
+ expect(out?.backgroundTaskIds).toEqual(['agy-bg'])
})
- it('Stop with fullyIdle:true → done, not errored', () => {
+ it('Stop with fullyIdle:true → done, not errored, no backgroundTaskIds', () => {
const out = run(pick('Stop', finalStopMatch))
expect(out?.state).toBe('done')
expect(out?.errored).toBeUndefined()
+ expect(out?.backgroundTaskIds).toBeUndefined()
})
it('a hook-terminated Stop (TERMINAL_CUSTOM_HOOK) is an ordinary end, not an error', () => {
@@ -153,12 +156,13 @@ describe('normalizeAntigravity — the rules the capture could not produce', ()
}
})
- it('a Stop WITHOUT fullyIdle reads as finished (strict === false)', () => {
+ it('a Stop WITHOUT fullyIdle or with non-boolean fullyIdle reads as finished without backgroundTaskIds (strict === false)', () => {
const rest: Record<string, unknown> = { ...finalStop.payload }
delete rest.fullyIdle
- expect(normalizeAntigravity(envFor('Stop', rest))?.state).toBe('done')
- // A falsy-but-not-false oddity is also "finished"; only a literal false keeps it working.
- expect(normalizeAntigravity(envFor('Stop', { ...rest, fullyIdle: 0 }))?.state).toBe('done')
+ expect(normalizeAntigravity(envFor('Stop', rest))).toMatchObject({ state: 'done' })
+ expect(normalizeAntigravity(envFor('Stop', rest))?.backgroundTaskIds).toBeUndefined()
+ // A falsy-but-not-false oddity is also "finished"; only a literal false stamps backgroundTaskIds.
+ expect(normalizeAntigravity(envFor('Stop', { ...rest, fullyIdle: 0 }))?.backgroundTaskIds).toBeUndefined()
// An empty payload (agy sent no stdin; the script POSTs `{}`) still ends the badge.
expect(normalizeAntigravity(envFor('Stop', {}))?.state).toBe('done')
})
@@ -198,7 +202,7 @@ describe('normalizeAntigravity — measured event orders', () => {
const states = (seq: [string, Record<string, unknown>][]) =>
seq.map(([ev, p]) => normalizeAntigravity(envFor(ev, p))?.state ?? null)
- it('background tool: the late PostToolUse neither ends nor restarts anything', () => {
+ it('background tool: intermediate Stop transitions to done (with backgroundTaskIds), and wakeup PreInvocation(0) starts a new working turn', () => {
// log-bg.jsonl: the PostToolUse lands 27.5 s after `Stop fullyIdle:false`.
const pre = pick('PreToolUse', toolIs('run_command')).payload
const post = pick('PostToolUse', toolIs('run_command')).payload
@@ -216,7 +220,7 @@ describe('normalizeAntigravity — measured event orders', () => {
['PreInvocation', inv(0)],
['Stop', end]
]
- expect(states(seq)).toEqual(['working', 'working', 'working', 'working', null, 'working', 'done'])
+ expect(states(seq)).toEqual(['working', 'working', 'working', 'done', null, 'working', 'done'])
expect(seq.map(([ev, p]) => normalizeAntigravity(envFor(ev, p))?.newTurn ?? false)).toEqual([
true,
false,
diff --git a/src/shared/agents/normalize.ts b/src/shared/agents/normalize.ts
index aae47a11f..c3d46932f 100644
--- a/src/shared/agents/normalize.ts
+++ b/src/shared/agents/normalize.ts
@@ -1027,13 +1027,17 @@ const antigravityToolName = (p: AntigravityPayload): string | undefined => {
}
/**
- * PURE — no state, on purpose. Three decisions carry the whole mapping:
+ * PURE — no state, on purpose. Four decisions carry the whole mapping:
*
- * 1. `Stop` with `fullyIdle === false` is NOT terminal (→ `working`). `agy` stops its model loop
- * between steps while a background tool still runs, then reports `fullyIdle:true` at the real
- * end. Strict `=== false`: a payload missing the field reads as "finished", the safe direction
- * for a badge that would otherwise stick. With this rule the `PostToolUse` that arrives AFTER
- * such a Stop is simply the end of that background tool.
+ * 1. `Stop` always ends the turn (`state: 'done'`), matching Claude Code and every other CLI.
+ * `agy` sets `fullyIdle === false` whenever ANY background command (`WaitMsBeforeAsync`,
+ * `IsDaemon: true`, timer or subagent) is still alive after the turn ends and the `>` prompt
+ * returns to the user. Keeping `state: 'working'` left the card stuck on `RUNNING` and blocked
+ * `send` delivery for the life of any background process. Instead, `fullyIdle === false` stamps
+ * `backgroundTaskIds` (just like Claude's `Stop` with a live `Bash(run_in_background: true)`) so
+ * Eco hibernation and bulk restart do not kill the CLI while a background process runs; when a
+ * background task finishes and wakes the agent, `agy` fires a new `PreInvocation` (`invocationNum: 0`)
+ * which transitions back to `working` (`newTurn: true`).
*
* 2. NEEDS YOU is bracketed by the ask tool itself, never by adjacency. `PreToolUse` and
* `PostToolUse` do not alternate: a whole invocation can open and close between them (measured:
@@ -1083,12 +1087,12 @@ export function normalizeAntigravity(env: RawHookEnvelope): NormalizedAgentEvent
return null
}
if (ev === 'Stop') {
- if (p.fullyIdle === false) return { ...base, kind: 'state', state: 'working' }
return {
...base,
kind: 'state',
state: 'done',
- ...(p.terminationReason === 'ERROR' ? { errored: true } : {})
+ ...(p.terminationReason === 'ERROR' ? { errored: true } : {}),
+ ...(p.fullyIdle === false ? { backgroundTaskIds: ['agy-bg'] } : {})
}
}
return null
diff --git a/src/shared/recent-conversations.ts b/src/shared/recent-conversations.ts
index 2e2c79463..ed90487bf 100644
--- a/src/shared/recent-conversations.ts
+++ b/src/shared/recent-conversations.ts
@@ -15,14 +15,15 @@ import type { AgentId } from './agents/config'
* (`id`, `cwd`, `thread_source`); system and managed accounts.
* - gemini — `~/.gemini/tmp/<project>/chats/session-*.jsonl` + the project's `.project_root`.
* - grok — `$GROK_HOME/sessions/<url-encoded cwd>/<id>/`.
- * - copilot — `<copilot home>/session-state/<id>/events.jsonl`, `session.start` `context.cwd`.
+ * - copilot — `<copilot home>/session-state/<id>/events.jsonl`, `session.start` `context.cwd`.
+ * - antigravity — `~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl`
+ * + `~/.gemini/antigravity-cli/history.jsonl` (`conversationId`, `workspace`).
*
* Deliberately absent: opencode (its history is a SQLite database we never open; the only reader
* is `opencode export`, one CLI spawn of ~1.5 s and ~320 MB per session — far too heavy for a
- * list) and antigravity (its transcript record shapes were never captured). An agent absent here
- * simply contributes no rows; nothing guesses at its layout.
+ * list). An agent absent here simply contributes no rows; nothing guesses at its layout.
*/
-export const RECENT_CONVERSATION_AGENTS = ['claude', 'codex', 'gemini', 'grok', 'copilot'] as const
+export const RECENT_CONVERSATION_AGENTS = ['claude', 'codex', 'gemini', 'grok', 'copilot', 'antigravity'] as const
export type RecentConversationAgent = (typeof RECENT_CONVERSATION_AGENTS)[number]
export function isRecentConversationAgent(id: AgentId | string): id is RecentConversationAgent {