Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(brief): open Outlook emails in Outlook, not Gmail
AdityaUmale1882ffe9b7d9
diff --git a/server/connected-reads.test.ts b/server/connected-reads.test.tsindex 66824b5a70..4332fdf9c1 100644--- a/server/connected-reads.test.ts+++ b/server/connected-reads.test.ts@@ -252,14 +252,15 @@ describe("a check's reads", () => {it("reads Outlook inbox messages and single messages with preview, conversation id, and shortened-page fallback", async () => {const messages = [- { id: "o1", conversationId: "conv-1", receivedDateTime: "2026-10-22T08:00:00Z", from: { emailAddress: { name: "Ada", address: "[email protected]" } }, subject: "First", bodyPreview: "Can you review?" },+ { id: "o1", conversationId: "conv-1", receivedDateTime: "2026-10-22T08:00:00Z", from: { emailAddress: { name: "Ada", address: "[email protected]" } }, subject: "First", bodyPreview: "Can you review?", webLink: "https://outlook.office365.com/owa/?ItemID=o1" },{ id: "o2", conversationId: "conv-2", receivedDateTime: "2026-10-22T09:00:00Z", from: { emailAddress: { address: "[email protected]" } }, subject: "Second", bodyPreview: "Latest update" },];expect(outlookMessagesFromData({ value: messages }).map((m) => [m.id, m.threadId, m.from, m.preview, m.app])).toEqual([["o2", "conv-2", "[email protected]", "Latest update", "outlook"],["o1", "conv-1", "Ada <[email protected]>", "Can you review?", "outlook"],]);- expect(outlookMessageFromData(messages[0])).toMatchObject({ id: "o1", threadId: "conv-1", from: "Ada <[email protected]>", preview: "Can you review?", app: "outlook" });+ expect(outlookMessageFromData(messages[0])).toMatchObject({ id: "o1", threadId: "conv-1", from: "Ada <[email protected]>", preview: "Can you review?", app: "outlook", link: "https://outlook.office365.com/owa/?ItemID=o1" });+ expect(outlookMessageFromData(messages[1]).link).toBeUndefined();const { deps, frames } = relay({OUTLOOK_LIST_MESSAGES: (args) => {@@ -276,5 +277,8 @@ describe("a check's reads", () => {expect(frames.filter((one) => one.slug === "OUTLOOK_LIST_MESSAGES").map((one) => Number(one.args!.top))).toEqual([20, 10]);expect(await session.outlookMessage("o1")).toMatchObject({ id: "o1", app: "outlook" });expect(await session.outlookMessage("gone")).toBeNull();+ const outlookReads = frames.filter((one) => one.slug?.startsWith("OUTLOOK_"));+ expect(outlookReads.length).toBeGreaterThan(0);+ expect(outlookReads.every((one) => (one.args!.select as string[]).includes("webLink"))).toBe(true);});});diff --git a/server/connected-reads.ts b/server/connected-reads.tsindex a9fb88f71c..061743b8d8 100644--- a/server/connected-reads.ts+++ b/server/connected-reads.ts@@ -39,6 +39,8 @@ export interface EmailHeader {subject: string;preview: string;app?: MailApp;+ /** Outlook's own web address for the message. */+ link?: string;}export interface ThreadMessage {@@ -333,6 +335,7 @@ function outlookHeader(raw: unknown): EmailHeader | null {subject: flat(item.subject),preview: flat(item.bodyPreview).slice(0, PREVIEW_MAX),app: "outlook",+ ...(typeof item.webLink === "string" && item.webLink ? { link: item.webLink } : {}),};}@@ -626,7 +629,7 @@ export function createConnectedReads(deps: ConnectedReadDeps): Omit<ConnectedReafor (;;) {const data = await call(OUTLOOK_LIST_TOOL, {user_id: "me", folder: "inbox", top: size, received_date_time_ge: new Date(sinceMs).toISOString(),- select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],+ select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId", "webLink"],}, { shortened: size > GMAIL_PAGE_MIN, pin });if (data === SHORTENED) {size = Math.max(GMAIL_PAGE_MIN, Math.floor(size / 2));@@ -637,7 +640,7 @@ export function createConnectedReads(deps: ConnectedReadDeps): Omit<ConnectedRea},async outlookMessage(id) {const data = await call(OUTLOOK_MESSAGE_TOOL, {- user_id: "me", message_id: id, select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],+ user_id: "me", message_id: id, select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId", "webLink"],}, { gone: messageGone });return data === GONE ? null : parsed("outlook", () => outlookMessageFromData(data));},diff --git a/server/host/brief-cards.ts b/server/host/brief-cards.tsindex 0b205f3ac1..f54ceefd81 100644--- a/server/host/brief-cards.ts+++ b/server/host/brief-cards.ts@@ -5,7 +5,7 @@ import { inboxNoteWords } from "./inbox-words.ts";// and Caption nodes only, and a link becomes a button only when it is an https link with no username or password.import { WEB_URL_MAX, WIDGET_LIMITS, type WidgetRoot } from "../../shared/widget.ts";import type { WidgetMoment, WidgetText, WidgetTextFields } from "../../shared/widget-text.ts";-import type { CalendarEvent } from "../connected-reads.ts";+import type { CalendarEvent, MailApp } from "../connected-reads.ts";import { intlLocale } from "../language.ts";import { briefWords, type BriefWords } from "./brief-words.ts";import { localDate, validZone } from "./check-plan.ts";@@ -132,7 +132,7 @@ export const BRIEF_ROWS = 6;export const DISMISS_ACTION = "dismiss_row";export const DRAFT_ACTION = "draft_reply";-export interface BriefEmail { messageId: string; threadId: string; from: string; subject: string; why?: string; whyText?: ServerText; needsReply: boolean }+export interface BriefEmail { messageId: string; threadId: string; from: string; subject: string; why?: string; whyText?: ServerText; needsReply: boolean; app?: MailApp; link?: string }/** `page`: the live page a routine's run published; its row's Open page opens it, while Open opens the run's chat. */export interface BriefRow { text: string; note: string; open?: OpenTarget; page?: string; said?: { text?: WidgetText; note?: WidgetText } }/** A row that needs the person. `key` names what it is about in no particular language, so a new language is not news. */@@ -181,16 +181,24 @@ const section = (title: [string, string], rows: Node[], w: BriefWords, empty?: [const openButton = (target: OpenTarget | undefined, w: BriefWords): Node[] => (target ? [button(w.open, { type: "open_thread", payload: target }, false, words("brief.card.open"))] : []);const pageButton = (url: string | undefined, w: BriefWords): Node[] => { const link = httpsLink(url), open = link ? openUrl(link) : undefined; return open ? [button(w.openPage, open, false, words("brief.card.openPage"))] : []; };+function openEmailButton(email: BriefEmail, w: BriefWords): Node[] {+ if (email.app === "outlook") {+ const link = httpsLink(email.link), outlook = link ? openUrl(link) : undefined;+ return outlook ? [button(w.openInOutlook, outlook, false, words("brief.card.openOutlook"))] : [];+ }+ const gmail = email.threadId.length <= BRIEF_TEXT.link ? openUrl(gmailUrl(email.threadId)) : undefined;+ return gmail ? [button(w.openInGmail, gmail, false, words("brief.card.openGmail"))] : [];+}+function emailRow(email: BriefEmail, w: BriefWords): Node {const who = sender(email, BRIEF_TEXT.label, w);- const gmail = email.threadId.length <= BRIEF_TEXT.link ? openUrl(gmailUrl(email.threadId)) : undefined;const note = email.needsReply ? (email.why ? `${w.waitingOnReply} · ${email.why}` : w.waitingOnReply) : email.why ?? w.important;const whoWords = senderName(email.from).trim() ? who : words("brief.part.noSender");const line = words("brief.card.emailLine", { sender: senderName(email.from).trim() ? sender(email, BRIEF_TEXT.sender, w) : words("brief.part.noSender"), subject: email.subject || words("brief.part.noSubject") });const noteWords = inboxNoteWords(email.why, email.whyText, email.needsReply) ?? (email.needsReply ? (email.why ? words("brief.card.waitingReplyWhy", { why: email.why }) : words("brief.card.waitingReply")) : email.why ? undefined : words("brief.card.important"));return rowUnder(`${sender(email, BRIEF_TEXT.sender, w)}: ${email.subject || w.noSubject}`, note, [button(w.draftReply(who), { type: DRAFT_ACTION, payload: { messageId: email.messageId } }, true, words("brief.card.draftReply", { who: whoWords })),- ...(gmail ? [button(w.openInGmail, gmail, false, words("brief.card.openGmail"))] : []),+ ...openEmailButton(email, w),button(w.dismiss(who), { type: DISMISS_ACTION, payload: { messageId: email.messageId } }, false, words("brief.card.dismissEmail", { who: whoWords })),], { text: line, ...(noteWords ? { note: noteWords } : {}) });}diff --git a/server/host/brief-words.ts b/server/host/brief-words.tsindex fc9a17b8d2..c707e87fee 100644--- a/server/host/brief-words.ts+++ b/server/host/brief-words.ts@@ -17,6 +17,7 @@ export interface BriefWords {open: string;join: string;openInGmail: string;+ openInOutlook: string;draftReply: Name;dismiss: Name;waitingOnReply: string;@@ -68,6 +69,7 @@ const en: BriefWords = {open: "Open",join: "Join",openInGmail: "Open in Gmail",+ openInOutlook: "Open in Outlook",draftReply: (who) => `Draft a reply to ${who}`,dismiss: (who) => `Dismiss ${who}'s email`,waitingOnReply: "Waiting on your reply",@@ -126,6 +128,7 @@ const ptBr: BriefWords = {open: "Abrir",join: "Participar",openInGmail: "Abrir no Gmail",+ openInOutlook: "Abrir no Outlook",draftReply: (who) => `Criar rascunho de resposta para ${who}`,dismiss: (who) => `Dispensar o e-mail de ${who}`,waitingOnReply: "Aguardando sua resposta",@@ -186,6 +189,7 @@ const es: BriefWords = {open: "Abrir",join: "Unirse",openInGmail: "Abrir en Gmail",+ openInOutlook: "Abrir en Outlook",draftReply: (who) => `Redactar respuesta a ${who}`,dismiss: (who) => `Descartar el correo de ${who}`,waitingOnReply: "Espera tu respuesta",@@ -246,6 +250,7 @@ const de: BriefWords = {open: "Öffnen",join: "Beitreten",openInGmail: "In Gmail öffnen",+ openInOutlook: "In Outlook öffnen",draftReply: (who) => `Antwort an ${who} entwerfen`,dismiss: (who) => `E-Mail von ${who} ausblenden`,waitingOnReply: "Deine Antwort steht aus",@@ -306,6 +311,7 @@ const fr: BriefWords = {open: "Ouvrir",join: "Rejoindre",openInGmail: "Ouvrir dans Gmail",+ openInOutlook: "Ouvrir dans Outlook",draftReply: (who) => `Rédiger une réponse à ${who}`,dismiss: (who) => `Ignorer l’e-mail : ${who}`,waitingOnReply: "Attend votre réponse",@@ -366,6 +372,7 @@ const ja: BriefWords = {open: "開く",join: "参加",openInGmail: "Gmailで開く",+ openInOutlook: "Outlookで開く",draftReply: (who) => `${who}への返信を下書きする`,dismiss: (who) => `${who}のメールを非表示にする`,waitingOnReply: "返信待ち",@@ -424,6 +431,7 @@ const zh: BriefWords = {open: "打开",join: "加入",openInGmail: "在 Gmail 中打开",+ openInOutlook: "在 Outlook 中打开",draftReply: (who) => `给 ${who} 起草回复`,dismiss: (who) => `忽略 ${who} 的邮件`,waitingOnReply: "等待你回复",@@ -482,6 +490,7 @@ const zhTw: BriefWords = {open: "開啟",join: "加入",openInGmail: "在 Gmail 中開啟",+ openInOutlook: "在 Outlook 中開啟",draftReply: (who) => `為 ${who} 草擬回覆`,dismiss: (who) => `略過 ${who} 的郵件`,waitingOnReply: "等待你回覆",@@ -540,6 +549,7 @@ const hi: BriefWords = {open: "खोलें",join: "जुड़ें",openInGmail: "Gmail में खोलें",+ openInOutlook: "Outlook में खोलें",draftReply: (who) => `${who} को जवाब का ड्राफ़्ट बनाएँ`,dismiss: (who) => `${who} का ईमेल अनदेखा करें`,waitingOnReply: "आपके जवाब का इंतज़ार है",@@ -605,6 +615,7 @@ const uk: BriefWords = {open: "Відкрити",join: "Приєднатися",openInGmail: "Відкрити в Gmail",+ openInOutlook: "Відкрити в Outlook",draftReply: (who) => `Створити чернетку відповіді для ${who}`,dismiss: (who) => `Приховати лист: ${who}`,waitingOnReply: "Чекає на вашу відповідь",@@ -663,6 +674,7 @@ const vi: BriefWords = {open: "Mở",join: "Tham gia",openInGmail: "Mở trong Gmail",+ openInOutlook: "Mở trong Outlook",draftReply: (who) => `Soạn nháp thư trả lời ${who}`,dismiss: (who) => `Bỏ qua email của ${who}`,waitingOnReply: "Đang chờ bạn trả lời",@@ -721,6 +733,7 @@ const tr: BriefWords = {open: "Aç",join: "Katıl",openInGmail: "Gmail’de aç",+ openInOutlook: "Outlook’ta aç",draftReply: (who) => `${who} için yanıt taslağı oluştur`,dismiss: (who) => `E-postayı yoksay: ${who}`,waitingOnReply: "Yanıtını bekliyor",@@ -779,6 +792,7 @@ const ko: BriefWords = {open: "열기",join: "참여",openInGmail: "Gmail에서 열기",+ openInOutlook: "Outlook에서 열기",draftReply: (who) => `${who}에게 보낼 답장 초안 쓰기`,dismiss: (who) => `${who}의 이메일 닫기`,waitingOnReply: "답장을 기다리는 중",diff --git a/server/host/brief.test.ts b/server/host/brief.test.tsindex 4cbd86f917..de361574f8 100644--- a/server/host/brief.test.ts+++ b/server/host/brief.test.ts@@ -388,4 +388,16 @@ describe("the brief", () => {expect(records).toContain("[Records from Outlook.");expect(records).toContain("Outlook draft");});++ it("opens an Outlook email in Outlook, never in Gmail", async () => {+ const s = setup();+ await s.brief.active("desktop", "UTC");+ const webLink = "https://outlook.live.com/owa/?ItemID=o1&exvsurl=1&viewmodel=ReadMessageItem";+ const linked: EmailHeader = { id: "o1", threadId: "conv-1", at: s.now() - 5 * MINUTE, from: "Bob <[email protected]>", subject: "Invoice", preview: "Due Friday", app: "outlook", link: webLink };+ const unlinked: EmailHeader = { id: "o2", threadId: "conv-2", at: s.now() - 5 * MINUTE, from: "Cy <[email protected]>", subject: "Quote", preview: "Due Monday", app: "outlook" };+ await s.brief.report({ routine: {} as never, at: s.now(), picked: [{ email: linked, why: "Due Friday.", needsReply: true }, { email: unlinked, why: "Due Monday.", needsReply: true }], trouble: [] });+ const opens = widgetActions(s.card()!.widget!.root as WidgetRoot).filter((entry) => entry.action.type === "open_url").map((entry) => [entry.label, entry.action.payload]);+ expect(opens).toEqual([["Open in Outlook", { url: webLink }]]);+ expect(s.shown()).not.toContain("mail.google.com");+ });});diff --git a/server/host/brief.ts b/server/host/brief.tsindex 6b89042b2a..aa0cc3afcc 100644--- a/server/host/brief.ts+++ b/server/host/brief.ts@@ -305,7 +305,8 @@ export function createBrief(deps: BriefDeps) {.map((meeting) => ({ title: meeting.title, start: meeting.start, ...(meeting.joinUrl ? { joinUrl: meeting.joinUrl } : {}) }));const emails = liveImportant(at).flatMap((row): BriefEmail[] => {const header = headers.get(row.messageId);- return header ? [{ messageId: row.messageId, threadId: row.threadId, from: header.from, subject: header.subject, needsReply: row.needsReply, ...(header.why ? { why: header.why, ...(header.whyText ? { whyText: header.whyText } : {}) } : {}) }] : [];+ return header ? [{ messageId: row.messageId, threadId: row.threadId, from: header.from, subject: header.subject, needsReply: row.needsReply, ...(header.why ? { why: header.why, ...(header.whyText ? { whyText: header.whyText } : {}) } : {}),+ ...(row.app === "outlook" ? { app: "outlook" as const, ...(header.link ? { link: header.link } : {}) } : {}) }] : [];});const dreamt = deps.ideas?.(chiefBot.id);const ideas = (dreamt?.ideas ?? []).map((idea): BriefRow => ({ text: idea, note: w.noticedAcross(dreamt!.conversations), said: { note: words("brief.row.noticedAcross", { count: String(dreamt!.conversations) }) } }));diff --git a/src/locales/en.json b/src/locales/en.jsonindex 6ec1213444..c3d9c5c9d8 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -8491,6 +8491,7 @@"brief.card.join": "Join","brief.card.open": "Open","brief.card.openGmail": "Open in Gmail",+ "brief.card.openOutlook": "Open in Outlook","brief.card.openPage": "Open page","brief.card.draftReply": "Draft a reply to {who}","brief.card.dismissEmail": "Dismiss {who}'s email",diff --git a/src/locales/it.json b/src/locales/it.jsonindex 750494dbd0..87a3f5a3b2 100644--- a/src/locales/it.json+++ b/src/locales/it.json@@ -8431,6 +8431,7 @@"brief.card.join": "Iscriviti","brief.card.open": "Aperto","brief.card.openGmail": "Aperto a Gmail",+ "brief.card.openOutlook": "Apri in Outlook","brief.card.openPage": "Pagina iniziale","brief.card.draftReply": "Progetto di risposta {who}","brief.card.dismissEmail": "Oggetto {who} E-mail",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 978cd3fe83..bb010b113b 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -8450,6 +8450,7 @@"brief.card.join": "Participar","brief.card.open": "Abrir","brief.card.openGmail": "Abrir no Gmail",+ "brief.card.openOutlook": "Abrir no Outlook","brief.card.openPage": "Abrir página","brief.card.draftReply": "Criar rascunho de resposta para {who}","brief.card.dismissEmail": "Dispensar o e-mail de {who}",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 1680fd8088..c0289dbf2f 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -7575,6 +7575,7 @@"brief.card.join": "加入","brief.card.open": "開啟","brief.card.openGmail": "在 Gmail 中開啟",+ "brief.card.openOutlook": "在 Outlook 中開啟","brief.card.openPage": "開啟頁面","brief.card.draftReply": "起草給 {who} 的回覆","brief.card.dismissEmail": "略過 {who} 的郵件",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex c011481601..a03afee087 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -733,6 +733,7 @@"brief.card.join": "加入","brief.card.open": "打开","brief.card.openGmail": "在 Gmail 中打开",+ "brief.card.openOutlook": "在 Outlook 中打开","brief.card.openPage": "打开页面","brief.card.draftReply": "起草给 {who} 的回复","brief.card.dismissEmail": "忽略 {who} 的邮件",