Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Rooms: hand skill shares only when a person started the room turn

AdityaUmaleb0399509e529
diff --git a/server/agents-turn.test.ts b/server/agents-turn.test.ts
index 746ecde2b2..073197c59e 100644
--- a/server/agents-turn.test.ts
+++ b/server/agents-turn.test.ts
@@ -187,25 +187,31 @@ describe("what a turn that may not use a listed tool is told", () => {
it("lets the first answer hand shares to the bots it @mentions even when its own engine can't write skills", () => {
const claim: RoomSkillsClaim = { claimed: false };
- expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: false })).toEqual({ writes: false, hands: true, claims: true });
- expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: true })).toEqual({ writes: true, hands: true, claims: true });
- expect(roomSkillsTurn(claim, 0, "writer", { allowed: false, canWrite: true })).toEqual({ writes: false, hands: false, claims: false });
+ expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: false, personStarted: true })).toEqual({ writes: false, hands: true, claims: true });
+ expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: true, personStarted: true })).toEqual({ writes: true, hands: true, claims: true });
+ expect(roomSkillsTurn(claim, 0, "writer", { allowed: false, canWrite: true, personStarted: true })).toEqual({ writes: false, hands: false, claims: false });
handRoomSkills(claim, ["video"]);
- expect(roomSkillsTurn(claim, 1, "video", { allowed: true, canWrite: true })).toEqual({ writes: true, hands: false, claims: true });
+ expect(roomSkillsTurn(claim, 1, "video", { allowed: true, canWrite: true, personStarted: true })).toEqual({ writes: true, hands: false, claims: true });
takeRoomSkills(claim, 0, "editor", true);
- expect(roomSkillsTurn(claim, 0, "other", { allowed: true, canWrite: true })).toEqual({ writes: false, hands: false, claims: false });
+ expect(roomSkillsTurn(claim, 0, "other", { allowed: true, canWrite: true, personStarted: true })).toEqual({ writes: false, hands: false, claims: false });
+ });
+
+ it("hands no shares when no person started the room turn (the team board starts it with a bot trigger)", () => {
+ const claim: RoomSkillsClaim = { claimed: false };
+ expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: false, personStarted: false })).toEqual({ writes: false, hands: false, claims: false });
+ expect(roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: true, personStarted: false })).toEqual({ writes: true, hands: false, claims: true });
});
it("keeps the claim with a first answer that can't write skills, so a later top-level answer hands no shares", () => {
const claim: RoomSkillsClaim = { claimed: false };
- const first = roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: false });
+ const first = roomSkillsTurn(claim, 0, "writer", { allowed: true, canWrite: false, personStarted: true });
expect(first.claims).toBe(true);
takeRoomSkills(claim, 0, "writer", true);
handRoomSkills(claim, ["video"])();
- expect(roomSkillsTurn(claim, 0, "editor", { allowed: true, canWrite: true })).toEqual({ writes: false, hands: false, claims: false });
+ expect(roomSkillsTurn(claim, 0, "editor", { allowed: true, canWrite: true, personStarted: true })).toEqual({ writes: false, hands: false, claims: false });
takeRoomSkills(claim, 0, "writer", false);
- expect(roomSkillsTurn(claim, 0, "editor", { allowed: true, canWrite: true }).hands).toBe(true);
- expect(roomSkillsTurn(claim, 1, "video", { allowed: true, canWrite: true }).claims).toBe(false);
+ expect(roomSkillsTurn(claim, 0, "editor", { allowed: true, canWrite: true, personStarted: true }).hands).toBe(true);
+ expect(roomSkillsTurn(claim, 1, "video", { allowed: true, canWrite: true, personStarted: true }).claims).toBe(false);
});
it("gives the share back to a turn that never ran", () => {
diff --git a/server/agents-turn.ts b/server/agents-turn.ts
index 6e49fda84f..727daffc40 100644
--- a/server/agents-turn.ts
+++ b/server/agents-turn.ts
@@ -112,11 +112,11 @@ export function roomTurnMayWriteSkills(claim: RoomSkillsClaim, hop: number, botI
}
/** What one room turn may do with skills: `writes` its own (it may, and its engine can), `hands` a share to each bot it
- * @mentions (the first answer, even when its own engine can't write skills), and `claims` its turn: it takes the claim once
+ * @mentions (the first answer to a person's message, even when its own engine can't write skills), and `claims` its turn: it takes the claim once
* set up, and gives it back if it never ran, whenever it writes or hands, so no later first answer can hand shares again. */
-export function roomSkillsTurn(claim: RoomSkillsClaim, hop: number, botId: string, { allowed, canWrite }: { allowed: boolean; canWrite: boolean }): { writes: boolean; hands: boolean; claims: boolean } {
+export function roomSkillsTurn(claim: RoomSkillsClaim, hop: number, botId: string, { allowed, canWrite, personStarted }: { allowed: boolean; canWrite: boolean; personStarted: boolean }): { writes: boolean; hands: boolean; claims: boolean } {
const may = allowed && roomTurnMayWriteSkills(claim, hop, botId);
- const writes = may && canWrite, hands = may && hop === 0;
+ const writes = may && canWrite, hands = may && hop === 0 && personStarted;
return { writes, hands, claims: writes || hands };
}
diff --git a/server/index.ts b/server/index.ts
index d8d78b2791..92594d1b9e 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -9591,7 +9591,7 @@ async function runClaimedGroupMemberTurn(
assertWithinBudget(cfg, DATA_DIR); if (!operation?.continuesRun) usageCapGate.assertTurn(bot.id, personWaitingInRoom(operation, routineTriggerOf(threadId)), threadLanguage(threadId));
assertModelVariantSupported(turnSelection, instance.adapter.capabilities);
const integrations: NonNullable<Parameters<typeof instance.adapter.sendTurn>[0]["integrations"]> = {};
- const roomSkills = roomSkillsTurn(skillAuthoringClaim, hop, bot.id, { allowed: skillAuthoringEnabled(cfg) && !cardContinuation, canWrite: instance.adapter.capabilities.agentsMcp === true });
+ const roomSkills = roomSkillsTurn(skillAuthoringClaim, hop, bot.id, { allowed: skillAuthoringEnabled(cfg) && !cardContinuation, canWrite: instance.adapter.capabilities.agentsMcp === true, personStarted: operation?.personStarted === true });
const skillAuthoring = roomSkills.writes;
if (instance.adapter.capabilities.agentsMcp === true) {
integrations.agents = agentsIntegration(bot.id, threadId, hop, skillAuthoring, internalGeneration, orchestration?.roomHandoffId, supportsWorkspaceFiles(instance.driverKind));