registerAgent method
Registers profile and returns its handle. Registering an already
known id returns the existing handle.
New registrations emit an AgentRegisteredEvent.
Implementation
AgentHandle registerAgent(AgentProfile profile) {
final existing = _agents[profile.id];
if (existing != null) return existing;
final handle = _createHandle(profile);
_agents[profile.id] = handle;
_logger.logDebug('Agent "${profile.id}" registered.');
_emit(AgentRegisteredEvent(agentId: profile.id));
return handle;
}