An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(bridge): a notice goes only to an app that said it may show one: only it hears that one is waiting and only it is handed anything, so a watcher that cannot post never drains what one that can would show; watch false lets go, as it does for Android
Shahriarcf20d7a9165c
diff --git a/docs/internals/transport.md b/docs/internals/transport.mdindex 35d558c..78ba31e 100644--- a/docs/internals/transport.md+++ b/docs/internals/transport.md@@ -207,8 +207,9 @@ that speaks 24; the Bridge sends `openNotice` only to an extension that speaks 2| `openNotice` | Bridge | `noticeId`: someone clicked it in the app, so the extension brings that notice's tab to the front |The app sends `/control` `notices {watch:true, allowed}` on every socket and again when the-computer starts or stops letting it notify; `notices-changed` tells it to call `takeNotices`, which-hands over and forgets what is waiting (a notice nobody takes within five minutes is dropped). A click+computer starts or stops letting it notify (`watch:false` lets go); `notices-changed` tells it to+call `takeNotices`, which hands over and forgets what is waiting (a notice nobody takes within five+minutes is dropped). Only a watcher that said `allowed` is told, and only it is handed anything. A clicksends `openNotice`, which reaches the browser the notice came from. Agent-run connections are refusedall three. Nothing about a notice is written to disk.diff --git a/src/daemon/daemon.ts b/src/daemon/daemon.tsindex 2824341..75ed1fd 100644--- a/src/daemon/daemon.ts+++ b/src/daemon/daemon.ts@@ -267,7 +267,7 @@ export async function startDaemon({ version, idleExit = true, android = androidOconst notices = noticeDesk({changed: () => {- for (const ws of notices.watchers()) send(ws as WebSocket, { event: 'notices-changed' });+ for (const ws of notices.showers()) send(ws as WebSocket, { event: 'notices-changed' });},});@@ -1017,10 +1017,11 @@ export async function startDaemon({ version, idleExit = true, android = androidOreturn send(ws, { id: request.id, op: request.op, ok: false });}if (request.op === 'notices') {- if (request.watch) notices.watch(ws, request.allowed === true);+ if (request.watch === false) notices.unwatch(ws);+ else if (request.watch) notices.watch(ws, request.allowed === true);return send(ws, { id: request.id, op: 'notices', ok: true });}- if (request.op === 'takeNotices') return send(ws, { id: request.id, op: 'takeNotices', notices: notices.take() });+ if (request.op === 'takeNotices') return send(ws, { id: request.id, op: 'takeNotices', notices: notices.take(ws) });const route = typeof request.notice === 'string' ? notices.routeOf(request.notice) : undefined;const link = route ? links.get(route) : undefined;const ok = !!link?.isOpen && link.speaks(NOTICE_PROTOCOL);diff --git a/src/daemon/notice-desk.test.ts b/src/daemon/notice-desk.test.tsindex 38e59a3..e6a2086 100644--- a/src/daemon/notice-desk.test.ts+++ b/src/daemon/notice-desk.test.ts@@ -23,35 +23,53 @@ describe('the notice desk', () => {it('queues a notice for an app that may show it, says so, and hands it over once', () => {const { desk: built, changed } = desk();- built.watch({}, true);+ const app = {};+ built.watch(app, true);expect(built.offer(done, from)).toBe(true);expect(changed).toHaveBeenCalledOnce();- expect(built.take()).toEqual([{ ...done, browser: 'Google Chrome', at: 1_000_000 }]);- expect(built.take()).toEqual([]);+ expect(built.take(app)).toEqual([{ ...done, browser: 'Google Chrome', at: 1_000_000 }]);+ expect(built.take(app)).toEqual([]);+ });++ it('hands notices only to a watcher that may show them, and tells only those', () => {+ const { desk: built } = desk();+ const silent = {};+ const app = {};+ built.watch(silent, false);+ built.watch(app, true);+ built.offer(done, from);++ expect(built.showers()).toEqual([app]);+ expect(built.take(silent)).toEqual([]);+ expect(built.take({})).toEqual([]);+ expect(built.take(app).map((notice) => notice.id)).toEqual([done.id]);});it('replaces a repeat of the same notice rather than stacking it', () => {const { desk: built } = desk();- built.watch({}, true);+ const app = {};+ built.watch(app, true);built.offer(done, from);built.offer({ ...done, body: 'Finished after 3:13.' }, from);- expect(built.take().map((notice) => notice.body)).toEqual(['Finished after 3:13.']);+ expect(built.take(app).map((notice) => notice.body)).toEqual(['Finished after 3:13.']);});it('drops a notice nobody took within five minutes', () => {const { desk: built, advance } = desk();- built.watch({}, true);+ const app = {};+ built.watch(app, true);built.offer(done, from);advance(5 * 60_000);- expect(built.take()).toEqual([]);+ expect(built.take(app)).toEqual([]);});it('remembers which browser a notice came from after it was taken, for a click', () => {const { desk: built } = desk();- built.watch({}, true);+ const app = {};+ built.watch(app, true);built.offer(done, from);- built.take();+ built.take(app);expect(built.routeOf(done.id)).toBe(from.id);expect(built.routeOf('monitor:other')).toBeUndefined();});diff --git a/src/daemon/notice-desk.ts b/src/daemon/notice-desk.tsindex 2ced413..5336b5f 100644--- a/src/daemon/notice-desk.ts+++ b/src/daemon/notice-desk.ts@@ -15,10 +15,12 @@ export interface NoticeDesk {watch(watcher: object, allowed: boolean): void;unwatch(watcher: object): void;canShow(): boolean;- watchers(): object[];+ /** The watchers that may show notices, the only ones told about a new one. */+ showers(): object[];/** True when an app will show it. */offer(notice: DeviceNotice, from: { id: string; browser?: string }): boolean;- take(): QueuedNotice[];+ /** What is waiting, for a watcher that may show it; any other caller gets nothing and leaves it waiting. */+ take(watcher: object): QueuedNotice[];/** The browser a notice came from. */routeOf(noticeId: string): string | undefined;}@@ -34,7 +36,7 @@ export function noticeDesk({ changed, now = Date.now }: { changed: () => void; nwatch: (watcher, allowed) => void allowedBy.set(watcher, allowed),unwatch: (watcher) => void allowedBy.delete(watcher),canShow,- watchers: () => [...allowedBy.keys()],+ showers: () => [...allowedBy].filter(([, allowed]) => allowed).map(([watcher]) => watcher),offer(notice, from) {if (!canShow()) return false;queue = [...queue.filter((queued) => queued.id !== notice.id), { ...notice, browser: from.browser, at: now() }].slice(-QUEUE_MAX);@@ -44,7 +46,8 @@ export function noticeDesk({ changed, now = Date.now }: { changed: () => void; nchanged();return true;},- take() {+ take(watcher) {+ if (!allowedBy.get(watcher)) return [];const fresh = queue.filter((queued) => now() - queued.at < KEEP_MS);queue = [];return fresh;