fix(remote-questions): use static ESM import for AuthStorage hydration
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
This commit is contained in:
parent
419a74672e
commit
c06e42eec4
1 changed files with 3 additions and 5 deletions
|
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue