Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: computer use asks only before paying and passwords in Normal

ogsamrat22da4b547e8d
diff --git a/apps/app/src/i18n/locales/en.ts b/apps/app/src/i18n/locales/en.ts
index 74ee4d90..971c765a 100644
--- a/apps/app/src/i18n/locales/en.ts
+++ b/apps/app/src/i18n/locales/en.ts
@@ -2126,7 +2126,7 @@ export default {
"permissions.mode.careful": "Careful",
"permissions.mode.careful_summary": "Asks before every file change and every command. Reading and searching run freely.",
"permissions.mode.normal": "Normal",
- "permissions.mode.normal_summary": "Asks only before risky actions: recursive deletes, sudo, git push or hard resets, changes outside the project, reading secrets, piping downloads into a shell, publishing packages.",
+ "permissions.mode.normal_summary": "Asks only before risky actions: recursive deletes, sudo, git push or hard resets, changes outside the project, reading secrets, piping downloads into a shell, publishing packages. Computer use asks once per app per chat, then only before paying, buying or ordering and before typing a password.",
"permissions.mode.auto": "Auto",
"permissions.mode.auto_summary": "Never asks. The agent runs everything it decides to run.",
"permissions.status_mode": "{mode} mode.",
diff --git a/apps/app/src/react-app/domains/session/surface/computer-use/request-card.tsx b/apps/app/src/react-app/domains/session/surface/computer-use/request-card.tsx
index 9db5a30b..78afbe55 100644
--- a/apps/app/src/react-app/domains/session/surface/computer-use/request-card.tsx
+++ b/apps/app/src/react-app/domains/session/surface/computer-use/request-card.tsx
@@ -145,7 +145,7 @@ export function ComputerUseRequestCard(props: { request: ComputerUseRequest }) {
<Check data-icon="inline-start" />
<span className="flex flex-col items-start leading-4">
<span>Allow for this chat</span>
- <span className="text-[10px] font-normal opacity-80">Same app, up to {Math.round(request.chat_seconds / 60)} minutes</span>
+ <span className="text-[10px] font-normal opacity-80">{request.chat_seconds > 0 ? `Same app, up to ${Math.max(1, Math.round(request.chat_seconds / 60))} minutes` : "Same app, until this chat ends"}</span>
</span>
</Button>
<Button type="button" variant="outline" size="sm" disabled={busy} onClick={(event) => answer("once", event)} data-computer-use-answer="once">
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.tsx
index b5429221..f889647a 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
@@ -174,6 +174,9 @@ export function ComputerUseConfig({ connected, connecting, onConnect, onRefresh,
<Button variant="outline" disabled={copyCli.isPending} onClick={() => copyCli.mutate()}><Copy className="size-4" />{copyCli.isSuccess ? "CLI connection copied" : "Copy CLI connection"}</Button>
<p className="text-xs leading-relaxed text-muted-foreground">Keep OmniRush.ai open. Add the copied server to ~/.omnirush/mcp.json, then run /mcp reconnect in the CLI. Window approval stays in this app.</p>
</div> : null}
+ <p className="text-xs leading-relaxed text-muted-foreground" data-computer-use-asks>
+ You approve each app once per chat, in every mode. Normal then works without asking, except before paying, buying or ordering and before typing a password. Careful asks before every action; Auto asks only that first time.
+ </p>
<p className="text-xs leading-relaxed text-muted-foreground">
{!mac ? "Keep the target app visible on an unlocked desktop. Computer Use moves the mouse and types in the foreground; choose Continue after taking over. Choose a model that accepts images. For background Blender work, ask for a Blender Python script or use an app connector. " : null}
Hide the preview if it covers app controls; Stop stays available in the OmniRush.ai window. Sessions end after 15 minutes and pause when idle. Window content is processed by your selected model provider. Enter passwords yourself. For websites, use the built-in browser.
diff --git a/apps/server/src/computer-use/contract-policy.test.ts b/apps/server/src/computer-use/contract-policy.test.ts
index 6a98fce0..1a4ec751 100644
--- a/apps/server/src/computer-use/contract-policy.test.ts
+++ b/apps/server/src/computer-use/contract-policy.test.ts
@@ -22,6 +22,7 @@ import {
} from "./shared/contract.mjs";
import {
actApproval,
+ ASK_REASONS,
computerUseSetting,
deniedApp,
documentOf,
@@ -30,7 +31,6 @@ import {
nestedAgent,
normalizeComputerUse,
readAncestors,
- riskyChord,
riskyWords,
SCREEN_BASH_RULES,
subagentPermissionRules,
@@ -212,53 +212,78 @@ describe("policy: approvals per permission mode", () => {
test("Careful asks every act; Auto never; Normal runs plain acts", () => {
expect(actApproval({ ...plain, mode: "careful" })).toEqual({ ask: true, reasons: [{ code: "careful" }] });
- expect(actApproval({ ...plain, mode: "auto", intent: "Delete everything", action: { type: "key", key: "q", modifiers: ["meta"] } })).toEqual({ ask: false, reasons: [] });
+ expect(actApproval({ ...plain, mode: "careful", target: {} })).toEqual({ ask: true, reasons: [{ code: "careful" }] });
+ expect(actApproval({ ...plain, mode: "auto", intent: "Buy it now", action: { type: "type", text: "ghp_" + "a1B2".repeat(9) }, target: { secure: true } })).toEqual({ ask: false, reasons: [] });
expect(actApproval(plain)).toEqual({ ask: false, reasons: [] });
});
- test("Normal asks on risky intents and targets", () => {
- expect(actApproval({ ...plain, intent: "Send the email to Bob" }).reasons[0]).toEqual({ code: "risky_intent", detail: "send" });
- expect(actApproval({ ...plain, intent: "Click Place order to buy it" }).ask).toBe(true);
- expect(actApproval({ ...plain, intent: "Sort in order to find the row" }).ask).toBe(false);
- expect(actApproval({ ...plain, target: { text: "Sign in" } }).reasons).toEqual([{ code: "risky_target", detail: "sign in" }]);
- expect(actApproval({ ...plain, action: { type: "key", key: "Enter" }, target: { text: "Publish" } }).ask).toBe(true);
- expect(actApproval({ ...plain, intent: "Turn off the location permission in settings" }).ask).toBe(true);
- expect(actApproval({ ...plain, action: { type: "move", x: 1, y: 1 }, target: { text: "Delete" } }).ask).toBe(false);
- expect(riskyWords("uninstall the plugin then post a reply")).toEqual(["uninstall", "post"]);
- });
+ // The rules table, Normal: what asks and what no longer does.
+ const table: Array<[string, Record<string, unknown>, string[]]> = [
+ // (a) paying, buying, ordering: intent or the text at a click/Enter target.
+ ["buy intent", { intent: "Click Buy now" }, ["risky_intent"]],
+ ["place order intent", { intent: "Click Place order to finish" }, ["risky_intent"]],
+ ["pay target", { target: { text: "Pay now" } }, ["risky_target"]],
+ ["checkout target, Enter", { action: { type: "key", key: "Enter" }, target: { text: "Checkout" } }, ["risky_target"]],
+ ["subscribe target", { target: { text: "Subscribe for $9.99/month" } }, ["risky_target"]],
+ ["donate intent", { intent: "Donate 5 dollars" }, ["risky_intent"]],
+ // (b) typing a password: secure field, credential text, or an intent that says so.
+ ["secure field", { action: { type: "type", text: "hunter22" }, target: { secure: true } }, ["secure_field"]],
+ ["credential text", { action: { type: "type", text: "ghp_" + "a1B2".repeat(9) } }, ["credential_text"]],
+ ["password intent", { action: { type: "type", text: "hunter22" }, intent: "Type the password" }, ["credential_intent"]],
+ ["one-time code intent", { action: { type: "type", text: "481516" }, intent: "Enter the one-time code" }, ["credential_intent"]],
+ // No longer asks in Normal.
+ ["unknown target click (X11)", { target: {} }, []],
+ ["unknown target right click", { action: { type: "right_click", x: 1, y: 1 }, target: {} }, []],
+ ["Enter after typing", { action: { type: "key", key: "Enter" }, target: {}, typed_before: true }, []],
+ ["send intent", { intent: "Send the email to Bob" }, []],
+ ["delete intent", { intent: "Delete the old draft" }, []],
+ ["post/publish/share", { intent: "Post, publish and share the article" }, []],
+ ["sign-in target", { target: { text: "Sign in" } }, []],
+ ["install intent", { intent: "Install the extension" }, []],
+ ["settings intent", { intent: "Turn off the location permission in settings" }, []],
+ ["paste chord", { action: { type: "key", key: "v", modifiers: ["ctrl"] } }, []],
+ ["quit chord", { action: { type: "key", key: "q", modifiers: ["meta"] } }, []],
+ ["close chord", { action: { type: "key", key: "F4", modifiers: ["alt"] } }, []],
+ ["site changed", { window: { ...window, url_host: "bank.example" }, approved: { ...approved, url_host: "shop.example" } }, []],
+ ["document changed", { window: { ...window, title: "secrets.txt - gedit" } }, []],
+ ["after takeover", { after_takeover: true }, []],
+ ["sort order", { intent: "Sort in order to find the row" }, []],
+ ["order history", { target: { text: "Order history" } }, []],
+ ["plain typing", { action: { type: "type", text: "Meeting notes for Tuesday" }, intent: "Type the notes" }, []],
+ ["move over a pay button", { action: { type: "move", x: 1, y: 1 }, target: { text: "Pay" } }, []],
+ // Kept: an act outside the approved window (a session never sends one).
+ ["another window", { window: { ...window, id: "w2" } }, ["other_window"]],
+ ];
+ for (const [label, change, codes] of table) {
+ test(`Normal rules table: ${label}`, () => {
+ const decision = actApproval({ ...plain, ...change });
+ expect(decision.reasons.map((r) => r.code)).toEqual(codes);
+ expect(decision.ask).toBe(codes.length > 0);
+ expect(actApproval({ ...plain, ...change, mode: "careful" }).ask).toBe(true);
+ expect(actApproval({ ...plain, ...change, mode: "auto" }).ask).toBe(false);
+ });
+ }
- test("Normal asks on secure fields, credentials, paste and close/quit chords", () => {
- expect(actApproval({ ...plain, action: { type: "type", text: "hunter22" }, target: { secure: true } }).reasons).toEqual([{ code: "secure_field" }]);
- expect(actApproval({ ...plain, action: { type: "type", text: "ghp_" + "a1B2".repeat(9) } }).reasons).toEqual([{ code: "credential_text" }]);
- expect(actApproval({ ...plain, action: { type: "type", text: "Meeting notes for Tuesday" } }).ask).toBe(false);
- for (const chord of [{ key: "v", modifiers: ["ctrl"] }, { key: "v", modifiers: ["meta"] }, { key: "Insert", modifiers: ["shift"] }]) expect(riskyChord({ type: "key", ...chord })).toBe("paste");
- for (const chord of [{ key: "q", modifiers: ["meta"] }, { key: "w", modifiers: ["ctrl"] }, { key: "F4", modifiers: ["alt"] }, { key: "Delete", modifiers: ["shift"] }, { key: "Backspace", modifiers: ["meta"] }]) expect(riskyChord({ type: "key", ...chord })).toBe("close_quit_delete");
- expect(riskyChord({ type: "key", key: "s", modifiers: ["ctrl"] })).toBeNull();
+ test("riskyWords: paying, buying and ordering only; every reason has people-facing text", () => {
+ expect(riskyWords("uninstall the plugin then post a reply")).toEqual([]);
+ expect(riskyWords("buy the plan, then place order")).toEqual(["buy", "place order"]);
+ expect(riskyWords("track my order")).toEqual([]);
+ expect(actApproval({ ...plain, intent: "Buy it" }).reasons[0]).toEqual({ code: "risky_intent", detail: "buy" });
+ for (const code of ["careful", "risky_intent", "risky_target", "secure_field", "credential_text", "credential_intent", "other_window"]) expect(typeof ASK_REASONS[code as keyof typeof ASK_REASONS]).toBe("string");
+ expect(Object.keys(ASK_REASONS).sort()).toEqual(["careful", "credential_intent", "credential_text", "other_window", "risky_intent", "risky_target", "secure_field"]);
expect(looksLikeCredential("AKIAABCDEFGHIJKLMNOP")).toBe(true);
expect(looksLikeCredential("password=Sup3rS3cret!")).toBe(true);
expect(looksLikeCredential("Xk9#mP2$vL7qR4@nT8wZ")).toBe(true);
expect(looksLikeCredential("https://example.com/some/long/path?q=1")).toBe(false);
expect(looksLikeCredential("the quick brown fox jumps")).toBe(false);
- });
-
- test("Normal asks on another window, a changed document or site, and after takeover", () => {
- expect(actApproval({ ...plain, window: { ...window, id: "w2" } }).reasons).toEqual([{ code: "other_window" }]);
- expect(actApproval({ ...plain, window: { ...window, title: "secrets.txt - gedit" } }).reasons[0]?.code).toBe("document_changed");
- expect(actApproval({ ...plain, window: { ...window, title: "*notes.txt - gedit" } }).ask).toBe(false);
- expect(actApproval({ ...plain, window: { ...window, url_host: "bank.example" }, approved: { ...approved, url_host: "shop.example" } }).reasons[0]?.code).toBe("document_changed");
- expect(actApproval({ ...plain, after_takeover: true }).reasons).toEqual([{ code: "after_takeover" }]);
expect(documentOf("● main.ts - Code", "Code")).toBe("main.ts");
});
- test("Normal, no readable text at the target: a click asks (target unknown); Enter right after typing asks", () => {
- expect(actApproval({ ...plain, target: {} }).reasons).toEqual([{ code: "target_unknown" }]);
- expect(actApproval({ ...plain, action: { type: "right_click", x: 1, y: 1 }, target: {} }).ask).toBe(true);
- expect(actApproval({ ...plain, action: { type: "key", key: "Enter" }, target: {}, typed_before: true }).reasons).toEqual([{ code: "submit_after_typing" }]);
- expect(actApproval({ ...plain, action: { type: "key", key: "enter" }, target: {}, typed_before: false }).ask).toBe(false);
- expect(actApproval({ ...plain, action: { type: "move", x: 1, y: 1 }, target: {} }).ask).toBe(false);
- // With text the host read there, the target rules decide instead.
- expect(actApproval({ ...plain, target: { text: "Bold" }, typed_before: true }).ask).toBe(false);
- expect(actApproval({ ...plain, mode: "auto", target: {}, typed_before: true }).ask).toBe(false);
+ test("Allow for this chat: until the chat ends by default; the server's value is an upper bound", () => {
+ expect(DEFAULT_LIMITS.chat_approval_seconds).toBe(0);
+ expect(normalizeLimits({ chat_approval_seconds: 1800 }).chat_approval_seconds).toBe(1800);
+ expect(normalizeLimits({ chat_approval_seconds: 0 }).chat_approval_seconds).toBe(0);
+ expect(normalizeLimits({}).chat_approval_seconds).toBe(0);
});
test("shell screen capture asks; sub-agents get no computer tools", () => {
diff --git a/apps/server/src/computer-use/portable-host.test.ts b/apps/server/src/computer-use/portable-host.test.ts
index 600a77d8..48cf89f2 100644
--- a/apps/server/src/computer-use/portable-host.test.ts
+++ b/apps/server/src/computer-use/portable-host.test.ts
@@ -65,7 +65,7 @@ function fakeNative() {
return native;
}
-function rig(mode: "careful" | "normal" | "auto", options: { decision?: "chat" | "once" | "deny"; allowAct?: boolean; limits?: Record<string, number>; enabled?: boolean } = {}) {
+function rig(mode: "careful" | "normal" | "auto", options: { decision?: "chat" | "once" | "deny"; allowAct?: boolean; limits?: Record<string, number>; enabled?: boolean; chats?: Array<string | null> } = {}) {
const native = fakeNative();
const dir = mkdtempSync(path.join(os.tmpdir(), "cu-host-"));
dirs.push(dir);
@@ -77,7 +77,8 @@ function rig(mode: "careful" | "normal" | "auto", options: { decision?: "chat" |
native,
spool: createMediaSpool(path.join(dir, "spool")),
settings: () => settings,
- context: () => ({ ancestors: [], chat: "ses_1" }),
+ // The chat of each open in turn (options.chats), else always "ses_1".
+ context: () => ({ ancestors: [], chat: options.chats ? (options.chats.length > 1 ? options.chats.shift()! : options.chats[0]!) : "ses_1" }),
approve: {
open: async (request: OpenRequest) => { opens.push(request); return { decision: options.decision ?? "once", window_id: request.window_id }; },
act: async (request: ActRequest) => { acts.push(request); return { allow: options.allowAct ?? true }; },
@@ -146,6 +147,49 @@ describe("portable host: MCP surface and consent", () => {
await host.close();
});
+ test("Allow for this chat lasts the whole chat (no 30 min expiry), never another chat, and the server's value bounds it", async () => {
+ const realNow = Date.now;
+ let shift = 0;
+ Date.now = () => realNow() + shift;
+ try {
+ const r = rig("normal", { decision: "chat" });
+ const host = await r.hostPromise;
+ const c = host.connect();
+ const first = await call(c, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write" });
+ await call(c, "computer_close_session", { session_id: first.state.session_id });
+ shift = 6 * 3600_000;
+ const later = await call(c, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write later" });
+ expect(later.state).toMatchObject({ ok: true, approval: "chat" });
+ expect(r.opens.length).toBe(1);
+ expect(r.opens[0]?.chat_seconds).toBe(0);
+ await host.close();
+ shift = 0;
+ // The server says 600 s: asked again after it.
+ const b = rig("normal", { decision: "chat", limits: { chat_approval_seconds: 600 } });
+ const hb = await b.hostPromise;
+ const cb = hb.connect();
+ const one = await call(cb, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write" });
+ await call(cb, "computer_close_session", { session_id: one.state.session_id });
+ shift = 601_000;
+ await call(cb, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write" });
+ expect(b.opens.length).toBe(2);
+ expect(b.opens[0]?.chat_seconds).toBe(600);
+ await hb.close();
+ shift = 0;
+ // Another chat asks again; no chat known: no grant.
+ for (const chats of [["ses_1", "ses_2"], [null, null]]) {
+ const d = rig("normal", { decision: "chat", chats });
+ const hd = await d.hostPromise;
+ const cd = hd.connect();
+ const x = await call(cd, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write" });
+ await call(cd, "computer_close_session", { session_id: x.state.session_id });
+ await call(cd, "computer_open_session", { app_id: "/usr/bin/gedit", mode: "control", purpose: "Write" });
+ expect(d.opens.length).toBe(2);
+ await hd.close();
+ }
+ } finally { Date.now = realNow; }
+ });
+
test("off by the server: no session", async () => {
const r = rig("normal", { enabled: false });
const host = await r.hostPromise;
@@ -205,8 +249,13 @@ describe("portable host: observe and act", () => {
const plain = await call(c, "computer_act", { session_id: session, observation_id: obs.state.observation?.id, request_id: "a", intent: "Put the cursor at the end", action: { type: "click", x: 5, y: 5 } });
expect(plain.state).toMatchObject({ ok: true, approval: { asked: false } });
expect(r.acts.length).toBe(0);
- const risky = await call(c, "computer_act", { session_id: session, observation_id: (plain.state.observation as { id: string }).id, request_id: "b", intent: "Paste the copied text", action: { type: "key", key: "v", modifiers: ["ctrl"] } });
- expect(risky.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["paste"] } });
+ const paste = await call(c, "computer_act", { session_id: session, observation_id: (plain.state.observation as { id: string }).id, request_id: "b", intent: "Paste the copied text", action: { type: "key", key: "v", modifiers: ["ctrl"] } });
+ expect(paste.state).toMatchObject({ ok: true, approval: { asked: false } });
+ const send = await call(c, "computer_act", { session_id: session, observation_id: (paste.state.observation as { id: string }).id, request_id: "c", intent: "Send the message", action: { type: "key", key: "Enter" } });
+ expect(send.state).toMatchObject({ ok: true, approval: { asked: false } });
+ expect(r.acts.length).toBe(0);
+ const risky = await call(c, "computer_act", { session_id: session, observation_id: (send.state.observation as { id: string }).id, request_id: "d", intent: "Buy the ticket", action: { type: "click", x: 5, y: 5 } });
+ expect(risky.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["risky_intent"] } });
expect(r.acts.length).toBe(1);
await host.close();
});
@@ -250,33 +299,39 @@ describe("portable host: observe and act", () => {
await host.close();
});
- test("Normal: the text the host read at the point decides (risky target, secure field); without text, a click after typing asks", async () => {
+ test("Normal: the text the host read at the point decides (a pay target asks); without text, clicks run", async () => {
const r = rig("normal");
- // A host that reads text (macOS): a "Sign in" button at 300,200 (native pixels; the image is 640 wide, window 2560).
- r.native.state.texts = [{ x: 300, y: 200, width: 80, height: 30, text: "Sign in" }];
+ // A host that reads text (macOS): a "Buy now" button at 300,200 (native pixels; the image is 640 wide, window 2560).
+ r.native.state.texts = [{ x: 300, y: 200, width: 80, height: 30, text: "Buy now" }];
const { host, c, session, obs } = await opened(r);
const sign = 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(sign.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["risky_target"] } });
const secure = await call(c, "computer_act", { session_id: session, observation_id: (sign.state.observation as { id: string }).id, request_id: "b", intent: "Fill in the field", action: { type: "type", text: "abc" } });
expect(secure.state).toMatchObject({ ok: true, approval: { asked: false } });
await host.close();
- // A host that reads no text (X11): every click asks (the app doesn't say what it is); typing does not.
+ // A host that reads no text (X11): clicks and plain typing run without asking; a password asks.
const x = rig("normal");
const o = await opened(x);
const typed = await call(o.c, "computer_act", { session_id: o.session, observation_id: o.obs.state.observation?.id, request_id: "t", intent: "Type the name", action: { type: "type", text: "Ada" } });
expect(typed.state).toMatchObject({ ok: true, approval: { asked: false } });
const click = await call(o.c, "computer_act", { session_id: o.session, observation_id: (typed.state.observation as { id: string }).id, request_id: "k", intent: "Go to the next field", action: { type: "click", x: 400, y: 300 } });
- expect(click.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["target_unknown"] } });
- // The same click on the same image within 30 s (a retry) is not asked again.
- const again = await call(o.c, "computer_act", { session_id: o.session, observation_id: (click.state.observation as { id: string }).id, request_id: "k2", intent: "Go to the next field", action: { type: "click", x: 400, y: 300 } });
+ expect(click.state).toMatchObject({ ok: true, approval: { asked: false } });
+ const enter = await call(o.c, "computer_act", { session_id: o.session, observation_id: (click.state.observation as { id: string }).id, request_id: "e", intent: "Submit the form", action: { type: "key", key: "Enter" } });
+ expect(enter.state).toMatchObject({ ok: true, approval: { asked: false } });
+ expect(x.acts.length).toBe(0);
+ const pw = await call(o.c, "computer_act", { session_id: o.session, observation_id: (enter.state.observation as { id: string }).id, request_id: "p", intent: "Type the password", action: { type: "type", text: "hunter22" } });
+ expect(pw.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["credential_intent"] } });
+ // The same act on the same image within 30 s (a retry) is not asked again.
+ const again = await call(o.c, "computer_act", { session_id: o.session, observation_id: (pw.state.observation as { id: string }).id, request_id: "p2", intent: "Type the password", action: { type: "type", text: "hunter22" } });
expect(again.state).toMatchObject({ ok: true, approval: { asked: false } });
+ expect(x.acts.length).toBe(1);
expect(await o.host.physicalInput()).toBe(true);
x.native.state.synthetic = true;
expect(await o.host.physicalInput()).toBe(false);
await o.host.close();
});
- test("person input pauses; only Continue resumes; first act after takeover asks in Normal", async () => {
+ test("person input pauses; only Continue resumes; the first act after takeover runs in Normal", async () => {
const r = rig("normal");
const { host, c, session, obs } = await opened(r);
r.native.personInput();
@@ -286,7 +341,8 @@ describe("portable host: observe and act", () => {
await host.control({ session_id: session, action: "continue" });
const next = await call(c, "computer_observe", { session_id: session });
const act = await call(c, "computer_act", { session_id: session, observation_id: next.state.observation?.id, request_id: "b", intent: "Click in the text", action: { type: "click", x: 5, y: 5 } });
- expect(act.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["target_unknown", "after_takeover"] } });
+ expect(act.state).toMatchObject({ ok: true, approval: { asked: false } });
+ expect(r.acts.length).toBe(0);
expect(r.events.map((e) => `${e.event}:${e.by}`)).toEqual(["opened:agent", "approved:person", "paused:person", "continued:person"]);
await host.control({ session_id: session, action: "stop" });
expect(r.events.at(-1)).toMatchObject({ event: "stopped", by: "person", app_id: "/usr/bin/gedit", app_name: "gedit", bundle_or_exe: "/usr/bin/gedit", mode: "control", approval: "once", os: "linux", screen: { id: "0", width: 3840, height: 2160 } });
@@ -319,7 +375,7 @@ describe("portable host: observe and act", () => {
});
describe("portable host: titles that follow the agent's own typing, and a worker that died", () => {
- test("Normal: the agent's own act retitling the window does not ask; a change between acts does", async () => {
+ test("Normal: the window's title changing (the agent's own typing or another document) does not ask", async () => {
const r = rig("normal");
const { host, c, session, obs } = await opened(r);
r.native.state.retitle = () => "first line - Notepad";
@@ -333,7 +389,8 @@ describe("portable host: titles that follow the agent's own typing, and a worker
r.native.windows[0]!.title = "secrets.txt - Notepad";
const next = await call(c, "computer_observe", { session_id: session });
const d = await call(c, "computer_act", { session_id: session, observation_id: next.state.observation?.id, request_id: "d", intent: "Type more", action: { type: "type", text: "x" } });
- expect(d.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["document_changed"] } });
+ expect(d.state).toMatchObject({ ok: true, approval: { asked: false } });
+ expect(r.acts.length).toBe(0);
await host.close();
});
@@ -391,7 +448,7 @@ describe("portable host: the person's own press answers a question", () => {
});
describe("portable host: the control under the point from the worker (Windows MSAA)", () => {
- test("a named control decides (risky target, protected field); no name falls back to target_unknown", async () => {
+ test("a named control decides (pay target, protected field); no name runs", async () => {
const r = rig("normal");
let next: { name: string; role: number | null; protected: boolean } | null = { name: "Pay now", role: 43, protected: false };
const call0 = r.native.call.bind(r.native);
@@ -404,7 +461,7 @@ describe("portable host: the control under the point from the worker (Windows MS
expect(bold.state).toMatchObject({ ok: true, approval: { asked: false } });
next = { name: "", role: 42, protected: false };
const blank = await call(c, "computer_act", { session_id: session, observation_id: (bold.state.observation as { id: string }).id, request_id: "n", intent: "Click there", action: { type: "click", x: 30, y: 10 } });
- expect(blank.state).toMatchObject({ ok: true, approval: { asked: true, reasons: ["target_unknown"] } });
+ expect(blank.state).toMatchObject({ ok: true, approval: { asked: false } });
await host.close();
});
});
diff --git a/apps/server/src/computer-use/shared/PARITY.sha256 b/apps/server/src/computer-use/shared/PARITY.sha256
index 4720e2c8..0773b91f 100644
--- a/apps/server/src/computer-use/shared/PARITY.sha256
+++ b/apps/server/src/computer-use/shared/PARITY.sha256
@@ -1,13 +1,13 @@
# Computer use (contract v2, policy, media refs, image codecs, Windows/X11 host): the same files in omnirush-cli (src/computer-use/) and omnirush-gui (apps/server/src/computer-use/shared/).
# A change to one must be ported to the other and this list updated in both.
-36b49e5c1a90d4eb9b7d8c8fda207e6385c7ec0f8ba633e96f6726fc92ab2f53 contract.mjs
+59abb350a935c9462f3ea2e863396cdc785634dd2907f2f8947d87e9b30ec209 contract.mjs
aef0973f520f56ab8ad2699c14428bb2dd7ddb4b00dff823e4598e64d0c4a35b contract.d.mts
-68cbfd310412988babd3fc772ac5bfd2842ec99d726ea7316e6d8b2a02fb5490 policy.mjs
-6d5cd2d2e8e1665806caca5b229ddb0513be130f78476e17d712e0f3647d46bd policy.d.mts
+43810f0b2d2fba8b51878ab895d6475a98b2582f05c918995c554a6aa148503b policy.mjs
+88d60f32b244cde8a1c1328ee7ac13d1e61c7ef1d0f036fffcc780c0ef7c1e6e policy.d.mts
a96246342720364eb3e5843ba70fbbf640365f94597fc4dbb6a7be7d95254ec4 image.mjs
5eac31868aedd3e1d1e71b445f9a55d01316da7397f27f6db11472453bee4588 image.d.mts
e47c9ff67b9fce2ec12307737e973ce22551719c482b87f601569bd4f8a77e17 media.mjs
eabdf78c56733577d05aad490d9d7d5ece6c22e9b3ea9e6e9803d1a4a546fdd4 media.d.mts
a0bd964a5d0c7c5e26b4ce4ed8e8300f80a0a3a9da5d7f49c36f6ac2c907e934 native-worker.mjs
-9380ef9ababaae4f2defcef4eaeb3d6918fe24a0a3f710af3a428a371d8b5bbf portable-host.mjs
+329272889926cfcff24fa7e4c0188edc0f63b34e9bb3a73a0cc4361403bf7b0a portable-host.mjs
641be80cebb04d353031392d8f53f45ead1e1beaf83f1e67d24945f0eda330bf portable-host.d.mts
diff --git a/apps/server/src/computer-use/shared/contract.mjs b/apps/server/src/computer-use/shared/contract.mjs
index a9d4d43f..0a7bd7d2 100644
--- a/apps/server/src/computer-use/shared/contract.mjs
+++ b/apps/server/src/computer-use/shared/contract.mjs
@@ -62,7 +62,8 @@ export const DEFAULT_LIMITS = Object.freeze({
full_long_side: 3840,
observation_ttl_seconds: 15,
approval_timeout_seconds: 120,
- chat_approval_seconds: 1800,
+ // "Allow for this chat": 0 = until the chat ends; a server value above 0 is an upper bound.
+ chat_approval_seconds: 0,
media_full_bytes: 300 * 1024 * 1024,
media_model_bytes: 200 * 1024 * 1024,
});
@@ -77,7 +78,7 @@ export const LIMIT_RANGES = Object.freeze({
full_long_side: [640, 7680],
observation_ttl_seconds: [2, 120],
approval_timeout_seconds: [10, 600],
- chat_approval_seconds: [60, 7200],
+ chat_approval_seconds: [0, 30 * 86400],
media_full_bytes: [0, 2 * 1024 * 1024 * 1024],
media_model_bytes: [0, 2 * 1024 * 1024 * 1024],
});
diff --git a/apps/server/src/computer-use/shared/policy.d.mts b/apps/server/src/computer-use/shared/policy.d.mts
index 2a583ef3..2474dadc 100644
--- a/apps/server/src/computer-use/shared/policy.d.mts
+++ b/apps/server/src/computer-use/shared/policy.d.mts
@@ -53,20 +53,16 @@ export function nestedAgent(options?: { env?: Record<string, string | undefined>
export const RISKY_WORDS: readonly string[];
export function riskyWords(value: unknown): string[];
export function looksLikeCredential(value: unknown): boolean;
-export function riskyChord(action: unknown): "paste" | "close_quit_delete" | null;
export function documentOf(title: unknown, appName?: unknown): string;
-export type AskReasonCode = "careful" | "risky_intent" | "risky_target" | "secure_field" | "credential_text" | "paste" | "close_quit_delete" | "other_window" | "document_changed" | "after_takeover" | "submit_after_typing" | "target_unknown";
+export type AskReasonCode = "careful" | "risky_intent" | "risky_target" | "secure_field" | "credential_text" | "credential_intent" | "other_window";
export type ApprovalInput = {
mode?: PermissionMode | string;
action?: Action | Record<string, unknown>;
intent?: string;
- target?: { text?: string; secure?: boolean; url_host?: string };
- window?: { id?: string | number; app_id?: string; title?: string; app_name?: string; url_host?: string };
- approved?: { window_id?: string | number; app_id?: string; title?: string; url_host?: string };
- after_takeover?: boolean;
- /** The agent's previous act in this window typed text (and no click or Enter since). */
- typed_before?: boolean;
+ target?: { text?: string; secure?: boolean };
+ window?: { id?: string | number; app_id?: string };
+ approved?: { window_id?: string | number; app_id?: string };
};
export function actApproval(input?: ApprovalInput): { ask: boolean; reasons: Array<{ code: AskReasonCode; detail?: string }> };
export const ASK_REASONS: Readonly<Record<AskReasonCode, string>>;
diff --git a/apps/server/src/computer-use/shared/policy.mjs b/apps/server/src/computer-use/shared/policy.mjs
index 914e92c1..e0474aa3 100644
--- a/apps/server/src/computer-use/shared/policy.mjs
+++ b/apps/server/src/computer-use/shared/policy.mjs
@@ -253,17 +253,18 @@ export function nestedAgent({ env = process.env, ancestors = [] } = {}) {
// ------------------------------------------------------- per-action approvals
-/** Words in an intent or the text at the target that make an act ask (Normal). */
+/**
+ * Words in an intent or the text at the target that make an act ask in Normal:
+ * paying, buying and ordering (money leaving the person's account).
+ */
export const RISKY_WORDS = Object.freeze([
- "send", "pay", "payment", "buy", "purchase", "checkout", "check out", "order", "place order", "delete", "remove", "erase", "wipe", "trash",
- "post", "publish", "share", "sign in", "sign-in", "signin", "log in", "log-in", "login", "install", "uninstall", "transfer", "wire", "donate",
- "subscribe", "unsubscribe", "deploy", "merge", "submit password", "reset password", "change password",
+ "pay", "payment", "pay now", "buy", "buy now", "purchase", "checkout", "check out", "order", "place order", "order now",
+ "subscribe", "donate", "send money", "transfer money", "wire",
]);
const RISKY_RE = new RegExp(`(^|[^\\p{L}\\p{N}])(${[...RISKY_WORDS].sort((a, b) => b.length - a.length).map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/ /g, "\\s+")).join("|")})(?=$|[^\\p{L}\\p{N}])`, "iu");
-const SETTINGS_RE = /\b(change|edit|modify|update|grant|revoke|allow|deny|toggle|turn\s+(on|off)|enable|disable|reset)\b[^.]{0,60}\b(settings?|permissions?|privacy|access|preferences?|security)\b/i;
-const BENIGN = /\b(in\s+order\s+(to|for)|sort\s+order|order\s+by|reorder|ordered\s+list)\b/gi;
+const BENIGN = /\b(in\s+order\s+(to|for)|sort\s+order|order\s+by|reorder|ordered\s+list|order\s+(history|status|details|number)|track\s+(my\s+|your\s+|the\s+)?order)\b/gi;
-/** The risky words found in `value` (intent or on-screen text), lower case. */
+/** The paying/buying/ordering words found in `value` (intent or on-screen text), lower case. */
export function riskyWords(value) {
if (typeof value !== "string" || !value) return [];
const textValue = value.replace(BENIGN, " ");
@@ -271,10 +272,12 @@ export function riskyWords(value) {
const re = new RegExp(RISKY_RE.source, "giu");
let m;
while ((m = re.exec(textValue)) !== null) found.add(m[2].toLowerCase().replace(/\s+/g, " "));
- if (SETTINGS_RE.test(textValue)) found.add("change settings");
return [...found];
}
+/** An intent that says the typed text is a password, code or key (hosts that cannot see secure fields, X11). */
+const SECRET_INTENT = /\b(pass(word|code|phrase)s?|pins?|one[-\s]?time\s+(code|password)|otp|2fa|mfa|verification\s+code|security\s+code|secret|api[-\s]?key|access\s+key|token|credentials?|cvv|cvc|card\s+number)\b/i;
+
const CREDENTIAL_PATTERNS = [
/-----BEGIN [A-Z ]*PRIVATE KEY-----/,
/\b(AKIA|ASIA)[0-9A-Z]{16}\b/,
@@ -311,23 +314,6 @@ export function looksLikeCredential(value) {
return classes >= 3 && entropy(word) >= 3.8 && !/^https?:\/\//i.test(word) && !/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(word);
}
-/** Why a key chord asks (Normal): "paste", "close_quit_delete", or null. */
-export function riskyChord(action) {
- if (!isRecord(action)) return null;
- const mods = new Set(Array.isArray(action.modifiers) ? action.modifiers : []);
- const key = String(action.key ?? "").toLowerCase();
- const cmd = mods.has("ctrl") || mods.has("meta");
- if (action.type === "key") {
- if ((cmd && key === "v") || (mods.has("shift") && key === "insert")) return "paste";
- if (cmd && (key === "q" || key === "w" || key === "f4")) return "close_quit_delete";
- if (mods.has("alt") && key === "f4") return "close_quit_delete";
- if (mods.has("shift") && key === "delete") return "close_quit_delete";
- if (mods.has("meta") && (key === "backspace" || key === "delete")) return "close_quit_delete";
- if (cmd && mods.has("shift") && key === "delete") return "close_quit_delete";
- }
- return null;
-}
-
/** A window title without unsaved-change markers and the app name suffix, for "same document" checks. */
export function documentOf(title, appName) {
let t = String(title ?? "").trim().replace(/^[*•●◦]\s*/, "").replace(/\s*[*•●◦]$/, "").replace(/\s+\(modified\)$/i, "");
@@ -339,17 +325,17 @@ export function documentOf(title, appName) {
/**
* Whether one computer_act asks the person first, by permission mode:
* - careful: every act asks;
- * - normal: risky intents or targets, typing into a secure field or text that
- * looks like a credential, paste and close/quit/delete chords, acting in
- * another window or app, the window's document/site changed from the
- * approved one, and the first act after the person took over;
- * - auto: never (open-session consent, the deny list, hit-testing, the
- * indicator and Stop still apply).
- * `input`: { mode, action, intent, target: { text, secure, url_host },
- * window: { id, app_id, title, app_name, url_host }, approved: { window_id,
- * app_id, title, url_host }, after_takeover, typed_before } (target.text
- * undefined: the host reads no text there; typed_before: the last act in this
- * window was `type`).
+ * - normal: only paying, buying or ordering (the intent, or the text at a
+ * click or Enter target) and typing a password (a secure field, text that
+ * looks like a credential, or an intent that says so); plus an act outside
+ * the approved window, which a session never does (acts go to the approved
+ * window, other apps need their own open consent);
+ * - auto: never.
+ * In every mode the open-session consent, the deny list, hit-testing, the
+ * indicator and Stop still apply.
+ * `input`: { mode, action, intent, target: { text, secure }, window: { id,
+ * app_id }, approved: { window_id, app_id } } (target.text undefined: the
+ * host reads no text there).
* Returns { ask, reasons: [{ code, detail? }] }.
*/
export function actApproval(input = {}) {
@@ -365,41 +351,26 @@ export function actApproval(input = {}) {
const targetWords = riskyWords(target.text);
if (targetWords.length) reasons.push({ code: "risky_target", detail: targetWords.join(", ") });
}
- // No text the host could read at the target (X11; Windows when the control has no accessible name):
- // a click could be "Pay" or "Delete account", so it asks; an Enter right after typing may submit what
- // was typed (a login, a message, a payment), so it asks too.
- if (typeof target.text !== "string" && ["click", "double_click", "right_click"].includes(action.type)) reasons.push({ code: "target_unknown" });
- else if (typeof target.text !== "string" && input.typed_before === true && action.type === "key" && String(action.key).toLowerCase() === "enter") reasons.push({ code: "submit_after_typing" });
if (action.type === "type") {
if (target.secure === true) reasons.push({ code: "secure_field" });
if (looksLikeCredential(action.text)) reasons.push({ code: "credential_text" });
+ else if (target.secure !== true && SECRET_INTENT.test(String(input.intent ?? ""))) reasons.push({ code: "credential_intent" });
}
- const chord = riskyChord(action);
- if (chord) reasons.push({ code: chord });
const window = isRecord(input.window) ? input.window : null;
const approved = isRecord(input.approved) ? input.approved : null;
- if (window && approved) {
- if ((approved.app_id && window.app_id && approved.app_id !== window.app_id) || (approved.window_id !== undefined && window.id !== undefined && String(approved.window_id) !== String(window.id))) reasons.push({ code: "other_window" });
- else if ((approved.url_host && window.url_host && approved.url_host !== window.url_host) || (approved.title !== undefined && documentOf(approved.title, window.app_name) !== documentOf(window.title, window.app_name))) reasons.push({ code: "document_changed", detail: String(window.url_host ?? window.title ?? "").slice(0, 120) });
- }
- if (input.after_takeover === true) reasons.push({ code: "after_takeover" });
+ if (window && approved && ((approved.app_id && window.app_id && approved.app_id !== window.app_id) || (approved.window_id !== undefined && window.id !== undefined && String(approved.window_id) !== String(window.id)))) reasons.push({ code: "other_window" });
return { ask: reasons.length > 0, reasons };
}
/** People-facing text for an approval reason code. */
export const ASK_REASONS = Object.freeze({
careful: "Careful mode asks before every action.",
- risky_intent: "The agent says it will do something that is hard to undo",
- risky_target: "The target looks like a button that sends, pays, deletes or signs in",
+ risky_intent: "The agent says it will pay, buy or order something",
+ risky_target: "The target looks like a button that pays, buys or orders",
secure_field: "It would type into a password field.",
credential_text: "The text looks like a password or key.",
- paste: "It would paste from the clipboard.",
- close_quit_delete: "The shortcut closes, quits or deletes.",
+ credential_intent: "The agent says it is typing a password, code or key.",
other_window: "It would act in another window.",
- document_changed: "The window now shows a different page or document",
- after_takeover: "First action after you took over.",
- submit_after_typing: "It would press Enter right after typing, which may send what was typed.",
- target_unknown: "The agent wants to click here; the app doesn't say what this control is.",
});
/**
diff --git a/apps/server/src/computer-use/shared/portable-host.mjs b/apps/server/src/computer-use/shared/portable-host.mjs
index 390ff774..ad2a23ba 100644
--- a/apps/server/src/computer-use/shared/portable-host.mjs
+++ b/apps/server/src/computer-use/shared/portable-host.mjs
@@ -382,7 +382,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, app_name: current.appName, title: current.title }, approved: s.approved, after_takeover: s.afterTakeover, 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 }, approved: s.approved });
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.
@@ -403,13 +403,11 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
s.allowed.set(key, Date.now() + 30_000);
if (s.allowed.size > 64) s.allowed.delete(s.allowed.keys().next().value);
}
- if (decision.reasons.some((r) => r.code === "document_changed")) s.approved = { ...s.approved, title: current.title };
// While the person answered, the window may have moved or been covered: geometry and hits again (no image compare).
const after = await native.call("window", { id: s.window.id });
if (after.identity !== current.identity || JSON.stringify(after.bounds) !== JSON.stringify(current.bounds)) return finish({ ...common, approval, ok: false, code: "window_changed", message: "The window moved or changed. Observe again.", next: "computer_observe" });
if (!(await hitAll(after))) return finish({ ...common, approval, ok: false, code: "window_occluded", message: "Another window covers this point, or it is outside the approved window. Observe again." });
}
- s.afterTakeover = false;
const cursorBefore = await native.call("cursor").catch(() => null);
const point = mapped.length === 1 ? { model: mapped[0].model, screen: mapped[0].screen } : undefined;
const path = action.type === "drag" ? mapped.map((m) => ({ model: m.model, screen: m.screen })) : undefined;
@@ -424,10 +422,8 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
return finish({ ...common, approval, point, path, cursor_before: cursorBefore, ok: false, code, message: error.message, may_have_acted: action.type !== "wait", next: "computer_session_status" });
}
s.lastOperation = Date.now();
- // "Submit after typing" (Normal, when the host reads no text): typing arms it, a click or Enter after it asks.
+ // Typing goes to the control the last click focused: its secure-field check reads this point.
if (["click", "double_click"].includes(action.type) && mapped.length === 1) s.focusPoint = { window: String(current.id), screen: mapped[0].screen };
- if (action.type === "type") s.typedIn = String(current.id);
- else if (["click", "double_click"].includes(action.type) || (action.type === "key" && String(action.key).toLowerCase() === "enter")) s.typedIn = null;
const cursorAfter = await native.call("cursor").catch(() => null);
const done = { ...common, approval, point, path, cursor_before: cursorBefore, cursor_after: cursorAfter, ok: true, may_have_acted: action.type !== "wait" };
if (!args.observe_after) return finish({ ...done, next: "computer_observe" });
@@ -437,9 +433,6 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
const w = await native.call("window", { id: s.window.id });
const after = await observation(s, w);
s.window = w; s.observation = { ...after, generation: s.generation };
- // The agent's own act may retitle the window (an editor's title follows its text): the next
- // "document changed" check compares with the title right after this act, not the approval-time one.
- s.approved = { ...s.approved, title: w.title };
return finish({ ...done, frame_after: { sha256: after.sha }, observation: after.ref, window: windowRef(w), next: "computer_act" }, { data: after.bytes, mime: after.mime });
} catch (error) {
return finish({ ...done, next: "computer_observe", message: `The action was done, but the window could not be observed: ${error.message}` });
@@ -492,12 +485,12 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
const s = {
id: randomUUID(), connection, window: preferred, windows, mode: args.mode, purpose: args.purpose, phase: "approval", status: "",
approval: null, chat: ctx.chat ?? null, actions: 0, requests: new Set(), observation: null, resumeObservation: null, log: [],
- lastOperation: Date.now(), lastAct: 0, afterTakeover: false, generation: 0, allowed: new Map(), expiresAt: Date.now() + l.approval_timeout_seconds * 1000, screen: await screenOf(preferred),
+ lastOperation: Date.now(), lastAct: 0, generation: 0, allowed: new Map(), expiresAt: Date.now() + l.approval_timeout_seconds * 1000, screen: await screenOf(preferred),
};
lease = s.id; sessions.set(s.id, s);
update();
const grantKey = `${s.chat ?? ""}\0${preferred.appId}\0${s.mode}`;
- const grant = grants.get(grantKey);
+ const grant = s.chat ? grants.get(grantKey) : null;
let answer;
if (grant && grant.until > Date.now()) answer = { decision: "chat", window_id: String(preferred.id), reused: true };
else {
@@ -531,10 +524,13 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
return mcpResult(failure(error.code ?? "window_unavailable", error.message));
}
s.approval = answer.decision;
- if (answer.decision === "chat" && !answer.reused) grants.set(grantKey, { until: Date.now() + l.chat_approval_seconds * 1000 });
+ // "Allow for this chat": this app, this chat, until the chat ends (chat_approval_seconds 0), or for at most the
+ // server's chat_approval_seconds. Kept in memory only, keyed to the chat: never another chat, never a restart.
+ // A call no chat can be named for gets no grant (it works as "Allow once").
+ if (answer.decision === "chat" && !answer.reused && s.chat) grants.set(grantKey, { until: l.chat_approval_seconds > 0 ? Date.now() + l.chat_approval_seconds * 1000 : Infinity });
s.phase = "working"; s.lastOperation = Date.now();
s.expiresAt = Date.now() + l.session_seconds * 1000;
- s.approved = { window_id: String(s.window.id), app_id: s.window.appId, title: s.window.title };
+ s.approved = { window_id: String(s.window.id), app_id: s.window.appId };
emit(s, "opened", "agent", restartedNote ? { reason: "worker_restarted" } : {});
restartedNote = false;
emit(s, "approved", answer.reused ? "agent" : "person", answer.reused ? { reused: true } : {});
@@ -650,7 +646,7 @@ export async function createPortableHost({ native: firstNative, nativeFactory =
if (s.mode === "control") await native.call("focus", { window: current });
const started = await native.call("start");
s.generation = started?.generation ?? s.generation;
- s.window = current; s.phase = "working"; s.status = ""; s.lastOperation = Date.now(); s.afterTakeover = true;
+ s.window = current; s.phase = "working"; s.status = ""; s.lastOperation = Date.now();
emit(s, "continued", "person");
// One observation now, so what the person changed is in the next result.
try { s.resumeObservation = await observation(s, current); } catch { s.resumeObservation = null; }
diff --git a/apps/server/src/permissions/PARITY.sha256 b/apps/server/src/permissions/PARITY.sha256
index 1c5f0c34..1e1b4425 100644
--- a/apps/server/src/permissions/PARITY.sha256
+++ b/apps/server/src/permissions/PARITY.sha256
@@ -1,3 +1,3 @@
# permission-modes.json is the same file in omnirush-cli (src/permissions/) and omnirush-gui (apps/server/src/permissions/).
# A change to one must be ported to the other and this list updated in both.
-d522241e2c4771024e3b5309a708b3d84b2a7973df28b9fcbfb4636fa350c3f3 permission-modes.json
+fcd98d42094365053880f8471f75f8aea7734223ec6c4769c5634e56678ec711 permission-modes.json
diff --git a/apps/server/src/permissions/permission-modes.json b/apps/server/src/permissions/permission-modes.json
index b5ba7b9e..fdd0f3dd 100644
--- a/apps/server/src/permissions/permission-modes.json
+++ b/apps/server/src/permissions/permission-modes.json
@@ -15,7 +15,7 @@
},
"normal": {
"title": "Normal",
- "summary": "Asks only before risky actions: recursive deletes, sudo, git push or hard resets, changes outside the project, reading secrets, piping downloads into a shell, publishing packages."
+ "summary": "Asks only before risky actions: recursive deletes, sudo, git push or hard resets, changes outside the project, reading secrets, piping downloads into a shell, publishing packages. Computer use asks once per app per chat, then only before paying, buying or ordering and before typing a password."
},
"auto": {
"title": "Auto",
diff --git a/packages/types/src/desktop-ipc.ts b/packages/types/src/desktop-ipc.ts
index a15a3584..b80db9c3 100644
--- a/packages/types/src/desktop-ipc.ts
+++ b/packages/types/src/desktop-ipc.ts
@@ -916,6 +916,7 @@ export type ComputerUseRequest =
purpose: string;
os: string;
seconds: number;
+ /** How long "Allow for this chat" lasts: 0 = until the chat ends, else at most this many seconds (the server's bound). */
chat_seconds: number;
chat: string | null;
}