import type { AgentProfile } from '../types' import { getConfig } from '../config' export function networkScore( agent: AgentProfile, getAgent: (addr: string) => AgentProfile | undefined ): number { if (!getConfig().networkScore?.enabled) return 0 const known = agent.counterparties .map(addr => getAgent(addr)) .filter((a): a is AgentProfile => a !== undefined) if (known.length === 0) return 0 const avg = known.reduce((sum, a) => sum + a.trustScore, 0) / known.length return Math.min(5, avg / 20) }