fix(agentstack): require agent DIDs for registration (#85)

This commit is contained in:
RissRIce 2026-06-22 06:24:33 -06:00 • committed by GitHub
parent 41ab662afa
commit 895bb9989e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -76,11 +76,12 @@ export class AgentStack {
return `${prefix}_${this.seq}`;
}
registerAgent(agent: AgentProfile): AgentProfile {
if (!parseDid(agent.did)) {
throw new Error(`Invalid agent DID: ${agent.did}`);
}
this.agents.set(agent.did, agent);
registerAgent(agent: AgentProfile): AgentProfile {
const parsed = parseDid(agent.did);
if (!parsed || parsed.kind !== "agent") {
throw new Error(`Invalid agent DID: ${agent.did}`);
}
this.agents.set(agent.did, agent);
this.emit({ type: "agent.registered", agent });
return agent;
}