A desktop coding agent with free access to frontier models.
TypeScript
feat: computer use on/off switch
ogsamrat00cee0aea659
diff --git a/apps/app/src/react-app/domains/session/surface/computer-use/setup.tsx b/apps/app/src/react-app/domains/session/surface/computer-use/setup.tsxindex 2ab7e72b..77e6b5fa 100644--- a/apps/app/src/react-app/domains/session/surface/computer-use/setup.tsx+++ b/apps/app/src/react-app/domains/session/surface/computer-use/setup.tsx@@ -1,33 +1,33 @@/** @jsxImportSource react */-// Computer use, findable: the Settings card (status, "Use my own screen", the account's yes) and the hint above-// the composer when a draft asks for something on a screen. The agent's own display needs nothing from the-// person; their own screen needs this computer's switch AND the account's yes, which only the web console sets.+// Computer use, findable: the Settings card (on/off for this computer, "Use my own screen") and the hint above+// the composer when a draft asks for something on a screen. Computer use is on by default and works on the+// agent's own display; the person's own screen is off until they turn it on here (with a confirm).import { useState } from "react";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";-import { ExternalLink, MousePointer2, X } from "lucide-react";+import { MousePointer2, X } from "lucide-react";import type { ComputerUseRealScreen } from "@omnirush/types/desktop-ipc";-import { desktopBridge, openDesktopUrl } from "@/app/lib/desktop";+import { desktopBridge } from "@/app/lib/desktop";import { Button } from "@/components/ui/button";import { Switch } from "@/components/ui/switch";import { useComputerUseStatus } from "./status-store";-/** Mirrors ACCOUNT_REAL_SCREEN_URL in apps/server/src/computer-use/shared/policy.mjs. */-export const ACCOUNT_REAL_SCREEN_URL = "https://omnirush.ai/console/account#computer-use";/** Mirrors SCREEN_INTENT in apps/server/src/computer-use/shared/policy.mjs (setup.test.ts compares them). */export const SCREEN_INTENT = /(?:^|[.,;!]\s*|\b(?:and|then|please|to)\s+)(?:double[- ])?click\b|\b(?:my (?:browser|screen|desktop|mouse|computer)|(?:use|open|launch|start) (?:the |a |my )?(?:browser|chrome|firefox|edge|safari|app|application|program)|screenshot|computer use|take over my|fill (?:in|out) (?:the |this )?form)\b/i;export const screenIntent = (text: string) => SCREEN_INTENT.test(text);export const COMPUTER_USE_TITLE = "Computer use";export const COMPUTER_USE_ON = "On. The agent works on its own display, with its own cursor and browser, and never asks for approval there.";+export const COMPUTER_USE_OFF = "Off on this computer. The agent gets no computer use tools.";export const OWN_SCREEN_HELP = "Off by default. When on, the agent can also click and type in the apps on your screen, without asking. Stop it any time with Stop.";-export const ACCOUNT_NEEDED = "Your account must allow it too. The app can't turn that on: it opens your account page, where you switch on “Let the agent use my real screen”, then come back here.";+export const OWN_SCREEN_CONFIRM = "The agent will be able to use your own screen, mouse and keyboard without asking: it can click and type in your apps.";+export const OWN_SCREEN_SERVER_OFF = "Your own screen is turned off for everyone right now; the agent uses its own display.";const REAL_SCREEN_KEY = ["computer-use", "real-screen"];-/** The status, this computer's own-screen switch and the account's yes, and the one-click way to turn both on. */+/** The status, this computer's switches, and the confirm before the person's own screen is turned on. */export function useComputerUseSetup(active = true) {const status = useComputerUseStatus();const queryClient = useQueryClient();@@ -38,39 +38,49 @@ export function useComputerUseSetup(active = true) {enabled: active && enabled,retry: false,staleTime: 30_000,- // Back from the account page: read the account's yes again.- refetchOnWindowFocus: true,});- const setOn = useMutation({+ const setOwnScreen = useMutation({mutationFn: async (on: boolean) => desktopBridge.setComputerUseRealScreen(on),onSuccess: (next) => queryClient.setQueryData(REAL_SCREEN_KEY, next),});- /** This computer's switch on, then the account page when the account has not said yes. */- const turnOn = async () => {- let now = realScreen.data ?? (await desktopBridge.getComputerUseRealScreen());- if (!now.on && !now.forced) now = await setOn.mutateAsync(true);- if (!now.allowed) await openDesktopUrl(ACCOUNT_REAL_SCREEN_URL);- };+ const setOn = useMutation({ mutationFn: async (on: boolean) => desktopBridge.setComputerUseOn(on) });const ownScreenReady = realScreen.data?.on === true && realScreen.data.allowed;- return { status, enabled, realScreen, setOn, turnOn, ownScreenReady };+ return { status, enabled, deviceOn: status?.device_on !== false, realScreen, setOwnScreen, setOn, ownScreenReady };}function statusLine(status: ReturnType<typeof useComputerUseStatus>) {if (!status) return "Checking…";+ if (status.device_on === false) return COMPUTER_USE_OFF;if (status.enabled) return COMPUTER_USE_ON;- return status.message ?? "Computer use is not turned on for your account yet.";+ return status.message ?? "Computer use is turned off right now.";}function modelsLine(models: string[] | null | undefined) {return models?.length ? `Works with ${models.join(", ")}. Pick one of them in the chat.` : null;}+/** "Turn on" / "Cancel" under a short warning: the one-time confirm before the person's own screen. */+function OwnScreenConfirm(props: { onConfirm: () => void; onCancel: () => void }) {+ return (+ <div className="mt-2 space-y-2 rounded-xl border border-dls-border p-3" role="alertdialog" aria-label="Use my own screen" data-computer-use-confirm>+ <div className="text-[11px] text-dls-text">{OWN_SCREEN_CONFIRM}</div>+ <div className="flex gap-2">+ <Button type="button" size="xs" onClick={props.onConfirm} data-computer-use-confirm-on>Turn on</Button>+ <Button type="button" variant="ghost" size="xs" onClick={props.onCancel}>Keep it off</Button>+ </div>+ </div>+ );+}+/** Settings > General > Computer use. */export function ComputerUseSettingsCard() {const setup = useComputerUseSetup();const data = setup.realScreen.data;+ const [confirming, setConfirming] = useState(false);const [error, setError] = useState<string | null>(null);const run = (action: () => Promise<unknown>) => { setError(null); action().catch((cause: unknown) => setError(cause instanceof Error ? cause.message : "That did not work. Try again.")); };+ // The switch is the person's own choice; while the server has computer use off here (macOS), only the reason shows.+ const showSwitch = setup.status !== null && (setup.enabled || !setup.deviceOn);return (<div className="space-y-3" data-computer-use-settings><div className="text-[11px] font-semibold uppercase tracking-[0.15em] text-dls-secondary">{COMPUTER_USE_TITLE}</div>@@ -81,9 +91,19 @@ export function ComputerUseSettingsCard() {</div><div className="min-w-0 flex-1"><div className="text-[13px] font-medium text-dls-text">{COMPUTER_USE_TITLE}</div>- <div className="text-[11px] text-dls-secondary" role="status" data-computer-use-status>{statusLine(setup.status)}</div>+ <div id="computer-use-status" className="text-[11px] text-dls-secondary" role="status" data-computer-use-status>{statusLine(setup.status)}</div>{setup.enabled && modelsLine(setup.status?.models) ? <div className="text-[11px] text-dls-secondary">{modelsLine(setup.status?.models)}</div> : null}</div>+ {showSwitch ? (+ <Switch+ aria-label={COMPUTER_USE_TITLE}+ aria-describedby="computer-use-status"+ checked={setup.deviceOn}+ disabled={setup.setOn.isPending}+ onCheckedChange={(on: boolean) => run(() => setup.setOn.mutateAsync(on))}+ data-computer-use-on+ />+ ) : null}</div>{setup.enabled ? (<div className="flex items-start gap-4 border-t border-dls-border pt-3">@@ -92,23 +112,16 @@ export function ComputerUseSettingsCard() {<div id="computer-use-own-screen-help" className="text-[11px] text-dls-secondary">{data?.forced ? "Set by the OMNIRUSH_COMPUTER_USE_REAL_SCREEN environment variable." : OWN_SCREEN_HELP}</div>- {data && !data.allowed ? (- <div className="mt-2 space-y-2">- <div className="text-[11px] text-dls-secondary" data-computer-use-account>{ACCOUNT_NEEDED}</div>- <Button type="button" variant="outline" size="xs" onClick={() => run(setup.turnOn)} data-computer-use-allow>- <ExternalLink data-icon="inline-start" />- Allow in my account- </Button>- </div>- ) : null}+ {data && !data.allowed ? <div className="mt-1 text-[11px] text-dls-secondary">{OWN_SCREEN_SERVER_OFF}</div> : null}+ {confirming ? <OwnScreenConfirm onConfirm={() => { setConfirming(false); run(() => setup.setOwnScreen.mutateAsync(true)); }} onCancel={() => setConfirming(false)} /> : null}{error ? <div className="mt-1 text-[11px] text-red-11" role="alert">{error}</div> : null}</div><Switcharia-label="Use my own screen"aria-describedby="computer-use-own-screen-help"checked={data?.on === true}- disabled={!data || data.forced || setup.setOn.isPending}- onCheckedChange={(on: boolean) => run(() => setup.setOn.mutateAsync(on))}+ disabled={!data || data.forced || setup.setOwnScreen.isPending}+ onCheckedChange={(on: boolean) => (on ? setConfirming(true) : run(() => setup.setOwnScreen.mutateAsync(false)))}data-computer-use-real-screen/></div>@@ -121,32 +134,31 @@ export function ComputerUseSettingsCard() {// "Not now": hidden for the rest of this launch.let hintDismissed = false;-/** Above the composer, while the draft asks for something on a screen and the person's own screen is not ready. */+/** Above the composer, while the draft asks for something on a screen and the person's own screen is not on. */export function useComputerUseHint(draft: string) {const intent = !hintDismissed && screenIntent(draft);const setup = useComputerUseSetup(intent);const [, rerender] = useState(0);- if (!intent || !setup.status || setup.ownScreenReady) return null;- if (setup.enabled && !setup.realScreen.data) return null;+ const [confirming, setConfirming] = useState(false);+ // Off on this computer: no tips. On but the server has the person's screen off: nothing they can do here.+ if (!intent || !setup.status || !setup.deviceOn || setup.ownScreenReady) return null;+ if (setup.enabled && (!setup.realScreen.data || !setup.realScreen.data.allowed || setup.realScreen.data.forced)) return null;const dismiss = () => { hintDismissed = true; rerender((n) => n + 1); };- const data = setup.realScreen.data;const message = !setup.enabled? statusLine(setup.status): "The agent can already do this on its own display, with its own browser and cursor. To let it use your screen and apps, turn on your own screen.";- const action = setup.enabled ? (data?.allowed ? "Use my own screen" : "Allow in my account") : null;return (<div className="mb-2 flex items-start gap-3 rounded-xl border border-dls-border bg-dls-surface px-3 py-2" role="status" data-computer-use-hint><MousePointer2 size={15} className="mt-0.5 shrink-0 text-dls-secondary" /><div className="min-w-0 flex-1 text-[12px] text-dls-text"><div className="font-medium">{COMPUTER_USE_TITLE}</div><div className="text-dls-secondary">{message}</div>- {action && !data?.allowed ? <div className="mt-0.5 text-[11px] text-dls-secondary">Opens your account page; come back here when it's on.</div> : null}+ {confirming ? <OwnScreenConfirm onConfirm={() => { setConfirming(false); void setup.setOwnScreen.mutateAsync(true).catch(() => undefined); }} onCancel={() => setConfirming(false)} /> : null}</div><div className="flex shrink-0 items-center gap-1">- {action ? (- <Button type="button" variant="outline" size="xs" onClick={() => void setup.turnOn().catch(() => undefined)} data-computer-use-hint-action>- {data?.allowed ? null : <ExternalLink data-icon="inline-start" />}- {action}+ {setup.enabled && !confirming ? (+ <Button type="button" variant="outline" size="xs" onClick={() => setConfirming(true)} data-computer-use-hint-action>+ Use my own screen</Button>) : null}<Button type="button" variant="ghost" size="icon-xs" aria-label="Not now" onClick={dismiss}>diff --git a/apps/app/src/react-app/domains/settings/computer-use-config.tsx b/apps/app/src/react-app/domains/settings/computer-use-config.tsxindex ed9fa13e..824b92d4 100644--- a/apps/app/src/react-app/domains/settings/computer-use-config.tsx+++ b/apps/app/src/react-app/domains/settings/computer-use-config.tsx@@ -169,7 +169,7 @@ export function ComputerUseConfig({ connected, connecting, onConnect, onRefresh,<p className="text-sm font-medium">Use my own screen</p><p className="mt-1 text-xs leading-relaxed text-muted-foreground" id="computer-use-real-screen-help">{realScreen.data?.forced ? "Set by the OMNIRUSH_COMPUTER_USE_REAL_SCREEN environment variable." : "Off by default. When on, the agent sees and uses the apps on your screen without asking. Your own mouse or keyboard pauses it until you choose Continue."}- {realScreen.data && !realScreen.data.allowed ? " It also needs your account's yes: turn on \u201cLet the agent use my real screen\u201d in your account at omnirush.ai/console/account. The app cannot turn that on; until then the agent uses its own display." : null}+ {realScreen.data && !realScreen.data.allowed ? " It is turned off for everyone right now; the agent uses its own display." : null}</p></div><Switchdiff --git a/apps/app/src/react-app/domains/whats-new/PARITY.sha256 b/apps/app/src/react-app/domains/whats-new/PARITY.sha256index 00e854f9..0ef4110c 100644--- a/apps/app/src/react-app/domains/whats-new/PARITY.sha256+++ b/apps/app/src/react-app/domains/whats-new/PARITY.sha256@@ -1,3 +1,3 @@# whats-new.json is the same file in omnirush-cli (src/whats-new/) and omnirush-gui (apps/app/src/react-app/domains/whats-new/).# A change to one must be ported to the other and this list updated in both.-45097a0df296ac81336af2e24f54a8e6e0e1709ee5497ecb63350478ed20ee85 whats-new.json+3cd7711e1dbbc1f20d46882aca3848e325bfeba05c6c5979a724443574c2c29c whats-new.jsondiff --git a/apps/app/src/react-app/domains/whats-new/whats-new.json b/apps/app/src/react-app/domains/whats-new/whats-new.jsonindex e031c5c7..ca325983 100644--- a/apps/app/src/react-app/domains/whats-new/whats-new.json+++ b/apps/app/src/react-app/domains/whats-new/whats-new.json@@ -6,7 +6,7 @@"version": "2.7.0","date": "2026-10-24","new": [- "/computer shows whether computer use is on and why not, and turns on the agent's use of your own screen, with a link to the account setting it also needs. When you ask for something on a screen (use my browser, click, open an app), a tip says what to turn on."+ "/computer shows whether computer use is on and why not. It turns computer use on or off for this computer (also `omnirush computer on|off`; on by default) and lets the agent use your own screen after you confirm (off by default). When you ask for something on a screen (use my browser, click, open an app), a tip says how."],"improved": [],"fixed": []@@ -270,7 +270,7 @@"version": "3.7.5","date": "2026-10-24","new": [- "Computer use in Settings > General: see whether it is on (and why not, such as on macOS), and turn on “Use my own screen”. When you ask for something on a screen (use my browser, click, open an app), a tip above the message box turns it on in one click and opens the account setting it also needs."+ "Computer use in Settings > General: see whether it is on (and why not, such as on macOS), turn it off for this computer, and turn on “Use my own screen” after a short confirm (off by default). When you ask for something on a screen (use my browser, click, open an app), a tip above the message box turns it on."],"improved": [],"fixed": []diff --git a/apps/app/tests/computer-use-setup.test.ts b/apps/app/tests/computer-use-setup.test.tsindex ea5b6c14..951d6f8a 100644--- a/apps/app/tests/computer-use-setup.test.ts+++ b/apps/app/tests/computer-use-setup.test.ts@@ -2,14 +2,22 @@ import { describe, expect, test } from "bun:test";import { readFileSync } from "node:fs";import path from "node:path";-import { ACCOUNT_REAL_SCREEN_URL, SCREEN_INTENT, screenIntent } from "../src/react-app/domains/session/surface/computer-use/setup";+import { SCREEN_INTENT, screenIntent } from "../src/react-app/domains/session/surface/computer-use/setup";const POLICY = readFileSync(path.join(import.meta.dir, "../../server/src/computer-use/shared/policy.mjs"), "utf8");describe("computer use setup", () => {- test("mirrors the shared policy's screen words and account link", () => {+ test("mirrors the shared policy's screen words", () => {expect(POLICY).toContain(`const SCREEN_INTENT = ${SCREEN_INTENT.toString()};`);- expect(POLICY).toContain(`export const ACCOUNT_REAL_SCREEN_URL = "${ACCOUNT_REAL_SCREEN_URL}";`);+ });++ test("defaults: computer use on, the person's own screen off", async () => {+ const policy = await import("../../server/src/computer-use/shared/policy.mjs");+ expect(policy.deviceComputerUse(undefined)).toBe(true);+ expect(policy.deviceComputerUse(false)).toBe(false);+ expect(policy.realScreenOptIn({ env: {} })).toBe(false);+ const off = policy.computerUseSetting({ env: {}, block: { enabled: true }, client: "desktop", platform: "linux", device: false });+ expect([off.enabled, off.reason, policy.unavailableMessage(off)]).toEqual([false, "device", "Computer use is turned off on this computer."]);});test("a draft that asks for the screen shows the hint; code words do not", () => {diff --git a/apps/desktop/electron/computer-use.mjs b/apps/desktop/electron/computer-use.mjsindex 57fc6e40..286076ee 100644--- a/apps/desktop/electron/computer-use.mjs+++ b/apps/desktop/electron/computer-use.mjs@@ -119,11 +119,14 @@ function supported() {function statusNow() {// Each session carries its cursor's latest move, so the live view glides it from `from` to `to`.const sessions = host ? host.state().map((s) => (cursors.has(s.id) ? { ...s, cursor_move: cursors.get(s.id) } : s)) : [];+ const device = deviceOn();return {- enabled: server?.enabled === true,+ enabled: server?.enabled === true && device,+ // The person's own on/off for this device (Settings > Computer use; on by default).+ device_on: device,// The agent's own display works without desktop access (no helper, Wayland), so only "off" is unavailable.supported: supported(),- message: server?.enabled ? (supported() ? null : "Computer use is unavailable on this desktop.") : server?.unavailable ?? server?.setting?.message ?? (server ? "Computer use is turned off." : null),+ message: !device ? "Computer use is turned off on this computer." : server?.enabled ? (supported() ? null : "Computer use is unavailable on this desktop.") : server?.unavailable ?? server?.setting?.message ?? (server ? "Computer use is turned off." : null),// The models that can use it (null: any).models: server?.setting?.models ?? null,mode: server?.mode ?? "normal",@@ -144,6 +147,33 @@ function onCursor(move) {preview?.cursor(move);}+// The person's on/off for computer use on this device (policy.mjs COMPUTER_USE_SETTING, on by default), saved in+// the profile and set only from the main window. Off: the host stops, so the engine gets no computer-use tools.+const deviceFile = () => path.join(profileDir(), "computer-use", shared?.policyModule?.COMPUTER_USE_FILE ?? "device.json");+let deviceSaved; // undefined: not read yet+function deviceOn() {+ const policy = shared?.policyModule;+ if (!policy) return true; // shown only: apply() loads the rules before it starts anything+ if (deviceSaved === undefined) {+ try { const value = JSON.parse(readFileSync(deviceFile(), "utf8"))?.[policy.COMPUTER_USE_SETTING]; deviceSaved = typeof value === "boolean" ? value : null; } catch { deviceSaved = null; }+ }+ return policy.deviceComputerUse(deviceSaved ?? undefined);+}++async function setComputerUseOn(on) {+ if (typeof on !== "boolean") throw new Error("Choose on or off.");+ const { policyModule } = await sharedModules();+ const file = deviceFile();+ mkdirSync(path.dirname(file), { recursive: true });+ const temp = `${file}.${process.pid}.tmp`;+ writeFileSync(temp, JSON.stringify({ [policyModule.COMPUTER_USE_SETTING]: on }), { mode: 0o600 });+ renameSync(temp, file);+ deviceSaved = on;+ // Live: off stops the host now (the engine drops the tools); on starts it with the next state read.+ await apply(server);+ return statusNow();+}+// The person's one-time real-screen setting (policy.mjs REAL_SCREEN_SETTING), saved in the profile, set only// from the main window (desktop IPC), never through the local server an agent's shell can reach.const realScreenFile = () => path.join(profileDir(), "computer-use", "real-screen.json");@@ -264,14 +294,16 @@ async function stopHost(by = "server") {}async function apply(next) {+ await sharedModules().catch(() => null);server = next;// A periodic answer can only take the account's real screen away; a fresh read gives it (hostRefresh).if (next?.read === true) serverRealScreen = saysRealScreen(next);// A refresh that could not read the server (read false) or a no: no (fail closed).else if (next?.read === false || !saysRealScreen(next)) serverRealScreen = false;if (!serverRealScreen) await stopRealScreen();- if (server?.enabled && supported() && !hostPromise && Date.now() - failedAt < 60_000) { pushStatus(); return; }- if (server?.enabled && supported()) await startHost().catch((error) => { failedAt = Date.now(); deps?.log?.("computer use host did not start", error); });+ const wanted = server?.enabled && supported() && deviceOn();+ if (wanted && !hostPromise && Date.now() - failedAt < 60_000) { pushStatus(); return; }+ if (wanted) await startHost().catch((error) => { failedAt = Date.now(); deps?.log?.("computer use host did not start", error); });else if (host) await stopHost("server");pushStatus();}@@ -475,6 +507,7 @@ export {getComputerUseState,getComputerUseRealScreen,setComputerUseRealScreen,+ setComputerUseOn,computerUseControl,getComputerUseMcpEnvironment,checkComputerUsePermissions,diff --git a/apps/desktop/electron/main.mjs b/apps/desktop/electron/main.mjsindex df8a4149..5f765e2e 100644--- a/apps/desktop/electron/main.mjs+++ b/apps/desktop/electron/main.mjs@@ -35,6 +35,7 @@ import {computerUseControl,getComputerUseRealScreen,setComputerUseRealScreen,+ setComputerUseOn,initComputerUse,listRunningApps,openComputerUseSetupApp,@@ -2334,6 +2335,10 @@ const desktopCommandHandlers = {if (!mainWindow || event.sender !== mainWindow.webContents || event.senderFrame !== mainWindow.webContents.mainFrame) throw new Error("Computer use settings require the main OmniRush.ai window.");return setComputerUseRealScreen(value);},+ "setComputerUseOn": async (event, value) => {+ if (!mainWindow || event.sender !== mainWindow.webContents || event.senderFrame !== mainWindow.webContents.mainFrame) throw new Error("Computer use settings require the main OmniRush.ai window.");+ return setComputerUseOn(value);+ },"computerUseControl": async (event, value) => {if (!mainWindow || event.sender !== mainWindow.webContents || event.senderFrame !== mainWindow.webContents.mainFrame) throw new Error("Computer use controls require the main OmniRush.ai window.");return computerUseControl(value);diff --git a/apps/server/src/computer-use/shared/PARITY.sha256 b/apps/server/src/computer-use/shared/PARITY.sha256index 67e15d3e..7548ec1b 100644--- a/apps/server/src/computer-use/shared/PARITY.sha256+++ b/apps/server/src/computer-use/shared/PARITY.sha256@@ -2,8 +2,8 @@# A change to one must be ported to the other and this list updated in both.da1cc6c26f3bf6758d3e2ce70e87bce383f68ee0ec6c85bbdc33b1f9a6c407fa contract.mjs30cfcead85a5b2b54005ba6a0a67a43d9950de944b4615861ce9342bf043d4a4 contract.d.mts-4d82d0f4510a5b09d2ee0272fd43ac85c4f1e1062d828ca50af33400649283e2 policy.mjs-8f15c565a8d80054cf41f68bb37b1801cb410d260928801d11e3f042a7858c52 policy.d.mts+324712aabed354250269e6e517beed77876c1bdab8aeb1452b078cd2bfa6a1b9 policy.mjs+e5807c6426f21853825a7db9248882da11dffa1fef9f3499a665f39e752dbbb0 policy.d.mtsda515baa8aec2b533685d20c2be7ae007acc6b116db0386f8180e6779cb80f5c image.mjs7c1a3224b7efd215656a94c38cf3152fe7a2444f25a6162988528978acf5458d image.d.mtse47c9ff67b9fce2ec12307737e973ce22551719c482b87f601569bd4f8a77e17 media.mjsdiff --git a/apps/server/src/computer-use/shared/policy.d.mts b/apps/server/src/computer-use/shared/policy.d.mtsindex a3c5ded7..15f29b65 100644--- a/apps/server/src/computer-use/shared/policy.d.mts+++ b/apps/server/src/computer-use/shared/policy.d.mts@@ -23,16 +23,19 @@ export type ComputerUseBlock = {ask_send_delete: boolean;};export type ComputerUseSetting = ComputerUseBlock & {- source: "env" | "server" | "default";- reason: null | "env" | "no_switch" | "off" | "client" | "os" | "no_display";+ source: "env" | "server" | "default" | "device";+ reason: null | "env" | "device" | "no_switch" | "off" | "client" | "os" | "no_display";/** This device's OS (macos, windows, linux) when computer use is off for it. */os_name?: string;};export function normalizeComputerUse(block: unknown): ComputerUseBlock;-export function computerUseSetting(options?: { env?: Record<string, string | undefined>; block?: unknown; client?: "cli" | "desktop"; platform?: string }): ComputerUseSetting;+export function computerUseSetting(options?: { env?: Record<string, string | undefined>; block?: unknown; client?: "cli" | "desktop"; platform?: string; device?: boolean | null }): ComputerUseSetting;export function modelAllowed(setting: ComputerUseSetting | ComputerUseBlock | null | undefined, modelId: unknown): boolean;-export const ACCOUNT_REAL_SCREEN_URL: string;+export const COMPUTER_USE_DEFAULT: boolean;+export const COMPUTER_USE_SETTING: string;+export const COMPUTER_USE_FILE: string;+export function deviceComputerUse(saved: unknown): boolean;export function unavailableMessage(setting: { enabled?: boolean; reason?: string | null; os_name?: string; message?: string | null } | null | undefined): string | null;export function screenIntent(text: unknown): boolean;export function offMessage(setting: { message?: string | null } | null | undefined): string;diff --git a/apps/server/src/computer-use/shared/policy.mjs b/apps/server/src/computer-use/shared/policy.mjsindex b8c03063..874d395c 100644--- a/apps/server/src/computer-use/shared/policy.mjs+++ b/apps/server/src/computer-use/shared/policy.mjs@@ -83,13 +83,16 @@ const OFF = ["0", "off", "false", "no"];/*** Whether computer use is on for this app. In this order: the environment* (OMNIRUSH_COMPUTER_USE=1/on or 0/off; tests and support), then the server's- * block (`block`, as last seen), else off. `client` is "cli" or "desktop".+ * block (`block`, as last seen), else off. `client` is "cli" or "desktop". `device`: the person's saved+ * on/off for this device (deviceComputerUse; off wins over the server).* Returns the normalized block plus { enabled, source, reason }.*/-export function computerUseSetting({ env = process.env, block, client, platform = process.platform } = {}) {+export function computerUseSetting({ env = process.env, block, client, platform = process.platform, device } = {}) {const server = normalizeComputerUse(block);const asked = String(env?.OMNIRUSH_COMPUTER_USE ?? "").trim().toLowerCase();if (OFF.includes(asked)) return { ...server, enabled: false, source: "env", reason: "env" };+ // The person turned it off on this device (/computer off, Settings): no tools, no tips.+ if (!deviceComputerUse(device)) return { ...server, enabled: false, source: "device", reason: "device" };// The environment turns computer use on (tests, support), never the person's real screen: that stays the server's.if (ON.includes(asked)) return { ...server, enabled: true, virtual_display: true, source: "env", reason: null };if (!isRecord(block)) return { ...server, enabled: false, source: "default", reason: "no_switch" };@@ -109,8 +112,18 @@ export function modelAllowed(setting, modelId) {const OS_LABELS = { macos: "macOS", windows: "Windows", linux: "Linux" };-/** Where the person turns their own screen on for the account (the web console only; the apps cannot). */-export const ACCOUNT_REAL_SCREEN_URL = "https://omnirush.ai/console/account#computer-use";+// ------------------------------------------------------------ this device's switch++/** Computer use on this device until the person turns it off (CLI /computer off, desktop Settings). */+export const COMPUTER_USE_DEFAULT = true;+/** The key both apps save it under, in <state or profile>/computer-use/device.json. */+export const COMPUTER_USE_SETTING = "computerUse";+export const COMPUTER_USE_FILE = "device.json";++/** Whether computer use is on for this device: the person's saved choice, else COMPUTER_USE_DEFAULT. */+export function deviceComputerUse(saved) {+ return typeof saved === "boolean" ? saved : COMPUTER_USE_DEFAULT;+}/** Why computer use is not available here, in plain words for people; null while it is on. */export function unavailableMessage(setting) {@@ -118,8 +131,9 @@ export function unavailableMessage(setting) {if (setting.reason === "os") return `Computer use is not available on ${OS_LABELS[setting.os_name] ?? "this system"} yet.`;if (setting.reason === "client") return "Computer use is not available in this app yet.";if (setting.reason === "env") return "Computer use is off on this computer (OMNIRUSH_COMPUTER_USE=0).";+ if (setting.reason === "device") return "Computer use is turned off on this computer.";if (setting.reason === "no_switch") return "Computer use is not ready yet: sign in and stay online once so the app can check your account.";- return setting.message ?? "Computer use is not turned on for your account yet.";+ return setting.message ?? "Computer use is turned off right now.";}// Words that ask for something on a screen: a browser, an app, clicks, typing into a window.@@ -147,11 +161,12 @@ export function serverRealScreen(block) {}/** Said to the agent when the account has not opted in (or the server turned it off). */-export const REAL_SCREEN_NOT_OPTED_IN_MESSAGE = "Computer use on the person's own screen is not turned on for this account. Work on your own display instead (app_id \"virtual:main\"). Only the person can turn it on, in their account; never try to change it and never ask to.";+export const REAL_SCREEN_NOT_OPTED_IN_MESSAGE = "Computer use on the person's own screen is turned off for this account right now. Work on your own display instead (app_id \"virtual:main\"). Never try to change it and never ask to.";/** Said to the agent when the server could not confirm it just now. */export const REAL_SCREEN_UNVERIFIED_MESSAGE = "The person's screen cannot be used right now: the account's setting could not be confirmed with the server. Work on your own display instead (app_id \"virtual:main\").";-/** The person's real screen is off until the person turns it on (Settings / `omnirush computer real-screen on`). */+/** The person's real screen is off until the person turns it on (Settings / `omnirush computer real-screen on`).+ * Off by default for privacy; flipping this one value makes it on by default in both apps. */export const REAL_SCREEN_DEFAULT = false;/** The key both apps save the person's choice under, in <state or profile>/computer-use/real-screen.json. */export const REAL_SCREEN_SETTING = "computerUseRealScreen";diff --git a/packages/types/src/desktop-ipc.ts b/packages/types/src/desktop-ipc.tsindex 9b789375..63e0bed6 100644--- a/packages/types/src/desktop-ipc.ts+++ b/packages/types/src/desktop-ipc.ts@@ -923,6 +923,8 @@ export type ComputerUseStatus = {supported: boolean;/** Why it is off or unavailable (people-facing), when it is. */message: string | null;+ /** The person's own on/off for this device (on by default). */+ device_on?: boolean;/** The models that can use computer use (null: any). */models?: string[] | null;mode: "careful" | "normal" | "auto";@@ -1022,6 +1024,7 @@ export type DesktopCommandMap = {getComputerUseState: { args: []; result: ComputerUseStatus };getComputerUseRealScreen: { args: []; result: ComputerUseRealScreen };setComputerUseRealScreen: { args: [on: boolean]; result: ComputerUseRealScreen };+ setComputerUseOn: { args: [on: boolean]; result: ComputerUseStatus };computerUseControl: { args: [value: { session_id: string; action: ComputerUseControlAction; rect?: ComputerUseButtonRect }]; result: void };getOmniRushUiMcpEnvironment: { args: []; result: Record<string, string> };