feat: add providers CLI and multi-account onboarding

This commit is contained in:
Peter Steinberger
2026-01-08 01:18:37 +01:00
parent 6b3ed40d0f
commit 05b8679c8b
54 changed files with 4399 additions and 1448 deletions

View File

@@ -322,17 +322,18 @@ function buildProviderBindings(params: {
agentId: string;
selection: ProviderChoice[];
config: ClawdbotConfig;
whatsappAccountId?: string;
accountIds?: Partial<Record<ProviderChoice, string>>;
}): AgentBinding[] {
const bindings: AgentBinding[] = [];
const agentId = normalizeAgentId(params.agentId);
for (const provider of params.selection) {
const match: AgentBinding["match"] = { provider };
if (provider === "whatsapp") {
const accountId =
params.whatsappAccountId?.trim() ||
resolveDefaultWhatsAppAccountId(params.config);
match.accountId = accountId || DEFAULT_ACCOUNT_ID;
const accountId = params.accountIds?.[provider]?.trim();
if (accountId) {
match.accountId = accountId;
} else if (provider === "whatsapp") {
const defaultId = resolveDefaultWhatsAppAccountId(params.config);
match.accountId = defaultId || DEFAULT_ACCOUNT_ID;
}
bindings.push({ agentId, match });
}
@@ -493,15 +494,15 @@ export async function agentsAddCommand(
});
let selection: ProviderChoice[] = [];
let whatsappAccountId: string | undefined;
const providerAccountIds: Partial<Record<ProviderChoice, string>> = {};
nextConfig = await setupProviders(nextConfig, runtime, prompter, {
allowSignalInstall: true,
onSelection: (value) => {
selection = value;
},
promptWhatsAppAccountId: true,
onWhatsAppAccountId: (value) => {
whatsappAccountId = value;
promptAccountIds: true,
onAccountId: (provider, accountId) => {
providerAccountIds[provider] = accountId;
},
});
@@ -516,7 +517,7 @@ export async function agentsAddCommand(
agentId,
selection,
config: nextConfig,
whatsappAccountId,
accountIds: providerAccountIds,
});
const result = applyAgentBindings(nextConfig, desiredBindings);
nextConfig = result.config;