Reject unknown task assignees (#80)

This commit is contained in:
phucnguyen1707 2026-06-16 17:19:08 +07:00 • committed by GitHub
parent e38688f16e
commit 41ab662afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 17 deletions

View file

@ -89,13 +89,16 @@ export class AgentStack {
return this.agents.get(did);
}
createTask(input: CreateTaskInput): DidTask {
if (!parseDid(input.ownerDid)) {
throw new Error(`Invalid owner DID: ${input.ownerDid}`);
}
const ts = this.now();
const task: DidTask = {
id: this.nextId("task"),
createTask(input: CreateTaskInput): DidTask {
if (!parseDid(input.ownerDid)) {
throw new Error(`Invalid owner DID: ${input.ownerDid}`);
}
if (input.assigneeDid && !this.agents.has(input.assigneeDid)) {
throw new Error(`Unknown agent: ${input.assigneeDid}`);
}
const ts = this.now();
const task: DidTask = {
id: this.nextId("task"),
ownerDid: input.ownerDid,
assigneeDid: input.assigneeDid,
sourceApp: input.sourceApp,