mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:38:26 +00:00
chore: update deps and pi model discovery
This commit is contained in:
@@ -68,8 +68,9 @@ export async function applyAuthChoiceOAuth(
|
||||
});
|
||||
|
||||
spin.stop("Chutes OAuth complete");
|
||||
const email = typeof creds.email === "string" ? creds.email.trim() : "";
|
||||
const profileId = `chutes:${email || "default"}`;
|
||||
const email =
|
||||
typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default";
|
||||
const profileId = `chutes:${email}`;
|
||||
|
||||
await writeOAuthCredentials("chutes", creds, params.agentDir);
|
||||
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||
|
||||
@@ -58,9 +58,9 @@ vi.mock("../agents/model-auth.js", () => ({
|
||||
getCustomProviderApiKey,
|
||||
}));
|
||||
|
||||
vi.mock("@mariozechner/pi-coding-agent", () => ({
|
||||
AuthStorage,
|
||||
ModelRegistry,
|
||||
vi.mock("../agents/pi-model-discovery.js", () => ({
|
||||
discoverAuthStorage,
|
||||
discoverModels,
|
||||
}));
|
||||
|
||||
function makeRuntime() {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { join } from "node:path";
|
||||
|
||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||
import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js";
|
||||
|
||||
import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js";
|
||||
import type { AuthProfileStore } from "../../agents/auth-profiles.js";
|
||||
@@ -43,8 +41,8 @@ const hasAuthForProvider = (provider: string, cfg: OpenClawConfig, authStore: Au
|
||||
export async function loadModelRegistry(cfg: OpenClawConfig) {
|
||||
await ensureOpenClawModelsJson(cfg);
|
||||
const agentDir = resolveOpenClawAgentDir();
|
||||
const authStorage = new AuthStorage(join(agentDir, "auth.json"));
|
||||
const registry = new ModelRegistry(authStorage, join(agentDir, "models.json"));
|
||||
const authStorage = discoverAuthStorage(agentDir);
|
||||
const registry = discoverModels(authStorage, agentDir);
|
||||
const models = registry.getAll() as Model<Api>[];
|
||||
const availableModels = registry.getAvailable() as Model<Api>[];
|
||||
const availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
|
||||
|
||||
@@ -9,10 +9,10 @@ export async function writeOAuthCredentials(
|
||||
creds: OAuthCredentials,
|
||||
agentDir?: string,
|
||||
): Promise<void> {
|
||||
// Write to resolved agent dir so gateway finds credentials on startup.
|
||||
const email = typeof creds.email === "string" ? creds.email.trim() : "";
|
||||
const email =
|
||||
typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default";
|
||||
upsertAuthProfile({
|
||||
profileId: `${provider}:${email || "default"}`,
|
||||
profileId: `${provider}:${email}`,
|
||||
credential: {
|
||||
type: "oauth",
|
||||
provider,
|
||||
|
||||
Reference in New Issue
Block a user