Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AntigravityInstallation.ts

1,224 lines49.2 KB

1// @effect-diagnostics nodeBuiltinImport:off - Effect has no incremental digest or free-space query.
2import * as EffectNodeStream from "@effect/platform-node/NodeStream";
3import { ProviderDriverKind, type ProviderInstallState } from "@t3tools/contracts";
4import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
5import * as HostProcess from "@t3tools/shared/HostProcess";
6import { resolveNodeExecutable, nodeRuntimeUnavailableMessage } from "@t3tools/shared/nodeRuntime";
7import { resolveCommandPath } from "@t3tools/shared/shell";
8import * as Clock from "effect/Clock";
9import * as Cause from "effect/Cause";
10import * as Context from "effect/Context";
11import * as SecureRandom from "effect/crypto/SecureRandom";
12import * as Effect from "effect/Effect";
13import * as Exit from "effect/Exit";
14import * as Fiber from "effect/Fiber";
15import * as FileSystem from "effect/FileSystem";
16import * as Layer from "effect/Layer";
17import * as Option from "effect/Option";
18import * as Path from "effect/Path";
19import * as Schema from "effect/Schema";
20import * as Schedule from "effect/Schedule";
21import * as Scope from "effect/Scope";
22import * as Semaphore from "effect/Semaphore";
23import * as Stream from "effect/Stream";
24import * as SubscriptionRef from "effect/SubscriptionRef";
25import {
26 FetchHttpClient,
27 HttpClient,
28 HttpClientError,
29 HttpClientRequest,
30 HttpClientResponse,
31} from "effect/http";
32import * as ChildProcess from "effect/process/ChildProcess";
33import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
34import * as NodeCrypto from "node:crypto";
35import * as NodeFSP from "node:fs/promises";
36import * as EffectAcpErrors from "effect-acp/errors";
37​
38import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
39import {
40 ACP_REGISTRY_URL,
41 MAX_REGISTRY_BYTES,
42 resolveAcpRegistryPlatformTarget,
43} from "@t3tools/provider-acp-registry/server/AcpRegistrySupport";
44​
45import * as ServerConfig from "../config.ts";
46import { openZipArchive } from "../zipArchive.ts";
47import { makeAntigravityAcpRuntime } from "./acp/AntigravityAcpSupport.ts";
48import {
49 buildAntigravityAcpSpawnInput,
50 prepareAntigravityProfile,
51} from "./antigravityAuthSupport.ts";
52import {
53 resolveAntigravityReleaseAsset,
54 type AntigravityRelease,
55 type AntigravityReleaseAsset,
56 type AntigravityUpstreamRelease,
57} from "./antigravityRelease.ts";
58import { selectManagedRelease } from "./managedRelease.ts";
59import * as ModelManifest from "./ModelManifest.ts";
60import { resolveProviderCompatibility } from "./providerCompatibility.ts";
61​
62const DRIVER = ProviderDriverKind.make("antigravity");
63const DOWNLOAD_TIMEOUT = "45 minutes";
64const VALIDATION_TIMEOUT = "90 seconds";
65const FREE_SPACE_MARGIN = 256 * 1024 * 1024;
66const RECORD_MAX_BYTES = 8 * 1024;
67const RELEASE_RECORD = ".install-complete.json";
68const UPDATE_CHECK_INTERVAL_MS = 60 * 60_000;
69const UPDATE_CHECK_TIMEOUT = "20 seconds";
70const UPSTREAM_AGENT_ID = "antigravity-acp";
71const UPSTREAM_DOWNLOAD_PREFIX = "https://dl.google.com/agy-extensions/releases/";
72// An upstream release has no pinned sizes. Current archives are about 340 MB
73// and extract to about 1.1 GB.
74const UPSTREAM_MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024;
75const UPSTREAM_MAX_EXTRACTED_BYTES = 2 * 1024 * 1024 * 1024;
76​
77const decodeRegistryIndex = Schema.decodeUnknownEffect(
78 Schema.fromJsonString(Schema.Struct({ agents: Schema.Array(Schema.Unknown) })),
79);
80const isUpstreamAgent = Schema.is(Schema.Struct({ id: Schema.Literal(UPSTREAM_AGENT_ID) }));
81const decodeRegistryAgent = Schema.decodeUnknownEffect(
82 Schema.Struct({
83 version: Schema.String,
84 distribution: Schema.Struct({
85 binary: Schema.optionalKey(
86 Schema.Record(Schema.String, Schema.Struct({ archive: Schema.String })),
87 ),
88 }),
89 }),
90);
91const LARGE_PAGE_KERNEL_MESSAGE =
92 "Google's linux-arm64 Antigravity runtime needs a kernel with 4 KiB memory pages, and this kernel uses larger pages (as on Asahi Linux or Raspberry Pi 5). Use a remote environment or a custom Antigravity executable.";
93​
94const ReleaseId = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/u));
95const ActiveRelease = Schema.Struct({ releaseId: ReleaseId });
96const InstalledRelease = Schema.Struct({
97 releaseId: ReleaseId,
98 version: Schema.String,
99 executable: Schema.Struct({ name: Schema.String, bytes: Schema.Number }),
100 harness: Schema.Struct({ name: Schema.String, bytes: Schema.Number }),
101});
102type InstalledRelease = typeof InstalledRelease.Type;
103const encodeActiveRelease = Schema.encodeEffect(Schema.fromJsonString(ActiveRelease));
104const encodeInstalledRelease = Schema.encodeEffect(Schema.fromJsonString(InstalledRelease));
105​
106export class AntigravityInstallationError extends Schema.TaggedError<AntigravityInstallationError>()(
107 "AntigravityInstallationError",
108 {
109 operation: Schema.String,
110 detail: Schema.String,
111 cause: Schema.optional(Schema.Defect()),
112 },
113) {
114 override get message() {
115 return this.detail;
116 }
118const isInstallationError = Schema.is(AntigravityInstallationError);
119const isAcpProcessExitedError = Schema.is(EffectAcpErrors.AcpProcessExitedError);
120​
121export interface AntigravityExecutable {
122 readonly executablePath: string;
123 /** Null for the `agy` CLI, which embeds the harness and runs as `agy acp`. */
124 readonly harnessPath: string | null;
125 readonly source: "override" | "managed" | "path";
126 readonly version: string | null;
127 readonly managedVersionDirectory: string | null;
129​
130interface AntigravityInstallationService {
131 readonly managedDirectory: string;
132 readonly resolve: (
133 binaryPath?: string,
134 environment?: NodeJS.ProcessEnv,
135 ) => Effect.Effect<AntigravityExecutable, AntigravityInstallationError>;
136 /** Hold the lease until the spawned process has exited. */
137 readonly acquire: (
138 binaryPath?: string,
139 environment?: NodeJS.ProcessEnv,
140 ) => Effect.Effect<AntigravityExecutable, AntigravityInstallationError, Scope.Scope>;
141 readonly start: Effect.Effect<ProviderInstallState, AntigravityInstallationError>;
142 readonly cancel: (
143 operationId: string,
144 ) => Effect.Effect<ProviderInstallState, AntigravityInstallationError>;
145 readonly state: Effect.Effect<ProviderInstallState>;
146 readonly changes: Stream.Stream<ProviderInstallState>;
147 /**
148 * Looks up the newest release in the ACP Registry, at most hourly, and
149 * offers it through `state.version` when it is newer than the install.
150 */
151 readonly checkForUpdate: Effect.Effect<void>;
152 readonly remove: (
153 protectedBinaryPaths?: ReadonlyArray<string>,
154 ) => Effect.Effect<void, AntigravityInstallationError>;
156​
157export class AntigravityInstallation extends Context.Service<
158 AntigravityInstallation,
159 AntigravityInstallationService
160>()("t3/provider/AntigravityInstallation") {
161 static readonly layer = Layer.effect(
162 AntigravityInstallation,
163 Effect.gen(function* () {
164 const config = yield* ServerConfig.ServerConfig;
165 return yield* makeAntigravityInstallation({ baseDir: config.baseDir });
166 }),
167 );
169​
170export interface AntigravityInstallationOptions {
171 readonly baseDir: string;
172 readonly releaseAsset?: AntigravityReleaseAsset | null;
173 readonly validate?: (
174 executable: AntigravityExecutable,
175 expectedVersion: string,
176 ) => Effect.Effect<void, AntigravityInstallationError, Scope.Scope>;
178​
179const installationError = (operation: string, detail: string, cause?: unknown) =>
180 new AntigravityInstallationError({
181 operation,
182 detail,
183 ...(cause === undefined ? {} : { cause }),
184 });
185​
186const wrapFailure = (operation: string, detail: string) => (cause: unknown) =>
187 isInstallationError(cause) ? cause : installationError(operation, detail, cause);
188​
189function executableNames(platform: NodeJS.Platform) {
190 return platform === "win32"
191 ? { executable: "agy_acp_server.exe", harness: "localharness_external.exe" }
192 : { executable: "agy_acp_server.par", harness: "localharness_external" };
194​
195/** Antigravity CLI 1.5.0+ serves ACP itself (`agy acp`), so it has no `localharness_external` sibling. */
196function isAntigravityCli(...candidates: ReadonlyArray<string>) {
197 return candidates.some((candidate) =>
198 /^(?:agy|antigravity)(?:\.(?:exe|cmd|bat))?$/iu.test(candidate.split(/[\\/]/u).at(-1) ?? ""),
199 );
201​
202function isRunning(state: ProviderInstallState) {
203 return (
204 state.phase === "downloading" || state.phase === "extracting" || state.phase === "verifying"
205 );
207​
208export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.make")(function* (
209 options: AntigravityInstallationOptions,
210) {
211 const manifestService = yield* ModelManifest.ModelManifest;
212 const fs = yield* FileSystem.FileSystem;
213 const path = yield* Path.Path;
214 const random = yield* SecureRandom.SecureRandom;
215 const http = yield* HttpClient.HttpClient;
216 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
217 const serviceScope = yield* Effect.scope;
218 const platform = yield* HostProcess.Platform;
219 const arch = yield* HostProcess.Architecture;
220 const environment = yield* HostProcess.Environment;
221 const releaseAsset =
222 options.releaseAsset === undefined
223 ? resolveAntigravityReleaseAsset(platform, arch)
224 : options.releaseAsset;
225 const names = executableNames(platform);
226 const managedDirectory = path.join(
227 options.baseDir,
228 "tools",
229 "antigravity-acp",
230 `${platform}-${arch}`,
231 );
232 const versionsDirectory = path.join(managedDirectory, "versions");
233 const activePath = path.join(managedDirectory, "active.json");
234 const gate = yield* Semaphore.make(1);
235 const updateCheckGate = yield* Semaphore.make(1);
236 const leases = new Map<string, number>();
237 let running: { readonly operationId: string; readonly fiber: Fiber.Fiber<void> } | undefined;
238 let upstream: AntigravityUpstreamRelease | null = null;
239 let upstreamCheckedAt: number | null = null;
240​
241 // What `start` installs next. Clients compare `version` with
242 // `installedVersion` to offer an update.
243 const offer = (installedVersion: string | null) => {
244 const release = selectManagedRelease<AntigravityRelease>(
245 installedVersion,
246 releaseAsset,
247 upstream,
248 );
249 return {
250 version: release?.version ?? installedVersion,
251 totalBytes: release && "archiveBytes" in release ? release.archiveBytes : null,
252 };
253 };
254​
255 const state = yield* SubscriptionRef.make<ProviderInstallState>({
256 driver: DRIVER,
257 operationId: null,
258 phase: "idle",
259 downloadedBytes: 0,
260 ...offer(null),
261 installedVersion: null,
262 canRemove: false,
263 message: null,
264 });
265​
266 // The model manifest can withdraw a bad upstream release without a T3 Code release.
267 const isWithdrawn = Effect.fn("AntigravityInstallation.isWithdrawn")(function* (version: string) {
268 const manifest = yield* manifestService.current;
269 const status = (
270 resolveProviderCompatibility(manifest.compatibility, DRIVER, version) ??
271 resolveProviderCompatibility(
272 ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility,
273 DRIVER,
274 version,
275 )
276 )?.status;
277 return status === "broken" || status === "unsupported";
278 });
279​
280 // Forgets what the manifest withdrew after it was seen. A withdrawn install
281 // is not kept either, so the pin replaces it rather than a re-check.
282 const keptInstall = Effect.fn("AntigravityInstallation.keptInstall")(function* (
283 installedVersion: string | null,
284 ) {
285 if (upstream && (yield* isWithdrawn(upstream.version))) upstream = null;
286 return installedVersion !== null && !(yield* isWithdrawn(installedVersion))
287 ? installedVersion
288 : null;
289 });
290​
291 const lookupUpstream = Effect.gen(function* () {
292 const target = resolveAcpRegistryPlatformTarget(platform, arch);
293 if (!target) return null;
294 const response = yield* http
295 .execute(HttpClientRequest.get(ACP_REGISTRY_URL))
296 .pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));
297 const body = yield* collectUint8StreamText({
298 stream: response.stream,
299 maxBytes: MAX_REGISTRY_BYTES + 1,
300 });
301 if (body.truncated || body.bytes > MAX_REGISTRY_BYTES || body.invalidUtf8) return null;
302 const index = yield* decodeRegistryIndex(body.text);
303 const entry = index.agents.find(isUpstreamAgent);
304 if (!entry) return null;
305 const agent = yield* decodeRegistryAgent(entry);
306 // Checked after normalization so an encoded `..` cannot leave the releases path.
307 const archive = agent.distribution.binary?.[target]?.archive;
308 const url = archive === undefined ? undefined : URL.parse(archive)?.href;
309 if (!/^\d+\.\d+\.\d+$/u.test(agent.version) || !url?.startsWith(UPSTREAM_DOWNLOAD_PREFIX)) {
310 return null;
311 }
312 if (yield* isWithdrawn(agent.version)) return null;
313 return { version: agent.version, url } satisfies AntigravityUpstreamRelease;
314 });
315​
316 // A check already in flight covers concurrent subscribers, including when it fails.
317 const checkForUpdate = updateCheckGate
318 .withPermitsIfAvailable(1)(
319 Effect.gen(function* () {
320 const now = yield* Clock.currentTimeMillis;
321 if (upstreamCheckedAt === null || now - upstreamCheckedAt >= UPDATE_CHECK_INTERVAL_MS) {
322 // A failed lookup counts too, and keeps whatever release was offered before.
323 upstreamCheckedAt = now;
324 upstream = yield* lookupUpstream.pipe(
325 Effect.timeout(UPDATE_CHECK_TIMEOUT),
326 Effect.orElseSucceed(() => upstream),
327 );
328 }
329 // A running install already published the release it is installing.
330 yield* SubscriptionRef.updateEffect(state, (current) =>
331 isRunning(current)
332 ? Effect.succeed(current)
333 : keptInstall(current.installedVersion).pipe(
334 Effect.map((kept) => ({ ...current, ...offer(kept) })),
335 ),
336 );
337 }),
338 )
339 .pipe(Effect.ignore);
340​
341 const readRecord = Effect.fn("AntigravityInstallation.readRecord")(function* <A>(
342 filePath: string,
343 schema: Schema.Codec<A>,
344 ) {
345 const info = yield* fs.stat(filePath);
346 if (info.type !== "File" || Number(info.size) > RECORD_MAX_BYTES) {
347 return yield* installationError(
348 "resolve",
349 "The managed runtime record is invalid. Reinstall Antigravity.",
350 );
351 }
352 const contents = yield* fs.readFileString(filePath);
353 return yield* Schema.decodeEffect(Schema.fromJsonString(schema))(contents);
354 });
355​
356 const executableFile = Effect.fn("AntigravityInstallation.executableFile")(function* (
357 filePath: string,
358 bytes?: number,
359 ) {
360 const info = yield* fs.stat(filePath).pipe(Effect.option);
361 return (
362 Option.isSome(info) &&
363 info.value.type === "File" &&
364 (bytes === undefined || Number(info.value.size) === bytes) &&
365 (platform === "win32" || (info.value.mode & 0o111) !== 0)
366 );
367 });
368​
369 const completedRelease = Effect.fn("AntigravityInstallation.completedRelease")(function* (
370 releaseId: string,
371 ) {
372 const directory = path.join(versionsDirectory, releaseId);
373 const record = yield* readRecord(path.join(directory, RELEASE_RECORD), InstalledRelease);
374 if (
375 record.releaseId !== releaseId ||
376 record.executable.name !== names.executable ||
377 record.harness.name !== names.harness ||
378 !Number.isSafeInteger(record.executable.bytes) ||
379 record.executable.bytes <= 0 ||
380 !Number.isSafeInteger(record.harness.bytes) ||
381 record.harness.bytes <= 0 ||
382 !record.version.trim() ||
383 !(yield* executableFile(path.join(directory, names.executable), record.executable.bytes)) ||
384 !(yield* executableFile(path.join(directory, names.harness), record.harness.bytes))
385 ) {
386 return yield* installationError(
387 "resolve",
388 "The managed Antigravity runtime is incomplete. Reinstall it.",
389 );
390 }
391 return {
392 executablePath: path.join(directory, names.executable),
393 harnessPath: path.join(directory, names.harness),
394 source: "managed",
395 version: record.version,
396 managedVersionDirectory: directory,
397 } satisfies AntigravityExecutable;
398 });
399​
400 const fromExternal = Effect.fn("AntigravityInstallation.fromExternal")(function* (
401 candidate: string,
402 source: "override" | "path",
403 ) {
404 if (!(yield* executableFile(candidate))) return null;
405 const executablePath = yield* fs.realPath(candidate);
406 // Keep launcher symlinks intact: version-manager shims dispatch by their invoked name.
407 if (isAntigravityCli(candidate, executablePath)) {
408 return {
409 executablePath: candidate,
410 harnessPath: null,
411 source,
412 version: null,
413 managedVersionDirectory: null,
414 } satisfies AntigravityExecutable;
415 }
416 const directory = path.dirname(executablePath);
417 const harnessPath = path.join(directory, names.harness);
418 if (!(yield* executableFile(harnessPath))) return null;
419 const realVersions = yield* fs.realPath(versionsDirectory).pipe(Effect.option);
420 if (
421 Option.isSome(realVersions) &&
422 path.dirname(directory) === realVersions.value &&
423 /^[a-f0-9]{64}$/u.test(path.basename(directory))
424 ) {
425 const installed = yield* completedRelease(path.basename(directory));
426 return { ...installed, executablePath, harnessPath, source } satisfies AntigravityExecutable;
427 }
428 return {
429 executablePath,
430 harnessPath,
431 source,
432 version: null,
433 managedVersionDirectory: null,
434 } satisfies AntigravityExecutable;
435 });
436​
437 const commandPath = (command: string, env: NodeJS.ProcessEnv) =>
438 resolveCommandPath(command, { env }).pipe(
439 Effect.map((resolved) => (resolved === null ? null : path.resolve(resolved))),
440 Effect.provideService(HostProcess.Platform, platform),
441 Effect.provideService(FileSystem.FileSystem, fs),
442 Effect.provideService(Path.Path, path),
443 );
444​
445 // Resolve per PATH entry so an executable without its harness falls through to later entries.
446 const commandCandidates = Effect.fn("AntigravityInstallation.commandCandidates")(function* (
447 command: string,
448 processEnvironment = environment,
449 ) {
450 if (command.includes("/") || command.includes("\\")) {
451 const resolved = yield* commandPath(command, processEnvironment);
452 return resolved === null ? [] : [resolved];
453 }
454 const pathValue =
455 platform === "win32"
456 ? Object.entries(processEnvironment).findLast(([key]) => key.toUpperCase() === "PATH")?.[1]
457 : processEnvironment.PATH;
458 const candidates: string[] = [];
459 for (const directory of (pathValue ?? "").split(platform === "win32" ? ";" : ":")) {
460 const entry = directory.trim().replace(/^"|"$/gu, "");
461 if (entry.length === 0) continue;
462 const resolved = yield* commandPath(command, { ...processEnvironment, PATH: entry });
463 if (resolved !== null) candidates.push(resolved);
464 }
465 return candidates;
466 });
467​
468 const resolve: AntigravityInstallationService["resolve"] = Effect.fn(
469 "AntigravityInstallation.resolve",
470 )(
471 function* (binaryPath?: string, processEnvironment?: NodeJS.ProcessEnv) {
472 const override = expandHomePath(binaryPath?.trim() ?? "", yield* HostProcess.HomeDirectory);
473 if (override) {
474 for (const candidate of yield* commandCandidates(override, processEnvironment)) {
475 const selected = yield* fromExternal(candidate, "override");
476 if (selected) return selected;
477 }
478 return yield* installationError(
479 "resolve",
480 "The custom Antigravity executable is missing or not executable, or it needs a localharness_external sibling. The agy CLI does not.",
481 );
482 }
483 if (yield* fs.exists(activePath)) {
484 const active = yield* readRecord(activePath, ActiveRelease);
485 const installed = yield* completedRelease(active.releaseId);
486 // Without this a withdrawn install keeps launching until its owner updates.
487 if (yield* isWithdrawn(installed.version)) {
488 return yield* installationError(
489 "resolve",
490 `Antigravity ${installed.version} no longer works with this T3 Code release. Update it in Antigravity setup.`,
491 );
492 }
493 return installed;
494 }
495 for (const candidate of yield* commandCandidates(names.executable, processEnvironment)) {
496 const selected = yield* fromExternal(candidate, "path");
497 if (selected) return selected;
498 }
499 return yield* installationError(
500 "resolve",
501 releaseAsset
502 ? "Antigravity ACP runtime is not installed. Install it in this environment's provider settings or set a custom ACP executable path. The Antigravity app, IDE, and CLI are separate installations."
503 : `Google does not publish an Antigravity runtime for ${platform}-${arch}. Use a supported environment or a custom executable.`,
504 );
505 },
506 Effect.mapError(
507 wrapFailure(
508 "resolve",
509 "Could not read the Antigravity installation. Reinstall it or set a custom executable path.",
510 ),
511 ),
512 );
513​
514 const acquire = (binaryPath?: string, processEnvironment?: NodeJS.ProcessEnv) =>
515 Effect.acquireRelease(
516 gate.withPermit(
517 Effect.gen(function* () {
518 const executable = yield* resolve(binaryPath, processEnvironment);
519 const directory = executable.managedVersionDirectory;
520 if (directory) leases.set(directory, (leases.get(directory) ?? 0) + 1);
521 return executable;
522 }),
523 ),
524 (executable) =>
525 gate.withPermit(
526 Effect.sync(() => {
527 const directory = executable.managedVersionDirectory;
528 if (!directory) return;
529 const remaining = (leases.get(directory) ?? 1) - 1;
530 if (remaining > 0) leases.set(directory, remaining);
531 else leases.delete(directory);
532 }),
533 ),
534 );
535​
536 const validate =
537 options.validate ??
538 Effect.fn("AntigravityInstallation.validate")(
539 function* (executable: AntigravityExecutable, expectedVersion: string) {
540 const validationScope = yield* Effect.scope;
541 const profileDirectory = yield* Effect.acquireRelease(
542 fs.makeTempDirectory({ prefix: "t3-antigravity-validate-" }),
543 (directory) =>
544 fs.remove(directory, { recursive: true, force: true }).pipe(
545 // Windows may retain DLL handles briefly after taskkill returns.
546 Effect.retry({
547 times: platform === "win32" ? 10 : 0,
548 schedule: Schedule.spaced("100 millis"),
549 while: (error) =>
550 error.reason._tag === "PermissionDenied" ||
551 error.reason._tag === "Busy" ||
552 error.reason._tag === "Unknown",
553 }),
554 Effect.orDie,
555 ),
556 );
557 const profile = yield* prepareAntigravityProfile({
558 profileDirectory,
559 platform,
560 baseEnv: environment,
561 // A shallow scoped profile cleans up unpacked files within Windows' path limit.
562 tempDirectory: profileDirectory,
563 });
564 const runtime = yield* makeAntigravityAcpRuntime({
565 runtimeVersion: expectedVersion,
566 spawn: buildAntigravityAcpSpawnInput({
567 installation: executable,
568 profile,
569 cwd: profileDirectory,
570 baseEnv: environment,
571 }),
572 cwd: profileDirectory,
573 childProcessSpawner:
574 platform === "win32"
575 ? ChildProcessSpawner.make(
576 Effect.fnUntraced(function* (command) {
577 const child = yield* spawner.spawn(command);
578 // Stop PyInstaller's tree before ACP closes pipes; after launcher exit, taskkill cannot reach children holding DLLs open.
579 yield* Scope.addFinalizer(
580 validationScope,
581 child.kill({ forceKillAfter: "1 second" }).pipe(Effect.orDie),
582 );
583 return child;
584 }),
585 )
586 : spawner,
587 });
588 const initialized = yield* runtime.initialize();
589 if (
590 initialized.agentInfo?.name !== "antigravity-acp" ||
591 initialized.agentInfo.version !== expectedVersion ||
592 // Antigravity 1.1.1 may report protocol 2 with legacy ACP; choose wire format from the response shape.
593 (initialized.protocolVersion !== 1 && initialized.protocolVersion !== 2) ||
594 initialized.agentCapabilities?.loadSession !== true ||
595 !initialized.agentCapabilities.sessionCapabilities?.resume ||
596 !initialized.agentCapabilities.auth?.logout ||
597 !initialized.authMethods?.some((method) => method.id === "oauth-personal")
598 ) {
599 return yield* installationError(
600 "verify",
601 "The downloaded runtime did not identify as the expected Google Antigravity release.",
602 );
603 }
604 },
605 Effect.provideService(FileSystem.FileSystem, fs),
606 Effect.provideService(Path.Path, path),
607 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
608 Effect.provideService(SecureRandom.SecureRandom, random),
609 Effect.mapError((cause) => {
610 if (isInstallationError(cause)) return cause;
611 const stderr = isAcpProcessExitedError(cause) ? (cause.stderr ?? "") : "";
612 const detail = /\b(?:AF_INET6|enforce_kernel_ipv6_support)\b/.test(stderr)
613 ? "Antigravity requires IPv6 socket support. Enable IPv6 in this environment. On WSL, remove ipv6.disable=1 from .wslconfig and run wsl --shutdown."
614 : /page-size\.cc|Compile-time page size does not match/.test(stderr)
615 ? LARGE_PAGE_KERNEL_MESSAGE
616 : "The downloaded Antigravity runtime could not start in this environment.";
617 return installationError("verify", detail, cause);
618 }),
619 );
620​
621 const install = Effect.fn("AntigravityInstallation.install")(
622 function* (release: AntigravityRelease) {
623 // A pinned release is checked against its recorded hash and sizes. An
624 // upstream release is bounded instead and identified by what downloads.
625 const pin = "sha256" in release ? release : null;
626 const ensureEligible = Effect.fn("AntigravityInstallation.ensureEligible")(function* () {
627 if (!pin && (yield* isWithdrawn(release.version))) {
628 return yield* installationError(
629 "verify",
630 "This Antigravity release was withdrawn. Check for updates and try again.",
631 );
632 }
633 });
634 const executable = pin?.executable ?? { name: names.executable, bytes: null };
635 const harness = pin?.harness ?? { name: names.harness, bytes: null };
636 yield* resolveNodeExecutable("Antigravity", environment).pipe(
637 Effect.provideService(FileSystem.FileSystem, fs),
638 Effect.provideService(Path.Path, path),
639 Effect.provideService(HostProcess.Platform, platform),
640 Effect.mapError((cause) =>
641 installationError("verify", nodeRuntimeUnavailableMessage("Antigravity"), cause),
642 ),
643 );
644 if (platform === "linux" && arch === "arm64") {
645 const pageSize = yield* spawner
646 .string(ChildProcess.make("getconf", ["PAGESIZE"], { stdin: "ignore", stderr: "ignore" }))
647 .pipe(
648 Effect.map((output) => Number(output.trim())),
649 Effect.timeout("5 seconds"),
650 Effect.orElseSucceed(() => Number.NaN),
651 );
652 if (pageSize > 4096) {
653 return yield* installationError("download", LARGE_PAGE_KERNEL_MESSAGE);
654 }
655 }
656 const report = (phase: ProviderInstallState["phase"], message: string | null) =>
657 SubscriptionRef.update(state, (current) => ({ ...current, phase, message }));
658 yield* fs.makeDirectory(versionsDirectory, { recursive: true });
659 yield* SubscriptionRef.update(state, (current) => ({ ...current, canRemove: true }));
660 const activate = Effect.fn("AntigravityInstallation.activate")(
661 function* (releaseId: string) {
662 const pointerDirectory = yield* fs.makeTempDirectoryScoped({
663 directory: managedDirectory,
664 prefix: "active.json.",
665 });
666 const pointerPath = path.join(pointerDirectory, "contents.tmp");
667 yield* fs.writeFileString(pointerPath, yield* encodeActiveRelease({ releaseId }), {
668 flag: "wx",
669 mode: 0o600,
670 });
671 yield* ensureEligible();
672 yield* fs.rename(pointerPath, activePath);
673 yield* SubscriptionRef.update(
674 state,
675 (current) =>
676 ({
677 ...current,
678 ...offer(release.version),
679 phase: "succeeded",
680 installedVersion: release.version,
681 message: null,
682 }) satisfies ProviderInstallState,
683 );
684 },
685 Effect.scoped,
686 Effect.mapError(
687 wrapFailure(
688 "activate",
689 "Could not activate Antigravity. The previous runtime is unchanged. Check for locked files and try again.",
690 ),
691 ),
692 Effect.uninterruptible,
693 );
694 const reuse = Effect.fn("AntigravityInstallation.reuse")(function* (releaseId: string) {
695 const existing = yield* completedRelease(releaseId);
696 if (existing.version !== release.version) {
697 return yield* installationError(
698 "verify",
699 "The existing managed release has the wrong version. Remove it before reinstalling.",
700 );
701 }
702 yield* report("verifying", "Checking the installed runtime.");
703 yield* ensureEligible();
704 yield* validate(existing, release.version).pipe(
705 Effect.scoped,
706 Effect.timeout(VALIDATION_TIMEOUT),
707 );
708 yield* activate(releaseId);
709 });
710​
711 if (pin && (yield* fs.exists(path.join(versionsDirectory, pin.sha256)))) {
712 return yield* reuse(pin.sha256);
713 }
714​
715 const ensureFreeSpace = Effect.fn("AntigravityInstallation.ensureFreeSpace")(function* (
716 operation: string,
717 bytes: number,
718 ) {
719 const available = yield* Effect.tryPromise({
720 try: () => NodeFSP.statfs(versionsDirectory, { bigint: true }),
721 catch: (cause) => installationError(operation, "Could not check free disk space.", cause),
722 }).pipe(Effect.option);
723 const required = bytes + FREE_SPACE_MARGIN;
724 if (
725 Option.isSome(available) &&
726 available.value.bavail * available.value.bsize < BigInt(required)
727 ) {
728 return yield* installationError(
729 operation,
730 `Antigravity needs at least ${Math.ceil(required / 1024 / 1024)} MiB of free space to install.`,
731 );
732 }
733 });
734 // An upstream release has no recorded sizes, so each member is checked
735 // against free space once the archive declares it.
736 if (pin) {
737 yield* ensureFreeSpace(
738 "download",
739 pin.archiveBytes + pin.executable.bytes + pin.harness.bytes,
740 );
741 }
742 const staging = yield* fs.makeTempDirectoryScoped({
743 directory: versionsDirectory,
744 prefix: ".install-",
745 });
746 const archivePath = path.join(staging, "download.zip");
747 const pairDirectory = path.join(staging, "runtime");
748 yield* fs.makeDirectory(pairDirectory);
749 const maxArchiveBytes = pin?.archiveBytes ?? UPSTREAM_MAX_ARCHIVE_BYTES;
750 const hash = NodeCrypto.createHash("sha256");
751 let downloadedBytes = 0;
752 let lastProgressAt = yield* Clock.currentTimeMillis;
753 yield* Effect.gen(function* () {
754 const request = http.execute(HttpClientRequest.get(release.url));
755 // Only its URL vouches for an upstream release, so a redirect is
756 // refused rather than followed somewhere that check never saw.
757 const response = yield* (
758 pin
759 ? request
760 : request.pipe(
761 Effect.provideService(FetchHttpClient.RequestInit, { redirect: "error" }),
762 )
763 ).pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));
764 // dl.google.com gzips the zip when the client accepts it, so
765 // `content-length` is the encoded size. The decoded stream is still
766 // checked against the byte limit and, when pinned, the hash below.
767 const contentLength = response.headers["content-length"];
768 const contentEncoding = response.headers["content-encoding"]?.trim().toLowerCase();
769 const identityBody = contentEncoding === undefined || contentEncoding === "identity";
770 if (identityBody && contentLength !== undefined) {
771 const declaredBytes = Number(contentLength);
772 if (pin && declaredBytes !== pin.archiveBytes) {
773 return yield* installationError(
774 "download",
775 "The Antigravity download size did not match the pinned release.",
776 );
777 }
778 if (!pin && Number.isSafeInteger(declaredBytes) && declaredBytes > 0) {
779 if (declaredBytes > maxArchiveBytes) {
780 return yield* installationError(
781 "download",
782 "The Antigravity download is larger than T3 Code accepts.",
783 );
784 }
785 yield* SubscriptionRef.update(state, (current) => ({
786 ...current,
787 totalBytes: declaredBytes,
788 }));
789 }
790 }
791 yield* response.stream.pipe(
792 Stream.tap((chunk) =>
793 Effect.gen(function* () {
794 downloadedBytes += chunk.byteLength;
795 if (downloadedBytes > maxArchiveBytes) {
796 return yield* installationError(
797 "download",
798 pin
799 ? "The Antigravity download exceeded the pinned release size."
800 : "The Antigravity download is larger than T3 Code accepts.",
801 );
802 }
803 hash.update(chunk);
804 const now = yield* Clock.currentTimeMillis;
805 if (now - lastProgressAt >= 250 || downloadedBytes === pin?.archiveBytes) {
806 lastProgressAt = now;
807 yield* SubscriptionRef.update(state, (current) => ({
808 ...current,
809 downloadedBytes,
810 }));
811 }
812 }),
813 ),
814 Stream.run(fs.sink(archivePath, { flag: "wx", mode: 0o600 })),
815 );
816 }).pipe(
817 Effect.timeout(DOWNLOAD_TIMEOUT),
818 Effect.mapError((cause) =>
819 HttpClientError.isHttpClientError(cause) || Cause.isTimeoutError(cause)
820 ? installationError(
821 "download",
822 "Could not download Antigravity from Google. Check the network connection and any proxy settings, then try again.",
823 cause,
824 )
825 : cause,
826 ),
827 );
828 const releaseId = hash.digest("hex");
829 if (pin && (downloadedBytes !== pin.archiveBytes || releaseId !== pin.sha256)) {
830 return yield* installationError(
831 "download",
832 "The Antigravity download failed its size or SHA-256 check. Nothing was installed.",
833 );
834 }
835 const destination = path.join(versionsDirectory, releaseId);
836 if (!pin && (yield* fs.exists(destination))) {
837 return yield* reuse(releaseId);
838 }
839​
840 yield* report("extracting", "Extracting the verified runtime.");
841 const extracted = new Map<string, number>();
842 let extractedTotal = 0;
843 yield* Effect.gen(function* () {
844 const archive = yield* openZipArchive(archivePath, (detail, cause) =>
845 installationError("extract", detail, cause),
846 );
847 if (archive.entryCount !== 2) {
848 return yield* installationError(
849 "extract",
850 "The archive must contain exactly the Antigravity executable and its harness.",
851 );
852 }
853 for (;;) {
854 const entry = yield* archive.next;
855 if (!entry) break;
856 const expected = [executable, harness].find((file) => file.name === entry.fileName);
857 const expectedBytes = expected?.bytes ?? entry.uncompressedSize;
858 const unixType = (entry.externalFileAttributes >>> 16) & 0o170000;
859 if (
860 !expected ||
861 extracted.has(entry.fileName) ||
862 entry.fileName.includes("/") ||
863 entry.fileName.includes("\\") ||
864 (unixType !== 0 && unixType !== 0o100000) ||
865 (entry.externalFileAttributes & 0x10) !== 0 ||
866 (entry.generalPurposeBitFlag & 1) !== 0 ||
867 ![0, 8].includes(entry.compressionMethod) ||
868 entry.uncompressedSize !== expectedBytes ||
869 expectedBytes <= 0 ||
870 extractedTotal + expectedBytes > UPSTREAM_MAX_EXTRACTED_BYTES
871 ) {
872 return yield* installationError(
873 "extract",
874 "The archive contains an unexpected, unsafe, or incorrectly sized member.",
875 );
876 }
877 if (!pin) yield* ensureFreeSpace("extract", expectedBytes);
878 extracted.set(entry.fileName, expectedBytes);
879 extractedTotal += expectedBytes;
880 yield* Effect.gen(function* () {
881 const readable = yield* archive.streamEntry(entry);
882 let extractedBytes = 0;
883 yield* EffectNodeStream.fromReadable<Uint8Array, AntigravityInstallationError>({
884 evaluate: () => readable,
885 onError: wrapFailure("extract", "Could not extract the Antigravity runtime."),
886 }).pipe(
887 Stream.tap((chunk) =>
888 Effect.gen(function* () {
889 extractedBytes += chunk.byteLength;
890 if (extractedBytes > expectedBytes) {
891 return yield* installationError(
892 "extract",
893 "An archive member exceeded its expected size.",
894 );
895 }
896 }),
897 ),
898 Stream.run(
899 fs.sink(path.join(pairDirectory, entry.fileName), { flag: "wx", mode: 0o700 }),
900 ),
901 );
902 if (extractedBytes !== expectedBytes) {
903 return yield* installationError("extract", "An archive member was truncated.");
904 }
905 }).pipe(Effect.scoped);
906 }
907 }).pipe(Effect.scoped);
908 const executableBytes = extracted.get(executable.name);
909 const harnessBytes = extracted.get(harness.name);
910 if (executableBytes === undefined || harnessBytes === undefined) {
911 return yield* installationError(
912 "extract",
913 "The archive is missing the Antigravity executable or its harness.",
914 );
915 }
916 yield* fs.remove(archivePath);
917 const executablePath = path.join(pairDirectory, executable.name);
918 const harnessPath = path.join(pairDirectory, harness.name);
919 if (platform !== "win32") {
920 yield* fs.chmod(executablePath, 0o755);
921 yield* fs.chmod(harnessPath, 0o755);
922 }
923 if (platform === "darwin" && arch === "x64") {
924 // Google signs the Intel build with the hardened runtime but no JIT entitlement, so
925 // libffi's writable+executable trampolines spin forever. Re-sign ad hoc after the hash check.
926 const exitCode = yield* spawner
927 .spawn(
928 ChildProcess.make(
929 "/usr/bin/codesign",
930 ["--force", "--sign", "-", executablePath, harnessPath],
931 { stdout: "ignore", stderr: "ignore" },
932 ),
933 )
934 .pipe(
935 Effect.flatMap((child) => child.exitCode),
936 Effect.scoped,
937 );
938 if (exitCode !== 0) {
939 return yield* installationError(
940 "extract",
941 "Could not prepare the Antigravity runtime for this Mac. Check that codesign is available.",
942 );
943 }
944 }
945 yield* report("verifying", "Checking the downloaded runtime.");
946 yield* ensureEligible();
947 yield* validate(
948 {
949 executablePath,
950 harnessPath,
951 source: "managed",
952 version: release.version,
953 managedVersionDirectory: pairDirectory,
954 },
955 release.version,
956 ).pipe(Effect.scoped, Effect.timeout(VALIDATION_TIMEOUT));
957 const record: InstalledRelease = {
958 releaseId,
959 version: release.version,
960 executable: {
961 name: executable.name,
962 bytes: Number((yield* fs.stat(executablePath)).size),
963 },
964 harness: { name: harness.name, bytes: Number((yield* fs.stat(harnessPath)).size) },
965 };
966 yield* fs.writeFileString(
967 path.join(pairDirectory, RELEASE_RECORD),
968 yield* encodeInstalledRelease(record),
969 { flag: "wx", mode: 0o600 },
970 );
971 yield* fs.rename(pairDirectory, destination).pipe(
972 Effect.catch((cause) =>
973 completedRelease(releaseId).pipe(
974 Effect.flatMap((existing) =>
975 existing.version === release.version
976 ? ensureEligible().pipe(
977 Effect.andThen(validate(existing, release.version)),
978 Effect.scoped,
979 Effect.timeout(VALIDATION_TIMEOUT),
980 )
981 : Effect.fail(
982 installationError(
983 "activate",
984 "Another installation published a different Antigravity release.",
985 ),
986 ),
987 ),
988 Effect.mapError(() =>
989 installationError(
990 "activate",
991 "Could not publish the Antigravity runtime. The previous release is unchanged. Try again.",
992 cause,
993 ),
994 ),
995 ),
996 ),
997 );
998 yield* activate(releaseId);
999 },
1000 Effect.scoped,
1001 Effect.mapError(
1002 wrapFailure(
1003 "install",
1004 "Could not install Antigravity. Check free disk space and directory access, then try again.",
1005 ),
1006 ),
1007 );
1008​
1009 // Nothing newer is known, so "reinstall" re-checks the active runtime rather
1010 // than replacing it with an older pinned release.
1011 const reverify = Effect.fn("AntigravityInstallation.reverify")(
1012 function* () {
1013 const active = yield* readRecord(activePath, ActiveRelease);
1014 const installed = yield* completedRelease(active.releaseId);
1015 yield* validate(installed, installed.version).pipe(
1016 Effect.scoped,
1017 Effect.timeout(VALIDATION_TIMEOUT),
1018 );
1019 const kept = yield* keptInstall(installed.version);
1020 if (kept === null) {
1021 yield* SubscriptionRef.update(state, (current) => ({ ...current, ...offer(kept) }));
1022 return yield* installationError(
1023 "verify",
1024 "This Antigravity release was withdrawn. Check for updates and try again.",
1025 );
1027 yield* SubscriptionRef.update(
1028 state,
1029 (current) =>
1030 ({
1031 ...current,
1032 ...offer(kept),
1033 phase: "succeeded",
1034 installedVersion: installed.version,
1035 message: null,
1036 }) satisfies ProviderInstallState,
1037 );
1038 },
1039 Effect.mapError(
1040 wrapFailure(
1041 "verify",
1042 "The installed Antigravity runtime could not start. Remove it and reinstall.",
1043 ),
1044 ),
1045 );
1046​
1047 const start = gate
1048 .withPermit(
1049 Effect.gen(function* () {
1050 const current = yield* SubscriptionRef.get(state);
1051 if (isRunning(current)) return current;
1052 const installedVersion = yield* keptInstall(current.installedVersion);
1053 const release = selectManagedRelease<AntigravityRelease>(
1054 installedVersion,
1055 releaseAsset,
1056 upstream,
1057 );
1058 if (!release && installedVersion === null) {
1059 return yield* installationError(
1060 "start",
1061 `Google does not publish an Antigravity runtime for ${platform}-${arch}. Use a supported remote environment or a custom executable.`,
1062 );
1064 const operationId = yield* random.uuidV4();
1065 const next: ProviderInstallState = {
1066 driver: DRIVER,
1067 operationId,
1068 phase: release ? "downloading" : "verifying",
1069 downloadedBytes: 0,
1070 ...offer(installedVersion),
1071 installedVersion: current.installedVersion,
1072 canRemove: current.canRemove,
1073 message: release
1074 ? "Downloading Google's official Antigravity runtime."
1075 : "Checking the installed runtime.",
1076 };
1077 yield* SubscriptionRef.set(state, next);
1078 const work = (release ? install(release) : reverify()).pipe(
1079 Effect.onExit((exit) =>
1080 Exit.isFailure(exit)
1081 ? SubscriptionRef.update(state, (value) => {
1082 if (value.operationId !== operationId || value.phase === "succeeded")
1083 return value;
1084 const error = Cause.findErrorOption(exit.cause);
1085 const cancelled = Cause.hasInterruptsOnly(exit.cause);
1086 return {
1087 ...value,
1088 phase: cancelled ? "cancelled" : "failed",
1089 message: cancelled
1090 ? "Installation cancelled. The previous runtime is unchanged."
1091 : Option.isSome(error)
1092 ? error.value.detail
1093 : "Could not finish the Antigravity installation. Check disk space and directory access.",
1094 } satisfies ProviderInstallState;
1095 })
1096 : Effect.void,
1097 ),
1098 Effect.ignoreCause,
1099 Effect.ensuring(
1100 Effect.sync(() => {
1101 if (running?.operationId === operationId) running = undefined;
1102 }),
1103 ),
1104 );
1105 const fiber = yield* Effect.forkIn(Effect.interruptible(work), serviceScope);
1106 running = { operationId, fiber };
1107 return next;
1108 }).pipe(Effect.uninterruptible),
1110 .pipe(Effect.mapError(wrapFailure("start", "Could not start the Antigravity installation.")));
1111​
1112 const cancel = Effect.fn("AntigravityInstallation.cancel")(function* (operationId: string) {
1113 return yield* gate.withPermit(
1114 Effect.gen(function* () {
1115 const current = yield* SubscriptionRef.get(state);
1116 if (current.operationId !== operationId) {
1117 return yield* installationError(
1118 "cancel",
1119 "This installation is no longer current. Refresh its status before cancelling.",
1120 );
1122 if (running?.operationId === operationId && isRunning(current)) {
1123 yield* Fiber.interrupt(running.fiber);
1125 return yield* SubscriptionRef.get(state);
1126 }),
1127 );
1128 });
1129​
1130 const remove = Effect.fn("AntigravityInstallation.remove")(
1131 function* (protectedBinaryPaths: ReadonlyArray<string> = []) {
1132 yield* gate.withPermit(
1133 Effect.gen(function* () {
1134 if (isRunning(yield* SubscriptionRef.get(state)) || leases.size > 0) {
1135 return yield* installationError(
1136 "remove",
1137 "Stop Antigravity sessions and sign-in flows before removing its managed runtime.",
1138 );
1140 const realManaged = yield* fs.realPath(managedDirectory).pipe(Effect.option);
1141 if (Option.isSome(realManaged)) {
1142 for (const binaryPath of protectedBinaryPaths) {
1143 if (!binaryPath.trim()) continue;
1144 const selected = yield* resolve(binaryPath).pipe(Effect.option);
1145 if (Option.isSome(selected) && selected.value.managedVersionDirectory) {
1146 return yield* installationError(
1147 "remove",
1148 "A provider instance has a custom path inside this managed runtime. Clear that path before removing it.",
1149 );
1151 const resolved = yield* fs.realPath(binaryPath).pipe(Effect.option);
1152 const candidate = Option.getOrElse(resolved, () => path.resolve(binaryPath));
1153 if (candidate.startsWith(`${realManaged.value}${path.sep}`)) {
1154 return yield* installationError(
1155 "remove",
1156 "A provider instance has a custom path inside this managed runtime. Clear that path before removing it.",
1157 );
1161 yield* fs.remove(managedDirectory, { recursive: true, force: true });
1162 yield* SubscriptionRef.update(
1163 state,
1164 (current) =>
1165 ({
1166 ...current,
1167 ...offer(null),
1168 operationId: null,
1169 phase: "idle",
1170 downloadedBytes: 0,
1171 installedVersion: null,
1172 canRemove: false,
1173 message: null,
1174 }) satisfies ProviderInstallState,
1175 );
1176 }).pipe(Effect.uninterruptible),
1177 );
1178 },
1179 Effect.mapError(
1180 wrapFailure(
1181 "remove",
1182 "Could not remove the managed Antigravity runtime. Check for open processes and try again.",
1183 ),
1184 ),
1185 );
1186​
1187 yield* Effect.gen(function* () {
1188 const canRemove = yield* fs.exists(managedDirectory);
1189 yield* SubscriptionRef.update(state, (current) => ({ ...current, canRemove }));
1190 if (!(yield* fs.exists(activePath))) return;
1191 const active = yield* readRecord(activePath, ActiveRelease);
1192 const installed = yield* completedRelease(active.releaseId);
1193 const kept = yield* keptInstall(installed.version);
1194 yield* SubscriptionRef.update(state, (current) => ({
1195 ...current,
1196 ...offer(kept),
1197 installedVersion: installed.version,
1198 }));
1199 }).pipe(
1200 Effect.catch(() =>
1201 SubscriptionRef.update(
1202 state,
1203 (current) =>
1204 ({
1205 ...current,
1206 phase: "failed",
1207 message: "The managed Antigravity runtime is incomplete. Remove it and reinstall.",
1208 }) satisfies ProviderInstallState,
1209 ),
1210 ),
1211 );
1212​
1213 return AntigravityInstallation.of({
1214 managedDirectory,
1215 resolve,
1216 acquire,
1217 start,
1218 cancel,
1219 state: SubscriptionRef.get(state),
1220 changes: SubscriptionRef.changes(state),
1221 checkForUpdate,
1222 remove,
1223 });
1224});