Skip to main content

Module browser_owner

Module browser_owner 

Source
Expand description

Which agent owns which agent-opened browser pane (docs/specs/SPEC_AGENT_DRIVEN_BROWSER_PANES_2026_10_07.md §3).

An agent may drive a browser pane only if it opened that pane with OpenBrowser. The authority is this in-memory map, written only by ui_handlers::handle_ui_browser_open after verifying the caller’s signed identity. The block’s browser:owner_agent meta key mirrors it for the “Driven by” badge, and both must agree:

  • a client that writes the meta key itself gains nothing, since the map has no entry for it;
  • a duplicated pane copies the meta key but gets a new block id, which the map doesn’t know;
  • the human’s Take over clears the meta key; the client-write guard (guard_client_meta_write) then drops the map entry, so ownership ends for good, and no client can set the key at all;
  • deleting the block drops its entry (wcore::delete_block);
  • after srv restarts the map is filled again from browser_pane_records, for the panes whose block still names the same owner (a Take over cleared the key; a copy has no record).
  • a Take over is remembered for a day, so the agent that lost the pane is told what happened instead of guessing (lost_message); a pane that closed is only logged, since a deleted block is already answered as “no such pane”.
  • the agent gets such a pane back with retake once the person pressed Give back in the pane header (relayed by the host, like every answer to a pane’s banner, so no agent can give itself the pane) or took the pane over during the agent’s own hand-off; otherwise the person is still using it and the agent is told to wait.

Structs§

LostEntry 🔒
What srv remembers about a pane an agent lost to a Take over.

Enums§

Denied 🔒
Why a caller may not drive a pane. Not an authentication failure: the caller’s identity was already verified.
Lost 🔒
Why an agent no longer drives a pane.

Constants§

GIVEN_BACK_META_KEY 🔒
Block meta key naming the agent the person gave the pane back to (their Give back click, relayed by the host), so the retake still works after an srv restart. Cleared when an agent drives the pane again.
IDLE_BEFORE_RETAKE 🔒
How long the person must have left a pane they took over alone before the agent that lost it may drive it again.
LAST_DRIVER_META_KEY 🔒
Block meta key naming the agent that drove the pane last, written by srv whenever an agent becomes its driver and kept through the person’s Take over, so the pane header can offer “Give back to X”.
LOST_KEPT 🔒
LOST_KEPT_FOR 🔒
How long a lost pane is remembered, so an agent that comes back the next day is still told what happened.
OWNER_META_KEY 🔒
Block meta key mirroring the owner, for the frontend.
TOOK_CONTROL_META_KEY 🔒
Block meta key set to true while the agent that drives the pane did not open it (take_control), so the header says “took control”. Cleared when the agent lets the pane go.

Functions§

ago 🔒
How long ago, in words an agent can read.
ago_exact 🔒
How long ago, to the second under a minute.
all_owners 🔒
Every pane an agent owns and the agent, for browser_pane_records.
changed 🔒
Woken whenever the set of owned panes changes, or the host needs the whole set again (it registered). See browser_host_sync.
check 🔒
May agent_id drive pane? block is the pane’s block as stored (None if it no longer exists) and recorded its entry in the owner map.
driver_meta 🔒
The meta that shows agent driving a pane: the owner the header reads, and the last driver Give back names.
driver_of 🔒
Who drives a browser pane, for Pane layout: the agent’s id, person after they took it over from an agent that has not got it back, or None for a pane no agent has driven.
forget 🔒
Drop block_id’s owner: the pane was deleted or taken over. Its bypass, if any, ends with the ownership.
forget_because 🔒
Drop block_id’s owner and remember why. Its bypass, if any, ends with the ownership, and so does a pause (the action log stays, for the person to read). Logged, so a refusal an agent reports can be traced to its cause.
guard_client_meta_write 🔒
Guard for meta updates that come from a client (the setmeta WebSocket command and the UpdateObjectMeta service call), not from srv itself. browser:owner_agent is srv’s to write: a client may only clear it, which is the human’s Take over and ends that pane’s ownership for good. Setting or changing it is refused, so a taken-over agent can’t write itself back. browser:attention (the hand-off and approval banner) is srv’s alone: a client that could write it could keep a real request’s id and change what the banner tells the human they’re approving.
lost 🔒
Panes the person took over, newest few hundred. In memory like the owner map, so after an srv restart there is nothing here and the plain refusal is the right answer.
lost_message 🔒
What to tell the agent that lost a pane to the person’s Take over. Another agent asking about the same pane gets the plain refusal, and never learns who drove it. None after an srv restart (nothing is remembered) or for a pane the agent never opened.
mark_given_back 🔒
The person pressed Give back on block_id: the agent that lost it may retake it.
may_retake 🔒
May agent_id drive block (block_id) again, the pane it lost to the person’s Take over? Yes once the person gave the pane back (remembered in memory and in the block’s meta, which outlives an srv restart), or took it over during the agent’s own hand-off, or has not used the pane for IDLE_BEFORE_RETAKE; a pane the person is still using is refused with what to do. since_input is how long ago the host last saw the person use the pane’s page: Duration::MAX when it never has, None when the host could not say (then only Give back counts). The caller then writes the owner meta (retaken_meta) and records the agent (record).
owned_panes 🔒
Every pane an agent owns. The host keeps a copy, to decide inside on_before_popup which of a pane’s popups open in-app (SPEC_BROWSER_PANE_NATIVE_POPUPS_AGENT_DRIVEN_2026_10_08.md §3); it is only a hint there, since who may drive what is always checked here.
owner_of 🔒
owners 🔒
person_has_left 🔒
Has the person left a pane they took over alone for IDLE_BEFORE_RETAKE? Their Take over click is their last touch if they never used the page itself. Unknown (the host could not say) is not left.
record 🔒
Record agent_id as the owner of block_id. Only OpenBrowser calls this.
released_meta 🔒
The meta of a pane nobody drives and the person did not take over: an agent let it go (release).
restore 🔒
Put back the owner browser_pane_records kept across a restart, for a pane whose block still names that agent. Only the owner is restored; the take-over record and a pane’s grants keep their own rules.
retaken_meta 🔒
driver_meta for an agent that drives a pane again: the Give back it used is spent.
srv_only_keys 🔒
Meta keys only srv writes, from its own records: who drives a pane, the banner that asks the person something, the bypass the person granted, what the agent did and whether the person paused it, what opened a popup, the sites a pane is limited to, and which agent coaches a worker.
strip_srv_only_keys 🔒
Remove srv-only keys from the meta a client gives a NEW block (pane.open over RPC or HTTP, object.CreateBlock). Removed rather than refused, so duplicating a pane still works: the copy is an ordinary pane, without an owner, a banner, or a claim to be a popup. srv’s own callers (OpenBrowser, the popup route) set these keys after this check, through open_pane directly. Returns the keys it removed.
taken_over_ago 🔒
How long ago the person took block_id over from an agent, if srv remembers it (not after a restart).
takeover_in_use 🔒
The person took block_id over from agent_id and has neither given it back nor taken it over at the agent’s own request: only their idleness can return it. Some(how long ago they took it over) then, so the caller knows to ask the host when they last used the pane.
took_control_meta 🔒
The meta that shows agent driving a pane it did not open.