diff --git a/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts b/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts index 0da54a5ddbf..23381d89a05 100644 --- a/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts +++ b/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts @@ -17,17 +17,13 @@ const { getOAuthApiKeyMock } = vi.hoisted(() => ({ }), })); -vi.mock("@mariozechner/pi-ai", async (importOriginal) => { - const original = await importOriginal(); - return { - ...original, - getOAuthApiKey: getOAuthApiKeyMock, - getOAuthProviders: () => [ - { id: "openai-codex", envApiKey: "OPENAI_API_KEY", oauthTokenEnv: "OPENAI_OAUTH_TOKEN" }, // pragma: allowlist secret - { id: "anthropic", envApiKey: "ANTHROPIC_API_KEY", oauthTokenEnv: "ANTHROPIC_OAUTH_TOKEN" }, // pragma: allowlist secret - ], - }; -}); +vi.mock("@mariozechner/pi-ai/oauth", () => ({ + getOAuthApiKey: getOAuthApiKeyMock, + getOAuthProviders: () => [ + { id: "openai-codex", envApiKey: "OPENAI_API_KEY", oauthTokenEnv: "OPENAI_OAUTH_TOKEN" }, // pragma: allowlist secret + { id: "anthropic", envApiKey: "ANTHROPIC_API_KEY", oauthTokenEnv: "ANTHROPIC_OAUTH_TOKEN" }, // pragma: allowlist secret + ], +})); function createExpiredOauthStore(params: { profileId: string; diff --git a/src/agents/auth-profiles/oauth.ts b/src/agents/auth-profiles/oauth.ts index 6f2061501b6..edc1ddfb24e 100644 --- a/src/agents/auth-profiles/oauth.ts +++ b/src/agents/auth-profiles/oauth.ts @@ -3,7 +3,7 @@ import { getOAuthProviders, type OAuthCredentials, type OAuthProvider, -} from "@mariozechner/pi-ai"; +} from "@mariozechner/pi-ai/oauth"; import { loadConfig, type OpenClawConfig } from "../../config/config.js"; import { coerceSecretRef } from "../../config/types.secrets.js"; import { withFileLock } from "../../infra/file-lock.js"; diff --git a/src/agents/pi-embedded-runner/compact.hooks.test.ts b/src/agents/pi-embedded-runner/compact.hooks.test.ts index 768818e46a4..e3ef243b429 100644 --- a/src/agents/pi-embedded-runner/compact.hooks.test.ts +++ b/src/agents/pi-embedded-runner/compact.hooks.test.ts @@ -86,6 +86,11 @@ vi.mock("../../hooks/internal-hooks.js", async () => { }; }); +vi.mock("@mariozechner/pi-ai/oauth", () => ({ + getOAuthApiKey: vi.fn(), + getOAuthProviders: vi.fn(() => []), +})); + vi.mock("@mariozechner/pi-coding-agent", () => { return { createAgentSession: vi.fn(async () => { diff --git a/src/agents/pi-tools.workspace-only-false.test.ts b/src/agents/pi-tools.workspace-only-false.test.ts index 146eb943c49..99d3a9e4b39 100644 --- a/src/agents/pi-tools.workspace-only-false.test.ts +++ b/src/agents/pi-tools.workspace-only-false.test.ts @@ -7,11 +7,14 @@ vi.mock("@mariozechner/pi-ai", async (importOriginal) => { const original = await importOriginal(); return { ...original, - getOAuthApiKey: () => undefined, - getOAuthProviders: () => [], }; }); +vi.mock("@mariozechner/pi-ai/oauth", () => ({ + getOAuthApiKey: () => undefined, + getOAuthProviders: () => [], +})); + import { createOpenClawCodingTools } from "./pi-tools.js"; describe("FS tools with workspaceOnly=false", () => { diff --git a/src/commands/openai-codex-oauth.test.ts b/src/commands/openai-codex-oauth.test.ts index aa2a2d8f661..43f1ac41f8a 100644 --- a/src/commands/openai-codex-oauth.test.ts +++ b/src/commands/openai-codex-oauth.test.ts @@ -9,13 +9,9 @@ const mocks = vi.hoisted(() => ({ formatOpenAIOAuthTlsPreflightFix: vi.fn(), })); -vi.mock("@mariozechner/pi-ai", async (importOriginal) => { - const original = await importOriginal(); - return { - ...original, - loginOpenAICodex: mocks.loginOpenAICodex, - }; -}); +vi.mock("@mariozechner/pi-ai/oauth", () => ({ + loginOpenAICodex: mocks.loginOpenAICodex, +})); vi.mock("./oauth-flow.js", () => ({ createVpsAwareOAuthHandlers: mocks.createVpsAwareOAuthHandlers, diff --git a/src/commands/openai-codex-oauth.ts b/src/commands/openai-codex-oauth.ts index a8881bf0971..a868217750b 100644 --- a/src/commands/openai-codex-oauth.ts +++ b/src/commands/openai-codex-oauth.ts @@ -1,4 +1,4 @@ -import { loginOpenAICodex, type OAuthCredentials } from "@mariozechner/pi-ai"; +import { loginOpenAICodex, type OAuthCredentials } from "@mariozechner/pi-ai/oauth"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; import { createVpsAwareOAuthHandlers } from "./oauth-flow.js"; diff --git a/src/tts/tts.test.ts b/src/tts/tts.test.ts index 0ff3995ca97..eedc325fd4f 100644 --- a/src/tts/tts.test.ts +++ b/src/tts/tts.test.ts @@ -12,11 +12,14 @@ vi.mock("@mariozechner/pi-ai", async (importOriginal) => { return { ...original, completeSimple: vi.fn(), - getOAuthProviders: () => [], - getOAuthApiKey: vi.fn(async () => null), }; }); +vi.mock("@mariozechner/pi-ai/oauth", () => ({ + getOAuthProviders: () => [], + getOAuthApiKey: vi.fn(async () => null), +})); + vi.mock("../agents/pi-embedded-runner/model.js", () => ({ resolveModel: vi.fn((provider: string, modelId: string) => ({ model: {