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 23381d89a05..0da54a5ddbf 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,13 +17,17 @@ const { getOAuthApiKeyMock } = vi.hoisted(() => ({ }), })); -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 - ], -})); +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 + ], + }; +}); function createExpiredOauthStore(params: { profileId: string; diff --git a/src/agents/auth-profiles/oauth.ts b/src/agents/auth-profiles/oauth.ts index edc1ddfb24e..6f2061501b6 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/oauth"; +} from "@mariozechner/pi-ai"; 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 e3ef243b429..768818e46a4 100644 --- a/src/agents/pi-embedded-runner/compact.hooks.test.ts +++ b/src/agents/pi-embedded-runner/compact.hooks.test.ts @@ -86,11 +86,6 @@ 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 99d3a9e4b39..146eb943c49 100644 --- a/src/agents/pi-tools.workspace-only-false.test.ts +++ b/src/agents/pi-tools.workspace-only-false.test.ts @@ -7,14 +7,11 @@ 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 43f1ac41f8a..aa2a2d8f661 100644 --- a/src/commands/openai-codex-oauth.test.ts +++ b/src/commands/openai-codex-oauth.test.ts @@ -9,9 +9,13 @@ const mocks = vi.hoisted(() => ({ formatOpenAIOAuthTlsPreflightFix: vi.fn(), })); -vi.mock("@mariozechner/pi-ai/oauth", () => ({ - loginOpenAICodex: mocks.loginOpenAICodex, -})); +vi.mock("@mariozechner/pi-ai", async (importOriginal) => { + const original = await importOriginal(); + return { + ...original, + 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 a868217750b..a8881bf0971 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/oauth"; +import { loginOpenAICodex, type OAuthCredentials } from "@mariozechner/pi-ai"; 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 eedc325fd4f..0ff3995ca97 100644 --- a/src/tts/tts.test.ts +++ b/src/tts/tts.test.ts @@ -12,14 +12,11 @@ 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: {