INNER CODE UNIT · TypeScript
getHumanCount
Beever-AI/beever-atlas · bot/src/index.ts:313
async function getHumanCount(thread: ThreadForParticipants): Promise<number | undefined> {
const cached = participantCache.get(thread.id);
if (cached !== undefined) return cached;
try {
const participants = await thread.getParticipants();
// Count only humans — exclude self and other bots so a single human + a
// helper bot doesn't trip the multi-human "go quiet" threshold.
const humanCount = participants.filter((p) => p.isMe !== true && p.isBot !== true).length;
participantCache.set(thread.id, humanCount);
return humanCount;
} catch (err) {
console.error("getParticipants failed; defaulting to answer:", safeErrorMessage(err));
return undefined;
}
}
/** Ask the backend and post the rendered reply, swallowing errors into a friendly notice. */
export async function answerInThread(