Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: server switch for computer use send and delete asks

ogsamrat129ccb022e72
diff --git a/apps/desktop/electron/computer-use.mjs b/apps/desktop/electron/computer-use.mjs
index d3cb6f39..48d5e45a 100644
--- a/apps/desktop/electron/computer-use.mjs
+++ b/apps/desktop/electron/computer-use.mjs
@@ -168,7 +168,7 @@ const approve = {
function hostSettings() {
const setting = server?.setting ?? {};
- return { enabled: server?.enabled === true, real_screen: setting.real_screen !== false, limits: setting.limits ?? null, deny_apps: setting.deny_apps ?? [], mode: server?.mode ?? "normal", message: setting.message ?? null };
+ return { enabled: server?.enabled === true, real_screen: setting.real_screen !== false, limits: setting.limits ?? null, deny_apps: setting.deny_apps ?? [], mode: server?.mode ?? "normal", message: setting.message ?? null, ask_send_delete: setting.ask_send_delete === true };
}
async function hostContext() {
diff --git a/apps/server/src/computer-use/contract-policy.test.ts b/apps/server/src/computer-use/contract-policy.test.ts
index cb7fbf57..c17c2c06 100644
--- a/apps/server/src/computer-use/contract-policy.test.ts
+++ b/apps/server/src/computer-use/contract-policy.test.ts
@@ -304,6 +304,10 @@ describe("policy: approvals per permission mode", () => {
test("the send/delete switch (off by default): OS-read send and permanent-delete targets and delete chords ask; intents never", () => {
expect(ASK_SEND_DELETE).toBe(false);
+ expect(normalizeComputerUse({ enabled: true }).ask_send_delete).toBe(false);
+ expect(normalizeComputerUse({ enabled: true, ask_send_delete: "yes" }).ask_send_delete).toBe(false);
+ expect(normalizeComputerUse({ enabled: true, ask_send_delete: true }).ask_send_delete).toBe(true);
+ expect(normalizeComputerUse(null).ask_send_delete).toBe(false);
const on = { sendDelete: true };
for (const text of ["Send", "Post", "Publish", "Forward", "Reply all", "Delete permanently", "Empty Trash", "Delete account"]) expect(actApproval({ ...plain, target: { text } }, on).reasons.map((r) => r.code)).toEqual(["send_delete_target"]);
expect(actApproval({ ...plain, action: { type: "key", key: "Enter" }, target: { text: "Send" } }, on).ask).toBe(true);
diff --git a/apps/server/src/computer-use/portable-host.test.ts b/apps/server/src/computer-use/portable-host.test.ts
index ff2126f2..6dfb4fe9 100644
--- a/apps/server/src/computer-use/portable-host.test.ts
+++ b/apps/server/src/computer-use/portable-host.test.ts
@@ -471,6 +471,23 @@ describe("portable host: the person's own press answers a question", () => {
});
});
+describe("portable host: the server's send/delete switch", () => {
+ test("off: a Send button runs; on (capabilities ask_send_delete): it asks, and Enter after typing asks", async () => {
+ for (const on of [false, true]) {
+ const r = rig("normal");
+ (r.settings as Record<string, unknown>).ask_send_delete = on;
+ r.native.state.texts = [{ x: 300, y: 200, width: 80, height: 30, text: "Send" }];
+ const { host, c, session, obs } = await opened(r);
+ const send = await call(c, "computer_act", { session_id: session, observation_id: obs.state.observation?.id, request_id: "a", intent: "Press the button", action: { type: "click", x: 300, y: 200 } });
+ expect(send.state).toMatchObject({ ok: true, approval: on ? { asked: true, reasons: ["send_delete_target"] } : { asked: false } });
+ const typed = await call(c, "computer_act", { session_id: session, observation_id: (send.state.observation as { id: string }).id, request_id: "b", intent: "Write the reply", action: { type: "type", text: "see you" } });
+ const enter = await call(c, "computer_act", { session_id: session, observation_id: (typed.state.observation as { id: string }).id, request_id: "c", intent: "Done", action: { type: "key", key: "Enter", modifiers: ["ctrl"] } });
+ expect(enter.state).toMatchObject({ ok: true, approval: { asked: on } });
+ await host.close();
+ }
+ });
+});
+
describe("portable host: Enter and Space read the focused control; Tab forgets it", () => {
test("Enter on a focused pay button asks; after Tab it is unknown and runs", async () => {
const r = rig("normal");
diff --git a/apps/server/src/computer-use/routes.ts b/apps/server/src/computer-use/routes.ts
index 1e62640a..1ca479bd 100644
--- a/apps/server/src/computer-use/routes.ts
+++ b/apps/server/src/computer-use/routes.ts
@@ -51,7 +51,7 @@ export function registerComputerUseRoutes(deps: ComputerUseRouteDeps): void {
const chat = deps.chats.resolve(await deps.runningSessions().catch(() => null));
return {
enabled: setting.enabled,
- setting: { enabled: setting.enabled, real_screen: setting.real_screen, virtual_display: setting.virtual_display, limits: setting.limits, deny_apps: setting.deny_apps, models: setting.models, message: setting.message, reason: setting.reason, source: setting.source },
+ setting: { enabled: setting.enabled, real_screen: setting.real_screen, virtual_display: setting.virtual_display, limits: setting.limits, deny_apps: setting.deny_apps, models: setting.models, message: setting.message, ask_send_delete: setting.ask_send_delete === true, reason: setting.reason, source: setting.source },
mode,
dir,
spool: mediaSpoolDir(deps.stateDir()),
diff --git a/apps/server/src/computer-use/shared/PARITY.sha256 b/apps/server/src/computer-use/shared/PARITY.sha256
index 0c177ee1..69f9416c 100644
--- a/apps/server/src/computer-use/shared/PARITY.sha256
+++ b/apps/server/src/computer-use/shared/PARITY.sha256
@@ -2,12 +2,12 @@
# A change to one must be ported to the other and this list updated in both.
59abb350a935c9462f3ea2e863396cdc785634dd2907f2f8947d87e9b30ec209 contract.mjs
aef0973f520f56ab8ad2699c14428bb2dd7ddb4b00dff823e4598e64d0c4a35b contract.d.mts
-cbfe657947a1e3a093b76e91b150e16df2b8b70756b0b816e27255c1c6f70190 policy.mjs
-8b7a75400b54beb385301d6ebb67624fb19b970525da73ef0413ba238918fb0d policy.d.mts
+7d823cbd1db3b6a5200f173cfd1567e92804c09267eb06e462e72c5f8f82e3c2 policy.mjs
+31c50348ee77d5f61ba10a59e3ca7ff384c051dd70c60ed10e52b3186ad371d0 policy.d.mts
a96246342720364eb3e5843ba70fbbf640365f94597fc4dbb6a7be7d95254ec4 image.mjs
5eac31868aedd3e1d1e71b445f9a55d01316da7397f27f6db11472453bee4588 image.d.mts
e47c9ff67b9fce2ec12307737e973ce22551719c482b87f601569bd4f8a77e17 media.mjs
eabdf78c56733577d05aad490d9d7d5ece6c22e9b3ea9e6e9803d1a4a546fdd4 media.d.mts
a0bd964a5d0c7c5e26b4ce4ed8e8300f80a0a3a9da5d7f49c36f6ac2c907e934 native-worker.mjs
-cf76c3a7653aa9eba112a2387f890ce1d75e69075dbe9cfabc134b4ce1ff19a3 portable-host.mjs
-641be80cebb04d353031392d8f53f45ead1e1beaf83f1e67d24945f0eda330bf portable-host.d.mts
+bd3ad13f41e8ebbfc22a812901dfcfd2d009be8e3c5ae0304d6e06cbab99808b portable-host.mjs
+ecbac3ec99cc39d8b749699d97201074015b5746aa2baf32e17944c86ac8ef42 portable-host.d.mts
diff --git a/apps/server/src/computer-use/shared/policy.d.mts b/apps/server/src/computer-use/shared/policy.d.mts
index 23d779cb..e0e5fa25 100644
--- a/apps/server/src/computer-use/shared/policy.d.mts
+++ b/apps/server/src/computer-use/shared/policy.d.mts
@@ -18,6 +18,8 @@ export type ComputerUseBlock = {
deny_apps: DenyEntry[];
limits: Limits;
message: string | null;
+ /** The send/delete asks in Normal (off unless the server says true). */
+ ask_send_delete: boolean;
};
export type ComputerUseSetting = ComputerUseBlock & {
source: "env" | "server" | "default";
diff --git a/apps/server/src/computer-use/shared/policy.mjs b/apps/server/src/computer-use/shared/policy.mjs
index a29c1676..87bc54f0 100644
--- a/apps/server/src/computer-use/shared/policy.mjs
+++ b/apps/server/src/computer-use/shared/policy.mjs
@@ -35,10 +35,10 @@ function text(value, limit = 400) {
* missing or malformed block is off. The server already applied
* `rollout_percent` (and the account) to `enabled`.
* Shape: { enabled, clients, os, models, real_screen, virtual_display,
- * deny_apps, limits, message } (null lists: no restriction).
+ * deny_apps, limits, message, ask_send_delete } (null lists: no restriction).
*/
export function normalizeComputerUse(block) {
- if (!isRecord(block)) return { enabled: false, clients: null, os: null, models: null, real_screen: false, virtual_display: false, deny_apps: [], limits: normalizeLimits(null), message: null };
+ if (!isRecord(block)) return { enabled: false, clients: null, os: null, models: null, real_screen: false, virtual_display: false, deny_apps: [], limits: normalizeLimits(null), message: null, ask_send_delete: false };
const denyApps = Array.isArray(block.deny_apps)
? block.deny_apps.flatMap((item) => {
if (typeof item === "string" && item.trim()) return [{ match: item.trim().slice(0, 200), reason: null }];
@@ -56,6 +56,8 @@ export function normalizeComputerUse(block) {
deny_apps: denyApps,
limits: normalizeLimits(block.limits),
message: text(block.message),
+ // The send/delete asks in Normal (actApproval options.sendDelete): only an explicit true turns them on.
+ ask_send_delete: block.ask_send_delete === true,
};
}
@@ -290,7 +292,9 @@ export function riskyWords(value, from = "screen") {
const PAYMENT_PAGE = /\b(cart|basket|billing|payment|checkout|check\s*out)\b/i;
/**
- * The judge's narrower variant (send and delete), OFF by default: when true, Normal also asks when the text
+ * The narrower send/delete variant, OFF (the owner's decision, 2026-10-21). The server can turn it on without a
+ * release (capabilities `computer_use.ask_send_delete: true`, hosts pass it as options.sendDelete): Normal then
+ * also asks when the text
* the OS read at a click/Enter target says Send/Post/Publish/Forward/Reply all or a permanent delete, and on
* the Shift+Delete and Cmd+Backspace chords. Only OS-read text counts, never the agent's intent.
*/
diff --git a/apps/server/src/computer-use/shared/portable-host.d.mts b/apps/server/src/computer-use/shared/portable-host.d.mts
index a569c864..6251ef4f 100644
--- a/apps/server/src/computer-use/shared/portable-host.d.mts
+++ b/apps/server/src/computer-use/shared/portable-host.d.mts
@@ -16,10 +16,10 @@ export type NativeWorker = {
};
export function createNativeWorker(options?: { workerPath?: string; nodePath?: string; nodeEnv?: Record<string, string>; koffiPath?: string; timeoutMs?: number }): NativeWorker;
-export type HostSettings = { enabled: boolean; real_screen?: boolean; limits?: Partial<Limits> | null; deny_apps?: Array<DenyEntry | string>; mode?: PermissionMode | string | null; message?: string | null };
+export type HostSettings = { enabled: boolean; real_screen?: boolean; limits?: Partial<Limits> | null; deny_apps?: Array<DenyEntry | string>; mode?: PermissionMode | string | null; message?: string | null; ask_send_delete?: boolean };
export type HostContext = { ancestors?: ProcessInfo[]; self_pids?: number[]; tty_pids?: number[]; chat?: string | null };
export type AppRef = { app_id: string; app_name: string; bundle_or_exe: string; pid: number };
-export type OpenRequest = { session_id: string; request_id: string; app: AppRef; windows: Array<{ id: string; title: string }>; window_id: string; mode: "observe" | "control"; purpose: string; os: string; seconds: number; chat_seconds: number };
+export type OpenRequest = { session_id: string; request_id: string; app: AppRef; windows: Array<{ id: string; title: string }>; window_id: string; mode: "observe" | "control"; purpose: string; os: string; seconds: number; /** "Allow for this chat": 0 = until the chat ends, else at most this many seconds. */ chat_seconds: number };
export type OpenAnswer = { decision: "chat" | "once" | "deny"; window_id?: string };
export type ActRequest = {
session_id: string;
diff --git a/apps/server/src/computer-use/shared/portable-host.mjs b/apps/server/src/computer-use/shared/portable-host.mjs
index de47c04a..e61a4b86 100644
--- a/apps/server/src/computer-use/shared/portable-host.mjs
+++ b/apps/server/src/computer-use/shared/portable-host.mjs
@@ -36,7 +36,7 @@ import {
} from "./contract.mjs";
import { compareGrids, encodeJpeg, encodePng, fitLongSide, luminanceGrid, paintBoxes } from "./image.mjs";
import { sha256 } from "./media.mjs";
-import { actApproval, deniedApp } from "./policy.mjs";
+import { actApproval, ASK_SEND_DELETE, deniedApp } from "./policy.mjs";
const RPC = new Set(["initialize", "ping", "tools/list", "tools/call", "notifications/initialized", "notifications/cancelled"]);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -127,8 +127,8 @@ function describeAction(a) {
* The host. Options:
* - native: a createNativeWorker() (or the same interface)
* - spool: a media spool (media.mjs createMediaSpool) frames go to, or null
- * - settings(): { enabled, real_screen, limits, deny_apps, mode } now
- * (mode: the chat's permission mode careful|normal|auto)
+ * - settings(): { enabled, real_screen, limits, deny_apps, mode, ask_send_delete } now
+ * (mode: the chat's permission mode careful|normal|auto; ask_send_delete: the server's send/delete asks)
* - context(): { ancestors, self_pids, tty_pids, chat } now, or a promise of it
* (chat: the chat using computer use, for "Allow for this chat" and per-chat counts)
* - approve: { open(request) → { decision: "chat"|"once"|"deny", window_id? },
@@ -384,7 +384,7 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
if (compare.stale) return finish({ ...common, ok: false, code: "stale_observation", message: "The window changed since the observation. Observe again.", next: "computer_observe" });
}
// Per-action approval by permission mode (host channel, never the engine's).
- const decision = actApproval({ mode: settings()?.mode, action, intent: args.intent, target: await targetAt(observed, action, current, s), window: { id: String(current.id), app_id: current.appId, title: current.title }, approved: s.approved, typed_before: s.typedIn === String(current.id) });
+ const decision = actApproval({ mode: settings()?.mode, action, intent: args.intent, target: await targetAt(observed, action, current, s), window: { id: String(current.id), app_id: current.appId, title: current.title }, approved: s.approved, typed_before: s.typedIn === String(current.id) }, { sendDelete: settings()?.ask_send_delete === true || ASK_SEND_DELETE });
let approval = { asked: false };
if (decision.ask) {
// The same action with the same intent, allowed a moment ago (a retry after a fresh observation), is not asked again.