mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 11:30:41 +00:00
refactor: dedupe agent list filtering
This commit is contained in:
@@ -41,12 +41,12 @@ function normalizeAgentId(value: string | undefined | null): string {
|
||||
|
||||
type AgentEntry = NonNullable<NonNullable<OpenClawConfig["agents"]>["list"]>[number];
|
||||
|
||||
function isAgentEntry(entry: unknown): entry is AgentEntry {
|
||||
return Boolean(entry && typeof entry === "object");
|
||||
}
|
||||
|
||||
function listAgents(cfg: OpenClawConfig): AgentEntry[] {
|
||||
const list = cfg.agents?.list;
|
||||
if (!Array.isArray(list)) {
|
||||
return [];
|
||||
}
|
||||
return list.filter((entry): entry is AgentEntry => Boolean(entry && typeof entry === "object"));
|
||||
return Array.isArray(cfg.agents?.list) ? cfg.agents.list.filter(isAgentEntry) : [];
|
||||
}
|
||||
|
||||
function resolveAgentEntry(cfg: OpenClawConfig, agentId: string): AgentEntry | undefined {
|
||||
|
||||
Reference in New Issue
Block a user