Skip to content

[feat] harness: add Antigravity CLI runtime - #598

Open
Redivesue wants to merge 6 commits into
ThinkFlowLab:mainfrom
Redivesue:feat/585-antigravity-runtime
Open

Redivesue wants to merge 6 commits into
ThinkFlowLab:mainfrom
Redivesue:feat/585-antigravity-runtime

Conversation

@Redivesue

@Redivesue Redivesue commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds antigravity (Antigravity CLI, agy) as an external harness next to OpenCode, Codex, Claude Code, JiuwenSwarm, DeepSeek Harness and Pi: one agy --input-format stream-json --output-format stream-json --disable-slash-commands -p= process per turn, reusing the existing terminate, stderr, trace, session and cancel handling.
  • Uses the local agy sign-in, model catalog, global skills, plugins and MCP servers (modelSource: cli). OpenDirector model credentials are not passed to the child process.
  • The prompt goes over stdin as one {"event":"user"} line: -p does not read stdin, and a full replay can exceed the Windows command-line limit. agy has no system prompt flag, so runtime instructions travel in the first message of a fresh native conversation and are not repeated on resume.
  • agent_response text_delta updates are display only; result.response is authoritative. When it extends the streamed text, only the remainder is emitted; when it revises it, the adapter emits a new shared replace stream event with the final text. The API saves that text, and the assistant view swaps the visible text through streamedText, so a live view, a resumed stream and a reload show the final reply. Any non-SUCCESS status fails the turn (sign-in errors map to antigravity_login, 401). A SUCCESS with an empty response also fails: headless mode reports denied tools that way (denied_actions → antigravity_denied, otherwise antigravity_empty).
  • A per-run policy is pinned through --settings instead of inheriting the user's global mode: default agentMode, terminal sandbox on, toolPermission: proceed-in-sandbox. Only command(opendirector) may leave the sandbox, because the sandbox blocks the local socket the CLI uses to reach the app; read_file(*) and write_file(<turn work dir>/) are allowed, execute_url(*) and download_url(*) are denied. Other requests are soft-denied by headless mode. --dangerously-skip-permissions is not used.
  • Continuation uses --conversation in the same execution directory. Native conversations live in ~/.gemini/antigravity-cli/conversations/<id>.db (the CLI has no project-local override); a missing file keeps the workspace and replays the full history.
  • agy is discovered on PATH, then in ~/.gemini/bin, where the installer puts it without updating PATH. Readiness is agy --version → agy models; a sign-in error maps to needs_login.
  • Adds the picker entry, the Lobe Icons monochrome logo, the bilingual setup hint and backend error codes, the trace projection and trace export entry, runtime identifiers in the API contract, docs, and a lesson. Antigravity stays out of the credential-free release visual gate, like Pi.

Known limitations, stated in docs/architecture/agent-runtime.md:

  • Native conversations are written to the user's global agy history; the CLI offers no per-run data directory.
  • User-global skills, plugins and MCP servers are loaded; the CLI has no per-run switch to disable them.
  • The sandbox policy was exercised on macOS only. Linux and Windows sandbox behaviour is unverified.

Linked issue

  • Fixes #N or Refs #N is included, or no issue applies

Refs #585

Labels

  • Labels applied

type:feat, area:agent, area:harness

Test plan

Tip: a3f09289. c9c4296e adds the replace stream event requested in review on top of 8db1b0b1; a3f09289 only changes tests/browser/timeline_node_output.mjs, so the product evidence below, recorded on c9c4296e, applies to the tip.

  • Local, model and CLI doubles, on c9c4296e:
    • New regressions, each failing on 8db1b0b1 and passing on c9c4296e:
      • tests/test_antigravity_runtime.py::test_a_revised_final_response_replaces_the_streamed_draft: the adapter emits one replace with the final text.
      • tests/test_assistant_conversations.py::test_a_replaced_reply_streams_and_persists_the_final_text: the streamed, reread and on-disk message is the final text.
      • tests/assistantResume.test.ts: a replayed stream ends with the replaced text.
    • python -m pytest tests/test_antigravity_runtime.py tests/test_assistant_conversations.py tests/test_runtime_readiness.py tests/test_assistant_conversation_trace.py tests/test_pi_runtime.py tests/test_localization.py tests/test_agent_visual_gate.py tests/test_native_runtime.py -q (170 passed, 22 skipped). The fake agy covers argv and stdin stream-json, the pinned --settings policy, delta / remainder / replace reconciliation, sign-in / error / denied / empty failures, skill forwarding, --conversation resume, missing-conversation replay and readiness branches.
    • python -m pytest tests -m ready -q (223 passed); scripts/generate_contracts.py --check; lint-imports (4 kept, 0 broken).
    • npm test (1039 passed), npm run build, npm run check:i18n (3461 keys, 0 problems).
    • tests/browser/timeline_node_output.mjs against creation_server.py + Vite: 3 of 3 runs passed (see CI below).
  • Local, real agy 1.5.20 account against an isolated local API, on c9c4296e (gemini-3.8-flash-medium), recorded in the video below:
    • Turn 1 created a text node through opendirector canvas text create. The asset has provenance.agentRuntime: antigravity and agentRunId matching the turn.
    • The API process was stopped and a new uvicorn process started (PID 57589 → 57828). The project was reopened: the node, the conversation and runtime=antigravity / runtimeModel=gemini-3.8-flash-medium were kept.
    • Turn 2 resumed the same native conversation (f90a11d7…) in the same work directory as turn 1. It read the node (canvas text show, revision 1), wrote it with canvas text update --expected-version canvas_item:…:1, and read back revision 2 with both lines.
  • Earlier real-account checks, on 9bdb16be (adapter unchanged since, except the replace branch): readiness ready with 27 models; a user edit preserved across a restart; stop mid-run with no orphan agy process, then continuation; an unsandboxed non-opendirector command soft-denied as antigravity_denied; a second project isolated; no sentinel OpenDirector API key in agent-runs/<turn>.antigravity.jsonl.
  • CI: checks / browser (isolated) failed on c9c4296e in tests/browser/timeline_node_output.mjs, the same timeout seen on an unrelated PR on 2026-11-26. Three of its waits include a browser MP4 render and used the page's 20 s default; under CPU contention the first output's timeline.publishRender was applied after that wait expired, with no conflict or stuck state. a3f09289 gives those render-bound waits the 60 s budget timeline_workflow.mjs uses and waits for the publish receipt before the <video>. Locally it passes 5/5 unthrottled and 3/3 at 8× CPU throttling; under a 4-instance, 4× throttled load the previous version failed 12/12. Release checks on a3f09289 are pending. Native Windows and Linux runs with a signed-in agy are not covered and were not run.

Evidence that it works

  • Applicable evidence attached and any visual N/A explained

All artifacts below were captured on c9c4296e with agy 1.5.20 signed in, against an isolated local API and Vite server with a fresh project. Yellow banners in the video are recording notes injected by the capture script; they are not product UI.

  1. Workflow video with an API restart (en-US, 5 min 23 s, real time). New project → Chat with AI → pick Antigravity (setup card: Ready) → choose Gemini 3.8 Flash (Medium) → turn 1 creates "Opening line, written by Antigravity." (1 min 35 s, 7 tool calls) → the API is stopped and restarted (the page shows the request errors while it is down) → the project is reopened with the node, the conversation and the selected model intact → turn 2 reads the node and appends "Second line, after the restart." (2 min 44 s, 12 tool calls).
    Run receipt: project adf9e4ba-48bb-49e3-9b95-0a0c3fef80ea; native conversation f90a11d7-9bf9-423d-b694-55390f136110 for both turns.
antigravity-restart-en-US.mp4
  1. Setup card (en-US, zh-CN). Antigravity is Ready, with the bilingual hint and the agy command.
setup-en-US setup-zh-CN
  1. Picker and model list (en-US, zh-CN). Antigravity row with the monochrome logo, and the model list read from agy models.
picker-models-en-US picker-models-zh-CN
  1. After reload (en-US, zh-CN). Antigravity is still selected with gemini-3.8-flash-medium.
picker-after-reload-en-US picker-after-reload-zh-CN

Observed but not changed here:

  • The picker labels "Harnesses", "Models", "Edit" and "Default · OpenCode bundled" stay English in zh-CN. They are shared by every harness row and predate this PR.
  • After a reload the selected model shows its raw ID until the model list is fetched again, as it does for other CLI harnesses.
  • While agy models loads (about 6 s), the model submenu briefly reads "CLI exposes no selectable models" before the list appears.
  • A failed turn's reason is sent on the live stream only and is not saved with the message, the same behaviour reported in [bug] assistant: Claude Code 鉴权失败时回复为空且不显示原因,运行时仍显示可用 #557.

Provider verification

  • Real-provider calls are described honestly, or none were made

  • Unit, contract and regression tests use a local fake agy and synthetic fixtures; the replace path is covered by those doubles. No real agy run in this pass happened to return a revised final response.

  • The video run used a real signed-in agy 1.5.20 account with gemini-3.8-flash-medium against isolated local services on c9c4296e: node creation, an API restart with a reopened project, and a resumed native conversation that read and updated the node.

  • Image and video generation through Antigravity, other agy models, and Windows or Linux execution were not run.

Bilingual UI

  • Both locales are updated, or no user-facing copy changed

src/i18n/messages/{en-US,zh-CN}/assistant.ts (setup hint), apps/api/src/opendirector_api/localization.py (five antigravity_* error codes) and docs/guides/user-guide{,.zh-CN}.md. npm run check:i18n passed, and the setup card, picker and model list were inspected in both locales.

Redivesue and others added 3 commits November 30, 2026 13:54
- Run Antigravity as an external harness: one `agy` process per turn with
  stream-json input and output. The prompt goes to stdin as an
  `{"event":"user"}` message, because `-p` does not read stdin and a full
  replay exceeds the Windows command-line limit.
- The CLI has no system prompt flag, so a fresh native conversation carries
  the runtime instructions in its first message; a resumed one does not
  repeat them.
- Stream `agent_response` deltas for display and reconcile with
  `result.response`, emitting only text the stream did not show. A non-SUCCESS
  status fails the turn, and so does a SUCCESS result with an empty response:
  headless mode reports denied tools that way, listed in `denied_actions`.
- Grant permissions for this run only through `--settings`: shell commands,
  reads, and writes inside the turn's execution directory; browser URL
  actions are denied and anything else needing approval is soft-denied by
  headless mode. `--dangerously-skip-permissions` is not used.
- Resume with `--conversation` in the same execution directory. Native
  conversations live in `~/.gemini/antigravity-cli/conversations`; a missing
  file keeps the workspace and replays the full history.
- Discover `agy` on PATH, then in `~/.gemini/bin`, where the installer puts
  it without adding it to PATH. Probe readiness by version and `agy models`;
  a sign-in error maps to needs_login.
- Add the picker entry, Lobe Icons logo, bilingual setup hint and error
  codes, a trace projection, runtime identifiers in the API contract, and
  docs. Keep Antigravity out of the credential-free release visual gate.

Refs: ThinkFlowLab#585
- Antigravity CLI enables its terminal sandbox by default in auto mode.
  The sandbox blocked the local socket the opendirector CLI uses to reach
  the running app, so every project command failed with "Operation not
  permitted" and the agent could not change the project.
- Pin the policy per run through --settings instead of inheriting the
  user's global mode: default agent mode, terminal sandbox on, and
  proceed-in-sandbox. Allow only command(opendirector) to run outside the
  sandbox, replacing command(*). Other requests to leave the sandbox are
  soft-denied in headless mode.
- Tell the agent in its first message to run opendirector outside the
  sandbox.
- Update the runtime docs, add a lesson, and assert the pinned policy in
  the runtime test.

Verified with a real agy turn: a text node was created, and an image was
generated and adopted through opendirector. Video submissions reached the
providers but were rejected upstream (HTTP 400/402).

Refs: ThinkFlowLab#585

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Include `antigravity` in the raw conversation trace archive allowlist
  so exported ZIP archives include `antigravity.jsonl` instead of
  marking the source unsupported, with a unit test.
- Add Antigravity to `tests/browser/provider_settings.mjs` harness logo
  verification, matching the Pi runtime check.
- Instruct Antigravity to invoke each `opendirector` command standalone
  (without shell chaining, pipes, or command substitution) so the
  `command(opendirector)` unsandboxed allow rule matches reliably.
- Reuse `_logged_out()` for turn-result authentication failures, cover
  English localization of all five `antigravity_*` error codes, and drop
  redundant inline comments already documented in `agent-runtime.md`.

Refs: ThinkFlowLab#585
@github-actions github-actions Bot added area:agent Agent runtime, assistant chat and tools area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) type:feat New capability or behaviour labels Nov 30, 2026
@github-actions
github-actions Bot requested review from FayeSpica and wuzhf9 November 30, 2026 05:57
…apter

- Remove the multi-line docstrings and the trace JSDoc block; the sandbox
  policy, stream-json input and empty-SUCCESS handling are described in
  docs/architecture/agent-runtime.md.

Refs: ThinkFlowLab#585

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST CHANGES 8db1b0b Refs #585

Dot,代表 @david6666666。

当前证据暂定 52/100(非批准分)。 范围 3/3,正确性 2/3,验证 2/3,主张证据 0/3,简洁性 2/3。

接入范围符合 #585,当前提交的 Release checks 是绿的。最想先确认的是:最后一帧改写了流式正文时,用户能否看到并保留最终版本。我把具体分支标在代码里了。真机和重启验证目前写的是旧提交,也还缺从选择 Antigravity 到重新打开项目的可播放录像。建议修完后在当前提交上补这一段。我没有调用真实账号或重跑测试。

English summary: 52/100 provisional. Handle a non-prefix final response without losing the authoritative text; attach a current-tip workflow recording and restart evidence.

if not shown:
return [{'type': 'delta', 'text': response}]
for base in (last, shown):
if base and response.startswith(base):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里如果 result.response 不是已有流式文本的前缀延续(比如 CLI 在结束时修订了最后一句),就直接返回空列表。用户会看到草稿,但这轮仍当作成功完成。能否让完成帧在这个分支替换可见正文,并加一个「流式内容和最终正文不一致」的回归,顺手验证刷新后保留下来的是最终版本?

- Antigravity's `result.response` is authoritative, but a response that
  did not extend the streamed text was dropped: the draft stayed visible
  and was persisted while the turn reported success.
- Add a shared `replace` stream event. The adapter emits it with the final
  response in that case; the API turns it into the accumulated text that is
  persisted, and the assistant view swaps the visible text through
  `streamedText`, so a live view, a resumed stream and a reload agree.
- Regression tests fail on the previous revision: the adapter emits one
  `replace` with the final text, the saved and reread message is the final
  text, and a replayed stream ends with the replaced text.

Refs: ThinkFlowLab#585
- `checks / browser (isolated)` failed in `timeline_node_output.mjs` at the
  first output's `<video>` wait, on this branch and on an unrelated PR
  (run 46380611011, 2026-11-26 feat/midturn-composer-actions). The wait
  covers a browser MP4 render, asset import and `timeline.publishRender`
  under the page's 20 s default.
- Under CPU contention the render finished and `timeline.publishRender` was
  applied after the 20 s wait expired; no revision conflict or stuck state
  was observed.
- Give the render-bound waits the 60 s budget `timeline_workflow.mjs`
  already uses for its render, and wait for the first `publishRender`
  receipt before the `<video>`, so a slow render and a rejected publish fail
  with different messages.

Refs: ThinkFlowLab#585

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WITHHOLD a3f0928 Refs #585

Dot,代表 @david6666666。

当前证据暂定 60/100(非批准)。 范围、正确性、验证、证据、简洁性依次为 3/3、3/3、2/3、0/3、2/3。

之前卡的最终正文已修:遇到非前缀结果时发 replace,服务端保存和浏览器显示都用替换后的正文,新增用例也覆盖了刷新回读。当前 CI 是绿的,作者已补录像,但我未能读到录像内容,证据暂不补分;分支仍落后主线两个提交。建议同步主线后再核对从选择运行时到重新打开项目的录像。

English summary: 60/100. The replacement event addresses the prior finding. Exact-tip CI is green, but the branch is behind main and video content was not independently verifiable.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants