Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): link the Antigravity ACP server download for the device running Trilium

Elian Doran302ef7405519
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 77f84c8e50..053faf7307 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4048,15 +4048,16 @@
"base_url_invalid": "Base URL must be a valid http:// or https:// URL",
"claude_agent_description": "Uses your Claude Pro/Max subscription through Claude Code, so no API key is needed. Claude Code must be installed on the machine running Trilium (the server when self-hosting, or this computer on desktop); sign in once by running \"claude /login\" there.",
"copilot_agent_description": "Uses your GitHub Copilot subscription through the GitHub Copilot CLI, so no API key is needed. The Copilot CLI must be installed on the machine running Trilium (the server when self-hosting, or this computer on desktop); sign in once by running \"copilot login\" there — an existing Copilot login from another editor is reused automatically.",
- "antigravity_agent_description": "Uses the Gemini quota of your Google account (free, Google AI Pro or Ultra) through Google Antigravity, so no API key is needed.\n\nGoogle's Antigravity ACP server must be downloaded to the machine running Trilium: the server when self-hosting, or this computer on desktop.\n\nThe first time the models are listed, the Google sign-in page opens in a browser on that machine.",
- "antigravity_setup_download": "On the machine running Trilium, download the archive for your platform from Google's <Link>ACP registry entry</Link> and unzip it into a folder it can stay in.",
+ "antigravity_agent_description": "Uses the Gemini quota of your Google account (free, Google AI Pro or Ultra) through Google Antigravity, so no API key is needed.\n\nGoogle's Antigravity ACP server must be downloaded to the device running Trilium: the server when self-hosting, or this computer on desktop.\n\nThe first time the models are listed, the Google sign-in page opens in a browser on that device.",
+ "antigravity_setup_download": "On the device running Trilium, download the archive for your platform from Google's <Link>ACP registry entry</Link> and unzip it into a folder it can stay in.",
+ "antigravity_setup_archive": "Download <Link>the archive for the device running Trilium</Link> and unzip it there, into a folder it can stay in.",
"antigravity_setup_path": "Add that folder to <Code>PATH</Code>, or set the <Code>TRILIUM_ANTIGRAVITY_ACP_PATH</Code> environment variable to <Code>agy_acp_server.par</Code> in it (<Code>agy_acp_server.exe</Code> on Windows), then restart Trilium.",
- "antigravity_setup_sign_in": "Come back to this step. The first time, the Google sign-in page opens in a browser on that machine.",
+ "antigravity_setup_sign_in": "Come back to this step. The first time, the Google sign-in page opens in a browser on that device.",
"add_provider_title_named": "Add {{- name}}",
"provider_group_cloud": "Cloud providers",
"provider_group_cloud_description": "Pay per use with an API key, billed separately from any subscription you already have. Your notes are sent to the provider's servers.",
"provider_group_subscription": "Subscription",
- "provider_group_subscription_description": "Uses an account you already have instead of an API key, at no extra cost: Claude Pro/Max, GitHub Copilot or a Google account. The provider's program must be installed on the machine running Trilium, and your notes are sent to the provider's servers.",
+ "provider_group_subscription_description": "Uses an account you already have instead of an API key, at no extra cost: Claude Pro/Max, GitHub Copilot or a Google account. The provider's program must be installed on the device running Trilium, and your notes are sent to the provider's servers.",
"provider_group_local": "Local / self-hosted",
"provider_group_local_description": "No API key, no usage cost. Your notes only reach the machine running the model.",
"provider_group_custom": "Custom endpoint",
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
index 8f52a3bff0..6ee703d1ed 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -14,6 +14,7 @@ import MaskedIcon from "../../../react/MaskedIcon";
import SelectableCard, { SelectableCardGrid } from "../../../react/SelectableCard";
import WizardModal, { type WizardStep } from "../../../react/WizardModal";
import OptionsRow from "../components/OptionsRow";
+import { useAntigravityDownload } from "./antigravity_download";
import ModelSelection from "./ModelSelection";
import { PROVIDER_ICONS } from "./provider_icons.js";
@@ -510,7 +511,7 @@ export function prefilledBaseUrl(providerId: string): string {
* The checklist shown when a provider's models can't be listed, which is when
* the user needs setup instructions. Only the local runtimes and Google
* Antigravity have one: a hosted endpoint failing to list says nothing that
- * steps on the user's own machine would fix.
+ * steps on the user's own device would fix.
*/
function troubleshootingFor(providerType: ProviderType | undefined) {
if (providerType?.id === "antigravity-agent") {
@@ -519,8 +520,13 @@ function troubleshootingFor(providerType: ProviderType | undefined) {
return providerType?.group === "local" ? <SelfHostedTroubleshooting /> : undefined;
}
-/** How to install Google's Antigravity ACP server, which Trilium does not bundle. */
+/**
+ * How to install Google's Antigravity ACP server, which Trilium does not bundle.
+ * The first step links the archive for the device running Trilium; without
+ * one, it links the registry entry that lists them all.
+ */
function AntigravitySetup() {
+ const downloadUrl = useAntigravityDownload().url;
const components = {
Code: <code />,
// The registry entry lists the current archive for each platform.
@@ -528,7 +534,11 @@ function AntigravitySetup() {
};
return (
<ol className="model-selection-troubleshooting">
- <li><Trans i18nKey="llm.antigravity_setup_download" components={components} /></li>
+ <li>
+ {downloadUrl
+ ? <Trans i18nKey="llm.antigravity_setup_archive" components={{ Link: <a className="tn-link" href={downloadUrl} target="_blank" rel="noopener noreferrer" /> }} />
+ : <Trans i18nKey="llm.antigravity_setup_download" components={components} />}
+ </li>
<li><Trans i18nKey="llm.antigravity_setup_path" components={components} /></li>
<li><Trans i18nKey="llm.antigravity_setup_sign_in" components={components} /></li>
</ol>
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.wizard.spec.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.wizard.spec.tsx
index 9547cf8aea..c305626c21 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.wizard.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.wizard.spec.tsx
@@ -3,7 +3,14 @@ import { render } from "preact";
import { act } from "preact/test-utils";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-const mocks = vi.hoisted(() => ({ onSave: vi.fn(), onHidden: vi.fn() }));
+const mocks = vi.hoisted(() => ({
+ onSave: vi.fn(),
+ onHidden: vi.fn(),
+ /** The Antigravity download found for the device running Trilium. */
+ antigravityDownload: {} as { version?: string; url?: string }
+}));
+
+vi.mock("./antigravity_download", () => ({ useAntigravityDownload: () => mocks.antigravityDownload }));
/** Messages whose text a case depends on; every other key renders as itself. */
const MESSAGES = vi.hoisted<Record<string, string>>(() => ({
@@ -12,7 +19,14 @@ const MESSAGES = vi.hoisted<Record<string, string>>(() => ({
vi.mock("../../../../services/i18n", () => ({ t: (key: string) => MESSAGES[key] ?? key }));
-vi.mock("react-i18next", () => ({ Trans: ({ i18nKey }: { i18nKey: string }) => <>{i18nKey}</> }));
+// Renders the key, inside the `Link` component when one is passed, so links can be looked up.
+vi.mock("react-i18next", async () => {
+ const { cloneElement } = await import("preact");
+ return {
+ Trans: ({ i18nKey, components }: { i18nKey: string; components?: { Link?: preact.VNode } }) =>
+ components?.Link ? cloneElement(components.Link, {}, i18nKey) : <>{i18nKey}</>
+ };
+});
/*
* Stands in for the wizard shell, keeping only what drives it: the step being shown, and the one
@@ -64,6 +78,7 @@ afterEach(() => {
render(null, host);
document.body.innerHTML = "";
vi.clearAllMocks();
+ mocks.antigravityDownload = {};
});
function open(existingProvider?: LlmProviderConfig) {
@@ -121,6 +136,23 @@ describe("the model step", () => {
expect(modelStepFor("Ollama")?.textContent).toContain("llm.troubleshoot_server_running");
expect(modelStepFor("Claude Code")?.textContent).toBe("");
});
+
+ it("links the exact download for the device running Trilium when one was found", () => {
+ mocks.antigravityDownload = { version: "1.1.1", url: "https://dl.google.com/agy.zip" };
+
+ const step = modelStepFor("Google Antigravity");
+ const link = step?.querySelector<HTMLAnchorElement>("a[href='https://dl.google.com/agy.zip']");
+ expect(link?.textContent).toBe("llm.antigravity_setup_archive");
+ expect(link?.target).toBe("_blank");
+ expect(step?.querySelector("button")).toBeNull();
+ expect(step?.textContent).not.toContain("llm.antigravity_setup_download");
+
+ // Without one, the step links the registry entry instead.
+ mocks.antigravityDownload = {};
+ const fallback = modelStepFor("Google Antigravity");
+ expect(fallback?.querySelector("a[href*='agentclientprotocol/registry']")?.textContent).toBe("llm.antigravity_setup_download");
+ expect(fallback?.querySelector("a[href*='dl.google.com']")).toBeNull();
+ });
});
describe("picking a provider", () => {
diff --git a/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.spec.ts b/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.spec.ts
new file mode 100644
index 0000000000..70db2dbc46
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.spec.ts
@@ -0,0 +1,68 @@
+import { describe, expect, it, vi } from "vitest";
+
+import { findAntigravityDownload, registryPlatformKey } from "./antigravity_download";
+
+/** The registry's agent.json for antigravity-acp 1.1.1, trimmed to two platforms. */
+const ENTRY = {
+ id: "antigravity-acp",
+ version: "1.1.1",
+ distribution: {
+ binary: {
+ "linux-x86_64": {
+ archive: "https://dl.google.com/agy-extensions/releases/linux/agy-acp-server-agy_acp_server_1.1.1-linux-x86_64.zip",
+ cmd: "./agy_acp_server.par"
+ },
+ "windows-aarch64": {
+ archive: "https://example.com/agy_acp_server-windows-arm64.zip",
+ cmd: "./agy_acp_server.exe"
+ }
+ }
+ }
+};
+
+function respondWith(body: unknown, ok = true) {
+ return vi.fn(async () => ({ ok, status: ok ? 200 : 503, json: async () => body }) as Response);
+}
+
+describe("registryPlatformKey", () => {
+ it("names the platforms the registry lists, and nothing else", () => {
+ expect(registryPlatformKey("linux", "x64")).toBe("linux-x86_64");
+ expect(registryPlatformKey("linux", "arm64")).toBe("linux-aarch64");
+ expect(registryPlatformKey("darwin", "arm64")).toBe("darwin-aarch64");
+ expect(registryPlatformKey("win32", "x64")).toBe("windows-x86_64");
+ expect(registryPlatformKey("freebsd", "x64")).toBeUndefined();
+ expect(registryPlatformKey("linux", "ia32")).toBeUndefined();
+ // Standalone reports "web" and no architecture.
+ expect(registryPlatformKey("web", undefined)).toBeUndefined();
+ });
+});
+
+describe("findAntigravityDownload", () => {
+ it("returns the archive the registry lists for the server's platform", async () => {
+ const fetchMock = respondWith(ENTRY);
+ await expect(findAntigravityDownload("linux", "x64", fetchMock)).resolves.toEqual({
+ version: "1.1.1",
+ url: "https://dl.google.com/agy-extensions/releases/linux/agy-acp-server-agy_acp_server_1.1.1-linux-x86_64.zip"
+ });
+ expect(fetchMock).toHaveBeenCalledWith(
+ "https://raw.githubusercontent.com/agentclientprotocol/registry/main/antigravity-acp/agent.json",
+ expect.anything()
+ );
+ });
+
+ it("returns no link when there is none to trust", async () => {
+ // A platform the registry has no name for is not looked up at all.
+ const unnamed = respondWith(ENTRY);
+ await expect(findAntigravityDownload("freebsd", "x64", unnamed)).resolves.toEqual({});
+ expect(unnamed).not.toHaveBeenCalled();
+ // Google builds nothing for Intel Macs.
+ await expect(findAntigravityDownload("darwin", "x64", respondWith(ENTRY))).resolves.toEqual({});
+ // Listed, but not on Google's download host.
+ await expect(findAntigravityDownload("win32", "arm64", respondWith(ENTRY))).resolves.toEqual({});
+ // The registry is unreachable or answers with an error.
+ await expect(findAntigravityDownload("linux", "x64", vi.fn(async () => { throw new Error("offline"); }))).resolves.toEqual({});
+ await expect(findAntigravityDownload("linux", "x64", respondWith(ENTRY, false))).resolves.toEqual({});
+ // The entry changed shape.
+ await expect(findAntigravityDownload("linux", "x64", respondWith({ version: "2.0.0" }))).resolves.toEqual({});
+ });
+});
diff --git a/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.ts b/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.ts
new file mode 100644
index 0000000000..7b119a69a8
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/llm/antigravity_download.ts
@@ -0,0 +1,90 @@
+/**
+ * Finds the download of Google's Antigravity ACP server for the device running
+ * Trilium, which the setup checklist links.
+ *
+ * The archive must match the server, not the browser, so the platform and CPU
+ * come from `window.glob`, which the server fills in at startup. The archive
+ * URLs carry the version, so they are read from Google's entry in the ACP
+ * registry rather than written here.
+ */
+
+import { useEffect, useState } from "preact/hooks";
+
+/** A download of the server; empty when there is none to offer. */
+export interface AntigravityDownload {
+ version?: string;
+ url?: string;
+}
+
+/** The download for the device running Trilium, looked up once per mount. `{}` until then, and when there is none. */
+export function useAntigravityDownload(): AntigravityDownload {
+ const [ download, setDownload ] = useState<AntigravityDownload>({});
+ useEffect(() => {
+ let active = true;
+ void findAntigravityDownload(window.glob.platform, window.glob.arch).then(found => {
+ if (active) setDownload(found);
+ });
+ return () => { active = false; };
+ }, []);
+ return download;
+}
+
+/**
+ * The archive of the current release for a platform. Never rejects: without
+ * one, the checklist points at the registry entry instead.
+ */
+export async function findAntigravityDownload(
+ platform: string | undefined,
+ arch: string | undefined,
+ fetchImpl: typeof fetch = fetch
+): Promise<AntigravityDownload> {
+ const key = registryPlatformKey(platform, arch);
+ if (!key) {
+ return {};
+ }
+ try {
+ const response = await fetchImpl(REGISTRY_ENTRY_URL, { signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) });
+ if (!response.ok) {
+ return {};
+ }
+ const entry = await response.json() as RegistryEntry;
+ const archive = entry.distribution?.binary?.[key]?.archive;
+ if (typeof archive !== "string" || !isGoogleDownload(archive)) {
+ return {};
+ }
+ return { version: typeof entry.version === "string" ? entry.version : undefined, url: archive };
+ } catch {
+ return {};
+ }
+}
+
+/** The registry's name for a platform, such as `linux-x86_64`, from Node's names for it; undefined for one it does not list. */
+export function registryPlatformKey(platform: string | undefined, arch: string | undefined): string | undefined {
+ const os = platform === "linux" ? "linux" : platform === "darwin" ? "darwin" : platform === "win32" ? "windows" : undefined;
+ const cpu = arch === "x64" ? "x86_64" : arch === "arm64" ? "aarch64" : undefined;
+ return os && cpu ? `${os}-${cpu}` : undefined;
+}
+
+/** Google's entry in the ACP registry, which Google updates with each release. */
+const REGISTRY_ENTRY_URL = "https://raw.githubusercontent.com/agentclientprotocol/registry/main/antigravity-acp/agent.json";
+
+const REGISTRY_TIMEOUT_MS = 10_000;
+
+/** The part of the registry's `agent.json` that names the archives. */
+interface RegistryEntry {
+ version?: unknown;
+ distribution?: { binary?: Record<string, { archive?: unknown } | undefined> };
+}
+
+/**
+ * Whether a URL is one of Google's downloads. The registry is a third-party
+ * repository, and the checklist opens whatever link it finds there.
+ */
+function isGoogleDownload(url: string): boolean {
+ try {
+ const parsed = new URL(url);
+ return parsed.protocol === "https:" && parsed.hostname === "dl.google.com";
+ } catch {
+ return false;
+ }
+}
diff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.ts
index f6b73eb9d2..60f324efe7 100644
--- a/apps/server/src/routes/index.ts
+++ b/apps/server/src/routes/index.ts
@@ -60,6 +60,7 @@ export function bootstrap(req: Request, res: Response) {
isElectron: isElectronRenderer,
isDev,
platform: process.platform,
+ arch: process.arch,
triliumVersion: packageJson.version,
device: view,
TRILIUM_SAFE_MODE: !!process.env.TRILIUM_SAFE_MODE,
diff --git a/apps/server/src/routes/transport.spec.ts b/apps/server/src/routes/transport.spec.ts
index 4ef7263111..12aeb6b31f 100644
--- a/apps/server/src/routes/transport.spec.ts
+++ b/apps/server/src/routes/transport.spec.ts
@@ -46,6 +46,13 @@ describe("Route transport & middleware", () => {
expect(res.body.isMainWindow).toBe(false);
});
+ it("includes the server's platform and CPU architecture in the payload", async () => {
+ // The client picks the Antigravity ACP server download for the machine running Trilium.
+ const res = await supertest(app).get("/bootstrap").expect(200);
+ expect(res.body.platform).toBe(process.platform);
+ expect(res.body.arch).toBe(process.arch);
+ });
+
it("includes platform in the setup (uninitialized DB) payload", async () => {
// The setup window relies on `glob.platform` to apply the
// platform-darwin drag-region CSS on macOS.
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.ts b/apps/server/src/services/llm/providers/antigravity_agent.ts
index c7fc1df1e7..edbc465cf9 100644
--- a/apps/server/src/services/llm/providers/antigravity_agent.ts
+++ b/apps/server/src/services/llm/providers/antigravity_agent.ts
@@ -110,7 +110,7 @@ export class AntigravityAgentProvider extends AcpAgentProvider {
/**
* Open a session, signing in first when the server has no saved sign-in and
* the user is on the add-provider screen to complete it. The server opens
- * the Google sign-in page in a browser on the machine running Trilium and
+ * the Google sign-in page in a browser on the device running Trilium and
* answers `authenticate` once the user has finished there; it keeps the
* sign-in under `GEMINI_HOME`, so later sessions need none.
*/
@@ -129,10 +129,10 @@ export class AntigravityAgentProvider extends AcpAgentProvider {
protected describeFailure(error: unknown): string {
const text = describeError(error);
if (isSignInRequired(error)) {
- return "Google Antigravity is not signed in. Open this provider in the AI settings and go to the model selection, which opens the Google sign-in page in a browser on the machine running Trilium.";
+ return "Google Antigravity is not signed in. Open this provider in the AI settings and go to the model selection, which opens the Google sign-in page in a browser on the device running Trilium.";
}
if (/"authenticate" timed out/.test(text)) {
- return "The Google sign-in was not completed in time. Try again, and finish signing in in the browser window that opens on the machine running Trilium.";
+ return "The Google sign-in was not completed in time. Try again, and finish signing in in the browser window that opens on the device running Trilium.";
}
if (/ENOENT|spawn/i.test(text)) {
return `Failed to start Google's Antigravity ACP server: ${text}`;
diff --git a/packages/commons/src/lib/server_api.ts b/packages/commons/src/lib/server_api.ts
index fb217165bf..3f24aed5a4 100644
--- a/packages/commons/src/lib/server_api.ts
+++ b/packages/commons/src/lib/server_api.ts
@@ -1050,6 +1050,8 @@ export type BootstrapDefinition = {
headingStyle: "plain" | "underline" | "markdown";
layoutOrientation: "vertical" | "horizontal";
platform?: "aix" | "android" | "darwin" | "freebsd" | "haiku" | "linux" | "openbsd" | "sunos" | "win32" | "cygwin" | "netbsd" | "web";
+ /** The server's CPU architecture, as Node names it (`x64`, `arm64`, …). Absent in standalone. */
+ arch?: string;
isElectron: boolean;
isStandalone: boolean;
/**