Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(llm): keep Antigravity's hook request away from a configured proxy
Elian Doranfe86c5d2a312
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts b/apps/server/src/services/llm/providers/antigravity_agent.spec.tsindex 1c1421309f..d4541f04d4 100644--- a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts+++ b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts@@ -193,7 +193,7 @@ describe("AntigravityAgentProvider", () => {const hooks = JSON.parse(fs.readFileSync(path.join(home, "config", "hooks.json"), "utf8"));expect(hooks["trilium-file-access"].PreToolUse[0]).toMatchObject({matcher: ".*",- hooks: [ { command: "\"/usr/bin/curl\" --silent --show-error --fail --max-time 8 --data-binary @- http://127.0.0.1:12345/hook-secret" } ]+ hooks: [ { command: "\"/usr/bin/curl\" --silent --show-error --fail --noproxy 127.0.0.1 --max-time 8 --data-binary @- http://127.0.0.1:12345/hook-secret" } ]});const decide = getAcpHookEndpointUrlMock.mock.calls[0][0];diff --git a/apps/server/src/services/llm/providers/antigravity_hook.spec.ts b/apps/server/src/services/llm/providers/antigravity_hook.spec.tsindex 7e0937898e..32b6eabe99 100644--- a/apps/server/src/services/llm/providers/antigravity_hook.spec.ts+++ b/apps/server/src/services/llm/providers/antigravity_hook.spec.ts@@ -85,7 +85,7 @@ describe("writeAntigravityHooks", () => {describe("buildHookCommand", () => {it("posts the tool call to Trilium and fails on anything but a decision", () => {expect(buildHookCommand("C:\\Windows\\System32\\curl.exe", "http://127.0.0.1:5000/hook-abc"))- .toBe("\"C:\\Windows\\System32\\curl.exe\" --silent --show-error --fail --max-time 8 --data-binary @- http://127.0.0.1:5000/hook-abc");+ .toBe("\"C:\\Windows\\System32\\curl.exe\" --silent --show-error --fail --noproxy 127.0.0.1 --max-time 8 --data-binary @- http://127.0.0.1:5000/hook-abc");expect(() => buildHookCommand("/opt/\"odd\"/curl", "http://127.0.0.1:5000/hook-abc")).toThrow(/quote/);});});diff --git a/apps/server/src/services/llm/providers/antigravity_hook.ts b/apps/server/src/services/llm/providers/antigravity_hook.tsindex 23a7d0c266..bf77e78d13 100644--- a/apps/server/src/services/llm/providers/antigravity_hook.ts+++ b/apps/server/src/services/llm/providers/antigravity_hook.ts@@ -86,14 +86,16 @@ export function writeAntigravityHooks(home: string, command: string): void {/*** The hook command: `curl` posts the call (the hook's stdin) to Trilium and* prints the decision. `--fail` turns an error response into a failed hook,- * which the server treats as a denial. The server runs it with `sh -c`, or- * `cmd /c` on Windows; the URL holds no character either shell reads.+ * which the server treats as a denial. `--noproxy` keeps an `HTTP_PROXY`+ * from routing the loopback request away from Trilium. The server runs it+ * with `sh -c`, or `cmd /c` on Windows; the URL holds no character either+ * shell reads.*/export function buildHookCommand(curl: string, hookUrl: string): string {if (curl.includes("\"")) {throw new Error(`Cannot quote the path of curl for the Antigravity hook: ${curl}`);}- return `"${curl}" --silent --show-error --fail --max-time ${CURL_MAX_TIME_S} --data-binary @- ${hookUrl}`;+ return `"${curl}" --silent --show-error --fail --noproxy 127.0.0.1 --max-time ${CURL_MAX_TIME_S} --data-binary @- ${hookUrl}`;}/** The in-flight or successful lookup; a failed one is forgotten so a later install is found. */