Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
feat(live): accept a Chinese yes or no for a permission card
yofizane67a29615693f
diff --git a/apps/docs/content/docs/features/voice-and-memory.mdx b/apps/docs/content/docs/features/voice-and-memory.mdxindex 7cb6ab0209..d6f5bd48cb 100644--- a/apps/docs/content/docs/features/voice-and-memory.mdx+++ b/apps/docs/content/docs/features/voice-and-memory.mdx@@ -62,7 +62,7 @@ The voice speaks as the bot, in the first person, but the bot does the work: eacWhen a call that connected ends, the chat keeps one record of it: a small row with the call's length and what the bot did for the requests you spoke, its steps by name and the permission requests it raised, such as running a command, with how each was decided. The record reads "Call with" and the bot's name. The bot's own engine, which already saw those requests, gives it a short title from what you asked on the call; the call sends nothing more to OpenAI. The requests you spoke and the bot's answers stay in the chat as before. The record holds no speech: the voice's own words are still not saved. A call that never connected leaves no record, and a phone app that does not know the record yet shows it as one short line, such as "Call with Ada · 1:42".-A permission request, such as running a command, can be answered with a clear spoken yes or no, decided by MausBot, not by the voice model; the card stays on screen too, and a card decided on the call is marked "by voice" there and in the decision log. On a Live call the microphone stays open while the voice speaks, so "okay", "sure" or "fine" on their own do not count as a yes, and words heard while the voice itself was talking are left out; say "yes" or "no". A bot's changes to itself, such as a new skill or a routine, apply without a card and can be undone on screen; proposals that change another bot or the team, such as a team setup, are decided on screen only, and when the bot waits for you to connect an app or enter a credential, the voice tells you to do it in the chat (never to say a credential aloud).+A permission request, such as running a command, can be answered with a clear spoken yes or no, decided by MausBot, not by the voice model; the card stays on screen too, and a card decided on the call is marked "by voice" there and in the decision log. On a Live call the microphone stays open while the voice speaks, so "okay", "sure" or "fine" on their own do not count as a yes, and words heard while the voice itself was talking are left out; say "yes" or "no". In Chinese, say "同意" (agree) or "拒绝" (refuse) as a whole answer, since "好的" (okay) and "可以" (sure) on their own count as filler just like "okay". A bot's changes to itself, such as a new skill or a routine, apply without a card and can be undone on screen; proposals that change another bot or the team, such as a team setup, are decided on screen only, and when the bot waits for you to connect an app or enter a credential, the voice tells you to do it in the chat (never to say a credential aloud).A message typed during a call is answered by the bot, and the voice reads that answer once. With **Read replies to typed messages** off (under the gear), messages you type during a call and the bot's answers to them are not sent to OpenAI, with two exceptions. The voice still hears what the bot asks of you while it works on a typed message: an approval or a question (you can answer those on the call), a proposal, and a request to connect an app or enter a credential. And an answer that also covers something you said aloud is read out: lines that waited in the queue together get one answer.diff --git a/shared/call-consent.test.ts b/shared/call-consent.test.tsindex 8809e4ebef..d45a3d7820 100644--- a/shared/call-consent.test.ts+++ b/shared/call-consent.test.ts@@ -55,4 +55,34 @@ describe("spokenConsent", () => {expect(spokenConsent("fine")).toBe("allow");});});++ for (const mode of ["turns", "live"] as const) {+ it(`accepts a whole Chinese approval or refusal in ${mode} mode`, () => {+ for (const said of [+ "同意", "我同意", "允许", "我允许", "批准", "我批准", "是的", "确认执行", "可以执行", "允许执行", "同意执行", "请执行", "执行吧", "确认授权",+ "允許", "我允許", "確認執行", "可以執行", "允許執行", "同意執行", "請執行", "執行吧", "確認授權",+ "同意。", "同意!", " 同意 ", "可以执行.", "嗯,同意", "好的,同意。", "好,允许", "可以,执行吧", "嗯嗯 同意", "行,批准",+ "呃、额,没问题,我同意", "哦。啊!好吧.同意",+ ]) {+ expect.soft(spokenConsent(said, mode), said).toBe("allow");+ }+ for (const said of [+ "拒绝", "我拒绝", "不同意", "不允许", "不批准", "不要执行", "不执行", "取消执行", "取消", "停止执行", "不", "不行", "不可以", "不要", "不用",+ "拒絕", "我拒絕", "不允許", "不要執行", "不執行", "取消執行", "停止執行", "拒绝。", "嗯,拒绝", "好的,取消", "額,沒問題!我拒絕",+ ]) {+ expect.soft(spokenConsent(said, mode), said).toBe("deny");+ }+ });++ it(`ignores Chinese filler, questions, conditions, corrections and quotations in ${mode} mode`, () => {+ for (const said of [+ "好", "好的", "好的。", "行", "可以", "可以。", "嗯", "没问题", "同意吗", "同意吗?", "可以执行吗?", "要拒绝吗",+ "同意,但是先备份", "同意,不过别删文件", "可以执行,但只执行一次", "同意。不对,拒绝", "不,同意", "他说同意", "我不确定是否同意",+ "我需要你的同意", "请明确说同意或拒绝", "不知道", "不好意思,没听清", "同意书在哪里", "取消订单的事怎么样了",+ "好的同意", "同意,", "拒绝?", "同意?",+ ]) {+ expect(spokenConsent(said, mode), said).toBeNull();+ }+ });+ }});diff --git a/shared/call-consent.ts b/shared/call-consent.tsindex 2da42e418a..9ea6100576 100644--- a/shared/call-consent.ts+++ b/shared/call-consent.ts@@ -14,6 +14,18 @@ const LIVE_HEDGES = /^(?:(?:um+|uh+|er+|so|well|hmm+|ok|okay|sure|fine)(?:[\s,.!// questions or corrections are not permission for that unchanged action.const LIVE_YES = /^(?:yes|yeah|yep|yup|go ahead|do it|allow(?: it)?|approve(?: it)?|approved|please do)(?:[\s,]+(?:please|go ahead|do it))*[.!]*$/i;+// Chinese has no word boundaries, so only a whole answer can decide a card.+// 嗯 mm, 呃/额 uh, 哦 oh, 啊 ah, 好/好的 okay, 好吧 all right, 行/可以 sure, 没问题 no problem.+const ZH_HEDGES = /^(?:(?:嗯+|呃|[额額]|哦|啊|好[的吧]?|行|可以|[没沒][问問][题題])[\s,,、。.!!]+)+/;+// 同意 agree, 我同意 I agree, 允许 allow, 我允许 I allow it, 批准 approve, 我批准 I approve, 是的 yes.+// 确认执行 confirm the run, 可以执行 you may run it, 允许执行 allowed to run, 同意执行 agree to run it.+// 请执行 please run it, 执行吧 go ahead and run it, 确认授权 confirm the permission.+const ZH_YES = /^(?:我?(?:同意|允[许許]|批准)|是的|(?:[确確][认認]|可以|允[许許]|同意|[请請])[执執]行|[执執]行吧|[确確][认認]授[权權])[\s。.!!]*$/;+// 拒绝 refuse, 我拒绝 I refuse, 不同意 disagree, 不允许 not allowed, 不批准 not approved.+// 不要执行 do not run it, 不执行 do not run, 取消执行 cancel the run, 取消 cancel, 停止执行 stop running.+// 不 no, 不行 no way, 不可以 you may not, 不要 don't, 不用 no need.+const ZH_NO = /^(?:我?拒[绝絕]|不同意|不允[许許]|不批准|(?:不要|不|取消|停止)[执執]行|取消|不(?:行|可以|要|用)?)[\s。.!!]*$/;+/** "allow", "deny", or null when the words are not a clear decision. The* answer must open the utterance; filler before it ("uh, yes") is dropped.* `live`: a Live call, whose microphone stays open while the voice speaks@@ -21,6 +33,9 @@ const LIVE_YES = /^(?:yes|yeah|yep|yup|go ahead|do it|allow(?: it)?|approve(?: i* `turns` (take turns) keeps its own rule: its microphone is closed while* the bot talks. */export function spokenConsent(text: string, mode: "turns" | "live" = "turns"): "allow" | "deny" | null {+ const chinese = text.trim().replace(ZH_HEDGES, "");+ if (ZH_YES.test(chinese)) return "allow";+ if (ZH_NO.test(chinese)) return "deny";const said = text.trim().replace(mode === "live" ? LIVE_HEDGES : FILLER, "");if ((mode === "live" ? LIVE_YES : YES).test(said)) return "allow";if (NO.test(said)) return "deny";