feat: add ZAI auth choice

This commit is contained in:
Peter Steinberger
2026-01-10 16:32:21 +01:00
parent 8b47368167
commit 41c8bdfada
11 changed files with 156 additions and 2 deletions

View File

@@ -134,6 +134,51 @@ export async function setMinimaxApiKey(key: string, agentDir?: string) {
});
}
export const ZAI_DEFAULT_MODEL_REF = "zai/glm-4.7";
export async function setZaiApiKey(key: string, agentDir?: string) {
// Write to the multi-agent path so gateway finds credentials on startup
upsertAuthProfile({
profileId: "zai:default",
credential: {
type: "api_key",
provider: "zai",
key,
},
agentDir: agentDir ?? resolveDefaultAgentDir(),
});
}
export function applyZaiConfig(cfg: ClawdbotConfig): ClawdbotConfig {
const models = { ...cfg.agents?.defaults?.models };
models[ZAI_DEFAULT_MODEL_REF] = {
...models[ZAI_DEFAULT_MODEL_REF],
alias: models[ZAI_DEFAULT_MODEL_REF]?.alias ?? "GLM",
};
const existingModel = cfg.agents?.defaults?.model;
return {
...cfg,
agents: {
...cfg.agents,
defaults: {
...cfg.agents?.defaults,
models,
model: {
...(existingModel &&
"fallbacks" in (existingModel as Record<string, unknown>)
? {
fallbacks: (existingModel as { fallbacks?: string[] })
.fallbacks,
}
: undefined),
primary: ZAI_DEFAULT_MODEL_REF,
},
},
},
};
}
export function applyAuthProfileConfig(
cfg: ClawdbotConfig,
params: {