@devries-cameron20 / t3code Mirror · read-only / commits / 5dd565d6b1
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

feat(antigravity): Auto uses agy's own Auto review (#39378)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

miley committed Nov 20, 2026 at 03:23 UTC 5dd565d6b1f2f68479507824431d24a01835270d
9 files changed +255 -27
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
+101 -7
@@ -1813,7 +1813,10 @@ describe("AntigravityAdapterV2 subagent reads", () => {
1813 });
1814
1815 describe("AntigravityAdapterV2 runtime mode ceiling", () => {
1816 - const modesSetFor = (pickedMode: string) =>
1816 + const modesSetFor = (
1817 + pickedMode: string,
1818 + modes: Pick<ProviderAdapter.ProviderAdapterV2RuntimePolicy, "runtimeMode" | "maxRuntimeMode">,
1819 + ) =>
1820 Effect.gen(function* () {
1821 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1822 const path = yield* Path.Path;
@@ -1860,22 +1863,113 @@ describe("AntigravityAdapterV2 runtime mode ceiling", () => {
1863 options: [{ id: "_t3/session-mode", value: pickedMode }],
1864 },
1865 runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1863 - runtimeMode: "approval-required",
1866 + ...modes,
1867 interactionMode: "default",
1868 cwd: process.cwd(),
1866 - maxRuntimeMode: "auto-accept-edits",
1869 }),
1870 });
1871 return modesSet;
1872 }).pipe(Effect.provide(layerSession), Effect.scoped);
1873
1872 - it.effect("does not apply a picked session mode above the policy ceiling", () =>
1874 + it.effect("does not apply a picked session mode above the thread's runtime mode", () =>
1875 Effect.gen(function* () {
1874 - assert.deepEqual(yield* modesSetFor("yolo"), ["default"]);
1875 - // A mode under the ceiling is still the user's to pick.
1876 - assert.deepEqual(yield* modesSetFor("auto_edit"), ["default", "auto_edit"]);
1876 + assert.deepEqual(yield* modesSetFor("yolo", { runtimeMode: "approval-required" }), [
1877 + "default",
1878 + ]);
1879 + assert.deepEqual(
1880 + yield* modesSetFor("auto_edit", {
1881 + runtimeMode: "approval-required",
1882 + maxRuntimeMode: "auto-accept-edits",
1883 + }),
1884 + ["default"],
1885 + );
1886 + // A narrower mode is still the user's to pick.
1887 + assert.deepEqual(yield* modesSetFor("default", { runtimeMode: "auto-accept-edits" }), [
1888 + "auto_edit",
1889 + "default",
1890 + ]);
1891 }),
1892 );
1893 +
1894 + it.effect("leaving Plan keeps the permission mode the thread has now", () =>
1895 + Effect.gen(function* () {
1896 + const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1897 + const path = yield* Path.Path;
1898 + const crypto = yield* SecureRandom.SecureRandom;
1899 + const mockAgentPath = yield* path.fromFileUrl(
1900 + new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
1901 + );
1902 + let runtime: AcpSessionRuntime.AcpSessionRuntime["Service"] | undefined;
1903 + const instanceId = ProviderInstanceId.make("antigravity-plan-exit-test");
1904 + const adapter = yield* makeAntigravityAdapterV2({
1905 + instanceId,
1906 + selfInvocation: yield* resolveSelfInvocation(),
1907 + makeRuntime: (input) =>
1908 + makeAntigravityAcpRuntime({
1909 + ...input,
1910 + childProcessSpawner,
1911 + spawn: {
1912 + command: process.execPath,
1913 + args: [mockAgentPath],
1914 + cwd: input.cwd,
1915 + env: { T3_ACP_ANTIGRAVITY: "1" },
1916 + },
1917 + }).pipe(
1918 + Effect.provideService(SecureRandom.SecureRandom, crypto),
1919 + Effect.tap((made) =>
1920 + Effect.sync(() => {
1921 + runtime = made;
1922 + }),
1923 + ),
1924 + ),
1925 + withProcess: (_stop, task) => task,
1926 + defaultModel: Effect.undefined,
1927 + });
1928 + const threadId = ThreadId.make("thread-antigravity-plan-exit");
1929 + const modelSelection = { instanceId, model: "gemini-test-low" } as const;
1930 + const planPolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1931 + runtimeMode: "full-access",
1932 + interactionMode: "plan",
1933 + cwd: process.cwd(),
1934 + });
1935 + const session = yield* adapter.openSession({
1936 + threadId,
1937 + providerSessionId: ProviderSessionId.make("provider-session-antigravity-plan-exit"),
1938 + modelSelection,
1939 + runtimePolicy: planPolicy,
1940 + });
1941 + const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
1942 + yield* session.events.pipe(
1943 + Stream.runForEach((event) => Queue.offer(events, event)),
1944 + Effect.forkScoped,
1945 + );
1946 + const providerThread = yield* session.ensureThread({
1947 + threadId,
1948 + modelSelection,
1949 + runtimePolicy: planPolicy,
1950 + });
1951 + const supervisedPolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1952 + runtimeMode: "approval-required",
1953 + interactionMode: "default",
1954 + cwd: process.cwd(),
1955 + });
1956 + yield* session.startTurn(
1957 + makeTurnInput({
1958 + threadId,
1959 + providerThread,
1960 + instanceId,
1961 + runtimePolicy: supervisedPolicy,
1962 + modelSelection,
1963 + now: yield* DateTime.now,
1964 + }),
1965 + );
1966 + yield* Stream.fromQueue(events).pipe(
1967 + Stream.filter((event) => event.type === "turn.terminal"),
1968 + Stream.runHead,
1969 + );
1970 + assert.equal((yield* runtime!.getModeState)?.currentModeId, "default");
1971 + }).pipe(Effect.provide(layerSession), Effect.scoped),
1972 + );
1973 });
1974
1975 describe("AntigravityAdapterV2 session system prompt", () => {
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
+2
@@ -21,6 +21,7 @@ import type { AntigravityAuth } from "../../provider/AntigravityAuth.ts";
21 import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
22 import {
23 antigravityAppendsSystemPrompt,
24 + antigravityPermissionDisposition,
25 antigravityPermissionMode,
26 antigravityRuntimeModeForSessionMode,
27 antigravitySteersWithPrompt,
@@ -272,6 +273,7 @@ export function makeAntigravityAcpAdapterFlavor(
273 request,
274 }),
275 },
276 + permissionDisposition: antigravityPermissionDisposition,
277 approvalOptions: antigravityApprovalOptions,
278 extractPermissionQuestion: (request) => {
279 const question = extractAntigravityUserInputQuestion(request);
apps/server/src/provider/AntigravityProvider.test.ts
+27 -3
@@ -347,16 +347,40 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => {
347 }),
348 );
349
350 - it.effect("does not offer Auto, so Auto threads fall back to Supervised", () =>
350 + it.effect("offers Auto only while the signed-in session advertises agy's own Auto", () =>
351 Effect.gen(function* () {
352 const harness = yield* makeHarness();
353 yield* harness.initialize;
354 - // Antigravity has no automatic review; the shared ACP policy would approve every request.
355 - expect((yield* harness.provider.snapshot.getSnapshot).supportedRuntimeModes).toEqual([
354 + const supportedModes = harness.provider.snapshot.getSnapshot.pipe(
355 + Effect.map((snapshot) => snapshot.supportedRuntimeModes),
356 + );
357 + const withoutAuto = ["approval-required", "auto-accept-edits", "full-access"];
358 + const startedWithAuto = {
359 + ...started,
360 + sessionSetupResult: {
361 + ...sessionSetupResult,
362 + modes: {
363 + currentModeId: "default",
364 + availableModes: [
365 + { id: "default", name: "Default" },
366 + { id: "auto", name: "Auto" },
367 + ],
368 + },
369 + },
370 + };
371 + expect(yield* supportedModes).toEqual(withoutAuto);
372 + yield* harness.provider.onSessionStarted(startedWithAuto);
373 + expect(yield* supportedModes).toEqual([
374 "approval-required",
375 "auto-accept-edits",
376 + "auto",
377 "full-access",
378 ]);
379 + yield* harness.provider.onSessionStarted(started);
380 + expect(yield* supportedModes).toEqual(withoutAuto);
381 + yield* harness.provider.onSessionStarted(startedWithAuto);
382 + yield* harness.provider.onSignedOut;
383 + expect(yield* supportedModes).toEqual(withoutAuto);
384 }),
385 );
386
apps/server/src/provider/AntigravityProvider.ts
+22 -2
@@ -4,6 +4,7 @@ import {
4 ProviderDriverKind,
5 type AntigravitySettings,
6 type ProviderSetupError,
7 + type RuntimeMode,
8 type ServerProvider,
9 type ServerProviderModel,
10 type ServerProviderSlashCommand,
@@ -24,6 +25,7 @@ import type * as EffectAcpErrors from "effect-acp/errors";
25 import type * as EffectAcpSchema from "effect-acp/compat";
26
27 import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
28 +import { parseSessionModeState } from "@t3tools/provider-acp/server/runtimeModel";
29 import { acpProviderOptionDescriptors } from "@t3tools/provider-acp/server/sessionConfig";
30 import {
31 DeferringFailedCheck,
@@ -172,6 +174,23 @@ interface AntigravityProviderOptions {
174 readonly auth?: { readonly type: string; readonly label: string };
175 }
176
177 +const RUNTIME_MODES_WITHOUT_AUTO = [
178 + "approval-required",
179 + "auto-accept-edits",
180 + "full-access",
181 +] as const;
182 +
183 +/** Auto is offered only where the session advertises agy's own Auto; elsewhere it runs Supervised. */
184 +function antigravityRuntimeModes(
185 + sessionSetupResult: AcpSessionRuntime.AcpSessionRuntimeStartResult["sessionSetupResult"],
186 +): ReadonlyArray<RuntimeMode> {
187 + return parseSessionModeState(sessionSetupResult)?.availableModes.some(
188 + (mode) => mode.id === "auto",
189 + )
190 + ? ["approval-required", "auto-accept-edits", "auto", "full-access"]
191 + : RUNTIME_MODES_WITHOUT_AUTO;
192 +}
193 +
194 export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(function* (
195 settings: AntigravitySettings,
196 options: AntigravityProviderOptions,
@@ -190,8 +209,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
209 presentation: {
210 displayName: "Antigravity",
211 showInteractionModeToggle: false,
193 - // No automatic review, so Auto falls back to Supervised instead of approving everything.
194 - supportedRuntimeModes: ["approval-required", "auto-accept-edits", "full-access"],
212 + supportedRuntimeModes: RUNTIME_MODES_WITHOUT_AUTO,
213 },
214 enabled: settings.enabled,
215 checkedAt,
@@ -406,6 +424,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
424 },
425 checkedAt: updatedAt,
426 models: buildAntigravityModelsFromSession(started.sessionSetupResult, thinkingLevels),
427 + supportedRuntimeModes: antigravityRuntimeModes(started.sessionSetupResult),
428 supportsTextGeneration,
429 ...(cwd
430 ? {
@@ -494,6 +513,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
513 slashCommands: [],
514 skills: [],
515 workspaceSnapshots: [],
516 + supportedRuntimeModes: RUNTIME_MODES_WITHOUT_AUTO,
517 supportsTextGeneration: false,
518 usageLimits: undefined,
519 },
apps/server/src/provider/Drivers/AntigravityDriver.ts
+7 -2
@@ -47,8 +47,8 @@ import {
47 type AntigravityAuthConfig,
48 } from "../antigravityAuthSupport.ts";
49 import {
50 - antigravityCliSessionMode,
50 antigravityModelOptions,
51 + antigravitySessionMode,
52 antigravityThinkingConfig,
53 makeAntigravityAcpRuntime,
54 type AntigravityAcpRuntimeInput,
@@ -337,7 +337,12 @@ export const AntigravityDriver: ProviderDriver<
337 });
338 return {
339 ...runtime,
340 - setMode: (modeId: string) => runtime.setMode(antigravityCliSessionMode(modeId)),
340 + setMode: (modeId: string) =>
341 + runtime.getModeState.pipe(
342 + Effect.flatMap((modeState) =>
343 + runtime.setMode(antigravitySessionMode(modeId, modeState)),
344 + ),
345 + ),
346 start: () =>
347 startCompatible().pipe(
348 Effect.tapError((cause): Effect.Effect<void> =>
apps/server/src/provider/acp/AntigravityAcpSupport.test.ts
+48
@@ -16,7 +16,9 @@ import { resolveAttachmentPath } from "../../attachmentStore.ts";
16 import {
17 applyAntigravityAcpModelSelection,
18 antigravityClientInfo,
19 + antigravityPermissionDisposition,
20 antigravitySessionMeta,
21 + antigravitySessionMode,
22 buildAntigravityPrompt,
23 } from "./AntigravityAcpSupport.ts";
24
@@ -87,6 +89,52 @@ describe("Antigravity release gates", () => {
89 );
90 });
91
92 +describe("Antigravity Auto", () => {
93 + it.each([
94 + { offered: ["default", "accept-edits", "auto", "plan"], expected: "auto" },
95 + { offered: ["default", "accept-edits", "plan"], expected: "default" },
96 + ])("runs as $expected when the session offers $offered", ({ offered, expected }) => {
97 + const modeState = {
98 + currentModeId: "default",
99 + availableModes: offered.map((id) => ({ id, name: id })),
100 + };
101 + expect(antigravitySessionMode("auto", modeState)).toBe(expected);
102 + });
103 +
104 + it.each(["execute", "read"] as const)("asks about the %s requests agy's Auto sends", (kind) => {
105 + const request = {
106 + sessionId: "session-1",
107 + toolCall: { toolCallId: "call-1", title: "Tool call", kind },
108 + options: [{ optionId: "allow", name: "Allow", kind: "allow_once" }],
109 + } satisfies EffectAcpSchema.RequestPermissionRequest;
110 + expect(antigravityPermissionDisposition({ runtimeMode: "auto", cwd: null }, request)).toBe(
111 + "ask",
112 + );
113 + });
114 +
115 + it.each([{ type: "readOnly" }, { type: "workspaceWrite", writableRoots: [] }])(
116 + "keeps the $type sandbox's denials in Auto",
117 + (sandboxPolicy) => {
118 + const request = {
119 + sessionId: "session-1",
120 + toolCall: {
121 + toolCallId: "call-1",
122 + title: "Edit",
123 + kind: "edit",
124 + locations: [{ path: "/outside-workspace/file.txt" }],
125 + },
126 + options: [{ optionId: "allow", name: "Allow", kind: "allow_once" }],
127 + } satisfies EffectAcpSchema.RequestPermissionRequest;
128 + expect(
129 + antigravityPermissionDisposition(
130 + { runtimeMode: "auto", cwd: "/workspace", sandboxPolicy },
131 + request,
132 + ),
133 + ).toBe("deny");
134 + },
135 + );
136 +});
137 +
138 describe("applyAntigravityAcpModelSelection", () => {
139 it.effect("restores the saved model instead of the cold-resume default", () =>
140 Effect.gen(function* () {
apps/server/src/provider/acp/AntigravityAcpSupport.ts
+29 -4
@@ -23,6 +23,11 @@ import {
23 makeAntigravityStdoutTransform,
24 } from "../antigravityAuthSupport.ts";
25 import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
26 +import {
27 + acpPermissionDisposition,
28 + type AcpRuntimePolicy,
29 +} from "@t3tools/provider-acp/server/clientPolicy";
30 +import type { AcpSessionModeState } from "@t3tools/provider-acp/server/runtimeModel";
31 import packageJson from "../../../package.json" with { type: "json" };
32 import { normalizeAntigravitySessionUpdate } from "./AntigravityProtocol.ts";
33
@@ -153,20 +158,38 @@ export function antigravityPermissionMode(runtimeMode: RuntimeMode): string {
158 case "auto-accept-edits":
159 return "auto_edit";
160 case "auto":
161 + return "auto";
162 case "approval-required":
163 return "default";
164 }
165 }
166
167 /**
162 - * The agy CLI rejects the managed runtime's `yolo` and `auto_edit`. It stays in `default`, where
163 - * it asks before acting and T3 answers from the live runtime policy, so permission changes apply
164 - * on the next turn without a restart.
168 + * The agy CLI rejects `yolo` and `auto_edit`, and sessions without native Auto reject `auto`.
169 + * Those stay in `default`, where it asks before acting and T3 answers from the live runtime
170 + * policy, so permission changes apply on the next turn without a restart.
171 */
166 -export function antigravityCliSessionMode(modeId: string): string {
172 +export function antigravitySessionMode(
173 + modeId: string,
174 + modeState: AcpSessionModeState | undefined,
175 +): string {
176 + if (modeId === "auto") {
177 + return modeState?.availableModes.some((mode) => mode.id === "auto") === true
178 + ? "auto"
179 + : "default";
180 + }
181 return modeId === "yolo" || modeId === "auto_edit" ? "default" : modeId;
182 }
183
184 +export function antigravityPermissionDisposition(
185 + policy: AcpRuntimePolicy,
186 + request: EffectAcpSchema.RequestPermissionRequest,
187 +) {
188 + const disposition = acpPermissionDisposition(policy, request);
189 + // agy's Auto has already reviewed what it sends; the user decides unless the sandbox forbids it.
190 + return policy.runtimeMode === "auto" && disposition !== "deny" ? "ask" : disposition;
191 +}
192 +
193 /** The runtime mode an Antigravity session mode grants; the inverse of `antigravityPermissionMode`. */
194 export function antigravityRuntimeModeForSessionMode(modeId: string): RuntimeMode | undefined {
195 switch (modeId) {
@@ -174,6 +197,8 @@ export function antigravityRuntimeModeForSessionMode(modeId: string): RuntimeMod
197 return "full-access";
198 case "auto_edit":
199 return "auto-accept-edits";
200 + case "auto":
201 + return "auto";
202 case "default":
203 return "approval-required";
204 default:
docs/user/permission-modes.md
+7 -3
@@ -27,9 +27,13 @@ the parent conversation with the subagent's name, so you can respond without swi
27 ## Provider differences
28
29 Providers enforce permissions differently. Some read-only actions can proceed in **Supervised**.
30 -**Auto** uses automatic review on Codex, Claude, Cursor, Grok, and fx; providers without an equivalent,
31 -including OpenCode and Antigravity, fall back to asking. On Grok, commands its review blocks come
32 -to you for approval. On fx, prompts it still sends also come to you.
30 +**Auto** uses automatic review on Codex, Claude, Cursor, Grok, Antigravity, and fx; providers without
31 +an equivalent, including OpenCode, fall back to asking. On Grok and Antigravity, actions their review
32 +does not approve come to you for approval. On fx, prompts it still sends also come to you.
33 +
34 +Antigravity offers **Auto** only when your Antigravity sign-in provides its Auto mode; some accounts,
35 +including some personal Google accounts, do not. Without it, an Antigravity thread already set to
36 +**Auto** runs in **Supervised**.
37
38 Muse Code offers only **Supervised** and **Full access**. A Muse thread already set to another mode
39 runs in **Supervised**.
packages/provider-acp/src/server/adapter.ts
+12 -6
@@ -490,7 +490,7 @@ export interface AcpAdapterV2Flavor {
490 ) => ReadonlyArray<{ readonly id: string; readonly value: string }>;
491 /**
492 * The runtime mode a native session mode grants, for flavors whose modes are permission levels.
493 - * Under a policy ceiling, a mode the user picks that this does not place under it is not applied.
493 + * A picked mode this does not place within the thread's runtime mode is not applied.
494 */
495 readonly runtimeModeForSessionMode?: (modeId: string) => RuntimeMode | undefined;
496 readonly clientFileSystem?: {
@@ -8088,9 +8088,15 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
8088 });
8089 }
8090 const configOptions = yield* runtime.getConfigOptions;
8091 - // Under a policy ceiling, a mode the user picks applies only when the flavor can place
8092 - // it under the ceiling; an unknown mode could be the agent's own skip-approval mode.
8093 - const ceiling = runtimePolicy.maxRuntimeMode;
8091 + // A picked mode applies only when the flavor places it within the bound; an unknown mode
8092 + // could be the agent's own skip-approval mode. Modes known to be permission levels are
8093 + // also bounded by the thread's runtime mode, so model options cannot widen it.
8094 + const ceiling =
8095 + flavor.runtimeModeForSessionMode === undefined ||
8096 + (runtimePolicy.maxRuntimeMode !== undefined &&
8097 + isRuntimeModeAbove(runtimePolicy.runtimeMode, runtimePolicy.maxRuntimeMode))
8098 + ? runtimePolicy.maxRuntimeMode
8099 + : runtimePolicy.runtimeMode;
8100 const isModeChoice = (id: string) =>
8101 id === ACP_SESSION_MODE_OPTION_ID ||
8102 configOptions.some(
@@ -8243,7 +8249,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
8249 const nativeBuild = nativeBuildConfigurationBySessionId.get(startResult.sessionId);
8250 if (nativeBuild !== undefined) {
8251 if (
8246 - !modeLocked &&
8252 + policyMode === undefined &&
8253 nativeBuild.modeId !== undefined &&
8254 effectiveModeState?.currentModeId !== nativeBuild.modeId &&
8255 effectiveModeState?.availableModes.some(
@@ -8259,7 +8265,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
8265 if (
8266 option === undefined ||
8267 option.type !== "select" ||
8262 - (modeLocked && option.category === "mode")
8268 + (policyMode !== undefined && option.category === "mode")
8269 )
8270 continue;
8271 const choices = option.options.flatMap((entry) =>