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
12 changes: 6 additions & 6 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,16 @@ Build aliases resolve most local packages directly from source. Workflow integra

Provider selection is exhaustive at several boundaries: main factories and native operations, renderer mapping/rendering capabilities, and setup requirements. Adding a string to a UI picker is insufficient. The source owners are [main registry](src/providers/registry.main.ts), [setup registry](src/providers/registry.setup.ts), [renderer capability registry](src/providers/registry.renderer.capabilities.ts), and [feature capabilities](src/providers/shared/featureCapabilities.ts).

| Property | Claude | Codex | OpenCode structured | OpenCode terminal | Pi (terminal-only) | Hermes (remote chat) | Antigravity (structured, ACP) |
| Property | Claude | Codex | OpenCode structured | OpenCode terminal | Pi (terminal-only) | Hermes (remote chat) | Antigravity (ACP and native TUI) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Native execution | CLI in PTY | CLI in PTY | `opencode serve` spawned by the package | TUI in PTY with its embedded server | `pi` TUI in PTY with Agent Code's bridge extension loaded by `-e` | `hermes serve` on the user's own server; Agent Code launches nothing | `agy acp` spawned by Agent Code; ACP over stdio, no PTY |
| Native execution | CLI in PTY | CLI in PTY | `opencode serve` spawned by the package | TUI in PTY with its embedded server | `pi` TUI in PTY with Agent Code's bridge extension loaded by `-e` | `hermes serve` on the user's own server; Agent Code launches nothing | `agy` in a PTY for Terminal, `agy acp` over stdio for Agent view |
| Live observations | Terminal mirror, optional mitmproxy stream | Terminal mirror, rollout events, optional Responses proxy stream | Server SSE bus | TUI server SSE: turns, phases, requests; no streaming text | Bridge events over a private Unix socket: turns, phases, tools, dialogs, session switches; no streaming text | WebSocket JSON-RPC events with a per-session sequence and a replay ring | ACP `session/update` notifications: text, thinking and tool chunks, permission requests; assembled into the semantic vocabulary |
| Committed observations | Exact JSONL tail | Attributed rollout tail | Messages assembled from bus part snapshots, plus HTTP history | Read-only SQLite event log | Session JSONL tree, active branch only | `session.history` rows, fetched after each settled turn | Rows cut per conversation segment with ordinal keys `ag:<session>:<n>`, held in memory by the live session; agy's SQLite store is never read |
| Native identity | UUID selected before launch/resume | Exact rollout/thread identity, proven before tailing | `ses_...` | Pre-created `ses_...` | UUID passed as `--session-id`; the pane follows `/new`, `/resume` and `/fork` inside the TUI | Hermes' stored session id, created by the server; the pane follows `/new` | agy assigns the id at `session/new`; resume is `session/load`, which replays the conversation as a history reset |
| Prompt path | Readiness, absorption and durable acceptance transaction | Attested PTY delivery profile | HTTP `prompt_async`, text only | Keyboard to PTY; programmatic prompts through the TUI server with the session's agent, model and variant | Keyboard to PTY; programmatic prompts through the bridge (`sendUserMessage` as follow-up), acknowledged only by Pi's own evidence | `prompt.submit` over the socket; slash commands through `slash.exec` | ACP `session/prompt`, queued behind a running turn; text only; Esc sends `session/cancel` |
| App saved-session listing | Supported | Supported | Not implemented | Not a separate listing capability | Supported (conversation catalog) | Not implemented; a pane resumes its own conversation | Supported (conversation catalog through `session/list`) |
| Accepted upstream version | 2.1.263 | 0.149.1 | Not pinned by the package | 1.18.30 | 0.87.1 | v0.21.7 (desktop contract 8, minimum 7) | 1.5.15 (recorded live) |
| Native terminal view | Available | Available | Not a PTY | Required; the pane always shows the TUI | Required; Pi has no other surface | None; the pane is always a chat | None in Agent Code; the pane is always the rendered feed. `agy --conversation <id>` opens the same conversation in agy's TUI |
| Native terminal view | Available | Available | Not a PTY | Required; the pane always shows the TUI | Required; Pi has no other surface | None; the pane is always a chat | Available through the native agy terminal runtime |

#### 5.3.1 Observing a process Agent Code does not control

Expand Down Expand Up @@ -773,7 +773,7 @@ Sources: [Hermes runtime adapter](src/providers/hermes/runtime), [connections](s

#### 5.3.8 antigravity-acp-headless

Antigravity (the `agy` CLI, `antigravity.google/cli`) is Google's replacement for Gemini CLI for personal accounts: Gemini CLI stopped serving them on 2026-06-18. agy has no PTY hook, no socket and no transcript file that a host could observe. Its conversations live in private SQLite (`~/.gemini/antigravity-cli/conversations/<id>.db`) owned by a closed binary that updates itself. What it does ship is a supported integration surface, `agy acp`: the Agent Client Protocol, JSON-RPC over newline-delimited stdio. So Agent Code does not run the agy TUI in a PTY and watch it. It spawns `agy acp` and is the ACP client. `packages/antigravity-acp-headless` owns the protocol and the row assembly. Agent Code spawns the process; the package's session class never spawns or kills, and `stop()` only closes the protocol.
Antigravity (the `agy` CLI, `antigravity.google/cli`) is Google's replacement for Gemini CLI for personal accounts: Gemini CLI stopped serving them on 2026-06-18. agy has no PTY hook, no socket and no transcript file that a host could observe. Its conversations live in private SQLite (`~/.gemini/antigravity-cli/conversations/<id>.db`) owned by a closed binary that updates itself. What it does ship is a supported integration surface, `agy acp`: the Agent Client Protocol, JSON-RPC over newline-delimited stdio. Terminal view runs the interactive agy TUI in a PTY. The rendered view spawns `agy acp` and acts as the ACP client. `packages/antigravity-acp-headless` owns the protocol and the row assembly. Agent Code spawns the process; the package's session class never spawns or kills, and `stop()` only closes the protocol.

| Concern | Owner and rule |
| --- | --- |
Expand All @@ -786,7 +786,7 @@ Antigravity (the `agy` CLI, `antigravity.google/cli`) is Google's replacement fo
| Built-in MCP | agy advertises no HTTP MCP capability, so Agent Code's per-session HTTP endpoint reaches agy as a stdio server: `mcpProxy.mjs`, started by agy through Electron in node mode. Endpoint URLs and header values travel in the server's `env` list (one variable per header), never in argv, and nothing is written to agy's own MCP config. With no servers configured the proxy is a valid server with zero tools |
| History | A renderer reload or phone backfill adopts the running session and is served its in-memory rows back, so later live rows dedupe by key. A pane that is not live (the catalog preview, `read_agent` on a closed agent) replays the conversation through a short-lived `agy acp` and `session/load`, which makes no model call. Locator: `antigravity://session/<id>` |
| Catalog | `session/list`, following cursors up to 100 pages, in a short-lived `agy acp`. It also lists conversations made in agy's TUI, because ACP and the TUI share one store. agy reports the cwd of ACP-created sessions percent-encoded, so it is decoded only when the result is still an absolute path. A missing agy lists nothing rather than failing the catalog |
| Surface | `STRUCTURED_ONLY_PROVIDER_KINDS` pins the pane to the rendered feed, like structured OpenCode, but it is the coding feed, not Hermes' chat surface. `agy --conversation <id>` opens the same conversation in agy's own TUI, which is the verified external resume command |
| Surface | Terminal renders agy's own TUI. Agent view renders ACP events. `agy --conversation <id>` opens a known conversation in the native TUI |
| Skills | Project skills are discovered from `.agents/skills` up to the git root. agy's personal skills folder is undocumented, so personal skills are declared unsupported rather than deployed to a place agy may not read |

Rewind, duplicate and provider switching are off (`featureCapabilities.ts`). Each needs to write a conversation agy will resume, and the only place agy keeps one is the private SQLite schema. A command that no-ops or corrupts a conversation is worse than a missing command. The catalog, prompt history extraction and resume-in-app stay on, because they only read.
Expand Down Expand Up @@ -2204,7 +2204,7 @@ class Shadow caution

#### 8.3.1 Why the conversation must be reconstructed

Agent Code does not use a provider SDK or act as an API client for a user's subscription. Provider subscription OAuth is not available to a third-party application, and an SDK integration would also replace the native experience: slash commands, compaction, permission prompts, resume and authentication would become Agent Code reimplementations. Instead, the application runs the provider's own client and observes it. Claude Code and Codex run as CLIs inside a pseudo-terminal. Structured OpenCode runs as its native HTTP/SSE service, and OpenCode terminal mode runs its TUI in a PTY. Antigravity runs `agy acp` and speaks the Agent Client Protocol over stdio, with no PTY.
Agent Code does not use a provider SDK or act as an API client for a user's subscription. Provider subscription OAuth is not available to a third-party application, and an SDK integration would also replace the native experience: slash commands, compaction, permission prompts, resume and authentication would become Agent Code reimplementations. Instead, the application runs the provider's own client and observes it. Claude Code and Codex run as CLIs inside a pseudo-terminal. Structured OpenCode runs as its native HTTP/SSE service, and OpenCode terminal mode runs its TUI in a PTY. Antigravity runs its native TUI in a pseudo-terminal or uses `agy acp` over stdio for the rendered view.

Observation has a price. The same assistant message can exist simultaneously as a live semantic stream, retained semantic history, one or more committed transcript records, and a provisional ghost. A user's prompt can exist as a local optimistic echo, a native queue record and a committed message. These copies arrive on different channels, at different times, with different clocks and incompatible identifiers. Codex proxy events use `resp_*` ids that never match rollout ids. Any channel can also stall or die permanently; the committed tail is sometimes the only one that does.

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ program from the outside — the terminal screen, the model stream, the transcri
files on disk and the process — and expose it as an API. Agent Code reconciles
those observations into one conversation and renders it in React, without
replacing the agent loop underneath.
Antigravity is the exception to the PTY shape: Agent Code runs `agy acp` and
speaks the Agent Client Protocol with it through `antigravity-acp-headless`, so
there is no terminal to attach.
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.

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

**Status** — Native prompt and both view transitions verified locally. The release containing this change is pending.
**Approval mode** — The owner requested native agy and authorized staged implementation. Revisit scope with the owner if a solution requires changing their agy settings, submitting a model turn, or modifying the provider's private conversation store.

## Starting point and outcome

Agent Code 0.1.9 could drive agy through ACP. That proved the rendered conversation worked. It exposed no interactive terminal for this provider. The owner wants the real prompt inside an Antigravity pane. Terminal should accept native keyboard input, resizing and local commands. Agent view must still render ACP. Opening or changing views must follow the chosen conversation when two panes share a directory. If a handoff fails, the original pane should remain usable.

## Stage 0 results

The opt-in [registry-to-prompt probe](../../testing/live/antigravity-terminal.test.ts) exercised the installed macOS CLI through the production provider registry. Two signed-in panes opened in the same directory with distinct IDs. One pane displayed a typed draft, cleared it, ran the native local command `/new` and acquired a third ID. The probe reopened that ID in ACP, then reopened the native prompt while ACP was still running. It submitted zero model prompts. These are observed cases, not a population estimate.

| Hypothesis | Observation and verdict |
| --- | --- |
| H1. The CLI lacks a terminal interface. | Disproven. The installed CLI painted its own interactive prompt and accepted keyboard input. The restriction belonged to the host. |
| H2. A pane's directory identifies its conversation. | Disproven. The two panes shared a directory and had distinct IDs. |
| H3. An interactive process starting proves it resumed the requested conversation. | Disproven. With one nonexistent ID agy stayed alive and reported that it could not find the conversation. |
| H4. A pane can follow changes inside agy without reading its conversation content. | Observed on this CLI. The native `/new` action emitted a process-local active-conversation record naming the new ID. Other diagnostic records mention unrelated IDs. |

### Explicit resume probe

Nine native launches received no user input. Three of three ACP-created empty conversations and three of three conversations selected by a previous native `/new` emitted `conversation_manager.go:<line>] Streaming conversation <requested UUID>` within 380–514 ms. The matching redraw followed within 433–568 ms. Three of three nonexistent IDs emitted `Conversation <requested UUID> not found, ignoring --conversation flag` within 260–324 ms. None emitted a matching active-stream record within three seconds.

**Resume contract.** Only the matching active-stream record establishes a successful explicit handoff. The local store check catches an obviously missing target early. A wrong ID, a refusal, early exit or a timeout cannot retire the source pane. A fresh pane can open the CLI's own sign-in screen without a prior conversation.

## Verification stages

| Boundary | Produces | Independently verified by | Why separate | Real evidence |
| --- | --- | --- | --- | --- |
| 1. CLI and PTY | AntigravityTerminalSession and its registered terminal factory | Read and write through the pseudoterminal, resize, close, and observe exit. Exercise signed-out and slow bootstrap paths separately. | An enabled menu can still launch the headless process. | Installed agy, live prompt, and a controlled child process for error paths. |
| 2. Conversation ownership | terminalIdentity and a per-pane ID | Drive native `/new`, ignore unrelated records and reject a missing explicit resume target. Check the actual provider acknowledgment for a requested resume. | A painted prompt can belong to a different conversation. | Agy's per-process diagnostics and the real missing-ID probe. |
| 3. App handoff | Runtime selection, view picker, restore metadata and guarded replacement | Exercise new panes, saved conversations, previous ACP panes, cancellation, failed successors and activity or identity changes during a switch. | Killing the source early can lose a running turn even if both launchers work. | Actual renderer entry points and the registry probe with overlapping successor and source lifetimes. |
| 4. Distribution boundary | Tested application build and PR | Type-check, build the main process and renderer, run the focused suites and run the opt-in live probe on the combined tree. | A local CLI probe does not verify the application wiring. | Application build and integration test results recorded on the PR. |

## Ownership and fixtures

Agy owns conversation IDs. Only the native runtime consumes its per-process diagnostic stream. The identity parser accepts active-conversation metadata, bounds partial lines, and discards unrelated bytes. No renderer or command handler reads those diagnostics or agy's SQLite contents. The registry selects the launcher. The workspace owns view preference, source revalidation and replacement. Automated workers continue to use ACP by default for their session-specific tools.

The system tests use a contract-probe child for PTY operations and bootstrap failures. The identity examples use the observed agy diagnostic format with substitute IDs. Overlong lines, missing records and interleaved unrelated IDs are deliberate mutations. The live test uses agy's own prompt and local command in a trusted directory. Keep raw logs and user conversation contents out of fixtures.

## Unknowns and discarded approaches

1. A future CLI can change its diagnostic format. Keep the positive-resume probe as the compatibility check. A process ID or another pane's files cannot establish which conversation opened.
2. Native agy loads its configured MCP servers. The known mechanism for attaching Agent Code's per-pane tools is ACP. Native mode does not write global or workspace MCP configuration.
3. A signed public build needs its own release. The development evidence applies to this branch.

The structured-only provider flag, selecting the most recent conversation in the directory, and treating a successful process spawn as a successful resume all failed the observations above.

## Outcome and deviations

The first native implementation already existed when the owner requested staged verification. The staged probe found a real handoff gap. Six regression cases failed when process startup alone counted as a successful resume. They passed after explicit resume started waiting for agy's matching ID. In a disposable copy, disabling three renderer guards also reproduced four failures: the new-pane runtime default, the preference command restarting a process, and failure to preserve a source whose conversation or turn changed.

The combined live probe also reopens the rendered conversation in its native successor before the source exits. The native successor confirms its selection even before the new renderer can answer terminal queries. To repeat in an already trusted directory with a signed-in CLI, set `ANTIGRAVITY_TERMINAL_LIVE=1` and `ANTIGRAVITY_LIVE_CWD` and run `npx vitest run --config vitest.live.config.ts testing/live/antigravity-terminal.test.ts`. The probe creates empty conversations and submits only agy's local `/new` command.
11 changes: 11 additions & 0 deletions docs/plans/2026-11-27-native-agy-terminal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Antigravity native terminal

## Outcome and evidence

An Antigravity pane in Terminal mode should accept keyboard input in the installed agy terminal interface. In 0.1.9 the provider is marked structured-only and its only registered session starts agy acp on pipes. The installed CLI offers an interactive session and supports resuming a conversation by ID.

## Change and verification

Select a PTY-backed interactive agy session for Terminal and keep the existing ACP session for the rendered view. Carry the pane's selected runtime through creation, restoration and switching. Exercise input, resize, exit, runtime selection and the rendered path with focused tests. Smoke-test the installed CLI without submitting a model request. Releasing a new signed build is separate.

The staged contracts, evidence and remaining release boundary are recorded in the [native terminal decomposition](../decomposition/antigravity-terminal.md). The decomposition was added after the initial implementation when the owner requested this verification method.
Loading
Loading