fix: write auth profiles to multi-agent path during onboarding

- Onboarding now writes auth profiles under ~/.clawdbot/agents/main/agent so the gateway sees credentials on first start.
- Hardened onboarding test to ignore legacy env vars.

Thanks @minghinmatthewlam!
This commit is contained in:
minghinmatthewlam
2026-01-06 15:53:18 -05:00
committed by GitHub
parent c7ffa28980
commit 2dd6b3aeb2
4 changed files with 29 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import type { OAuthCredentials, OAuthProvider } from "@mariozechner/pi-ai";
import { resolveDefaultAgentDir } from "../agents/agent-scope.js";
import { upsertAuthProfile } from "../agents/auth-profiles.js";
import type { ClawdbotConfig } from "../config/config.js";
@@ -6,6 +7,8 @@ export async function writeOAuthCredentials(
provider: OAuthProvider,
creds: OAuthCredentials,
): Promise<void> {
// Write to the multi-agent path so gateway finds credentials on startup
const agentDir = resolveDefaultAgentDir();
upsertAuthProfile({
profileId: `${provider}:${creds.email ?? "default"}`,
credential: {
@@ -13,10 +16,13 @@ export async function writeOAuthCredentials(
provider,
...creds,
},
agentDir,
});
}
export async function setAnthropicApiKey(key: string) {
// Write to the multi-agent path so gateway finds credentials on startup
const agentDir = resolveDefaultAgentDir();
upsertAuthProfile({
profileId: "anthropic:default",
credential: {
@@ -24,6 +30,7 @@ export async function setAnthropicApiKey(key: string) {
provider: "anthropic",
key,
},
agentDir,
});
}