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
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,24 @@ describe("Antigravity CLI runtime", () => {
const path = yield* Path.Path;
const input = { profileDirectory: "/profile", userHome: "/home/user", path };
const profileArgs = ["acp", "--gemini-dir", "/profile", "--app-data-dir", "antigravity-acp"];
const spawn = { command: "agy", args: profileArgs, cwd: "/project" };
for (const [found, managedVersionDirectory, runtime, args] of [
["the user's own", null, "cli", ["acp"]],
["a managed release", "/managed/versions/release", "managed", profileArgs],
// Upstream marks a Google sign-in as an SSH session, so the CLI keeps it in a file.
const profileEnv = { GEMINI_HOME: "/profile", SSH_CONNECTION: "127.0.0.1 0 127.0.0.1 0" };
const spawn = { command: "agy", args: profileArgs, cwd: "/project", env: profileEnv };
for (const [found, managedVersionDirectory, runtime, args, env] of [
["the user's own", null, "cli", ["acp"], { GEMINI_HOME: "/profile" }],
["a managed release", "/managed/versions/release", "managed", profileArgs, profileEnv],
] as const) {
const executable = { managedVersionDirectory };
assert.equal(antigravityRuntimeState(executable, input).runtime, runtime, found);
assert.deepEqual(withUserAgyState(executable, spawn).args, args, found);
assert.deepEqual(withUserAgyState(executable, spawn, {}).args, args, found);
assert.deepEqual(withUserAgyState(executable, spawn, {}).env, env, found);
}
const sshEnv = { SSH_CONNECTION: "10.0.0.1 50000 10.0.0.2 22" };
assert.deepEqual(
withUserAgyState({ managedVersionDirectory: null }, spawn, sshEnv).env,
{ GEMINI_HOME: "/profile", ...sshEnv },
"the user's own SSH session stays",
);
}).pipe(Effect.provide(NodeServices.layer)),
);

Expand Down Expand Up @@ -444,11 +453,12 @@ describe("Antigravity CLI runtime", () => {
}),
);
let runtime: "cli" | "managed" = "cli";
let keyring: string | undefined;
const { probe } = yield* makeAntigravityRuntimeUsageProbe({
profileDirectory,
userHome,
authMethod: "oauth-personal",
readKeyringSecret: Effect.undefined,
readKeyringSecret: Effect.sync(() => keyring),
runtimeState: Effect.sync(() =>
runtime === "cli"
? antigravityRuntimeState(
Expand Down Expand Up @@ -481,6 +491,17 @@ describe("Antigravity CLI runtime", () => {
JSON.stringify([cli, managed]),
/cli-access|cli-refresh|profile-access|profile-refresh|profile-secret/,
);

// The user's own CLI may keep its Google sign-in only in the system keyring.
yield* fileSystem.remove(path.join(cliApp, "antigravity-oauth-token"));
keyring = JSON.stringify({
token: { access_token: "keyring-access", expiry: "1970-01-01T01:00:00.123456789Z" },
});
runtime = "cli";
requests.length = 0;
const fromKeyring = yield* probe;
assert.isUndefined(fromKeyring.unavailable);
assert.isTrue(requests.some((request) => request.bearer === "Bearer keyring-access"));
}).pipe(Effect.scoped, Effect.provide(layer)),
);
});
47 changes: 24 additions & 23 deletions apps/server/src/fork/antigravityCliRuntime/antigravityCliRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,32 @@ export function antigravityRuntimeState(

const PROFILE_FLAGS = new Set(["--gemini-dir", "--app-data-dir"]);

/** Upstream points every `agy` at T3's profile; the user's own `agy` keeps its own login and state. */
/**
* Upstream points every `agy` at T3's profile, and marks a Google sign-in as an SSH session so the
* CLI keeps it in that profile; the user's own `agy` keeps its own login, keyring and state.
*/
export const withUserAgyState = (
executable: Pick<AntigravityExecutable, "managedVersionDirectory">,
spawn: AcpSessionRuntime.AcpSpawnInput,
): AcpSessionRuntime.AcpSpawnInput =>
isUserAgy(executable)
? {
...spawn,
args: spawn.args.filter(
(arg, index) =>
!PROFILE_FLAGS.has(arg) && !PROFILE_FLAGS.has(spawn.args[index - 1] ?? ""),
),
}
: spawn;
baseEnv: NodeJS.ProcessEnv,
): AcpSessionRuntime.AcpSpawnInput => {
if (!isUserAgy(executable)) return spawn;
const { SSH_CONNECTION: _profileSsh, ...env } = spawn.env ?? {};
return {
...spawn,
args: spawn.args.filter(
(arg, index) => !PROFILE_FLAGS.has(arg) && !PROFILE_FLAGS.has(spawn.args[index - 1] ?? ""),
),
...(spawn.env === undefined
? {}
: {
env:
baseEnv.SSH_CONNECTION === undefined
? env
: { ...env, SSH_CONNECTION: baseEnv.SSH_CONNECTION },
}),
};
};

/** The state a caller was given, or the managed profile's when it was given none. */
export const antigravityRuntimeStateOf = (options: {
Expand All @@ -88,7 +100,7 @@ const antigravityTokenPath = (state: AntigravityRuntimeState, path: Path.Path) =
*/
export const makeAntigravityRuntimeUsageProbe = Effect.fn("makeAntigravityRuntimeUsageProbe")(
function* (
input: Parameters<typeof makeAntigravityUsageProbe>[0] & {
input: Omit<Parameters<typeof makeAntigravityUsageProbe>[0], "appDirectory"> & {
readonly userHome: string;
readonly runtimeState: Effect.Effect<AntigravityRuntimeState>;
},
Expand Down Expand Up @@ -142,17 +154,6 @@ export const readAntigravityAccount = Effect.fn("AntigravityAdapterV2.readAccoun
return Option.map(digest, Hex.encode);
});

// google.rpc.Code names. The CLI's error step is length-prefixed, so a length byte that may be
// a capital letter leads the status; only a known name finds where the status starts.
const CLI_API_ERROR =
/(CANCELLED|UNKNOWN|INVALID_ARGUMENT|DEADLINE_EXCEEDED|NOT_FOUND|ALREADY_EXISTS|PERMISSION_DENIED|RESOURCE_EXHAUSTED|FAILED_PRECONDITION|ABORTED|OUT_OF_RANGE|UNIMPLEMENTED|INTERNAL|UNAVAILABLE|DATA_LOSS|UNAUTHENTICATED) \(code (\d{3})\): ([^\p{Cc}]+)/u;

/** The CLI's `STATUS (code NNN): message`, in the managed pattern's group order: code, message, status. */
export function antigravityCliApiError(text: string) {
const match = CLI_API_ERROR.exec(text);
return match === null ? null : ([match[0], match[2], match[3], match[1]] as const);
}

const isNativeSessionId = Schema.is(Schema.String.check(Schema.isUUID(4)));

/** The length-delimited fields of one protobuf message, or none when the bytes are not one. */
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/fork/claudeUsageSource/claudeHub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function fixture(options: {
if (path.endsWith("/auth-files")) {
return HttpClientResponse.fromWeb(request, Response.json({ files: options.accounts }));
}
// A hub without upstream's per-account model list.
if (path.endsWith("/auth-files/models")) {
return HttpClientResponse.fromWeb(request, new Response(null, { status: 404 }));
}
if (path.endsWith("/reset-quota")) {
return HttpClientResponse.fromWeb(request, Response.json({}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ const startClaudeTurn = Effect.fn("startClaudeTurn")(function* (
mcpServerStatus: Effect.succeed([]),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
callMcpTool: () => Effect.die("unexpected MCP tool call"),
mcpAuthenticate: () => Effect.die("unexpected MCP sign-in"),
mcpSubmitOAuthCallbackUrl: () => Effect.die("unexpected MCP sign-in"),
reconnectMcpServer: () => Effect.die("unexpected MCP reconnect"),
listPermissionRules: Effect.die("unexpected permission rules read"),
stopTask: () => Effect.void,
interrupt: Effect.void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as PubSub from "effect/PubSub";
import * as Ref from "effect/Ref";
import type * as Schema from "effect/Schema";
import * as SqlClient from "effect/sql/SqlClient";
import * as Stream from "effect/Stream";

Expand All @@ -38,6 +39,7 @@ import {
CLAUDE_MODEL_SELECTION,
CODEX_MODEL_SELECTION,
} from "../../orchestration-v2/testkit/fixtures/shared.ts";
import { outputInstructions } from "../../orchestration-v2/runOutput.ts";
import * as ProviderReplayHarness from "../../orchestration-v2/testkit/ProviderReplayHarness.ts";
import * as SqlitePersistence from "../../persistence/Sqlite.ts";
import * as ServerSettings from "../../serverSettings.ts";
Expand Down Expand Up @@ -219,6 +221,7 @@ const notesPerAttempt = (
ordinal: number,
selection?: ModelSelection,
text?: string,
outputSchema?: Readonly<Record<string, Schema.Json>>,
) => Effect.Effect<void>;
readonly failResume: Ref.Ref<boolean>;
readonly failStart: Ref.Ref<boolean>;
Expand Down Expand Up @@ -297,6 +300,7 @@ const notesPerAttempt = (
ordinal: number,
selection: ModelSelection = CLAUDE_MODEL_SELECTION,
text = `Request ${ordinal}`,
outputSchema?: Readonly<Record<string, Schema.Json>>,
) {
const providerSessionId = (yield* orchestrator.getThreadProjection(
threadId,
Expand All @@ -321,6 +325,7 @@ const notesPerAttempt = (
attachments: [],
modelSelection: selection,
dispatchMode: { type: "start_immediately" },
...(outputSchema === undefined ? {} : { outputSchema }),
});
yield* orchestrator.streamStoredEvents.pipe(
Stream.filter(
Expand Down Expand Up @@ -465,16 +470,26 @@ const notesPerAttempt = (
describe("display mode note at turn start", () => {
it.live("goes once on the first message, and again after a failed native resume", () =>
Effect.gen(function* () {
const notes = yield* notesPerAttempt("display-wrap-resume", ({ send, failResume }) =>
Effect.gen(function* () {
yield* send(1);
yield* send(2);
yield* Ref.set(failResume, true);
yield* send(3);
yield* send(4);
}),
const outputSchema = { type: "object" };
const rewrapped = yield* Ref.make("");
const notes = yield* notesPerAttempt(
"display-wrap-resume",
({ send, failResume, lastAttempt }) =>
Effect.gen(function* () {
yield* send(1);
yield* send(2);
yield* Ref.set(failResume, true);
yield* send(3, undefined, undefined, outputSchema);
yield* Ref.set(rewrapped, yield* lastAttempt);
yield* send(4);
}),
);
assert.deepEqual(notes, [true, false, true, false]);
// The re-wrapped prompt keeps one copy of the output instructions, after the user's words.
const text = yield* Ref.get(rewrapped);
const instructions = outputInstructions(outputSchema);
assert.strictEqual(text.split(instructions).length, 2);
assert.isTrue(text.endsWith(`Request 3\n\n${instructions}`));
}),
);

Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/fork/generalRoleParity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ const claude: ProviderFixture = {
mcpServerStatus: Effect.succeed([]),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
callMcpTool: () => Effect.die("unexpected MCP tool call"),
mcpAuthenticate: () => Effect.die("unexpected MCP sign-in"),
mcpSubmitOAuthCallbackUrl: () => Effect.die("unexpected MCP sign-in"),
reconnectMcpServer: () => Effect.die("unexpected MCP reconnect"),
listPermissionRules: Effect.die("unexpected permission rules read"),
stopTask: () => Effect.void,
interrupt: Effect.void,
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/fork/hostFiles/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HttpRouter } from "effect/http";

import * as AssetSigner from "../../assets/AssetSigner.ts";
import * as NativeAppIconResolver from "../../assets/NativeAppIconResolver.ts";
import * as WorkspacePreviewRevisions from "../../assets/WorkspacePreviewRevisions.ts";
import * as EnvironmentAuth from "../../auth/EnvironmentAuth.ts";
import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
import * as ServerConfig from "../../config.ts";
Expand Down Expand Up @@ -60,6 +61,7 @@ const layerUnusedAssetServices = Layer.mergeAll(
Layer.mock(RepositoryIdentityResolver.RepositoryIdentityResolver)({}),
Layer.succeed(BuiltInDrivers.SourceControlDrivers, []),
Layer.mock(WorkspacePaths.WorkspacePaths)({}),
Layer.mock(WorkspacePreviewRevisions.WorkspacePreviewRevisions)({}),
);

const layerTest = ServerConfig.layerTest(process.cwd(), { prefix: "t3-host-files-http-" }).pipe(
Expand Down
18 changes: 9 additions & 9 deletions apps/server/src/fork/previewChrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import type { PreviewBrowserRelease } from "../preview/PreviewBrowser.ts";
// macOS keeps the shell: the Chrome app bundle holds symlinks the installer will not unpack.
// Pin from each chrome zip in known-good-versions-with-downloads.json, at PreviewBrowser.VERSION:
// the browser's --user-agent names that version in both modes.
const VERSION = "157.0.8103.78";
const VERSION = "158.0.8127.36";
const ARCHIVES: Partial<Record<string, { readonly bytes: number; readonly sha256: string }>> = {
linux64: {
bytes: 203_266_906,
sha256: "9223832977a13db3646201b1341c1f9cf08afa3ceae92540116d7b0c062364fb",
bytes: 208_062_943,
sha256: "dba9cc838e1ce269c33ea68170881127bd15d078fc3ca5891c90802819a4d7c7",
},
"linux-arm64": {
bytes: 203_144_198,
sha256: "f354d666822a11d8fe99e923c44be77dd226fab2750c5b5947e6318818bf10f1",
bytes: 205_790_900,
sha256: "f811b64a50cbc73f94fda7b3f3b3bf62be5d9409b3207e6ead9b61e6706afffe",
},
win32: {
bytes: 190_974_375,
sha256: "313261468c4b205198778b112c9ac6e44dff0ff501085b0f9336d7feae2b3715",
bytes: 196_218_437,
sha256: "427a02beb8887ceca6a1847dc67445580741c8c40bd15af334993d3a59863943",
},
win64: {
bytes: 209_854_321,
sha256: "5f6ec40206407112702e163bf694d07f9fdc8ccbd346c70ce61fa62f716493f9",
bytes: 214_927_656,
sha256: "6a8ad290952cc612c7777ffb3eb62f345539a2a1a8d440cfac190c6d36b34d2c",
},
};

Expand Down
3 changes: 0 additions & 3 deletions apps/server/src/git/GitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,7 @@ export const make = Effect.gen(function* () {
}
return result;
});
<<<<<<< origin/main
const hostPlatform = yield* HostProcess.Platform;
=======
const createPrNeedsPush = Effect.fn("GitManager.createPrNeedsPush")(function* (
cwd: string,
status: {
Expand All @@ -870,7 +868,6 @@ export const make = Effect.gen(function* () {
.pipe(Effect.orElseSucceed(() => null));
return target?.viaPushRemote === true;
});
>>>>>>> upstream/main
const readWorktreeCreationSettings = serverSettingsService.getSettings.pipe(
Effect.map((settings) => ({
worktreesDirectory: settings.worktreesDirectory,
Expand Down
21 changes: 4 additions & 17 deletions apps/server/src/orchestration-v2/ProviderTurnStartService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,40 +992,27 @@ export const layer: Layer.Layer<
});
let effectiveHandoffs = handoffs;
let resumeFellBack = false;
<<<<<<< origin/main
const wrapInput = {
threadId: run.threadId,
message: providerMessage,
text: withMessageSenderNote(
providerMessage,
projectComposerContextForProvider({
text: providerMessage.text,
records: providerMessage.context?.records ?? [],
}),
),
};
let wrapped = yield* displayModeWrap.wrapUserText(wrapInput);
let userText = wrapped.text;
=======
const messageText = withMessageSenderNote(
providerMessage,
projectComposerContextForProvider({
text: providerMessage.text,
records: providerMessage.context?.records ?? [],
}),
);
>>>>>>> upstream/main
// Native goal commands go verbatim; handoff history waits a turn.
const goalDriver =
session.driver === "codex" ||
session.driver === "claudeAgent" ||
session.providerSession.capabilities.turns.supportsNativeGoals === true;
const goalCommand = goalDriver && parseGoalCommand(providerMessage) !== null;
// Part of the user text, so every way a turn starts carries it, after the user's own words.
const userText =
const unwrappedText =
run.outputSchema === undefined || goalCommand || isProviderCommand(providerMessage)
? messageText
: `${messageText}\n\n${outputInstructions(run.outputSchema)}`;
const wrapInput = { threadId: run.threadId, message: providerMessage, text: unwrappedText };
let wrapped = yield* displayModeWrap.wrapUserText(wrapInput);
let userText = wrapped.text;
// The provider turn marks cancellation work delivered; restart continuations use their own text or resume natively.
const noteContinuation = isRestartNoteContinuation(
run,
Expand Down
Loading
Loading