From c06e42eec41a1eeb9804c2168866b45e15e5e3b4 Mon Sep 17 00:00:00 2001 From: Jeremy McSpadden Date: Wed, 25 Mar 2026 19:39:09 -0500 Subject: [PATCH] fix(remote-questions): use static ESM import for AuthStorage hydration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hydrateRemoteTokensFromAuth() function used require() to load AuthStorage from @gsd/pi-coding-agent, but the package is ESM-only ("type": "module" with only an "import" export condition). Node's require() always throws for ESM packages, and the outer try/catch silently swallowed the error — making hydration a no-op. Replace require() with a static ESM import (consistent with every other extension) and use AuthStorage.create() which resolves the auth.json path internally via getAgentDir(). Closes #2565 --- src/resources/extensions/remote-questions/config.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/resources/extensions/remote-questions/config.ts b/src/resources/extensions/remote-questions/config.ts index 7aa95fa3e..b0f4e3138 100644 --- a/src/resources/extensions/remote-questions/config.ts +++ b/src/resources/extensions/remote-questions/config.ts @@ -2,7 +2,7 @@ * Remote Questions — configuration resolution and validation */ -import { join } from "node:path"; +import { AuthStorage } from "@gsd/pi-coding-agent"; import { loadEffectiveGSDPreferences, type RemoteQuestionsConfig } from "../gsd/preferences.js"; import type { RemoteChannel } from "./types.js"; @@ -54,9 +54,7 @@ function hydrateRemoteTokensFromAuth(): void { if (needed.length === 0) return; try { - const { AuthStorage } = require("@gsd/pi-coding-agent") as typeof import("@gsd/pi-coding-agent"); - const authPath = join(process.env.HOME ?? "~", ".gsd", "agent", "auth.json"); - const auth = AuthStorage.create(authPath); + const auth = AuthStorage.create(); for (const [providerId, envVar] of needed) { try { @@ -72,7 +70,7 @@ function hydrateRemoteTokensFromAuth(): void { } } } catch { - // AuthStorage unavailable (unit tests, stripped build) — skip silently. + // AuthStorage unavailable or auth.json missing/unreadable — skip silently. } }