Skip to content

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

Merge pull request #6075 from AdityaUmale/fix/mail-1a1d995a-guest-card-explain

milind-soni5cf36bfffd4f
diff --cc server/routes/bot-settings.ts
index bcd70dfbfa,00eec47d1d..8daf5beec3
--- a/server/routes/bot-settings.ts
+++ b/server/routes/bot-settings.ts
@@@ -20,7 -19,7 +20,7 @@@ import type { ModelSelectionCheck } fro
import { PASS, type RouteHandler } from "./table.ts";
import { pinnedClientThreadGuard } from "./pinned-client-thread.ts";
import { sawThread } from "../thread-presence.ts";
- import { refusalBody, userError } from "../user-errors.ts";
-import { refusalBody, refusalText } from "../user-errors.ts";
++import { refusalBody, refusalText, userError } from "../user-errors.ts";
import { readThreadNotifications, type NotificationListed } from "./notifications.ts";
export interface BotSettingsRouteDeps {
@@@ -222,17 -221,16 +222,17 @@@ export function createBotSettingsRoutes
}
// A standing grant is an approval: only those who may approve the card may remember it.
const refusal = cardAnswerRefusal(auth, bot.threadId, pending.card!.requestId!, "allow");
- if (refusal) return json(res, 403, { error: refusal });
+ if (refusal) return json(res, 403, refusalText(refusal));
- const savedBot = store.bot(bot.id)!;
- store.patchBot(bot.id, {
- alwaysAllow: [...new Set([...(savedBot.alwaysAllow ?? []), allowKey])].slice(0, 200),
- });
- store.patchTask(bot.id, bot.threadId, {
- alwaysAllow: [...new Set([...(bot.alwaysAllow ?? []), allowKey])].slice(0, 200),
- });
const live = directTurnBots.get(bot.threadId);
- if (live) live.alwaysAllow = [...new Set([...(live.alwaysAllow ?? []), allowKey])].slice(0, 200);
+ const botAllow = withAlwaysAllowKey(store.bot(bot.id)!.alwaysAllow, allowKey);
+ const taskAllow = withAlwaysAllowKey(bot.alwaysAllow, allowKey);
+ const liveAllow = live ? withAlwaysAllowKey(live.alwaysAllow, allowKey) : null;
+ if (!botAllow || !taskAllow || (live && !liveAllow)) {
+ return json(res, 400, userError("serverError.bot.alwaysAllowFull", { max: MAX_ALWAYS_ALLOW }));
+ }
+ store.patchBot(bot.id, { alwaysAllow: botAllow });
+ store.patchTask(bot.id, bot.threadId, { alwaysAllow: taskAllow });
+ if (live && liveAllow) live.alwaysAllow = liveAllow;
const updated = store.bot(bot.id)!;
const visible = wireBot(updated);
broadcast({ kind: "bot", bot: visible });