Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(browser): hire employees with a browser and surface its requests
trohitga80199b93ffb
diff --git a/client/src/components/credentials/PanelRenderer.tsx b/client/src/components/credentials/PanelRenderer.tsxindex ce27812f..0f58ce0d 100644--- a/client/src/components/credentials/PanelRenderer.tsx+++ b/client/src/components/credentials/PanelRenderer.tsx@@ -23,6 +23,7 @@ const PANEL_LOADERS: Record<PanelKind, () => Promise<{ default: React.ComponentToauth: () => import('./panels/OAuthPanel'),qrPairing: () => import('./panels/QrPairingPanel'),email: () => import('./panels/EmailPanel'),+ browserProfiles: () => import('./panels/BrowserProfilesPanel'),};// Memoize the lazy wrappers at module scope so switching providers of@@ -34,6 +35,7 @@ const LAZY_PANELS: Record<PanelKind, React.LazyExoticComponent<React.ComponentTyoauth: React.lazy(PANEL_LOADERS.oauth),qrPairing: React.lazy(PANEL_LOADERS.qrPairing),email: React.lazy(PANEL_LOADERS.email),+ browserProfiles: React.lazy(PANEL_LOADERS.browserProfiles),};/** `full`: the editor's Credentials modal (usage, provider defaults, ratediff --git a/client/src/components/credentials/panels/BrowserProfilesPanel.tsx b/client/src/components/credentials/panels/BrowserProfilesPanel.tsxnew file mode 100644index 00000000..f29d769c--- /dev/null+++ b/client/src/components/credentials/panels/BrowserProfilesPanel.tsx@@ -0,0 +1,232 @@+/**+ * BrowserProfilesPanel — the Web browser's login profiles.+ *+ * A profile is a browser's own cookies and logins. Each workflow's Browser+ * node uses that workflow's profile unless it picks a shared one, which is+ * added here. Logins come in two ways: sign in by hand with Take control in+ * the Browser workspace, or import a session file here (Playwright storage+ * state, Cookie-Editor JSON or cookies.txt). Sites show as domains and+ * cookie counts only; no cookie value ever reaches the client.+ */++import React, { useRef, useState } from 'react';+import { useQuery, useQueryClient } from '@tanstack/react-query';+import { Loader2, Trash2, Upload } from 'lucide-react';+import { toast } from 'sonner';++import { ActionButton } from '@/components/ui/action-button';+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from '@/components/ui/alert-dialog';+import { Badge } from '@/components/ui/badge';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { buildApiUrl } from '@/config/api';+import { useWebSocketActions } from '@/contexts/WebSocketContext';+import type { ProviderConfig } from '../types';++interface BrowserSite {+ domain: string;+ cookie_count: number;+}++interface BrowserProfile {+ id: string;+ name: string;+ kind: 'shared' | 'employee';+ sites: BrowserSite[];+ in_use: { label: string } | null;+}++interface Result {+ success?: boolean;+ error?: string;+}++/** Invalidated by the `browser_profiles_updated` broadcast (WebSocketContext). */+const BROWSER_PROFILES_QUERY_KEY = ['browserProfiles'];++function sitesText(sites: BrowserSite[]): string {+ if (sites.length === 0) return 'no logins yet';+ const shown = sites.slice(0, 3).map((site) => site.domain).join(', ');+ return sites.length > 3 ? `${shown} and ${sites.length - 3} more` : shown;+}++const BrowserProfilesPanel: React.FC<{ config: ProviderConfig; visible: boolean }> = ({ visible }) => {+ const { sendRequest, isReady } = useWebSocketActions();+ const queryClient = useQueryClient();+ const [name, setName] = useState('');+ const [busy, setBusy] = useState(false);+ const [doomed, setDoomed] = useState<BrowserProfile | null>(null);+ const importFor = useRef<string | null>(null);+ const fileInput = useRef<HTMLInputElement>(null);++ const profiles = useQuery({+ queryKey: BROWSER_PROFILES_QUERY_KEY,+ queryFn: async () => {+ const result = await sendRequest<Result & { profiles?: BrowserProfile[] }>('browser_profiles_list');+ if (result.success === false) throw new Error(result.error || 'Could not load the browser profiles.');+ return result.profiles ?? [];+ },+ enabled: isReady && visible,+ // Agent runs create profiles while this panel is closed.+ refetchOnMount: 'always',+ staleTime: 0,+ });++ /** Runs one change, reports a failure, and refreshes the list. */+ const run = async (change: () => Promise<Result>): Promise<boolean> => {+ setBusy(true);+ try {+ const result = await change();+ if (result.success === false) toast.error(result.error || 'That did not work.');+ return result.success !== false;+ } catch (error) {+ toast.error(error instanceof Error ? error.message : 'That did not work.');+ return false;+ } finally {+ setBusy(false);+ void queryClient.invalidateQueries({ queryKey: BROWSER_PROFILES_QUERY_KEY });+ }+ };++ const create = async (event: React.FormEvent) => {+ event.preventDefault();+ if (await run(() => sendRequest<Result>('browser_profile_create', { name: name.trim() }))) setName('');+ };++ const importFile = (profileId: string, file: File) =>+ run(async () => {+ const body = new FormData();+ body.append('file', file, file.name);+ // No Content-Type: the browser sets the multipart boundary.+ const response = await fetch(buildApiUrl(`/api/browser/profiles/${encodeURIComponent(profileId)}/session-file`), {+ method: 'POST',+ body,+ credentials: 'include',+ });+ const upload = await response.json().catch(() => null);+ if (!response.ok) return { success: false, error: upload?.detail || `Upload failed (${response.status}).` };+ const domains = ((upload?.sites ?? []) as BrowserSite[]).map((site) => site.domain);+ if (domains.length === 0) return { success: false, error: 'That file has no logins in it.' };+ // Opens the profile's browser to write the cookies, so allow for a start.+ const result = await sendRequest<Result>(+ 'browser_import_commit',+ { import_id: upload.import_id, profile_id: profileId, domains },+ 60_000,+ );+ if (result.success !== false) toast.success(`Imported logins for ${domains.length} ${domains.length === 1 ? 'site' : 'sites'}.`);+ return result;+ });++ const list = profiles.data ?? [];++ return (+ <div className="flex flex-col gap-4 p-6">+ <p className="m-0 text-sm text-muted-foreground">+ A profile keeps a browser's logins. Each workflow's browser has its own; add a shared one to use the same logins in+ several workflows. To sign in to a site, use Take control in the Browser workspace, or import a session file here.+ </p>++ <form onSubmit={(event) => void create(event)} className="flex gap-2">+ <Input+ value={name}+ onChange={(event) => setName(event.target.value)}+ placeholder="New profile, e.g. Work"+ aria-label="New profile name"+ maxLength={64}+ />+ <ActionButton intent="save" type="submit" disabled={busy || !name.trim()}>+ Add profile+ </ActionButton>+ </form>++ {profiles.isPending ? (+ <Loader2 aria-label="Loading profiles" className="size-5 animate-spin text-muted-foreground" />+ ) : profiles.isError ? (+ <p className="m-0 text-sm text-destructive">{profiles.error.message}</p>+ ) : list.length === 0 ? (+ <p className="m-0 text-sm text-muted-foreground">No profiles yet. One is made the first time a workflow uses its browser.</p>+ ) : (+ <ul className="m-0 flex list-none flex-col gap-2 p-0">+ {list.map((profile) => (+ <li key={profile.id} className="flex flex-wrap items-center gap-3 rounded-md border border-border bg-card p-3">+ <div className="flex min-w-0 flex-1 flex-col">+ <span className="truncate text-sm font-medium">{profile.name}</span>+ <span className="truncate text-xs text-muted-foreground">+ {profile.kind === 'employee' ? 'Workflow profile' : 'Shared profile'} · {sitesText(profile.sites)}+ </span>+ </div>+ {profile.in_use && <Badge variant="secondary">In use by {profile.in_use.label}</Badge>}+ <ActionButton+ intent="config"+ disabled={busy}+ onClick={() => {+ importFor.current = profile.id;+ fileInput.current?.click();+ }}+ >+ <Upload aria-hidden className="size-3.5" />+ Import logins+ </ActionButton>+ <Button+ variant="ghost"+ size="icon-sm"+ aria-label={`Delete ${profile.name}`}+ title={profile.in_use ? 'In use; stop it first' : `Delete ${profile.name}`}+ disabled={busy || profile.in_use !== null}+ onClick={() => setDoomed(profile)}+ >+ <Trash2 aria-hidden />+ </Button>+ </li>+ ))}+ </ul>+ )}++ <input+ ref={fileInput}+ type="file"+ accept=".json,.txt"+ className="sr-only"+ tabIndex={-1}+ aria-hidden+ onChange={(event) => {+ const file = event.target.files?.[0];+ event.target.value = '';+ if (file && importFor.current) void importFile(importFor.current, file);+ }}+ />++ <AlertDialog open={doomed !== null} onOpenChange={(open) => !open && setDoomed(null)}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Delete {doomed?.name}?</AlertDialogTitle>+ <AlertDialogDescription>Its saved logins are removed. Browsers that used it will need to sign in again.</AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={() => {+ const profile = doomed;+ setDoomed(null);+ if (profile) void run(() => sendRequest<Result>('browser_profile_delete', { profile_id: profile.id }));+ }}+ >+ Delete+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </div>+ );+};++export default BrowserProfilesPanel;diff --git a/client/src/components/credentials/types.ts b/client/src/components/credentials/types.tsindex c914a9a9..7281ee43 100644--- a/client/src/components/credentials/types.ts+++ b/client/src/components/credentials/types.ts@@ -12,7 +12,7 @@ export type { ActionButtonIntent };// Panel kinds — one renderer branch per kind// ============================================================================-export type PanelKind = 'apiKey' | 'oauth' | 'qrPairing' | 'email';+export type PanelKind = 'apiKey' | 'oauth' | 'qrPairing' | 'email' | 'browserProfiles';// ============================================================================// Field schema — drives antd Form.Item rendering via FieldRendererdiff --git a/client/src/components/parameterPanel/MiddleSection.tsx b/client/src/components/parameterPanel/MiddleSection.tsxindex c49aa28f..7c1be080 100644--- a/client/src/components/parameterPanel/MiddleSection.tsx+++ b/client/src/components/parameterPanel/MiddleSection.tsx@@ -37,6 +37,7 @@ import CanvasPanel from './CanvasPanel';import ContextPanel from './ContextPanel';import MemoryToolPanel from './MemoryToolPanel';import DataPanel from './DataPanel';+import BrowserWorkspace from '../browser/BrowserWorkspace';import { useAppStore } from '../../store/useAppStore';import { useNodeStatus, useWebSocket, CompactionStats } from '../../contexts/WebSocketContext';import { useUserSettingsQuery } from '../../hooks/useUserSettingsQuery';@@ -213,6 +214,7 @@ const MiddleSection: React.FC<MiddleSectionProps> = ({const isProcessManagerNode = hints.isProcessManagerPanel === true;const isGalleryNode = hints.isGalleryPanel === true;const isCanvasNode = hints.isCanvasPanel === true;+ const isBrowserNode = hints.isBrowserPanel === true;const isAgentWithSkills = hints.hasSkills === true;const { data: userSettings } = useUserSettingsQuery();@@ -616,6 +618,12 @@ const MiddleSection: React.FC<MiddleSectionProps> = ({: 'block flex-1 overflow-y-auto',)}>+ {/* The node's live browser, above its settings. */}+ {isBrowserNode && (+ <div className="mb-4 h-90 overflow-hidden rounded-md border border-border-default">+ <BrowserWorkspace workflowId={currentWorkflow?.id} nodes={[{ node_id: nodeId, label: 'Browser' }]} />+ </div>+ )}{/* Parameters Container */}<divclassName={cn(diff --git a/client/src/contexts/WebSocketContext.tsx b/client/src/contexts/WebSocketContext.tsxindex f03dcd77..f6b25126 100644--- a/client/src/contexts/WebSocketContext.tsx+++ b/client/src/contexts/WebSocketContext.tsx@@ -1156,6 +1156,28 @@ export const WebSocketProvider: React.FC<{ children: React.ReactNode }> = ({ chibreak;}+ case 'browser_updated': {+ // CloudEvents-typed browser control change from+ // server/nodes/browser/_events.py: identity + state only; the live+ // view (/ws/browser) carries the details. When an agent in the+ // open workflow asks for help, show its browser.+ const identity = (data as WorkflowEvent<{ workflow_id?: string | null; state?: string }>)?.data;+ if (+ identity?.state === 'awaiting_user' &&+ identity.workflow_id &&+ identity.workflow_id === useAppStore.getState().currentWorkflow?.id+ ) {+ useCanvasDockStore.getState().showBrowser();+ }+ break;+ }++ case 'browser_profiles_updated': {+ // Identity-only; the Browser profiles panel refetches.+ void queryClient.invalidateQueries({ queryKey: ['browserProfiles'] });+ break;+ }+case 'todos_updated': {// CloudEvents-typed todo-list change from// server/nodes/tool/write_todos/_events.py, emitted via thediff --git a/client/src/features/home/__tests__/presentation.test.ts b/client/src/features/home/__tests__/presentation.test.tsindex b7878f47..939818d2 100644--- a/client/src/features/home/__tests__/presentation.test.ts+++ b/client/src/features/home/__tests__/presentation.test.ts@@ -52,6 +52,15 @@ describe('presentEmployee', () => {});});+ it('says Needs you while the agent waits in the browser', () => {+ const request = { node_id: 'w:browser:1', reason: 'login', since: null };+ expect(presentEmployee(employee({ status: 'working', browser_request: request }, { state: 'running' })).pill).toEqual({+ label: 'Needs you',+ tone: 'waiting',+ });+ expect(employee({ status: 'working' }).browser_request).toBeNull();+ });+it('labels the button while a change is in flight', () => {const view = presentEmployee(employee({ status: 'working' }, { state: 'running' }), { action: 'pause', state: 'pausing' });expect(view.busyLabel).toBe('Pausing…');diff --git a/client/src/features/home/data/liveTask.ts b/client/src/features/home/data/liveTask.tsindex 2ad200d1..e9e7cbff 100644--- a/client/src/features/home/data/liveTask.ts+++ b/client/src/features/home/data/liveTask.ts@@ -50,7 +50,9 @@ export function useLiveTask(employee: EmployeeSummary): { label: 'Now'; text: st[employee.workflow_id, watchKey],),);- if (employee.status !== 'working') return null;+ // While the agent waits for the owner in the browser its node is still+ // executing; the server's "Needs you…" task is the one to show.+ if (employee.status !== 'working' || employee.browser_request) return null;const todo = todoNodeId ? currentTodo(todos) : null;if (todo) return { label: 'Now', text: todo };if (running) return { label: 'Now', text: 'Working on it…' };diff --git a/client/src/features/home/data/presentation.ts b/client/src/features/home/data/presentation.tsindex bee3321e..c7baa0e4 100644--- a/client/src/features/home/data/presentation.ts+++ b/client/src/features/home/data/presentation.ts@@ -13,6 +13,7 @@* | paused | Paused | Resume |* | attention | Needs attention | Resume when possible, else Open workflow |* | pending_approvals > 0 | Needs you (overrides pill) | (the drafts are the action) |+ * | browser_request | Needs you (overrides pill) | (Help in browser opens the Workspace) |*/import type { AppRef, ColorRole, EmployeeSummary } from './schemas';@@ -73,7 +74,8 @@ export function presentEmployee(employee: EmployeeSummary,pending?: WorkflowControlPendingMutation,): EmployeePresentation {- const pill = employee.pending_approvals > 0 ? { label: 'Needs you', tone: 'waiting' as const } : PILL[employee.status];+ const needsYou = employee.pending_approvals > 0 || employee.browser_request !== null;+ const pill = needsYou ? { label: 'Needs you', tone: 'waiting' as const } : PILL[employee.status];return {pill,// Only a green working dot pulses (its ring is green).diff --git a/client/src/features/home/data/schemas.ts b/client/src/features/home/data/schemas.tsindex a6ce1aa0..a8cfd58f 100644--- a/client/src/features/home/data/schemas.ts+++ b/client/src/features/home/data/schemas.ts@@ -55,6 +55,11 @@ export const employeeSummarySchema = z.object({canvas_node_id: z.string().nullable().catch(null),/** Saved Browser nodes available in this employee's workspace. */browser_nodes: z.array(z.object({ node_id: z.string().min(1), label: z.string() })).catch([]),+ /** A browser waiting for the owner (the agent asked for help). The agent's message is in the live view only. */+ browser_request: z+ .object({ node_id: z.string().min(1), reason: z.string(), since: z.string().nullable().catch(null) })+ .nullable()+ .catch(null),revision: z.number().catch(0),hired_at: z.string().nullable().catch(null),});diff --git a/client/src/features/home/employee/EmployeeView.tsx b/client/src/features/home/employee/EmployeeView.tsxindex 4cba1022..f43bc90c 100644--- a/client/src/features/home/employee/EmployeeView.tsx+++ b/client/src/features/home/employee/EmployeeView.tsx@@ -9,7 +9,8 @@* "Pausing…" label until the summary has caught up with the new state (or* a few seconds pass and the list is refetched), so it never flashes the* old label in between. "Open workflow" opens this employee's graph in Dev- * mode, and "Watch live" opens the Workspace on this employee.+ * mode, and "Watch live" opens the Workspace on this employee ("Help in+ * browser", on its Browser tab, while the agent is waiting for the owner).*/import { useQueryClient } from '@tanstack/react-query';@@ -94,6 +95,8 @@ function EmployeeCard({ employee, onConnect }: { employee: EmployeeSummary; onCoconst queryClient = useQueryClient();const openSettings = useHomeStore((s) => s.openSettings);const openWorkspace = useHomeStore((s) => s.openWorkspace);+ const setWorkspaceTab = useHomeStore((s) => s.setWorkspaceTab);+ const helpInBrowser = employee.browser_request !== null;const [running, setRunning] = useState<ControlKind | null>(null);const [awaiting, setAwaiting] = useState<{ kind: ControlKind; target: WorkflowControlStatus } | null>(null);const cardRef = useRef<HTMLDivElement>(null);@@ -244,9 +247,16 @@ function EmployeeCard({ employee, onConnect }: { employee: EmployeeSummary; onCoOpen workflow</Button>)}- <ActionButton intent="tools" onClick={() => openWorkspace(employee.workflow_id)} className="h-9 gap-2 rounded-row px-3.5">+ <ActionButton+ intent="tools"+ onClick={() => {+ openWorkspace(employee.workflow_id);+ if (helpInBrowser) setWorkspaceTab('browser');+ }}+ className="h-9 gap-2 rounded-row px-3.5"+ ><Monitor aria-hidden className="size-3.5" />- Watch live+ {helpInBrowser ? 'Help in browser' : 'Watch live'}</ActionButton></div></div>diff --git a/client/src/features/home/workspace/WorkspaceDock.tsx b/client/src/features/home/workspace/WorkspaceDock.tsxindex 857717ac..59747112 100644--- a/client/src/features/home/workspace/WorkspaceDock.tsx+++ b/client/src/features/home/workspace/WorkspaceDock.tsx@@ -72,7 +72,8 @@ function DockButtons() {/** Who, what they are doing, and a Live pill while they work. */function Identity({ employee }: { employee: EmployeeSummary }) {const live = useLiveTask(employee);- const pill = employee.status === 'working' ? { tone: 'live' as const, label: 'Live' } : presentEmployee(employee).pill;+ const pill =+ employee.status === 'working' && !employee.browser_request ? { tone: 'live' as const, label: 'Live' } : presentEmployee(employee).pill;return (<><Avatar name={employee.name} colorRole={employee.color_role} size="sm" />diff --git a/client/src/hooks/useCatalogueQuery.ts b/client/src/hooks/useCatalogueQuery.tsindex 5547400c..d5b9673d 100644--- a/client/src/hooks/useCatalogueQuery.ts+++ b/client/src/hooks/useCatalogueQuery.ts@@ -112,7 +112,7 @@ export interface ServerProviderConfig {category: string;category_label: string;color: string;- kind: 'apiKey' | 'oauth' | 'qrPairing' | 'email';+ kind: 'apiKey' | 'oauth' | 'qrPairing' | 'email' | 'browserProfiles';icon_ref?: string;fields?: ServerFieldDef[];ws?: { login: string; logout: string; status: string };diff --git a/client/src/stores/__tests__/canvasDockStore.test.ts b/client/src/stores/__tests__/canvasDockStore.test.tsindex e404f670..22a4b392 100644--- a/client/src/stores/__tests__/canvasDockStore.test.ts+++ b/client/src/stores/__tests__/canvasDockStore.test.ts@@ -67,6 +67,13 @@ describe('canvasDockStore.notifyPushed', () => {useCanvasDockStore.getState().notifyPushed('canvas-2');expect(useCanvasDockStore.getState().tab).toBe('browser');});++ it('opens on the Browser tab when an agent asks for help', () => {+ useCanvasDockStore.getState().showBrowser();+ const state = useCanvasDockStore.getState();+ expect(state.open).toBe(true);+ expect(state.tab).toBe('browser');+ });});describe('canvasDockStore prefs', () => {diff --git a/client/src/stores/canvasDockStore.ts b/client/src/stores/canvasDockStore.tsindex f6e93124..683a9878 100644--- a/client/src/stores/canvasDockStore.ts+++ b/client/src/stores/canvasDockStore.ts@@ -81,6 +81,8 @@ interface CanvasDockState {* preview.*/notifyPushed: (nodeId: string) => void;+ /** An agent in the CURRENT workflow asked for help in its browser (caller verifies): show the Browser tab. */+ showBrowser: () => void;}const persisted = loadDockPrefs();@@ -150,4 +152,8 @@ export const useCanvasDockStore = create<CanvasDockState>((set, get) => ({set({ mode: 'node', selectedNodeId: nodeId });}},+ showBrowser: () => {+ set({ open: true, tab: 'browser' });+ persist(get());+ },}));diff --git a/docs-internal/normal_mode.md b/docs-internal/normal_mode.mdindex c29e2c50..e983dbc5 100644--- a/docs-internal/normal_mode.md+++ b/docs-internal/normal_mode.md@@ -76,7 +76,13 @@ is the reference.Status comes from the server: an employee summary is `working`, `ready`,`paused` or `attention` (an automatic pause, see below), and a pending draft-shows as "Needs you". Motion goes through [lib/motion.ts](../client/src/lib/motion.ts),+shows as "Needs you". So does a browser waiting for the owner: when an agent+calls `request_user`, the summary's `browser_request` (`{node_id, reason,+since}`, never the agent's message, since summaries reach every socket) takes+over the task line, and the card's Watch live button becomes Help in browser,+which opens the Workspace on its Browser tab. The Browser plugin publishes+that state through `services/employees/node_signals.py` and re-sends the+summary when it changes. Motion goes through [lib/motion.ts](../client/src/lib/motion.ts),which reads the `--dur-*` / `--ease-*` tokens, runs at 1 ms under reducedmotion and while the page is hidden ([lib/pageActivity.ts](../client/src/lib/pageActivity.ts)),and never starts loops then. Toasts are a second sonner toaster@@ -206,7 +212,12 @@ the client's `HIRE_PAYLOAD_KEYS` must match, locked byskill named `skill`, or one ending in `-personality`, is left out: it wouldtake over the Skill tool, or replace the whole system message. With "Ask me beforesending anything" on, a reply goes through `approvalGate`, and tools that- send or spend money are left off. Every node type must pass+ send or spend money are left off, except one that declares+ `ask_first_params`: the "Web browser" app's browser stays on with+ `interaction: read_only`, so it can read pages and hands any change to the+ owner through `request_user`. The Web browser app has nothing to connect+ (its catalogue entry's `connected_check` is `builtin`); its Connectors+ panel manages optional login profiles. Every node type must pass`node_allowlist.is_hire_allowed` ([Node Allowlist](./node_allowlist.md));node types never come from the payload;4. validates it with `validate_workflow` and saves it withdiff --git a/server/config/credential_providers.json b/server/config/credential_providers.jsonindex d59cca49..5cc4e5a3 100644--- a/server/config/credential_providers.json+++ b/server/config/credential_providers.json@@ -46,6 +46,10 @@"developer": {"label": "Developer Tools","order": 11+ },+ "browser": {+ "label": "Browser",+ "order": 12}},"consumer_categories": {@@ -759,6 +763,21 @@},"icon_ref": "/api/schemas/nodes/emailRead/icon"},+ "browser": {+ "name": "Web browser",+ "publisher": "OpenCompany",+ "verified": true,+ "consumer_category": "devices",+ "description": "A real browser your employees use, with the logins you save in its profiles.",+ "category": "browser",+ "category_label": "Browser",+ "color": "dracula.pink",+ "kind": "browserProfiles",+ "connected_check": {+ "type": "builtin"+ },+ "icon_ref": "/api/schemas/nodes/browser/icon"+ },"android_remote": {"name": "Android Device","publisher": "OpenCompany",diff --git a/server/config/employee_apps.json b/server/config/employee_apps.jsonindex 85fd29ff..7af06ee7 100644--- a/server/config/employee_apps.json+++ b/server/config/employee_apps.json@@ -1,5 +1,5 @@{- "_description": "The apps a Normal-mode employee can use, and how each maps onto workflow nodes. Loaded by server/services/employees/apps.py. `provider_id` is the credential catalogue id (config/credential_providers.json) that decides whether the app is connected. `trigger` starts the employee (audience `public`: strangers write in, so replies go back to them; `owner`: only the owner talks to it); `reply` answers whoever wrote in; `notify_owner` reports to the owner; `tools` are handed to the agent, each with the most dangerous thing it can do (`side_effects`: read < write < send < money), because a tool call lets the model choose any operation the node has. Under the `ask first` ground rule no `send` or `money` tool is attached. Parameter strings may use placeholders the graph builder resolves: ${trigger.<field>} (the trigger node's output), ${reply_text} / ${reply_subject} (the approved draft when the approval gate is on, otherwise the agent's response), and ${owner.<field>} (the owner's own address for the app, looked up when the employee is built). Node types, parameter names and trigger output fields are verified against the plugins; see tests/services/employees/test_app_registry.py.",+ "_description": "The apps a Normal-mode employee can use, and how each maps onto workflow nodes. Loaded by server/services/employees/apps.py. `provider_id` is the credential catalogue id (config/credential_providers.json) that decides whether the app is connected. `trigger` starts the employee (audience `public`: strangers write in, so replies go back to them; `owner`: only the owner talks to it); `reply` answers whoever wrote in; `notify_owner` reports to the owner; `tools` are handed to the agent, each with the most dangerous thing it can do (`side_effects`: read < write < send < money), because a tool call lets the model choose any operation the node has. Under the `ask first` ground rule no `send` or `money` tool is attached, unless it declares `ask_first_params` that make it safe: then it is attached with those merged over `params` (the browser turns read-only). A tool's optional `role` names its node in the employee's node roles. Parameter strings may use placeholders the graph builder resolves: ${trigger.<field>} (the trigger node's output), ${reply_text} / ${reply_subject} (the approved draft when the approval gate is on, otherwise the agent's response), and ${owner.<field>} (the owner's own address for the app, looked up when the employee is built). Node types, parameter names and trigger output fields are verified against the plugins; see tests/services/employees/test_app_registry.py.","version": 1,"apps": {"whatsapp": {@@ -457,6 +457,42 @@"phrases": {"working": "Looking up payments in Stripe"}+ },+ "web": {+ "name": "Web browser",+ "provider_id": "browser",+ "aliases": [+ "web browser",+ "browser",+ "chrome",+ "website",+ "websites",+ "web page",+ "internet"+ ],+ "_provider_note": "Nothing to connect (connected_check builtin); logins live in the optional profiles its Connectors panel manages.",+ "trigger": null,+ "reply": null,+ "notify_owner": null,+ "tools": [+ {+ "type": "browser",+ "label": "Browser",+ "role": "browser",+ "params": {+ "interaction": "full"+ },+ "ask_first_params": {+ "interaction": "read_only"+ },+ "side_effects": "money",+ "_side_effects_note": "a page can do anything the profile's logins allow, a checkout included. Under ask first it stays attached read-only: it can browse and read, and must hand any change to the owner (request_user)."+ }+ ],+ "side_effects": "money",+ "phrases": {+ "working": "Using the web browser"+ }}}}diff --git a/server/config/node_allowlist.json b/server/config/node_allowlist.jsonindex 3d9d5f92..28131286 100644--- a/server/config/node_allowlist.json+++ b/server/config/node_allowlist.json@@ -27,6 +27,7 @@"currentTimeTool","writeTodos","canvas",+ "browser","context","approvalGate",diff --git a/server/nodes/browser/_handlers.py b/server/nodes/browser/_handlers.pyindex 2ea01d33..5ed7fe91 100644--- a/server/nodes/browser/_handlers.py+++ b/server/nodes/browser/_handlers.py@@ -486,8 +486,15 @@ WS_HANDLERS: Dict[str, WSHandler] = {async def load_browser_profiles(params: Dict[str, Any]) -> list:- """``loadOptionsMethod: browserProfiles`` for the node's profile field."""- owner = str(params.get("user_id") or "owner")+ """``loadOptionsMethod: browserProfiles`` for the node's profile field.++ Lists the caller's profiles. The caller comes from the authenticated+ request, never from ``params``, which the client writes.+ """+ from constants import OWNER_PRINCIPAL_ID+ from services.ws_handler_registry import current_load_options_principal++ owner = current_load_options_principal() or OWNER_PRINCIPAL_IDprofiles = await ProfileStore(get_database()).list(owner)options = [{"value": "", "label": "This workflow's own profile", "description": "Created the first time it runs"}]options.extend(diff --git a/server/nodes/groups.py b/server/nodes/groups.pyindex 5e62d852..71d158b4 100644--- a/server/nodes/groups.py+++ b/server/nodes/groups.py@@ -27,6 +27,7 @@ register_group(key="model", metadata={"label": "AI Models", "icon": "🧬", "colregister_group(key="skill", metadata={"label": "AI Skills", "icon": "🎯", "color": "#50fa7b", "visibility": "normal"})register_group(key="tool", metadata={"label": "AI Tools", "icon": "🛠️", "color": "#50fa7b", "visibility": "normal"})register_group(key="android", metadata={"label": "Android", "icon": "📱", "color": "#8be9fd", "visibility": "normal"})+register_group(key="browser", metadata={"label": "Browser", "icon": "🌐", "color": "#ff79c6", "visibility": "normal"})# ---------------------------------------------------------------------------@@ -63,7 +64,6 @@ register_group(key="email", metadata={"label": "Email", "icon": "✉️", "colorregister_group(key="payments", metadata={"label": "Payments", "icon": "asset:stripe", "color": "#635BFF", "visibility": "dev"})register_group(key="deployment", metadata={"label": "Deployment", "icon": "lobehub:Vercel", "color": "#666666", "visibility": "dev"})register_group(key="vcs", metadata={"label": "Version Control", "icon": "lobehub:Github", "color": "#F05133", "visibility": "dev"})-register_group(key="browser", metadata={"label": "Browser", "icon": "🌐", "color": "#ff79c6", "visibility": "dev"})register_group(key="scraper", metadata={"label": "Scrapers", "icon": "🕸", "color": "#ff79c6", "visibility": "dev"})register_group(key="filesystem", metadata={"label": "Filesystem", "icon": "📁", "color": "#8be9fd", "visibility": "dev"})register_group(key="service", metadata={"label": "Services", "icon": "⚙️", "color": "#50fa7b", "visibility": "dev"})diff --git a/server/routers/schemas.py b/server/routers/schemas.pyindex 725ff046..a9f6780a 100644--- a/server/routers/schemas.py+++ b/server/routers/schemas.py@@ -7,7 +7,7 @@ the design rationale and docs-internal/ARCHIVE/schema_source_of_truth_rfc.mdfor the frontend consumer (useNodeOutputSchemaQuery)."""-from fastapi import APIRouter, HTTPException, Path, Query, Response+from fastapi import APIRouter, HTTPException, Path, Query, Request, Responsefrom fastapi.responses import FileResponsefrom nodes._visuals import get_plugin_icon_path@@ -156,18 +156,21 @@ async def list_specs():@router.post("/nodes/options/{method}")-async def load_options(method: str, body: dict | None = None):+async def load_options(method: str, request: Request, body: dict | None = None):"""Wave 6 Phase 4: REST mirror of the load_options WS handler.Resolves a ``loadOptionsMethod`` string against the registry andreturns the dynamic dropdown contents. Body is the per-methodparameter map (e.g. ``{"group_id": "..."}`` for- whatsappGroupMembers).+ whatsappGroupMembers). The caller is the one the auth middleware+ resolved, never a ``user_id`` in the body."""+ from constants import OWNER_PRINCIPAL_IDfrom services.ws_handler_registry import dispatch_load_optionsparams = (body or {}).get("params", body or {}) if isinstance(body, dict) else {}- options = await dispatch_load_options(method, params)+ principal = getattr(request.state, "user_id", None)+ options = await dispatch_load_options(method, params, principal=str(principal or OWNER_PRINCIPAL_ID))return {"method": method, "options": options}diff --git a/server/routers/websocket.py b/server/routers/websocket.pyindex c5ba7d11..a299b53f 100644--- a/server/routers/websocket.py+++ b/server/routers/websocket.py@@ -352,10 +352,15 @@ async def handle_load_options(data: Dict[str, Any], websocket: WebSocket) -> DicBody: ``{"method": "...", "params": {...}}``Response: ``{"options": [{"value": ..., "label": ...}]}``++ The caller's identity comes from the socket (an empty payload goes to+ ``execution_principal`` so a client-sent ``user_id`` is never trusted)."""from services.ws_handler_registry import dispatch_load_options- options = await dispatch_load_options(data["method"], data.get("params", {}))+ options = await dispatch_load_options(+ data["method"], data.get("params", {}), principal=execution_principal({}, websocket)+ )return {"method": data["method"], "options": options}diff --git a/server/services/credential_registry.py b/server/services/credential_registry.pyindex 9d7aa1a0..9e1955ec 100644--- a/server/services/credential_registry.py+++ b/server/services/credential_registry.py@@ -334,8 +334,12 @@ async def _connected_check(check: Dict[str, Any], auth_service: Any) -> bool:provider's plugin keeps on the status broadcaster (WhatsApp's pairing).``{"type": "api_keys", "keys": [...]}``: every listed key is stored(the IMAP/SMTP account, which is several keys and no OAuth token).+ ``{"type": "builtin"}``: nothing to connect, always usable (the web+ browser, whose panel manages optional login profiles)."""kind = check.get("type")+ if kind == "builtin":+ return Trueif kind == "status":return _status_slot_on(check)if kind == "api_keys":diff --git a/server/services/employees/apps.py b/server/services/employees/apps.pyindex c746d013..9b10ea74 100644--- a/server/services/employees/apps.py+++ b/server/services/employees/apps.py@@ -18,7 +18,7 @@ from __future__ import annotationsimport jsonimport re-from dataclasses import dataclass+from dataclasses import dataclass, fieldfrom pathlib import Pathfrom types import MappingProxyTypefrom typing import Any, Dict, Iterable, Mapping, Optional, Sequence, Tuple@@ -58,6 +58,14 @@ class TriggerTemplate(NodeTemplate):@dataclass(frozen=True)class ToolTemplate(NodeTemplate):side_effects: str = "read"+ #: Params that make the tool safe under ``ask first``. A tool that+ #: declares them stays attached for such an employee, with these+ #: merged over ``params`` (the browser turns read-only and hands any+ #: page change to the owner); a tool without them is left out.+ ask_first_params: Mapping[str, Any] = field(default_factory=lambda: MappingProxyType({}))+ #: The key under which the builder records the tool's node id in the+ #: employee's ``node_roles``.+ role: Optional[str] = None@dataclass(frozen=True)@@ -119,6 +127,14 @@ def _template(app_id: str, role: str, raw: Any, cls: type = NodeTemplate) -> Anyif effect not in SIDE_EFFECTS:raise AppRegistryError(f"{app_id}.tools[{raw['type']}].side_effects must be one of {SIDE_EFFECTS}")fields["side_effects"] = effect+ ask_first = raw.get("ask_first_params") or {}+ if not isinstance(ask_first, dict):+ raise AppRegistryError(f"{app_id}.tools[{raw['type']}].ask_first_params must be an object")+ fields["ask_first_params"] = MappingProxyType(dict(ask_first))+ tool_role = raw.get("role")+ if tool_role is not None and (not isinstance(tool_role, str) or not tool_role):+ raise AppRegistryError(f"{app_id}.tools[{raw['type']}].role must be a non-empty string")+ fields["role"] = tool_rolereturn cls(**fields)diff --git a/server/services/employees/builder.py b/server/services/employees/builder.pyindex 64ffc3ac..f7dbbc67 100644--- a/server/services/employees/builder.py+++ b/server/services/employees/builder.py@@ -11,7 +11,8 @@ One employee is one workflow:- tools on the agent: web search, a checklist (writeTodos), a clock and acanvas (what the agent puts there shows in Home's Workspace), always; theapps' tools, minus anything that sends or spends while "ask me first" is- on; Memory when the owner keeps memory across chats;+ on (a tool with ``ask_first_params``, the browser, stays in its read-only+ form instead); Memory when the owner keeps memory across chats;- the owner's skill library (Settings > Skills): every skill that is on, onone Skills node (masterSkill), with its text copied in, so a later edit tothe library never changes an employee already hired;@@ -48,7 +49,7 @@ from datetime import datetime, timezonefrom typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Set, Tuplefrom zoneinfo import ZoneInfo, ZoneInfoNotFoundError-from services.employees.apps import AppSpec, NodeTemplate, allowed_when_asking_first, resolve_app+from services.employees.apps import AppSpec, NodeTemplate, ToolTemplate, allowed_when_asking_first, resolve_appfrom services.employees.hire_request import HireEmployeeRequest, HireTriggerfrom services.employees.llm import LLMChoicefrom services.approvals.contract import APPROVAL_GATE_TYPE, NO_REPLY, approved_edge_condition, send_condition@@ -548,6 +549,47 @@ def _plan_reply()+# ----- app tools -----+++@dataclass+class _ToolPlan:+ app: AppSpec+ tool: ToolTemplate+ params: Dict[str, Any]+ #: Attached in its ask-first form (``ask_first_params`` applied).+ read_only: bool = False+++def _plan_app_tools(inputs: BuildInputs, trigger: _TriggerPlan, warnings: List[str]) -> List[_ToolPlan]:+ """The apps' tools the agent gets, decided before its instructions are+ written so they can mention them.++ Under ``ask first`` a tool that can send or spend is left out, unless+ the app declares ``ask_first_params`` that make it safe: then it is+ attached with those applied (the browser can read, and hands any page+ change to the owner)."""+ plans: List[_ToolPlan] = []+ for app in inputs.apps:+ for tool in app.tools:+ params = dict(tool.params)+ read_only = False+ if inputs.request.rules.ask_first and not allowed_when_asking_first(tool.side_effects):+ if not tool.ask_first_params:+ warnings.append(f"{app.name} is left out while they ask before sending anything")+ continue+ params.update(tool.ask_first_params)+ read_only = True+ warnings.append(f"{app.name} can only read while they ask before sending anything; they hand changes to you")+ try:+ params = _substitute(params, {}, trigger.key, inputs.owner_values)+ except _Unresolved:+ warnings.append(f"{app.name} could not be set up as a tool")+ continue+ plans.append(_ToolPlan(app=app, tool=tool, params=params, read_only=read_only))+ return plans++# ----- the whole graph -----@@ -562,6 +604,9 @@ def build_employee_graph(inputs: BuildInputs) -> BuiltEmployee:trigger = _plan_trigger(inputs, labels, now, warnings)delivery = _plan_delivery(inputs, trigger, agent_key, labels, warnings)+ app_tools = _plan_app_tools(inputs, trigger, warnings)+ browser_tools = [plan for plan in app_tools if plan.tool.role == "browser"]+delivery_mode = "chat" if trigger.kind == "manual" else ("reply" if delivery is not None and delivery.role == "reply" else "report")system_message = build_system_message(PromptInputs(@@ -572,6 +617,8 @@ def build_employee_graph(inputs: BuildInputs) -> BuiltEmployee:unsupported_apps=list(inputs.unsupported_apps),has_memory=inputs.memory,has_canvas=True,+ has_browser=bool(browser_tools),+ browser_read_only=bool(browser_tools) and all(plan.read_only for plan in browser_tools),))if trigger.kind == "schedule" and request.trigger is not None and request.trigger.every == "weekday":@@ -617,18 +664,9 @@ def build_employee_graph(inputs: BuildInputs) -> BuiltEmployee:if inputs.memory:add_tool(MEMORY_TYPE, "Memory", {}, role="memory")add_tool(CANVAS_TYPE, "Canvas", {}, role="canvas")- for app in inputs.apps:- for tool in app.tools:- if request.rules.ask_first and not allowed_when_asking_first(tool.side_effects):- warnings.append(f"{app.name} is left out while they ask before sending anything")- continue- try:- params = _substitute(dict(tool.params), {}, trigger.key, inputs.owner_values)- except _Unresolved:- warnings.append(f"{app.name} could not be set up as a tool")- continue- add_tool(tool.type, tool.label or app.name, params)- use(app)+ for plan in app_tools:+ add_tool(plan.tool.type, plan.tool.label or plan.app.name, plan.params, role=plan.tool.role)+ use(plan.app)# Context, for owner-facing triggers only.if trigger.kind in ("schedule", "manual"):diff --git a/server/services/employees/prompt.py b/server/services/employees/prompt.pyindex 377edf43..8c8e798c 100644--- a/server/services/employees/prompt.py+++ b/server/services/employees/prompt.py@@ -56,6 +56,10 @@ class PromptInputs:has_todos: bool = True#: The canvas tool, whose board the owner sees in Home's Workspace.has_canvas: bool = False+ #: The browser tool, whose Chrome the owner watches in the Workspace.+ has_browser: bool = False+ #: The browser may only read pages (ask-first employees).+ browser_read_only: bool = Falsedef _clean(text: str) -> str:@@ -150,6 +154,22 @@ def _rules(inputs: PromptInputs, owner: str) -> List[str]:f"- Check your memory before answering anything about {owner} or the people you talk to, and remember ""what you will need next time (names, preferences, decisions).")+ if inputs.has_browser:+ out.append(+ "- Use the browser tool when the work needs a website: take a snapshot, then act on what it lists. If "+ "a site offers its own tools, prefer them. When a site needs a login, a CAPTCHA or a code, call "+ f"request_user and wait for {owner}; never ask for a password in a message."+ )+ if inputs.browser_read_only:+ out.append(+ "- Your browser can only read pages. To change anything on a site (submit a form, send, book, "+ f"buy), call request_user and say exactly what {owner} should do there."+ )+ else:+ out.append(+ f"- Before anything on a site that spends money, sends something for {owner} or cannot be undone, "+ f"call request_user so {owner} can check it, unless they already told you to go ahead."+ )if inputs.unsupported_apps:names = ", ".join(_clean(name) for name in inputs.unsupported_apps)out.append(diff --git a/server/services/employees/summaries.py b/server/services/employees/summaries.pyindex 76fe2f7e..0cae4aed 100644--- a/server/services/employees/summaries.py+++ b/server/services/employees/summaries.py@@ -5,7 +5,9 @@ the hire screen captured; ones built in the editor are described from thegraph (``derived: true``). Either way the live parts come from the sameplaces the editor reads: the latest control generation (state and thecapabilities Start / Pause / Resume need) and the credential store (which-apps are connected).+apps are connected). A browser that is waiting for the owner is live+plugin state (``node_signals``); the plugin re-sends the summary when it+changes.A team list costs one query per table, never one per workflow, and nevercalls Temporal: the list shows the last recorded control state, and the@@ -136,6 +138,38 @@ def _attention_text(control: Mapping[str, Any]) -> str:return "Stopped after an error. Open the workflow to see what happened."+#: Task text while the agent waits in ``request_user``, by its reason.+_BROWSER_REQUEST_TEXT = {+ "login": "Needs you to sign in to a site in the browser",+ "captcha": "Needs you to solve a CAPTCHA in the browser",+ "two_factor": "Needs a sign-in code from you in the browser",+ "confirm": "Needs you to check something in the browser",+}+++def _browser_request(workflow_id: str, graph: GraphIndex) -> Optional[Dict[str, Any]]:+ """The first browser node waiting for the owner (the agent called+ ``request_user``), read live from the Browser plugin.++ Identity and reason only: summaries are broadcast to every connected+ socket, so the agent's message stays behind the authorized live view.+ """+ from services.employees.node_signals import node_state++ for node_id in graph.browser_ids:+ state = node_state("browser", workflow_id, node_id)+ if not state or state.get("state") != "awaiting_user":+ continue+ request = state.get("request") or {}+ since = request.get("since")+ return {+ "node_id": node_id,+ "reason": str(request.get("reason") or "other"),+ "since": datetime.fromtimestamp(since, timezone.utc).isoformat() if isinstance(since, (int, float)) else None,+ }+ return None++def _task(status: str,*,@@ -145,7 +179,10 @@ def _task(needs_ai: bool,employee: Any,graph: GraphIndex,+ browser_request: Optional[Mapping[str, Any]] = None,) -> Dict[str, str]:+ if browser_request is not None:+ return {"label": "Waiting", "text": _BROWSER_REQUEST_TEXT.get(browser_request["reason"], "Needs your help in the browser")}if pending > 0:return {"label": "Waiting", "text": f"{pending} {_plural(pending, 'draft is', 'drafts are')} waiting for you to check"}if status == "working":@@ -206,6 +243,7 @@ async def _summary(# still in the graph, else the first canvas the owner added.canvas = roles.get("canvas") if roles else Nonecanvas_node_id = canvas if canvas in graph.canvas_ids else next(iter(graph.canvas_ids), None)+ browser_request = _browser_request(workflow.id, graph)return {"workflow_id": workflow.id,"name": workflow.name,@@ -213,7 +251,16 @@ async def _summary("color_role": getattr(employee, "color_role", None) or "agent","derived": employee is None,"status": status,- "task": _task(status, control=control, pending=pending, missing=missing, needs_ai=needs_ai, employee=employee, graph=graph),+ "task": _task(+ status,+ control=control,+ pending=pending,+ missing=missing,+ needs_ai=needs_ai,+ employee=employee,+ graph=graph,+ browser_request=browser_request,+ ),"done_today": done_today,"pending_approvals": pending,"apps": apps,@@ -224,6 +271,9 @@ async def _summary("watch_node_ids": watch,"canvas_node_id": canvas_node_id,"browser_nodes": [{"node_id": node_id, "label": graph.labels.get(node_id) or "Browser"} for node_id in graph.browser_ids],+ #: A browser node waiting for the owner ({node_id, reason, since}),+ #: else None. Read live, so it changes without a new revision.+ "browser_request": browser_request,"revision": _millis(getattr(workflow, "updated_at", None),getattr(employee, "updated_at", None),diff --git a/server/services/ws_handler_registry.py b/server/services/ws_handler_registry.pyindex 25487034..a0517616 100644--- a/server/services/ws_handler_registry.py+++ b/server/services/ws_handler_registry.py@@ -18,7 +18,9 @@ Four sibling concerns share this file because they're the same patterndynamic-options dropdowns wired through the``loadOptionsMethod`` Pydantic field metadata. Read by:func:`dispatch_load_options` (here in this module) and the matching- WS handler in ``routers/websocket.py``.+ WS handler in ``routers/websocket.py``. A loader whose options belong+ to a user reads the caller from :func:`current_load_options_principal`,+ never from ``params`` (the client writes those).4. **OAuth callback paths** — ``register_oauth_callback_path(provider,path)`` so :func:`services.oauth_utils.get_redirect_uri` can derive@@ -33,7 +35,8 @@ from __future__ import annotationsimport functoolsimport logging-from typing import Any, Awaitable, Callable, Dict, List+from contextvars import ContextVar+from typing import Any, Awaitable, Callable, Dict, List, Optionalfrom fastapi import APIRouter, WebSocket@@ -165,17 +168,38 @@ def list_registered_option_methods() -> List[str]:return sorted(_OPTION_LOADER_REGISTRY.keys())-async def dispatch_load_options(method: str, params: Dict[str, Any] | None = None) -> List[Dict[str, Any]]:+_LOAD_OPTIONS_PRINCIPAL: ContextVar[Optional[str]] = ContextVar("load_options_principal", default=None)+++def current_load_options_principal() -> Optional[str]:+ """The authenticated caller of the load-options request being served.++ ``None`` outside a request or when the caller is unknown. Set by+ :func:`dispatch_load_options` from the socket or HTTP identity, so a+ loader that lists one user's things (browser profiles) never has to+ trust a ``user_id`` inside ``params``.+ """+ return _LOAD_OPTIONS_PRINCIPAL.get()+++async def dispatch_load_options(+ method: str, params: Dict[str, Any] | None = None, *, principal: Optional[str] = None+) -> List[Dict[str, Any]]:"""Look up and invoke a registered loader.Returns an empty list when the method isn't registered (matchesn8n's tolerant fallback -- the dropdown stays empty rather than- erroring out).+ erroring out). ``principal`` is the authenticated caller, exposed to+ the loader through :func:`current_load_options_principal`."""loader = _OPTION_LOADER_REGISTRY.get(method)if loader is None:return []- return await loader(params or {})+ token = _LOAD_OPTIONS_PRINCIPAL.set(principal)+ try:+ return await loader(params or {})+ finally:+ _LOAD_OPTIONS_PRINCIPAL.reset(token)def list_load_options_methods() -> List[str]:diff --git a/server/tests/nodes/browser/test_browser_node.py b/server/tests/nodes/browser/test_browser_node.pyindex e3f3411f..32eaef0a 100644--- a/server/tests/nodes/browser/test_browser_node.py+++ b/server/tests/nodes/browser/test_browser_node.py@@ -216,3 +216,22 @@ async def test_legacy_agent_browser_parameters_still_validate(runtime):op, args = runtime.cli.calls[-1]assert op == "type" and args["text"] == "hello" and args["clear"] is True and args["selector"] == "#q"assert result.get("success") is not False+++async def test_the_profile_dropdown_lists_the_callers_profiles_not_a_client_named_user():+ import nodes.browser # noqa: F401 - registers the browserProfiles loader+ from services.ws_handler_registry import dispatch_load_options++ listed: List[str] = []++ class Store:+ def __init__(self, database) -> None:+ pass++ async def list(self, owner: str):+ listed.append(owner)+ return []++ with patch("nodes.browser._handlers.ProfileStore", Store), patch("nodes.browser._handlers.get_database", lambda: None):+ await dispatch_load_options("browserProfiles", {"user_id": "someone-else"}, principal="alice")+ assert listed == ["alice"]diff --git a/server/tests/services/employees/test_app_registry.py b/server/tests/services/employees/test_app_registry.pyindex fadff04f..4a97fc39 100644--- a/server/tests/services/employees/test_app_registry.py+++ b/server/tests/services/employees/test_app_registry.py@@ -161,6 +161,32 @@ def test_side_effects_and_the_ask_first_rule():assert get_apps()["google_sheets"].tools[0].side_effects == "write"+ ("app", "tool"),+ [(app, tool) for app in get_apps().values() for tool in app.tools if tool.ask_first_params],+ ids=lambda value: getattr(value, "id", None) or getattr(value, "type", ""),+)+def test_ask_first_params_are_real_fields_and_make_the_tool_safe(app, tool):+ """The ask-first form of a tool is only offered for a send/money tool,+ and must itself be a valid node."""+ assert not allowed_when_asking_first(tool.side_effects), f"{app.id}: a read/write tool is never left out, so needs no ask-first form"+ params_model = get_node_class(tool.type).Params+ assert set(tool.ask_first_params) <= set(params_model.model_fields)+ params_model.model_validate({**tool.params, **tool.ask_first_params})+++def test_the_web_browser_is_an_app_that_turns_read_only_under_ask_first():+ web = get_apps()["web"]+ assert web.provider_id == "browser" and web.trigger is None and web.reply is None+ (tool,) = web.tools+ assert (tool.type, tool.role, tool.side_effects) == ("browser", "browser", "money")+ assert dict(tool.params) == {"interaction": "full"}+ assert dict(tool.ask_first_params) == {"interaction": "read_only"}+ assert app_for_node_type("browser").id == "web"+ for name in ("Web browser", "browser", "Chrome", "our website", "the internet"):+ assert resolve_app(name).id == "web", name++def test_node_types_map_back_to_one_app():assert app_for_node_type("whatsappReceive").id == "whatsapp"assert app_for_node_type("whatsappSend").id == "whatsapp"@@ -197,9 +223,21 @@ def test_resolve_app(name, connected, expected):assert (app.id if app else None) == expected-def test_a_malformed_registry_fails_loudly(tmp_path, monkeypatch):+_TOOL = '{"type": "browser", "side_effects": "money", %s}'+++ "app_json",+ [+ '{"name": "X", "provider_id": "p", "side_effects": "dangerous"}',+ '{"name": "X", "provider_id": "p", "side_effects": "money", "tools": [%s]}' % (_TOOL % '"ask_first_params": ["read_only"]'),+ '{"name": "X", "provider_id": "p", "side_effects": "money", "tools": [%s]}' % (_TOOL % '"role": ""'),+ ],+ ids=["bad side effect", "ask_first_params not an object", "empty role"],+)+def test_a_malformed_registry_fails_loudly(tmp_path, monkeypatch, app_json):bad = tmp_path / "employee_apps.json"- bad.write_text('{"apps": {"x": {"name": "X", "provider_id": "p", "side_effects": "dangerous"}}}', encoding="utf-8")+ bad.write_text('{"apps": {"x": %s}}' % app_json, encoding="utf-8")monkeypatch.setattr(apps_module, "CONFIG_PATH", bad)apps_module.reload_apps()try:diff --git a/server/tests/services/employees/test_graph_builder.py b/server/tests/services/employees/test_graph_builder.pyindex 3168e453..5337b894 100644--- a/server/tests/services/employees/test_graph_builder.py+++ b/server/tests/services/employees/test_graph_builder.py@@ -151,6 +151,20 @@ async def test_money_tools_come_back_when_not_asking_first():await assert_valid(built)+async def test_the_browser_stays_read_only_while_asking_first():+ request = hire(apps=["Web browser"], steps=[{"title": "Check prices online", "role": "agent"}], trigger=None)+ built = build_employee_graph(inputs(request, "web"))+ assert built.parameters[built.node_roles["browser"]]["interaction"] == "read_only"+ instructions = built.parameters[built.node_roles["agent"]]["system_message"]+ assert "request_user" in instructions and "can only read pages" in instructions+ await assert_valid(built)++ request = hire(apps=["Web browser"], steps=[{"title": "Check prices online", "role": "agent"}], trigger=None, rules={"ask_first": False})+ built = build_employee_graph(inputs(request, "web"))+ assert built.parameters[built.node_roles["browser"]]["interaction"] == "full"+ assert "can only read pages" not in built.parameters[built.node_roles["agent"]]["system_message"]++async def test_no_apps_means_chat():request = hire(apps=[], steps=[{"title": "Help me write", "role": "agent"}], trigger=None)built = build_employee_graph(inputs(request))diff --git a/server/tests/services/employees/test_list_employees.py b/server/tests/services/employees/test_list_employees.pyindex 393f8501..e4109f3a 100644--- a/server/tests/services/employees/test_list_employees.py+++ b/server/tests/services/employees/test_list_employees.py@@ -123,6 +123,25 @@ async def test_summary_discovers_all_browser_capabilities_including_disabled(reaassert listed["browser_nodes"] == summary["browser_nodes"]+async def test_a_browser_waiting_for_the_owner_is_the_task(real_database, monkeypatch):+ import nodes # noqa: F401 - registers the browser plugin (found by its isBrowserPanel hint)+ import services.employees.node_signals as node_signals++ states = {"b1": {"state": "awaiting_user", "request": {"reason": "login", "message": "text from the page", "since": 1.5}}}+ monkeypatch.setattr(node_signals, "node_state", lambda kind, workflow_id, node_id: states.get(node_id))+ await save(real_database, "92", "Shopper", graph(node("a1", "aiAgent", "Sam"), node("b1", "browser", "Browser")))++ summary = await get_employee_summary(real_database, "92", auth_service=FakeAuth())+ assert summary["browser_request"] == {"node_id": "b1", "reason": "login", "since": "1970-01-01T00:00:01.500000+00:00"}+ assert summary["task"] == {"label": "Waiting", "text": "Needs you to sign in to a site in the browser"}+ # Summaries reach every socket: the agent's message stays in the live view.+ assert "text from the page" not in str(summary)++ states.clear()+ summary = await get_employee_summary(real_database, "92", auth_service=FakeAuth())+ assert summary["browser_request"] is None++@pytest.mark.parametrize(("trigger", "text"),[diff --git a/server/tests/test_credential_catalogue_consumer_fields.py b/server/tests/test_credential_catalogue_consumer_fields.pyindex c8aa9052..3ab86220 100644--- a/server/tests/test_credential_catalogue_consumer_fields.py+++ b/server/tests/test_credential_catalogue_consumer_fields.py@@ -132,6 +132,7 @@ class TestCatalogueFields:("github", "developer"),("claude_code", "developer"),("android_remote", "devices"),+ ("browser", "devices"),("openai_compatible", "ai"),],)@@ -143,10 +144,10 @@ class TestCatalogueFields:check = provider.get("connected_check")if not check:continue- assert check["type"] in {"status", "api_keys"}, provider["id"]+ assert check["type"] in {"status", "api_keys", "builtin"}, provider["id"]if check["type"] == "status":assert check.get("key") and check.get("field"), provider["id"]- else:+ elif check["type"] == "api_keys":assert check.get("keys"), provider["id"]def test_catalogue_payload_carries_consumer_categories(self, registry):@@ -179,6 +180,12 @@ class TestProviderConnectionState:state = await provider_connection_state(registry.get_provider("openai"), FakeAuth())assert state["stored"] is False and state["connected"] is False+ async def test_the_web_browser_needs_nothing_connected(self, registry):+ """Its panel manages optional login profiles; an employee that uses+ the browser must never be blocked from starting for want of one."""+ state = await provider_connection_state(registry.get_provider("browser"), FakeAuth())+ assert state["stored"] is True and state["connected"] is True+async def test_email_account_is_stored_and_connected_only_with_both_keys(self, registry):provider = registry.get_provider("email_himalaya")state = await provider_connection_state(provider, FakeAuth(keys={"email_address"}))