Skip to content

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

Merge origin/main into train/nov12-j3

milind-soni1ac610bbeb1d
diff --cc server/drivers/phone-proxy.ts
index 7c270846c0,b9fa17ad74..0a3f61892f
--- a/server/drivers/phone-proxy.ts
+++ b/server/drivers/phone-proxy.ts
@@@ -137,16 -151,19 +151,19 @@@ async function readySerial(adb: Adb, re
return device.serial;
}
- async function onDevice(serial: string, args: string[], binary = false) {
- return runAdb(["-s", serial, ...args], { binary });
- }
+ // A call runs several commands and a person may take the phone between two of them, so each one asks again.
+ const claimedDevice = (ensureClaim: EnsureClaim, adb: Adb): OnDevice => async (serial, args, binary = false) => {
+ const claim = await ensureClaim(true);
+ if (!claim.ok) throw new Error(claim.message);
+ return adb(["-s", serial, ...args], { binary });
+ };
type Shell = (...command: string[]) => Promise<string>;
- const deviceShell = (serial: string): Shell => async (...command) => (await onDevice(serial, ["shell", ...command])).toString("utf8");
+ const deviceShell = (onDevice: OnDevice, serial: string): Shell => async (...command) => (await onDevice(serial, ["shell", ...command])).toString("utf8");
-export async function typePhoneText(shell: Shell, text: string): Promise<string> {
+export async function typePhoneText(shell: Shell, text: string, clear = false): Promise<string> {
if (!text || [...text].length > 256) throw new Error("Android text must be 1 to 256 characters");
- if (SAFE_TEXT.test(text)) {
+ if (!clear && SAFE_TEXT.test(text)) {
await shell("input", "text", text.replaceAll(" ", "%s"));
return "Typed text into the focused Android field";
}
@@@ -384,7 -391,7 +405,7 @@@ async function callTool(name: string, a
await onDevice(serial, ["shell", "input", "swipe", ...point.map((value) => String(Math.round(value))), "260"]);
return textResult(`Swiped ${direction}`);
}
- if (name === "type_text") return textResult(await typePhoneText(deviceShell(serial), String(args.text ?? ""), args.clear === true));
- if (name === "type_text") return textResult(await typePhoneText(deviceShell(onDevice, serial), String(args.text ?? "")));
++ if (name === "type_text") return textResult(await typePhoneText(deviceShell(onDevice, serial), String(args.text ?? ""), args.clear === true));
if (name === "press") {
const key = String(args.key ?? "").toLowerCase();
if (!KEYCODES[key]) throw new Error("Unsupported Android key");
diff --cc src/App.tsx
index e038aa5bb5,50c218207a..3b844925a1
--- a/src/App.tsx
+++ b/src/App.tsx
@@@ -69,7 -68,7 +69,8 @@@ import { botCycleStep, shouldOpenKeyboa
import { effectiveLanguage, useLanguageChoice, usePageLanguage } from "@/lib/language-preference";
import { botUnreadCount, showBrowserUnread } from "@/lib/bot-unread";
import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { useConnectLink } from "@/lib/use-connect-link";
+import { isSettingsPage } from "@/components/settings/settings-index";
+ import { useBotListDrawer } from "@/hooks/use-bot-list-drawer";
import { useDesktopNotificationOpens, useExternalChatLinks } from "@/hooks/use-external-chat-links";
import { useUsageSnapshot } from "@/hooks/use-usage-snapshot";
import { useReadShownChatOnFocus } from "@/hooks/use-read-shown-chat";
diff --cc src/components/WorkspaceBackupSettings.tsx
index e6aa303d2c,fa5980ef85..ba2b9bedfe
--- a/src/components/WorkspaceBackupSettings.tsx
+++ b/src/components/WorkspaceBackupSettings.tsx
@@@ -193,17 -196,15 +197,15 @@@ export function WorkspaceBackupSettings
{(!status || status.busy) && <span role="status">{status?.busy ? t("backup.serverBusy") : t("backup.checkStatus")}{" "}<button type="button" onClick={() => void refresh()} className="cursor-pointer text-accent-text hover:underline">{t("connectors.action.retry")}</button></span>}
{error && <span role="alert" className="block break-words text-danger">{error}</span>}
</>}>
- {/* Simple's Overview keeps Your data to one row: Import is the row's quiet second button. */}
- {compact && <button type="button" className="settings-quiet cursor-pointer" disabled={disabled} data-backup-import="" onClick={() => setImporting(true)}>{t("backup.importAction")}</button>}
<button type="button" className="ui-button" disabled={disabled} data-backup-export="" onClick={() => setExporting(true)}>{t("backup.exportAction")}</button>
- </SettingRow>
- {!compact && <SettingRow title={t("backup.import")} subtitle={t("backup.importShort")}>
+ </SettingRow>,
+ importRow: <SettingRow title={t("backup.import")} subtitle={t("backup.importShort")}>
<button type="button" className="ui-button" disabled={disabled} data-backup-import="" onClick={() => setImporting(true)}>{t("backup.chooseFile")}</button>
- </SettingRow>}
- </SettingsRows>
+ </SettingRow>,
+ })}
{exporting && (
<SettingsDialog title={t("backup.export")} onClose={closeExport}>
- <form id="backup-export" className="flex flex-col gap-4" onSubmit={(event) => { event.preventDefault(); void exportBackup().then(() => { if (alive.current) setExporting(false); }); }}>
+ <form id="backup-export" className="flex flex-col gap-4" onSubmit={(event) => { event.preventDefault(); void exportBackup(); }}>
<p className="text-[13px] leading-[18px] text-ink-secondary">{t("backup.passwordHint")}</p>
<SettingsField label={t("backup.exportPassword")}>
<input type="password" autoComplete="new-password" minLength={12} maxLength={1024} required disabled={disabled} value={exportPassword} onChange={(event) => setExportPassword(event.target.value)} className={SETTINGS_INPUT} />