Open History to see the last commit
1import * as NodeCrypto from "node:crypto";
2// @effect-diagnostics-next-line nodeBuiltinImport:off - Effect's symlink has no type argument, and Windows needs a junction to link without elevation.
3import * as NodeFSP from "node:fs/promises";
4// @effect-diagnostics-next-line nodeBuiltinImport:off - resolveAntigravityProfileDirectory is a pure sync helper, so it cannot use the Path service.
5import * as NodePath from "node:path";
6
7import type { AntigravityAuthMethod, ProviderInstanceId } from "@t3tools/contracts";
8import { HostProcessExecutablePath, HostProcessPlatform } from "@t3tools/shared/hostProcess";
9import * as Effect from "effect/Effect";
10import * as FileSystem from "effect/FileSystem";
11import * as Path from "effect/Path";
12import type * as PlatformError from "effect/PlatformError";
13import * as Schema from "effect/Schema";
14import * as Stream from "effect/Stream";
15import * as ChildProcess from "effect/unstable/process/ChildProcess";
16import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
17import * as AcpErrors from "effect-acp/errors";
18
19import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts";
20import type { AcpSpawnInput } from "./acp/AcpSessionRuntime.ts";
21import {
22 antigravityUserSkillDirectories,
23 resolveAntigravityUserHome,
24} from "./Drivers/AntigravitySkills.ts";
25
26export const ANTIGRAVITY_AUTH_STDOUT_PREFIX =
27 "Open the following link to authenticate the ACP server: ";
28export const ANTIGRAVITY_AUTH_BROWSER_MARKER = "__T3_ANTIGRAVITY_AUTH_URL__";
29export const ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE =
30 "Sign in to Antigravity in Settings before you continue.";
31
32const maxAuthorizationUrlLength = 16_384;
33const maxBrowserHelperLineLength =
34 Math.max(ANTIGRAVITY_AUTH_BROWSER_MARKER.length, ANTIGRAVITY_AUTH_STDOUT_PREFIX.length) +
35 maxAuthorizationUrlLength +
36 2;
37const maxStdoutLineBytes = 16 * 1024 * 1024;
38const authPrefixBytes = new TextEncoder().encode(ANTIGRAVITY_AUTH_STDOUT_PREFIX);
39const decodeUrl = Schema.decodeUnknownEffect(Schema.URLFromString);
40const decodeBrowserHelperUrl = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.String));
41const ProfileSettingsFile = Schema.Struct({
42 auth: Schema.Struct({ type: Schema.String }),
43 gcp: Schema.optional(
44 Schema.Struct({
45 project: Schema.optional(Schema.String),
46 location: Schema.optional(Schema.String),
47 }),
48 ),
49});
50const encodeProfileSettings = Schema.encodeSync(Schema.fromJsonString(ProfileSettingsFile));
51const isAcpRequestError = Schema.is(AcpErrors.AcpRequestError);
52const isAcpTransportError = Schema.is(AcpErrors.AcpTransportError);
53
54// Python splits BROWSER on the platform path separator before it parses quotes.
55// Keep this source free of both colons and semicolons. EPIPE must still exit 0
56// so Python does not fall back to an OS browser after cancellation.
57const browserHelperSource =
58 `process.stderr.on("error",()=>process.exit(0)).write(` +
59 `"${ANTIGRAVITY_AUTH_BROWSER_MARKER}"+JSON.stringify(process.argv[1])+"\\n",` +
60 `()=>process.exit(0))`;
61const browserPreflightUrl = "https://example.invalid/t3-antigravity-browser-preflight";
62
63const removedEnvironmentKeys = new Set([
64 "GEMINI_API_KEY",
65 "GOOGLE_API_KEY",
66 "GOOGLE_APPLICATION_CREDENTIALS",
67 "GOOGLE_CLOUD_PROJECT",
68 "GOOGLE_CLOUD_LOCATION",
69 "GOOGLE_CLOUD_QUOTA_PROJECT",
70 "GOOGLE_GENAI_USE_VERTEXAI",
71 "GCLOUD_PROJECT",
72 "CLOUDSDK_CORE_PROJECT",
73 "AGY_ACP_CCPA_PROJECT",
74 "AGY_ACP_ENABLE_OAUTH",
75 "GEMINI_HOME",
76 "AGY_ACP_FORCE_FILE_STORAGE",
77 "ANTIGRAVITY_HARNESS_PATH",
78 "BROWSER",
79 "PYTHONUNBUFFERED",
80 "ELECTRON_RUN_AS_NODE",
81]);
82
83export interface AntigravityProfile {
84 readonly platform: NodeJS.Platform;
85 readonly geminiHome: string;
86 readonly acpDirectory: string;
87 readonly tokenPath: string;
88 /** Parent of the per-process temp directories PyInstaller unpacks into. */
89 readonly tempDirectory: string;
90 readonly browserCommand: string;
91}
92
93/**
94 * Credentials for the non-personal ACP auth methods. The agent reads the API
95 * key from its environment and the GCP project and location from
96 * `settings.json` in the profile. Empty strings mean "not set".
97 */
98export interface AntigravityAuthConfig {
99 readonly authMethod: AntigravityAuthMethod;
100 readonly apiKey: string;
101 readonly gcpProject: string;
102 readonly gcpLocation: string;
103}
104
105export const ANTIGRAVITY_PERSONAL_AUTH: AntigravityAuthConfig = {
106 authMethod: "oauth-personal",
107 apiKey: "",
108 gcpProject: "",
109 gcpLocation: "",
110};
111
112/** True for the two methods that open a Google sign-in page. */
113export function antigravityAuthUsesBrowser(authMethod: AntigravityAuthMethod): boolean {
114 return authMethod === "oauth-personal" || authMethod === "oauth-business";
115}
116
117/** Label shown on the provider card once the method has authenticated. */
118export function antigravityAuthLabel(authMethod: AntigravityAuthMethod): string {
119 switch (authMethod) {
120 case "oauth-personal":
121 return "Google account";
122 case "oauth-business":
123 return "Gemini Enterprise";
124 case "gemini-api-key":
125 return "Gemini API key";
126 case "agent-platform":
127 return "Agent Platform";
128 }
129}
130
131/**
132 * Explains what is missing before a non-personal method can authenticate, or
133 * null when the config is complete. Personal sign-in never needs config.
134 */
135export function antigravityAuthConfigIssue(auth: AntigravityAuthConfig): string | null {
136 switch (auth.authMethod) {
137 case "oauth-personal":
138 return null;
139 case "oauth-business":
140 return auth.gcpProject && auth.gcpLocation
141 ? null
142 : "Gemini Enterprise needs a GCP project and location in the Antigravity provider settings.";
143 case "gemini-api-key":
144 return auth.apiKey ? null : "Enter a Gemini API key in the Antigravity provider settings.";
145 case "agent-platform":
146 return auth.apiKey || (auth.gcpProject && auth.gcpLocation)
147 ? null
148 : "Agent Platform needs an API key, or a GCP project and location, in the Antigravity provider settings.";
149 }
150}
151
152/**
153 * `settings.json` content for the agent's profile. `auth.type` names the
154 * selected method so a native logout clears only that method's credentials
155 * instead of every stored token. The GCP block feeds Enterprise and Agent
156 * Platform. Never holds a credential.
157 */
158export function antigravityProfileSettings(auth: AntigravityAuthConfig): string {
159 const gcp = {
160 ...(auth.gcpProject ? { project: auth.gcpProject } : {}),
161 ...(auth.gcpLocation ? { location: auth.gcpLocation } : {}),
162 };
163 return `${encodeProfileSettings({
164 auth: { type: auth.authMethod },
165 ...(Object.keys(gcp).length > 0 ? { gcp } : {}),
166 })}\n`;
167}
168
169export interface AntigravityAuthorizationUrl {
170 readonly authorizationUrl: string;
171 readonly redirectUri: string;
172 readonly state: string;
173}
174
175function authSupportError(detail: string) {
176 return new AcpErrors.AcpTransportError({ detail, cause: undefined });
177}
178
179/** Recognizes native auth failures and interactive login blocked by T3. */
180export function isAntigravitySignInRequiredError(error: unknown): boolean {
181 return (
182 (isAcpRequestError(error) && error.code === -32000) ||
183 (isAcpTransportError(error) && error.detail === ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE)
184 );
185}
186
187/** Keeps case-sensitive instance IDs separate on case-insensitive filesystems. */
188export function resolveAntigravityProfileDirectory(
189 stateDir: string,
190 instanceId: ProviderInstanceId,
191): string {
192 const directoryName = NodeCrypto.createHash("sha256").update(instanceId).digest("hex");
193 return NodePath.join(stateDir, "providers", "antigravity", directoryName);
194}
195
196/** Parent of the per-process runtime temp directories inside a profile. */
197export function resolveAntigravityRuntimeTempDirectory(profileDirectory: string): string {
198 return NodePath.join(profileDirectory, "antigravity-acp", "tmp");
199}
200
201function quoteBrowserArgument(value: string): string {
202 return `'${value.replaceAll("'", `'"'"'`)}'`;
203}
204
205function antigravityEnvironment(
206 profile: AntigravityProfile,
207 baseEnv: NodeJS.ProcessEnv,
208 auth: AntigravityAuthConfig,
209 runtimeTempDirectory?: string,
210) {
211 const environment: NodeJS.ProcessEnv = {};
212 for (const [key, value] of Object.entries(baseEnv)) {
213 // Windows treats environment keys as case-insensitive. Remove aliases too.
214 if (!removedEnvironmentKeys.has(key.toUpperCase())) environment[key] = value;
215 }
216 // Only the configured method's credential reaches the agent. The agent
217 // prefers GOOGLE_API_KEY over the GCP pair for Agent Platform, so the pair
218 // goes through settings.json instead of the environment.
219 const credential =
220 auth.authMethod === "gemini-api-key" && auth.apiKey
221 ? { GEMINI_API_KEY: auth.apiKey }
222 : auth.authMethod === "agent-platform" && auth.apiKey
223 ? { GOOGLE_API_KEY: auth.apiKey }
224 : {};
225 // The agent is a PyInstaller one-file bundle. It unpacks about 1 GB into
226 // the system temp directory per launch and a force kill leaves that behind.
227 // Point it at a T3-owned directory so the driver can reclaim the space.
228 const tempDirectory = runtimeTempDirectory ?? profile.tempDirectory;
229 return {
230 ...environment,
231 ...credential,
232 GEMINI_HOME: profile.geminiHome,
233 AGY_ACP_FORCE_FILE_STORAGE: "1",
234 BROWSER: profile.browserCommand,
235 PYTHONUNBUFFERED: "1",
236 ELECTRON_RUN_AS_NODE: "1",
237 ...(profile.platform === "win32"
238 ? { TEMP: tempDirectory, TMP: tempDirectory }
239 : { TMPDIR: tempDirectory }),
240 };
241}
242
243/**
244 * The agent reads its user-global skills under `GEMINI_HOME`, which T3 points
245 * at the private profile. Link the two skill directories back to the user's
246 * real `~/.gemini` so global skills load, while MCP servers, hooks, and
247 * credentials stay isolated. Best effort: a link that cannot be made only
248 * costs global skills, never the session. A real directory at the link path
249 * is the user's own content and is left alone.
250 */
251const linkAntigravityUserSkills = Effect.fn("linkAntigravityUserSkills")(function* (input: {
252 readonly profileDirectory: string;
253 readonly userHome: string;
254 readonly platform: NodeJS.Platform;
255}): Effect.fn.Return<void, never, FileSystem.FileSystem | Path.Path> {
256 const fs = yield* FileSystem.FileSystem;
257 const path = yield* Path.Path;
258 const links = antigravityUserSkillDirectories(path, input.profileDirectory);
259 const targets = antigravityUserSkillDirectories(path, path.join(input.userHome, ".gemini"));
260 for (const [link, target] of [
261 [links[0], targets[0]],
262 [links[1], targets[1]],
263 ] as const) {
264 yield* Effect.gen(function* () {
265 const existing = yield* fs.readLink(link).pipe(
266 Effect.map((value): string | undefined => path.resolve(path.dirname(link), value)),
267 Effect.catch((error) =>
268 error.reason._tag === "NotFound" ? Effect.succeed(undefined) : Effect.fail(error),
269 ),
270 );
271 if (existing === target) return;
272 if (existing !== undefined) {
273 yield* fs.remove(link);
274 }
275 yield* fs.makeDirectory(path.dirname(link), { recursive: true });
276 yield* Effect.tryPromise(() =>
277 NodeFSP.symlink(target, link, input.platform === "win32" ? "junction" : "dir"),
278 );
279 }).pipe(
280 // A non-symlink at the link path fails `readLink`; anything else is a
281 // filesystem refusal. Both leave the profile usable.
282 Effect.catch((error) =>
283 Effect.logWarning("Antigravity user skills are not linked into the profile.", {
284 link,
285 target,
286 error,
287 }),
288 ),
289 );
290 }
291});
292
293/** Prepares a private profile without reading or copying Google credentials. */
294export const prepareAntigravityProfile = Effect.fn("prepareAntigravityProfile")(function* (input: {
295 readonly profileDirectory: string;
296 readonly baseEnv?: NodeJS.ProcessEnv;
297 readonly runtimeExecutablePath?: string;
298 readonly platform?: NodeJS.Platform;
299 readonly auth?: AntigravityAuthConfig;
300 /** Home the agent expands `~` against. Defaults to the launch environment's. */
301 readonly userHome?: string;
302}) {
303 const auth = input.auth ?? ANTIGRAVITY_PERSONAL_AUTH;
304 const fs = yield* FileSystem.FileSystem;
305 const path = yield* Path.Path;
306 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
307 const platform = input.platform ?? (yield* HostProcessPlatform);
308 const userHome =
309 input.userHome ?? resolveAntigravityUserHome(platform, input.baseEnv ?? process.env);
310 const runtimeExecutablePath = input.runtimeExecutablePath ?? (yield* HostProcessExecutablePath);
311 const helperExecutable =
312 platform === "win32" ? runtimeExecutablePath.replaceAll("\\", "/") : runtimeExecutablePath;
313 const browserArguments = [helperExecutable, "-e", browserHelperSource, "--", "%s"];
314 const browserCommand = browserArguments.map(quoteBrowserArgument).join(" ");
315 if (
316 browserCommand.includes(platform === "win32" ? ";" : ":") ||
317 helperExecutable.includes("\r") ||
318 helperExecutable.includes("\n") ||
319 helperExecutable.includes("\0") ||
320 helperExecutable.includes("%s")
321 ) {
322 return yield* authSupportError(
323 "The T3 runtime path cannot be used to suppress Antigravity browser launches.",
324 );
325 }
326
327 const geminiHome = path.resolve(input.profileDirectory);
328 const acpDirectory = path.join(geminiHome, "antigravity-acp");
329 const tempDirectory = resolveAntigravityRuntimeTempDirectory(geminiHome);
330 const profile: AntigravityProfile = {
331 platform,
332 geminiHome,
333 acpDirectory,
334 tokenPath: path.join(acpDirectory, "acp_token.json"),
335 tempDirectory,
336 browserCommand,
337 };
338 const environment = antigravityEnvironment(profile, input.baseEnv ?? process.env, auth);
339 yield* Effect.gen(function* () {
340 const child = yield* spawner.spawn(
341 ChildProcess.make(helperExecutable, ["-e", browserHelperSource, "--", browserPreflightUrl], {
342 env: environment,
343 extendEnv: false,
344 shell: false,
345 }),
346 );
347 const [stdout, stderr, exitCode] = yield* Effect.all(
348 [
349 collectUint8StreamText({ stream: child.stdout, maxBytes: 4_096 }),
350 collectUint8StreamText({ stream: child.stderr, maxBytes: 4_096 }),
351 child.exitCode,
352 ],
353 { concurrency: "unbounded" },
354 );
355 if (
356 Number(exitCode) !== 0 ||
357 stdout.bytes !== 0 ||
358 stdout.truncated ||
359 stderr.truncated ||
360 stderr.text !== `${ANTIGRAVITY_AUTH_BROWSER_MARKER}"${browserPreflightUrl}"\n`
361 ) {
362 return yield* authSupportError("Antigravity browser suppression could not be verified.");
363 }
364 }).pipe(
365 Effect.scoped,
366 Effect.timeoutOrElse({
367 duration: "5 seconds",
368 orElse: () =>
369 Effect.fail(authSupportError("Antigravity browser suppression verification timed out.")),
370 }),
371 Effect.mapError((error) =>
372 error._tag === "AcpTransportError"
373 ? error
374 : authSupportError("Antigravity browser suppression could not be verified."),
375 ),
376 );
377
378 for (const directory of [geminiHome, acpDirectory, tempDirectory]) {
379 yield* fs
380 .makeDirectory(directory, { recursive: true, mode: 0o700 })
381 .pipe(
382 Effect.mapError(() =>
383 authSupportError("The Antigravity profile directory could not be created."),
384 ),
385 );
386 if (platform !== "win32") {
387 yield* fs
388 .chmod(directory, 0o700)
389 .pipe(
390 Effect.mapError(() =>
391 authSupportError("The Antigravity profile directory permissions could not be set."),
392 ),
393 );
394 }
395 }
396 // Rewriting on every launch keeps a method, project, or location edit in
397 // Settings effective. The agent also records auth.type here after a
398 // sign-in, which matches the value written below.
399 yield* fs
400 .writeFileString(path.join(acpDirectory, "settings.json"), antigravityProfileSettings(auth))
401 .pipe(
402 Effect.mapError(() =>
403 authSupportError("The Antigravity profile settings could not be written."),
404 ),
405 );
406 yield* linkAntigravityUserSkills({ profileDirectory: geminiHome, userHome, platform });
407 return profile;
408});
409
410/** Applies the same subscription-only launch settings to every ACP process. */
411export function buildAntigravityAcpSpawnInput(input: {
412 readonly installation: {
413 readonly executablePath: string;
414 readonly harnessPath: string;
415 };
416 readonly profile: AntigravityProfile;
417 readonly cwd: string;
418 readonly baseEnv?: NodeJS.ProcessEnv;
419 readonly auth?: AntigravityAuthConfig;
420 /** Per-process temp directory. Defaults to the profile's shared temp directory. */
421 readonly runtimeTempDirectory?: string;
422}): AcpSpawnInput {
423 return {
424 command: input.installation.executablePath,
425 args: input.profile.platform === "linux" ? ["--uid="] : [],
426 cwd: input.cwd,
427 env: {
428 ...antigravityEnvironment(
429 input.profile,
430 input.baseEnv ?? process.env,
431 input.auth ?? ANTIGRAVITY_PERSONAL_AUTH,
432 input.runtimeTempDirectory,
433 ),
434 ANTIGRAVITY_HARNESS_PATH: input.installation.harnessPath,
435 },
436 extendEnv: false,
437 };
438}
439
440/** Reads only the public authorization request, never an OAuth token file. */
441export const parseAntigravityAuthorizationUrl = Effect.fn("parseAntigravityAuthorizationUrl")(
442 function* (
443 authorizationUrl: string,
444 ): Effect.fn.Return<AntigravityAuthorizationUrl, AcpErrors.AcpError> {
445 const invalidUrl = () =>
446 authSupportError("Antigravity returned an invalid Google sign-in URL.");
447 if (authorizationUrl.length > maxAuthorizationUrlLength || /\s/.test(authorizationUrl)) {
448 return yield* invalidUrl();
449 }
450 const url = yield* decodeUrl(authorizationUrl).pipe(Effect.mapError(invalidUrl));
451 const state = url.searchParams.get("state");
452 const redirectUri = url.searchParams.get("redirect_uri");
453 if (
454 url.origin !== "https://accounts.google.com" ||
455 url.pathname !== "/o/oauth2/v2/auth" ||
456 url.username !== "" ||
457 url.password !== "" ||
458 url.hash !== "" ||
459 url.searchParams.getAll("state").length !== 1 ||
460 url.searchParams.getAll("redirect_uri").length !== 1 ||
461 url.searchParams.getAll("response_type").length !== 1 ||
462 url.searchParams.get("response_type") !== "code" ||
463 state === null ||
464 state.length === 0 ||
465 state.length > 512 ||
466 /\s/.test(state) ||
467 redirectUri === null ||
468 !/^http:\/\/127\.0\.0\.1:[1-9][0-9]{0,4}\/$/.test(redirectUri)
469 ) {
470 return yield* invalidUrl();
471 }
472 const redirect = yield* decodeUrl(redirectUri).pipe(Effect.mapError(invalidUrl));
473 if (Number(redirect.port) < 1_024) return yield* invalidUrl();
474 return { authorizationUrl, redirectUri, state };
475 },
476);
477
478export function makeAntigravityStdoutTransform(
479 input: {
480 readonly onAuthorizationUrl?: (
481 authorizationUrl: string,
482 ) => Effect.Effect<void, AcpErrors.AcpError>;
483 } = {},
484) {
485 const handleLine = Effect.fn("antigravityAuthSupport.handleStdoutLine")(function* (
486 line: Uint8Array,
487 ) {
488 if (!authPrefixBytes.every((byte, index) => line[index] === byte)) return [line];
489 const message = new TextDecoder().decode(line).replace(/\r?\n$/, "");
490 const request = yield* parseAntigravityAuthorizationUrl(
491 message.slice(ANTIGRAVITY_AUTH_STDOUT_PREFIX.length),
492 );
493 if (!input.onAuthorizationUrl) {
494 return yield* authSupportError(ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE);
495 }
496 yield* input.onAuthorizationUrl(request.authorizationUrl);
497 return [];
498 });
499
500 return (
501 stdout: ChildProcessSpawner.ChildProcessHandle["stdout"],
502 ): Stream.Stream<Uint8Array, PlatformError.PlatformError | AcpErrors.AcpError> =>
503 Stream.suspend(() => {
504 let pending: Uint8Array[] = [];
505 let pendingBytes = 0;
506 const finishLine = () => {
507 const line = Buffer.concat(pending, pendingBytes);
508 pending = [];
509 pendingBytes = 0;
510 return line;
511 };
512 return stdout.pipe(
513 Stream.mapEffect(
514 Effect.fn("antigravityAuthSupport.splitStdoutLines")(function* (chunk: Uint8Array) {
515 const lines: Uint8Array[] = [];
516 let offset = 0;
517 while (offset < chunk.byteLength) {
518 const newline = chunk.indexOf(10, offset);
519 const end = newline === -1 ? chunk.byteLength : newline + 1;
520 const part = chunk.subarray(offset, end);
521 if (pendingBytes + part.byteLength > maxStdoutLineBytes) {
522 return yield* authSupportError(
523 "Antigravity sent a protocol line that is too large.",
524 );
525 }
526 pending.push(part);
527 pendingBytes += part.byteLength;
528 if (newline !== -1) lines.push(finishLine());
529 offset = end;
530 }
531 return lines;
532 }),
533 ),
534 Stream.flatMap(Stream.fromIterable),
535 Stream.concat(
536 Stream.suspend(() => (pendingBytes > 0 ? Stream.succeed(finishLine()) : Stream.empty)),
537 ),
538 Stream.mapEffect(handleLine),
539 Stream.flatMap(Stream.fromIterable),
540 );
541 });
542}
543
544/** Receives native 1.1.1 sign-in URLs and T3 browser-helper URLs without logging stderr. */
545export function makeAntigravityStderrHandler(
546 input: {
547 readonly onAuthorizationUrl?: (
548 authorizationUrl: string,
549 ) => Effect.Effect<void, AcpErrors.AcpError>;
550 } = {},
551) {
552 let pending = "";
553 const handleLine = (line: string) => {
554 const message = line.endsWith("\r") ? line.slice(0, -1) : line;
555 if (message.length > maxBrowserHelperLineLength) {
556 return Effect.void;
557 }
558 const url = message.startsWith(ANTIGRAVITY_AUTH_STDOUT_PREFIX)
559 ? Effect.succeed(message.slice(ANTIGRAVITY_AUTH_STDOUT_PREFIX.length))
560 : message.startsWith(ANTIGRAVITY_AUTH_BROWSER_MARKER)
561 ? decodeBrowserHelperUrl(message.slice(ANTIGRAVITY_AUTH_BROWSER_MARKER.length))
562 : undefined;
563 if (url === undefined) return Effect.void;
564 return url.pipe(
565 Effect.flatMap(parseAntigravityAuthorizationUrl),
566 Effect.matchEffect({
567 onFailure: () => Effect.void,
568 onSuccess: (request) =>
569 input.onAuthorizationUrl
570 ? input.onAuthorizationUrl(request.authorizationUrl)
571 : Effect.fail(authSupportError(ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE)),
572 }),
573 );
574 };
575
576 return Effect.fn("antigravityAuthSupport.handleStderr")(function* (text: string) {
577 const lines = `${pending}${text}`.split("\n");
578 pending = lines.pop() ?? "";
579 if (pending.length > maxBrowserHelperLineLength) pending = "";
580 yield* Effect.forEach(lines, handleLine, { discard: true });
581 });
582}