mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:31:24 +00:00
fix: align embedded agent session setup
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { getOAuthApiKey, type OAuthCredentials } from "@mariozechner/pi-ai";
|
||||
import {
|
||||
getOAuthApiKey,
|
||||
getOAuthProviders,
|
||||
type OAuthCredentials,
|
||||
type OAuthProvider,
|
||||
} from "@mariozechner/pi-ai";
|
||||
import lockfile from "proper-lockfile";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { AuthProfileStore } from "./types.js";
|
||||
@@ -10,6 +15,11 @@ import { ensureAuthStoreFile, resolveAuthStorePath } from "./paths.js";
|
||||
import { suggestOAuthProfileIdForLegacyDefault } from "./repair.js";
|
||||
import { ensureAuthProfileStore, saveAuthProfileStore } from "./store.js";
|
||||
|
||||
const OAUTH_PROVIDER_IDS = new Set(getOAuthProviders().map((provider) => provider.id));
|
||||
|
||||
const resolveOAuthProvider = (provider: string): OAuthProvider | null =>
|
||||
OAUTH_PROVIDER_IDS.has(provider as OAuthProvider) ? (provider as OAuthProvider) : null;
|
||||
|
||||
function buildOAuthApiKey(provider: string, credentials: OAuthCredentials): string {
|
||||
const needsProjectId = provider === "google-gemini-cli" || provider === "google-antigravity";
|
||||
return needsProjectId
|
||||
@@ -63,7 +73,13 @@ async function refreshOAuthTokenWithLock(params: {
|
||||
const newCredentials = await refreshQwenPortalCredentials(cred);
|
||||
return { apiKey: newCredentials.access, newCredentials };
|
||||
})()
|
||||
: await getOAuthApiKey(cred.provider, oauthCreds);
|
||||
: await (async () => {
|
||||
const oauthProvider = resolveOAuthProvider(cred.provider);
|
||||
if (!oauthProvider) {
|
||||
return null;
|
||||
}
|
||||
return await getOAuthApiKey(oauthProvider, oauthCreds);
|
||||
})();
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user