mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Limit DM task inference to one agent participant
This commit is contained in:
@@ -104,6 +104,18 @@ test("DM task agent inference requires exactly one other known agent", () => {
|
||||
[],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getDmTaskAgentPubkeys({
|
||||
channel: channel({
|
||||
channelType: "dm",
|
||||
participantPubkeys: ["human", "agent-one", "human-two"],
|
||||
}),
|
||||
currentPubkey: "human",
|
||||
knownAgentPubkeys,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
getDmTaskAgentPubkeys({
|
||||
channel: channel({
|
||||
|
||||
@@ -110,15 +110,22 @@ export function getDmTaskAgentPubkeys({
|
||||
const normalizedCurrentPubkey = currentPubkey
|
||||
? normalizePubkey(currentPubkey)
|
||||
: null;
|
||||
const otherParticipants = new Map<string, string>();
|
||||
|
||||
return singleKnownAgentPubkey(
|
||||
channel.participantPubkeys.filter(
|
||||
(pubkey) =>
|
||||
!normalizedCurrentPubkey ||
|
||||
normalizePubkey(pubkey) !== normalizedCurrentPubkey,
|
||||
),
|
||||
knownAgentPubkeys,
|
||||
);
|
||||
for (const pubkey of channel.participantPubkeys) {
|
||||
const normalized = normalizePubkey(pubkey);
|
||||
if (normalizedCurrentPubkey && normalized === normalizedCurrentPubkey) {
|
||||
continue;
|
||||
}
|
||||
|
||||
otherParticipants.set(normalized, pubkey);
|
||||
}
|
||||
|
||||
if (otherParticipants.size !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return singleKnownAgentPubkey(otherParticipants.values(), knownAgentPubkeys);
|
||||
}
|
||||
|
||||
export function getThreadTaskAgentPubkeys({
|
||||
|
||||
Reference in New Issue
Block a user