Skip to content

Commit 4432fbe

Browse files
t3dotggclaude
andauthored
feat(antigravity): Claude and GPT models, thinking levels, and diff edits (#26876)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 58e60bf commit 4432fbe

18 files changed

Lines changed: 298 additions & 149 deletions

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts‎

Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const layerSession = Layer.mergeAll(
127127
);
128128

129129
describe("AntigravityAdapterV2 client file system", () => {
130-
it.effect("confines agent file requests to the workspace under full access", () =>
130+
it.effect("serves confined reads and leaves edits to the agent's diff tools", () =>
131131
Effect.gen(function* () {
132132
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
133133
const fileSystem = yield* FileSystem.FileSystem;
@@ -140,6 +140,8 @@ describe("AntigravityAdapterV2 client file system", () => {
140140
// effect-acp keeps the last handler registered per method; so does this.
141141
let readTextFile: Parameters<RuntimeService["handleReadTextFile"]>[0] | undefined;
142142
let writeTextFile: Parameters<RuntimeService["handleWriteTextFile"]>[0] | undefined;
143+
const logs = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-antigravity-log-" });
144+
const requestLog = path.join(logs, "requests.ndjson");
143145
const crypto = yield* Crypto.Crypto;
144146
const instanceId = ProviderInstanceId.make("antigravity-containment-test");
145147
const adapter = yield* makeAntigravityAdapterV2({
@@ -153,7 +155,7 @@ describe("AntigravityAdapterV2 client file system", () => {
153155
command: process.execPath,
154156
args: [mockAgentPath],
155157
cwd: input.cwd,
156-
env: { T3_ACP_ANTIGRAVITY: "1" },
158+
env: { T3_ACP_ANTIGRAVITY: "1", T3_ACP_REQUEST_LOG_PATH: requestLog },
157159
},
158160
}).pipe(
159161
Effect.provideService(Crypto.Crypto, crypto),
@@ -198,17 +200,31 @@ describe("AntigravityAdapterV2 client file system", () => {
198200
runtimePolicy,
199201
});
200202
yield* session.ensureThread({ threadId, modelSelection, runtimePolicy });
201-
if (readTextFile === undefined || writeTextFile === undefined) {
202-
return yield* Effect.die("Antigravity sessions must serve client file requests");
203+
const initialize = (yield* fileSystem.readFileString(requestLog))
204+
.trim()
205+
.split("\n")
206+
.map(
207+
(line) =>
208+
JSON.parse(line) as {
209+
method?: string;
210+
params?: { clientCapabilities?: { fs?: unknown }; clientInfo?: { name?: string } };
211+
},
212+
)
213+
.find((request) => request.method === "initialize");
214+
assert.deepEqual(initialize?.params?.clientCapabilities?.fs, {
215+
readTextFile: true,
216+
writeTextFile: false,
217+
});
218+
assert.equal(initialize?.params?.clientInfo?.name, "zed");
219+
assert.isUndefined(writeTextFile);
220+
if (readTextFile === undefined) {
221+
return yield* Effect.die("Antigravity sessions must serve client file reads");
203222
}
204223
const context = (method: string) => ({ requestId: `test-${method}`, method });
205224

206225
const insidePath = path.join(workspace, "src", "inside.ts");
207-
yield* writeTextFile(
208-
{ sessionId: "mock-session-1", path: insidePath, content: "inside" },
209-
context("fs/write_text_file"),
210-
);
211-
assert.equal(yield* fileSystem.readFileString(insidePath), "inside");
226+
yield* fileSystem.makeDirectory(path.dirname(insidePath), { recursive: true });
227+
yield* fileSystem.writeFileString(insidePath, "inside");
212228
const pasted = yield* readTextFile(
213229
{ sessionId: "mock-session-1", path: attachment },
214230
context("fs/read_text_file"),
@@ -220,59 +236,13 @@ describe("AntigravityAdapterV2 client file system", () => {
220236
context("fs/read_text_file"),
221237
).pipe(Effect.exit);
222238
assert.isTrue(Exit.isFailure(outsideRead));
223-
const outsideWrite = yield* writeTextFile(
224-
{ sessionId: "mock-session-1", path: path.join(outside, "planted.txt"), content: "x" },
225-
context("fs/write_text_file"),
226-
).pipe(Effect.exit);
227-
assert.isTrue(Exit.isFailure(outsideWrite));
228-
assert.isFalse(yield* fileSystem.exists(path.join(outside, "planted.txt")));
229-
230239
const linkPath = path.join(workspace, "linked-secret.txt");
231240
yield* fileSystem.symlink(outsideFile, linkPath);
232241
const linkedRead = yield* readTextFile(
233242
{ sessionId: "mock-session-1", path: linkPath },
234243
context("fs/read_text_file"),
235244
).pipe(Effect.exit);
236245
assert.isTrue(Exit.isFailure(linkedRead), "a read through an escaping symlink is denied");
237-
const linkedWrite = yield* writeTextFile(
238-
{ sessionId: "mock-session-1", path: linkPath, content: "overwritten" },
239-
context("fs/write_text_file"),
240-
).pipe(Effect.exit);
241-
assert.isTrue(Exit.isFailure(linkedWrite), "a write through an escaping symlink is denied");
242-
assert.equal(yield* fileSystem.readFileString(outsideFile), "secret");
243-
const plantedTarget = path.join(outside, "created-through-link.txt");
244-
const danglingLink = path.join(workspace, "dangling.txt");
245-
yield* fileSystem.symlink(plantedTarget, danglingLink);
246-
const danglingWrite = yield* writeTextFile(
247-
{ sessionId: "mock-session-1", path: danglingLink, content: "planted" },
248-
context("fs/write_text_file"),
249-
).pipe(Effect.exit);
250-
assert.isTrue(Exit.isFailure(danglingWrite), "a write through a dangling symlink is denied");
251-
assert.isFalse(yield* fileSystem.exists(plantedTarget));
252-
yield* fileSystem.symlink(outside, path.join(workspace, "linked-dir"));
253-
const linkedDirWrite = yield* writeTextFile(
254-
{
255-
sessionId: "mock-session-1",
256-
path: path.join(workspace, "linked-dir", "new.txt"),
257-
content: "planted",
258-
},
259-
context("fs/write_text_file"),
260-
).pipe(Effect.exit);
261-
assert.isTrue(Exit.isFailure(linkedDirWrite), "a write under an escaping directory link");
262-
assert.isFalse(yield* fileSystem.exists(path.join(outside, "new.txt")));
263-
const nestedLinkedDirWrite = yield* writeTextFile(
264-
{
265-
sessionId: "mock-session-1",
266-
path: path.join(workspace, "linked-dir", "a", "b", "file.txt"),
267-
content: "planted",
268-
},
269-
context("fs/write_text_file"),
270-
).pipe(Effect.exit);
271-
assert.isTrue(
272-
Exit.isFailure(nestedLinkedDirWrite),
273-
"a write to missing directories under an escaping directory link",
274-
);
275-
assert.isFalse(yield* fileSystem.exists(path.join(outside, "a")));
276246
const insideLink = path.join(workspace, "inside-link.ts");
277247
yield* fileSystem.symlink(insidePath, insideLink);
278248
const viaInsideLink = yield* readTextFile(

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import {
2323
buildAntigravityPrompt,
2424
type AntigravityAcpRuntimeInput,
2525
} from "../../provider/acp/AntigravityAcpSupport.ts";
26-
import {
27-
readAntigravityClientTextFile,
28-
writeAntigravityClientTextFile,
29-
} from "../../provider/acp/AntigravityClientFiles.ts";
26+
import { readAntigravityClientTextFile } from "../../provider/acp/AntigravityClientFiles.ts";
3027
import {
3128
antigravityApprovalOptions,
3229
antigravitySubagentOutput,
@@ -82,7 +79,7 @@ export interface AntigravityAdapterV2Options {
8279
readonly continuationRequests?: Parameters<typeof makeAcpAdapterV2>[0]["continuationRequests"];
8380
}
8481

85-
/** ACP 1.1.1 reports `start_subagent` tools without child session ids. */
82+
/** Native subagent tools report no child session ids. */
8683
const extractAntigravitySubagentUpdate: NonNullable<AcpAdapterV2Flavor["extractSubagentUpdate"]> = (
8784
toolCall,
8885
) => {
@@ -126,7 +123,7 @@ export function makeAntigravityAcpAdapterFlavor(
126123
Scope.close(scope, Exit.void),
127124
options.makeRuntime({
128125
...input,
129-
clientFileSystem: true,
126+
clientFileReads: true,
130127
additionalDirectories: [options.host.paths.attachmentsDir],
131128
}),
132129
)
@@ -191,13 +188,6 @@ export function makeAntigravityAcpAdapterFlavor(
191188
allowedRoots: antigravityClientFileRoots(cwd),
192189
request,
193190
}),
194-
writeTextFile: (request, cwd) =>
195-
writeAntigravityClientTextFile({
196-
fileSystem: options.fileSystem,
197-
path: options.path,
198-
allowedRoots: antigravityClientFileRoots(cwd),
199-
request,
200-
}),
201191
},
202192
approvalOptions: antigravityApprovalOptions,
203193
extractPermissionQuestion: (request) => {

‎apps/server/src/provider/AntigravityInstallation.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
398398
}),
399399
)
400400
: spawner,
401-
clientInfo: { name: "t3-code", version: "0.0.0" },
402401
});
403402
const initialized = yield* runtime.initialize();
404403
if (

‎apps/server/src/provider/AntigravityProvider.test.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,50 @@ describe("Antigravity model catalog", () => {
214214
"gemini-pro-agent",
215215
);
216216
});
217+
218+
it("offers each model the thinking levels it reported when selected", () => {
219+
const thinking = (currentValue: string) =>
220+
({
221+
id: "thinking_level",
222+
name: "Thinking Level",
223+
category: "thought_level",
224+
type: "select",
225+
currentValue,
226+
options: [
227+
{ value: "low", name: "Low" },
228+
{ value: "high", name: "High" },
229+
],
230+
}) satisfies EffectAcpSchema.SessionConfigOption;
231+
const models = buildAntigravityModelsFromSession(
232+
{
233+
configOptions: [
234+
{
235+
...modelConfig,
236+
currentValue: "gemini",
237+
options: [
238+
{ value: "gemini", name: "Gemini" },
239+
{ value: "claude", name: "Claude" },
240+
{ value: "plain", name: "Plain" },
241+
{ value: "unseen", name: "Unseen" },
242+
],
243+
},
244+
thinking("high"),
245+
],
246+
},
247+
new Map([
248+
["claude", thinking("low")],
249+
["plain", null],
250+
]),
251+
);
252+
const thinkingOf = (slug: string) =>
253+
models.find((model) => model.slug === slug)?.capabilities?.optionDescriptors?.[0];
254+
255+
expect(thinkingOf("gemini")).toMatchObject({ id: "thinking_level", currentValue: "high" });
256+
expect(thinkingOf("claude")).toMatchObject({ id: "thinking_level", currentValue: "low" });
257+
expect(thinkingOf("plain")).toBeUndefined();
258+
expect(thinkingOf("unseen")).toMatchObject({ id: "thinking_level" });
259+
expect(thinkingOf("unseen")).not.toHaveProperty("currentValue");
260+
});
217261
});
218262

219263
it.layer(layerTest)("Antigravity provider snapshots", (it) => {

‎apps/server/src/provider/AntigravityProvider.ts‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type * as EffectAcpErrors from "effect-acp/errors";
2020
import type * as EffectAcpSchema from "effect-acp/compat";
2121

2222
import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
23+
import { acpProviderOptionDescriptors } from "@t3tools/provider-acp/server/sessionConfig";
2324
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
2425
import {
2526
makeManualOnlyProviderMaintenanceCapabilities,
@@ -32,6 +33,8 @@ import {
3233
} from "@t3tools/provider-core/server/snapshotProbe";
3334
import { resolveUsageLimitsAfterProbe } from "@t3tools/provider-core/server/usageLimits";
3435

36+
import { antigravityThinkingConfig } from "./acp/AntigravityAcpSupport.ts";
37+
3538
const EMPTY_MODEL_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] });
3639
const MAX_WORKSPACE_SNAPSHOTS = 32;
3740
const HEALTH_CHECK_TIMEOUT = "90 seconds";
@@ -44,8 +47,24 @@ type SessionSetupResult = Pick<
4447
"configOptions" | "models"
4548
>;
4649

50+
type ThinkingConfig = NonNullable<ReturnType<typeof antigravityThinkingConfig>>;
51+
52+
/** Thinking options each model reported when selected; `null` means it has none. */
53+
export type AntigravityThinkingLevels = ReadonlyMap<string, ThinkingConfig | null>;
54+
55+
function thinkingCapabilities(config: ThinkingConfig | null | undefined, observed: boolean) {
56+
const descriptor = config
57+
? acpProviderOptionDescriptors({ configOptions: [config], modeState: undefined })[0]
58+
: undefined;
59+
if (descriptor?.type !== "select") return EMPTY_MODEL_CAPABILITIES;
60+
// Another model's selected level is not this model's default.
61+
const { currentValue: _currentValue, ...unobserved } = descriptor;
62+
return createModelCapabilities({ optionDescriptors: [observed ? descriptor : unobserved] });
63+
}
64+
4765
export function buildAntigravityModelsFromSession(
4866
setup: SessionSetupResult,
67+
thinkingLevels: AntigravityThinkingLevels = new Map(),
4968
): ReadonlyArray<ServerProviderModel> {
5069
const config = setup.configOptions?.find(
5170
(option) => option.id === "model" || option.category === "model",
@@ -61,10 +80,13 @@ export function buildAntigravityModelsFromSession(
6180
name: model.name,
6281
})) ?? [])
6382
: [];
83+
const currentThinking = antigravityThinkingConfig(setup.configOptions);
6484
const seen = new Set<string>();
6585
return entries.flatMap((entry): ServerProviderModel[] => {
6686
if (!entry.value.trim() || seen.has(entry.value)) return [];
6787
seen.add(entry.value);
88+
const observed =
89+
entry.value === currentValue ? (currentThinking ?? null) : thinkingLevels.get(entry.value);
6890
return [
6991
{
7092
slug: entry.value,
@@ -73,7 +95,10 @@ export function buildAntigravityModelsFromSession(
7395
...(entry.value === currentValue
7496
? { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] }
7597
: {}),
76-
capabilities: EMPTY_MODEL_CAPABILITIES,
98+
capabilities:
99+
observed === undefined
100+
? thinkingCapabilities(currentThinking, false)
101+
: thinkingCapabilities(observed, true),
77102
},
78103
];
79104
});
@@ -162,6 +187,17 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
162187
});
163188
// Preserve disk-discovered skills when callbacks replace workspace commands; the registry will not rescan them.
164189
const discoveredSkills = new Map<string, ServerProvider["skills"]>();
190+
const thinkingLevels = new Map<string, ThinkingConfig | null>();
191+
const observeThinkingLevels = (
192+
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption> | null | undefined,
193+
) => {
194+
const model = configOptions?.find(
195+
(option) => option.id === "model" || option.category === "model",
196+
);
197+
if (model?.type === "select" && model.currentValue) {
198+
thinkingLevels.set(model.currentValue, antigravityThinkingConfig(configOptions) ?? null);
199+
}
200+
};
165201
const getSnapshot = SubscriptionRef.get(metadata).pipe(
166202
Effect.flatMap((state) => options.stampIdentity(state.draft)),
167203
);
@@ -267,6 +303,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
267303
cwd?: string,
268304
) {
269305
if (!settings.enabled) return;
306+
observeThinkingLevels(started.sessionSetupResult.configOptions);
270307
const before = yield* SubscriptionRef.get(metadata);
271308
const supportsTextGeneration = yield* options.supportsTextGeneration;
272309
const usageLimits =
@@ -301,7 +338,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
301338
published: draft.usageLimits,
302339
probed: usageLimits ?? draft.usageLimits,
303340
}),
304-
models: buildAntigravityModelsFromSession(started.sessionSetupResult),
341+
models: buildAntigravityModelsFromSession(started.sessionSetupResult, thinkingLevels),
305342
supportsTextGeneration,
306343
...(cwd
307344
? {
@@ -324,7 +361,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
324361
const onConfigOptionsUpdated = Effect.fn("AntigravityProvider.onConfigOptionsUpdated")(function* (
325362
configOptions: ReadonlyArray<EffectAcpSchema.SessionConfigOption>,
326363
) {
327-
const models = buildAntigravityModelsFromSession({ configOptions });
364+
observeThinkingLevels(configOptions);
365+
const models = buildAntigravityModelsFromSession({ configOptions }, thinkingLevels);
328366
yield* SubscriptionRef.update(metadata, (state) => {
329367
if (state.draft.auth.status !== "authenticated") return state;
330368
return { ...state, draft: { ...state.draft, models } };
@@ -391,6 +429,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
391429
}) satisfies AntigravityProviderState,
392430
);
393431
discoveredSkills.clear();
432+
thinkingLevels.clear();
394433
});
395434

396435
const snapshotForCwd = Effect.fn("AntigravityProvider.snapshotForCwd")(function* (

0 commit comments

Comments
 (0)