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

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

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

Synced Nov 21, 04:45 UTC

main
ts 58 lines 2.29 KB
Raw
1 import * as Schema from "effect/Schema";
2
3 export const ANTIGRAVITY_CLI_MANIFEST_BASE =
4 "https://antigravity-cli-auto-updater-974169037036.us-central1.run.app/manifests";
5
6 const Manifest = Schema.Struct({
7 version: Schema.String.check(Schema.isPattern(/^\d+\.\d+\.\d+$/u)),
8 url: Schema.String,
9 sha512: Schema.String.check(Schema.isPattern(/^[a-fA-F0-9]{128}$/u)),
10 });
11 const decodeManifest = Schema.decodeUnknownOption(Manifest);
12
13 export interface AntigravityCliReleaseAsset {
14 readonly version: string;
15 readonly url: string;
16 readonly sha512: string;
17 readonly executable: { readonly name: string };
18 readonly format: "tar.gz" | "executable";
19 }
20
21 export function antigravityCliTarget(platform: NodeJS.Platform, arch: string, musl = false) {
22 if (!["darwin", "linux", "win32"].includes(platform) || !["x64", "arm64"].includes(arch)) {
23 return null;
24 }
25 const os = platform === "win32" ? "windows" : platform;
26 return `${os}_${arch === "x64" ? "amd64" : arch}${platform === "linux" && musl ? "_musl" : ""}`;
27 }
28
29 export function parseAntigravityCliRelease(
30 value: unknown,
31 platform: NodeJS.Platform,
32 arch: string,
33 musl = false,
34 ): AntigravityCliReleaseAsset | null {
35 const decoded = decodeManifest(value);
36 if (decoded._tag === "None" || antigravityCliTarget(platform, arch, musl) === null) return null;
37 const manifest = decoded.value;
38 const os = platform === "darwin" ? "mac" : platform === "win32" ? "windows" : "linux";
39 const cpu = arch === "x64" ? "x64" : "arm64";
40 const suffix = platform === "linux" && musl ? "_musl" : "";
41 const extension = platform === "win32" ? "exe" : "tar.gz";
42 const folder = `${platform === "win32" ? "windows" : platform}-${arch === "arm64" ? "arm" : "x64"}${suffix ? "-musl" : ""}`;
43 const prefix = `https://storage.googleapis.com/antigravity-public/antigravity-cli/${manifest.version}-`;
44 const rest = manifest.url.startsWith(prefix) ? manifest.url.slice(prefix.length) : "";
45 if (
46 !/^\d+\//u.test(rest) ||
47 rest.replace(/^\d+\//u, "") !== `${folder}/cli_${os}_${cpu}${suffix}.${extension}`
48 ) {
49 return null;
50 }
51 return {
52 version: manifest.version,
53 url: manifest.url,
54 sha512: manifest.sha512.toLowerCase(),
55 executable: { name: platform === "win32" ? "agy.exe" : "antigravity" },
56 format: platform === "win32" ? "executable" : "tar.gz",
57 };
58 }