Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ those observations into one conversation and renders it in React, without
replacing the agent loop underneath.
Antigravity’s Terminal view runs the interactive `agy` CLI in a PTY. Its Agent
view uses `agy acp` to render the conversation through the Agent Client Protocol.
Both views receive the Agent Code tools enabled for that pane. Open `/mcp` inside the
native prompt to inspect its servers. To attach your own stdio or Streamable HTTP server,
enable its Antigravity column in **Settings → MCP** and reload the pane. Agent Code keeps
these grants local to the pane. Running `agy mcp list` in an ordinary shell lists your
separately configured CLI servers.

Agent view accepts pasted images through the composer. In Terminal view, Agent Code can
deliver a text prompt when the CLI is showing an empty editor in the confirmed conversation.
An existing draft or dialog holds delivery. Both views discover Agent Code's personal skills
in `~/.gemini/config/skills` and the current project's skills in `.agents/skills`.

[`agent-transcript-parser`](https://github.com/Juliusolsson05/agent-transcript-parser)
translates transcripts between harnesses, which is what makes switching,
Expand Down
35 changes: 35 additions & 0 deletions docs/decomposition/antigravity-agent-code-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Antigravity compatibility in Agent Code

## Outcome

Opening an Antigravity pane should preserve the Agent Code capabilities granted to that pane. A user can choose the native prompt or the rendered Agent view without silently losing tools. Preserve the provider's conversation identity and the user's CLI configuration.

## Evidence

- The released Terminal launcher forwards terminal I/O and conversation selection. It drops the already registered MCP servers.
- Agent view passes the built-in bridge to session/new or session/load. User-configured MCP servers are a separate path to verify.
- Native prompt delivery, project and personal skill discovery, management, and provider-specific conversation actions each have their own capability gates. Making a tool appear does not establish its behavior.
- The installed agy 1.5.18 lists zero configured servers on the reported setup. A disposable profile accepts an MCP server through its MCP config and rejects mcpServers as an unknown --settings key.

## Stages

1. Prove the installed CLI's supported configuration boundaries. Verify discovery using an isolated workspace and a harmless MCP server. Keep the application token scoped to the intended pane.
2. Reuse the existing session registration and implement native and rendered tool provisioning for supported transports, preferences and lifecycle paths. Preserve existing CLI settings and test concurrent panes.
3. Wire programmatic prompt delivery to the correct runtime, retaining native drafts and safe retry semantics. Verify readiness, permissions and session control.
4. Reconcile skill deployment and provider capability declarations against the CLI, including managed and personal skills, conversation operations and composer inputs. Expose only functions with verified behavior.
5. Exercise the normal application paths and record evidence for each feature plus any provider limitations. Run targeted tests, typecheck and review the combined changes.

## Verification

Use the real installed CLI with disposable settings and identifiable local MCP servers. Verify list, tool execution and isolation independently. Check failure and teardown with deterministic tests. Keep credentials, conversations and model responses out of fixtures.

## Observations on agy 1.5.18

- Two concurrent native panes in one real checkout listed distinct grants from the application MCP host. Resuming the first pane restored its original tool. Opening agy separately left its configured servers intact.
- Native prompt dispatch preserved a human draft and submitted the local /new command from an empty confirmed editor. Rendered Agent view accepts image content over ACP. CLI permissions remain under the user's control.
- The CLI recognized personal skills from its current and two legacy directories. Agent Code uses the current directory for managed installs.
- Reading a confirmed native conversation uses ACP replay through the running pane's identity. Closing the pane revokes this access. Rendered panes retain their in-memory history.
- Google's documented hooks are configured in a temporary per-pane workspace. PreInvocation starts a reporting turn, PostToolUse marks work, and a fully idle Stop can request a TLDR or complete the turn. The adapter strips prompts, tool input and output before contacting the reporting host. See https://antigravity.google/docs/hooks.
- The installed ACP server returned method-not-found for fork, rewind and import. The CLI provides interactive /fork and /rewind; the application cannot use them as an exact durable conversation-editing API. Cross-provider history transfer and native subagent visualization remain outside verified support.
- A real SDK tools/call over the native relay wrote a TLDR into the intended pane's reporting store. The live CLI probe exercised discovery. External OAuth consent and model interpretation of an image were not exercised. Native agy handles OAuth directly for headerless HTTPS servers at an origin or /mcp. A server that relies on browser OAuth at a custom path can be configured in agy itself.
- The CLI can retain a globally started MCP server when an additional workspace declares the same name. Managed launches check global, project, and plugin configuration for an enabled external operator server before spawning agy. A real CLI disable sets the entry's disabled field to true. Reopen the pane after changing these settings so the check runs again.
4 changes: 4 additions & 0 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function copyMainRuntimeResourcesPlugin(): Plugin {
from: resolve(__dirname, 'packages/antigravity-acp-headless/src/mcpProxy.mjs'),
to: resolve(__dirname, 'out/main/runtime/antigravity/mcpProxy.mjs'),
},
{
from: resolve(__dirname, 'src/providers/antigravity/runtime/nativeMcpRelay.cjs'),
to: resolve(__dirname, 'out/main/runtime/antigravity/nativeMcpRelay.cjs'),
},
]

const copyResources = async () => {
Expand Down
16 changes: 13 additions & 3 deletions packages/antigravity-acp-headless/src/AntigravityAcpSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export class AntigravityAcpSession extends EventEmitter {
private started = false
private closed = false
private turnActive = false
private promptImages = false

get acceptsImages(): boolean { return this.promptImages }
private readonly rows: AntigravityRow[] = []
private readonly permissions = new Map<string, { request: AcpIncomingRequest; info: AntigravityPermissionRequest }>()
private activity: AntigravityActivity = { active: false, status: 'starting' }
Expand Down Expand Up @@ -161,6 +164,9 @@ export class AntigravityAcpSession extends EventEmitter {
throw new AcpError('protocol', 'agy acp answered initialize with an unsupported protocol version')
}

const caps = init.agentCapabilities
this.promptImages = isRecord(caps) && isRecord(caps.promptCapabilities) && caps.promptCapabilities.image === true

const mcpServers = [...(this.options.mcpServers ?? [])]
const resumeId = this.options.resumeSessionId ?? null
let result: unknown
Expand Down Expand Up @@ -230,7 +236,11 @@ export class AntigravityAcpSession extends EventEmitter {
* session/prompt at a time per session; a prompt typed during a turn should
* run after it, as it would in agy's own TUI queue.
*/
prompt(text: string): { accepted: Promise<void>; finished: Promise<string | null> } {
prompt(text: string, images: readonly { type: 'image'; mimeType: string; data: string }[] = []): { accepted: Promise<void>; finished: Promise<string | null> } {
if (images.length && !this.promptImages) {
const error = new AntigravityPromptError('rejected', 'agy does not advertise image prompts')
return { accepted: Promise.reject(error), finished: Promise.reject(error) }
}
if (this.closed || !this.sessionId) {
const error = new AntigravityPromptError(this.closed ? 'closed' : 'not-ready', this.closed ? 'agy has stopped' : 'agy is not ready yet')
return { accepted: Promise.reject(error), finished: Promise.reject(error) }
Expand All @@ -248,9 +258,9 @@ export class AntigravityAcpSession extends EventEmitter {
throw error
}
this.turnActive = true
this.assembler.beginTurn(text)
this.assembler.beginTurn(images.length && !text.trim() ? '[Image attached]' : text)
this.setActivity({ active: true, status: 'working' })
const request = this.connection.request('session/prompt', { sessionId: this.sessionId, prompt: [{ type: 'text', text }] }, null)
const request = this.connection.request('session/prompt', { sessionId: this.sessionId, prompt: [...(text ? [{ type: 'text', text }] : []), ...images] }, null)
accept()
// Settled early only when agy ignores a cancel (see cancel()).
const abandoned = new Promise<never>((_, reject) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/antigravity-acp-headless/src/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function isRecord(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === 'object' && !Array.isArray(value)
}

async function withConnection<T>(input: Readable, output: Writable, run: (connection: AcpConnection, updates: (handler: ((update: Record<string, unknown>) => void) | null) => void) => Promise<T>): Promise<T> {
async function withConnection<T>(input: Readable, output: Writable, run: (connection: AcpConnection, updates: (handler: ((update: Record<string, unknown>) => void) | null) => void) => Promise<T>, sessionId?: string): Promise<T> {
let onUpdate: ((update: Record<string, unknown>) => void) | null = null
const connection = new AcpConnection(input, output, {
onNotification: (method, params) => {
if (method === 'session/update' && isRecord(params) && isRecord(params.update)) onUpdate?.(params.update)
if (method === 'session/update' && isRecord(params) && params.sessionId === sessionId && isRecord(params.update)) onUpdate?.(params.update)
},
// A read-only query never grants anything: refuse every agent request.
onRequest: request => connection.respondError(request.id, -32601, 'read-only catalog client'),
Expand Down Expand Up @@ -81,5 +81,5 @@ export async function readAntigravityConversation(input: Readable, output: Writa
await connection.request('session/load', { sessionId: options.sessionId, cwd: options.cwd, mcpServers: [] }, 120_000)
assembler.flush()
return rows.sort((a, b) => a.ordinal - b.ordinal)
})
}, options.sessionId)
}
12 changes: 8 additions & 4 deletions packages/antigravity-acp-headless/src/transcript/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type AntigravityRow = {

export type AntigravitySemanticEvent = Record<string, unknown> & { type: string; source: 'antigravity-acp'; ts: number }

type OpenSegment = { kind: 'user' | 'assistant' | 'thought'; ordinal: number; text: string; blockId: string; blockIndex: number; openedAt: number }
type OpenSegment = { includesImage?: boolean; kind: 'user' | 'assistant' | 'thought'; ordinal: number; text: string; blockId: string; blockIndex: number; openedAt: number }
type OpenTool = AntigravityToolSnapshot & { ordinal: number; blockIndex: number; committed: boolean; openedAt: number }

const TERMINAL_TOOL_STATUSES = new Set(['completed', 'failed', 'cancelled', 'canceled', 'error'])
Expand Down Expand Up @@ -235,7 +235,7 @@ export class TurnAssembler {
apply(update: Record<string, unknown>): void {
switch (update.sessionUpdate) {
case 'user_message_chunk':
return this.appendText('user', contentText(update.content))
return this.appendText('user', contentText(update.content), isRecord(update.content) && update.content.type === 'image')
case 'agent_message_chunk':
return this.appendText('assistant', contentText(update.content))
case 'agent_thought_chunk':
Expand All @@ -251,8 +251,8 @@ export class TurnAssembler {
}
}

private appendText(kind: OpenSegment['kind'], text: string): void {
if (text.length === 0) return
private appendText(kind: OpenSegment['kind'], text: string, isImage = false): void {
if (text.length === 0 && !isImage) return
if (this.segment?.kind !== kind) {
this.closeSegment()
const blockIndex = this.blockCounter++
Expand All @@ -264,6 +264,7 @@ export class TurnAssembler {
}
}
const segment = this.segment!
if (isImage) segment.includesImage = true
segment.text += text
if (!this.live || !this.turnId || kind === 'user') return
if (kind === 'assistant') {
Expand All @@ -281,6 +282,9 @@ export class TurnAssembler {
if (this.live && this.turnId && segment.kind !== 'user') {
this.emit({ type: 'block_completed', turnId: this.turnId, blockId: segment.blockId, blockIndex: segment.blockIndex, kind: segment.kind === 'thought' ? 'reasoning' : 'text' })
}
// Images may be the entire user prompt. Preserve its turn and ordinal on reload
// without copying base64 into the UI journal or altering mixed prompts' typed text.
if (segment.includesImage && !segment.text.trim()) segment.text = '[Image attached]'
if (segment.text.trim().length === 0) return
this.sink.row({
type: 'antigravity-row',
Expand Down
4 changes: 4 additions & 0 deletions scripts/copy-packaged-resources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const staticResources = [
from: 'packages/antigravity-acp-headless/src/mcpProxy.mjs',
to: 'out/main/runtime/antigravity/mcpProxy.mjs',
},
{
from: 'src/providers/antigravity/runtime/nativeMcpRelay.cjs',
to: 'out/main/runtime/antigravity/nativeMcpRelay.cjs',
},
]

// WHY fileURLToPath and not `new URL(import.meta.url).pathname`:
Expand Down
1 change: 1 addition & 0 deletions scripts/verify-build-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const requiredOutputs = [
// without it they start with no Agent Code tools, which only a live run
// would notice.
'out/main/runtime/antigravity/mcpProxy.mjs',
'out/main/runtime/antigravity/nativeMcpRelay.cjs',
]

const missing = []
Expand Down
10 changes: 6 additions & 4 deletions src/main/agentCodeConventions/targets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ describe('Agent Code conventions provider targets', () => {
// agent skills unsupported; targets resolution must tolerate it — grok
// simply never contributes a target row. Hermes (#1482) is the second:
// its skills live on the user's own server, not in a local root.
// Antigravity: its personal skill folder is undocumented (project
// .agents/skills is discovered instead).
expect(result.unsupportedProviders).toEqual(['antigravity', 'grok', 'hermes'])
expect(result.targets).toHaveLength(2)
expect(result.unsupportedProviders).toEqual(['grok', 'hermes'])
expect(result.targets).toHaveLength(3)
expect(result.targets.find(target => target.id === 'antigravity-personal-skills')).toMatchObject({
providers: ['antigravity'],
skillsDirectory: join(homeDirectory, '.gemini', 'config', 'skills'),
})
expect(result.targets.find(target => target.id === 'claude-personal-skills')).toMatchObject({
providers: ['claude', 'opencode'],
skillsDirectory: join(claudeConfig, 'skills'),
Expand Down
23 changes: 23 additions & 0 deletions src/main/agentSkills/inventory.system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { dirname, join } from 'node:path'
import { execFileSync } from 'node:child_process'
import { afterEach, describe, expect, it } from 'vitest'
import type { AgentSkillRoot, AgentSkillsSnapshot } from '@shared/types/agentSkills.js'
import { discoverAntigravitySkillRoots } from '@providers/antigravity/runtime/skillDiscovery.js'
import { collectInstalledAgentSkills } from './inventory.js'

const temporary: string[] = []
Expand All @@ -26,6 +27,28 @@ afterEach(async () => {
})

describe('installed skill inventory', () => {
it('lists Antigravity managed, legacy and workspace skills and respects the repository root', async () => {
const homeDirectory = await temp()
const project = join(homeDirectory, 'repo')
const cwd = join(project, 'sub')
await mkdir(join(project, '.git'), { recursive: true })
const managed = join(homeDirectory, '.gemini/config/skills/agent-code-goal/SKILL.md')
await write(managed, skill('agent-code-goal'))
for (const [folder, name] of [
[join(homeDirectory, '.gemini/antigravity-cli/skills'), 'cli-legacy'],
[join(homeDirectory, '.gemini/skills'), 'gemini-legacy'],
[join(cwd, '.agents/skills'), 'child-skill'],
[join(project, '.agents/skills'), 'project-skill'],
[join(homeDirectory, '.agents/skills'), 'outside-project'],
] as const) await write(join(folder, name, 'SKILL.md'), skill(name))
const discovery = await discoverAntigravitySkillRoots({ cwd, homeDirectory, environment: {} })
const result = await collectInstalledAgentSkills(discovery, { paths: [managed], notices: [] })
expect(result.skills.map(({ source, name }) => [source, name])).toEqual([
['agent-code', 'agent-code-goal'], ['project', 'child-skill'], ['personal', 'cli-legacy'],
['personal', 'gemini-legacy'], ['project', 'project-skill'],
])
})

it('labels managed deployments and returns metadata only, without modifying files', async () => {
const base = await temp()
const managedPath = join(base, 'personal', 'conventions', 'SKILL.md')
Expand Down
17 changes: 10 additions & 7 deletions src/main/agentTranscripts/AgentTranscriptReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { constants } from 'node:fs'

import { parseOpencodeTranscriptFile, type OpencodeStore } from 'opencode-terminal-headless'
import { readPiBranch } from 'pi-terminal-headless'
import { liveAntigravityRows, parseAntigravityTranscriptLocator } from '@providers/antigravity/runtime/antigravityHistory.js'
import { readOpenAntigravityRows, parseAntigravityTranscriptLocator } from '@providers/antigravity/runtime/antigravityHistory.js'

import { streamJsonl } from '@shared/runtime/streamJsonl.js'
import { codexExecScriptCalls, decodeDoubleQuotedLiteral, parseExecCommandArgument } from '@shared/codex/execScript.js'
Expand Down Expand Up @@ -84,8 +84,8 @@ type TranscriptSource =
| { kind: 'pi'; path: string }
// An Antigravity conversation has no file Agent Code reads (agy's store is
// private SQLite); its locator `antigravity://session/<id>` names the rows
// the LIVE pane holds (antigravityHistory.ts).
| { kind: 'antigravity'; path: string; sessionId: string }
// from its live runtime or a confirmed native pane’s ACP replay.
| { kind: 'antigravity'; path: string; rows: readonly import('antigravity-acp-headless').AntigravityRow[] }

type PreparedTranscript = {
ok: true
Expand Down Expand Up @@ -280,10 +280,13 @@ async function prepareTranscript(
if (requestedProvider !== 'auto' && requestedProvider !== 'antigravity') {
return { ok: false, error: 'unsupported_provider', message: `${path} is an Antigravity conversation, not a ${requestedProvider} transcript.` }
}
if (!liveAntigravityRows(antigravitySessionId)) {
return { ok: false, error: 'file_not_readable', message: 'This Antigravity conversation is not open in Agent Code; open or resume the agent to read it.' }
try {
const rows = await readOpenAntigravityRows(antigravitySessionId)
if (!rows) return { ok: false, error: 'file_not_readable', message: 'This Antigravity conversation is not open in Agent Code; open or resume the agent to read it.' }
return { ok: true, source: { kind: 'antigravity', path, rows }, provider: 'antigravity' }
} catch {
return { ok: false, error: 'file_not_readable', message: 'Antigravity could not replay this open conversation.' }
}
return { ok: true, source: { kind: 'antigravity', path, sessionId: antigravitySessionId }, provider: 'antigravity' }
}

try {
Expand Down Expand Up @@ -338,7 +341,7 @@ async function* transcriptRecords(source: TranscriptSource): AsyncGenerator<Json
yield* streamJsonl<JsonRecord>(source.path)
return
case 'antigravity': {
for (const row of liveAntigravityRows(source.sessionId) ?? []) yield row as unknown as JsonRecord
for (const row of source.rows) yield row as unknown as JsonRecord
return
}
case 'pi': {
Expand Down
2 changes: 2 additions & 0 deletions src/main/conversations/sources/antigravity.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { assertAntigravityExternalControlExcluded } from '@providers/antigravity/runtime/externalControl.js'
import { spawn } from 'node:child_process'

import { listAntigravityConversations } from 'antigravity-acp-headless'
Expand Down Expand Up @@ -48,6 +49,7 @@ export class AntigravityConversationSource implements ConversationSource {
}
let listings
try {
await assertAntigravityExternalControlExcluded(process.cwd())
const child = spawn(this.binary(), ['acp'], { stdio: ['pipe', 'pipe', 'pipe'] })
child.stderr.on('data', () => {})
const failed = new Promise<never>((_, reject) => child.once('error', reject))
Expand Down
Loading
Loading