mirror of https://github.com/openclaw/openclaw.git
fix(auth): lazy-load provider oauth helpers
This commit is contained in:
parent
6ebcd853be
commit
91d37ccfc3
|
|
@ -5,7 +5,6 @@ import type {
|
|||
} from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { buildOauthProviderAuthResult } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { fetchGeminiUsage } from "openclaw/plugin-sdk/provider-usage";
|
||||
import { loginGeminiCliOAuth } from "./oauth.js";
|
||||
import { isModernGoogleModel, resolveGoogle31ForwardCompatModel } from "./provider-models.js";
|
||||
|
||||
const PROVIDER_ID = "google-gemini-cli";
|
||||
|
|
@ -82,6 +81,7 @@ export function registerGoogleGeminiCliProvider(api: OpenClawPluginApi) {
|
|||
|
||||
const spin = ctx.prompter.progress("Starting Gemini CLI OAuth…");
|
||||
try {
|
||||
const { loginGeminiCliOAuth } = await import("./oauth.runtime.js");
|
||||
const result = await loginGeminiCliOAuth({
|
||||
isRemote: ctx.isRemote,
|
||||
openUrl: ctx.openUrl,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export { loginGeminiCliOAuth } from "./oauth.js";
|
||||
|
|
@ -16,7 +16,7 @@ import {
|
|||
minimaxMediaUnderstandingProvider,
|
||||
minimaxPortalMediaUnderstandingProvider,
|
||||
} from "./media-understanding-provider.js";
|
||||
import { loginMiniMaxPortalOAuth, type MiniMaxRegion } from "./oauth.js";
|
||||
import type { MiniMaxRegion } from "./oauth.js";
|
||||
import { applyMinimaxApiConfig, applyMinimaxApiConfigCn } from "./onboard.js";
|
||||
import { buildMinimaxPortalProvider, buildMinimaxProvider } from "./provider-catalog.js";
|
||||
|
||||
|
|
@ -97,6 +97,7 @@ function createOAuthHandler(region: MiniMaxRegion) {
|
|||
return async (ctx: ProviderAuthContext): Promise<ProviderAuthResult> => {
|
||||
const progress = ctx.prompter.progress(`Starting MiniMax OAuth (${regionLabel})…`);
|
||||
try {
|
||||
const { loginMiniMaxPortalOAuth } = await import("./oauth.runtime.js");
|
||||
const result = await loginMiniMaxPortalOAuth({
|
||||
openUrl: ctx.openUrl,
|
||||
note: ctx.prompter.note,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export { loginMiniMaxPortalOAuth } from "./oauth.js";
|
||||
|
|
@ -0,0 +1 @@
|
|||
export { getOAuthApiKey } from "@mariozechner/pi-ai/oauth";
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import { getOAuthApiKey } from "@mariozechner/pi-ai/oauth";
|
||||
import type {
|
||||
ProviderAuthContext,
|
||||
ProviderResolveDynamicModelContext,
|
||||
|
|
@ -142,6 +141,7 @@ function resolveCodexForwardCompatModel(
|
|||
|
||||
async function refreshOpenAICodexOAuthCredential(cred: OAuthCredential) {
|
||||
try {
|
||||
const { getOAuthApiKey } = await import("./openai-codex-provider.runtime.js");
|
||||
const refreshed = await getOAuthApiKey("openai-codex", {
|
||||
"openai-codex": cred,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ensureAuthProfileStore, listProfilesForProvider } from "openclaw/plugin-sdk/agent-runtime";
|
||||
import { QWEN_OAUTH_MARKER } from "openclaw/plugin-sdk/agent-runtime";
|
||||
import { loginQwenPortalOAuth } from "./oauth.js";
|
||||
import { buildQwenPortalProvider, QWEN_PORTAL_BASE_URL } from "./provider-catalog.js";
|
||||
import {
|
||||
buildOauthProviderAuthResult,
|
||||
|
|
@ -77,6 +76,7 @@ export default definePluginEntry({
|
|||
run: async (ctx: ProviderAuthContext) => {
|
||||
const progress = ctx.prompter.progress("Starting Qwen OAuth…");
|
||||
try {
|
||||
const { loginQwenPortalOAuth } = await import("./oauth.runtime.js");
|
||||
const result = await loginQwenPortalOAuth({
|
||||
openUrl: ctx.openUrl,
|
||||
note: ctx.prompter.note,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export { loginQwenPortalOAuth } from "./oauth.js";
|
||||
|
|
@ -18,11 +18,25 @@ export type TelegramBotDeps = {
|
|||
};
|
||||
|
||||
export const defaultTelegramBotDeps: TelegramBotDeps = {
|
||||
loadConfig,
|
||||
resolveStorePath,
|
||||
readChannelAllowFromStore,
|
||||
enqueueSystemEvent,
|
||||
dispatchReplyWithBufferedBlockDispatcher,
|
||||
listSkillCommandsForAgents,
|
||||
wasSentByBot,
|
||||
get loadConfig() {
|
||||
return loadConfig;
|
||||
},
|
||||
get resolveStorePath() {
|
||||
return resolveStorePath;
|
||||
},
|
||||
get readChannelAllowFromStore() {
|
||||
return readChannelAllowFromStore;
|
||||
},
|
||||
get enqueueSystemEvent() {
|
||||
return enqueueSystemEvent;
|
||||
},
|
||||
get dispatchReplyWithBufferedBlockDispatcher() {
|
||||
return dispatchReplyWithBufferedBlockDispatcher;
|
||||
},
|
||||
get listSkillCommandsForAgents() {
|
||||
return listSkillCommandsForAgents;
|
||||
},
|
||||
get wasSentByBot() {
|
||||
return wasSentByBot;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export { loginChutes } from "../commands/chutes-oauth.js";
|
||||
export { loginOpenAICodexOAuth } from "../plugins/provider-openai-codex-oauth.js";
|
||||
export { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js";
|
||||
|
|
@ -1,5 +1,16 @@
|
|||
// Public interactive auth/login helpers for provider plugins.
|
||||
|
||||
export { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js";
|
||||
export { loginChutes } from "../commands/chutes-oauth.js";
|
||||
export { loginOpenAICodexOAuth } from "../plugins/provider-openai-codex-oauth.js";
|
||||
import { createLazyRuntimeMethodBinder, createLazyRuntimeModule } from "../shared/lazy-runtime.js";
|
||||
|
||||
const loadProviderAuthLoginRuntime = createLazyRuntimeModule(
|
||||
() => import("./provider-auth-login.runtime.js"),
|
||||
);
|
||||
const bindProviderAuthLoginRuntime = createLazyRuntimeMethodBinder(loadProviderAuthLoginRuntime);
|
||||
|
||||
export const githubCopilotLoginCommand = bindProviderAuthLoginRuntime(
|
||||
(runtime) => runtime.githubCopilotLoginCommand,
|
||||
);
|
||||
export const loginChutes = bindProviderAuthLoginRuntime((runtime) => runtime.loginChutes);
|
||||
export const loginOpenAICodexOAuth = bindProviderAuthLoginRuntime(
|
||||
(runtime) => runtime.loginOpenAICodexOAuth,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -535,7 +535,12 @@ function recordPluginError(params: {
|
|||
logPrefix: string;
|
||||
diagnosticMessagePrefix: string;
|
||||
}) {
|
||||
const errorText = String(params.error);
|
||||
const errorText =
|
||||
process.env.OPENCLAW_PLUGIN_LOADER_DEBUG_STACKS === "1" &&
|
||||
params.error instanceof Error &&
|
||||
typeof params.error.stack === "string"
|
||||
? params.error.stack
|
||||
: String(params.error);
|
||||
const deprecatedApiHint =
|
||||
errorText.includes("api.registerHttpHandler") && errorText.includes("is not a function")
|
||||
? "deprecated api.registerHttpHandler(...) was removed; use api.registerHttpRoute(...) for plugin-owned routes or registerPluginHttpRoute(...) for dynamic lifecycle routes"
|
||||
|
|
|
|||
Loading…
Reference in New Issue