Skip to content

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

Merge pull request #5142 from AdityaUmale/fix/mail-1a1bca40-changed-routine-message

milind-soni56a1f4f7ed8f
diff --cc server/host/cloud-lending-turns.ts
index 8164ca2c5a,0231adc648..8a87399e26
--- a/server/host/cloud-lending-turns.ts
+++ b/server/host/cloud-lending-turns.ts
@@@ -1,7 -1,7 +1,7 @@@
// Which turns on a Cloud home may use the Mac lent to it, read from the harness's own records (server/cloud-lending.ts
// decides), and the plain words a turn that can't is told. A room member turn acts for the person's line that started
// its run, for that turn generation alone, while the run lasts.
- import { answersOwnersLine, cloudHomeLendingRefusal, cloudHomeOwnTurnRefusal, cloudLendingRefusalText, handedOnForOwner, ON_THE_CARD, ONLY_THE_PERSON, teamLendingRefusal, type CloudLendingRefusal, type CloudLendingTurn } from "../cloud-lending.ts";
-import { answersOwnersLine, changedRoutineRefusalText, cloudHomeLendingRefusal, cloudLendingRefusalText, ON_THE_CARD, ONLY_THE_PERSON, teamLendingRefusal, type CloudLendingRefusal, type CloudLendingTurn } from "../cloud-lending.ts";
++import { answersOwnersLine, changedRoutineRefusalText, cloudHomeLendingRefusal, cloudHomeOwnTurnRefusal, cloudLendingRefusalText, handedOnForOwner, ON_THE_CARD, ONLY_THE_PERSON, teamLendingRefusal, type CloudLendingRefusal, type CloudLendingTurn } from "../cloud-lending.ts";
import { unstamped } from "../cloud-owner-lines.ts";
import { deviceWord } from "../lent-computers.ts";
import type { Routine, RoutineManager, RoutineRun } from "../routines.ts";
@@@ -127,11 -128,18 +129,23 @@@ export function createCloudLendingTurns
return conversation;
}
+ /** What the owner's phones take: every gate, with work handed on for the owner not counting as the owner's. */
+ function cloudOwnTurnRefusal(capability: Turn): CloudLendingRefusal | "memory-changed" | null {
+ return deps.memoryChangedBySomeoneElse(capability.botId) ? "memory-changed" : conversationGate(capability, cloudHomeOwnTurnRefusal);
+ }
+
+ /** The name of the routine this turn runs, when the run is refused only because the routine is no longer the owner's
+ * (someone else changed it); a webhook's or another app's run, or one somebody else started by hand, is not this. */
+ function changedRoutine(capability: Turn): string | undefined {
+ const turn = cloudLendingTurn(capability);
+ const automation = turn.request?.automation;
+ if (automation === undefined || automation === "webhook" || automation === "api") return undefined;
+ const run = turn.routineRun();
+ if (!run || run.ownerAuthored || run.triggerSource === "webhook" || run.triggerSource === "api" || (run.triggerSource === "manual" && !run.ownerStarted)) return undefined;
+ const routineId = deps.activeRoutineRun(capability.threadId)?.routineId;
+ return deps.routines()?.listRoutines().find((routine) => routine.id === routineId)?.name;
+ }
+
/** A bot opened this conversation (a hand-off's work thread, one a bot started itself, a Chief's notices). */
function cloudBotOpened(threadId: string): boolean {
const bot = store.botByThread(threadId);