Skip to main content

Module google_handlers

Module google_handlers 

Source
Expand description

The Google connectors’ agent routes (docs/specs/SPEC_GOOGLE_CONNECTORS_GMAIL_CALENDAR_DRIVE_2026_10_14.md D3, D4):

  • GET /api/v1/google/self/services: the services the calling agent has a grant on, so its MCP lists only those tools.
  • POST /api/v1/google/calendar: one Calendar action.
  • POST /api/v1/google/drive: one Drive action (pick_files opens Google’s file picker for the person).
  • POST /api/v1/google/gmail: one Gmail action.

Both need an attributed caller (the agent’s own X-Agent-Token): a grant belongs to an agent, so a request that names none has none.

Modules§

connect 🔒
Google connect, connect_status and cancel: an agent connects a Google account itself (docs/specs/SPEC_GOOGLE_PHASE_B_AGENTMUXS_OWN_CLIENT_2026_11_01.md §7, §9, D3). It runs the same flow as the Accounts panel’s Connect (oauth_client::start), so the two can’t drift, except that the consent page is not opened in the system browser: the agent opens it in a Browser pane it drives (the account picker, the unverified-app screen, the scope boxes), and stops for the person only at a password, a second factor or an administrator’s block.

Structs§

CalendarBody 🔒
DisconnectBody 🔒
DriveBody 🔒
GmailBody 🔒
GrantBody 🔒
HostApprover 🔒
Tells the person in the agent’s own pane that it is about to act, with a countdown that goes ahead on its own (agent_notice): they can stop it, hurry it, or say “Always” for this agent. With no pane for the agent there is nowhere to tell them and nothing is done.

Constants§

BUILT_SERVICES 🔒
The services a grant can be set on today; the rest come with their stage.
PANEL_CALLS 🔒
How many log lines the account panel shows.
PICK_GAP 🔒
The least time between two pickers opened for one account by agents, so a loop of pick_files calls can’t fill the person’s browser with tabs.
SERVICES 🔒

Functions§

account_panel 🔒
calling_agent 🔒
The calling agent’s definition, or why there is none (answered 403).
disconnect_by_agent 🔒
error 🔒
google_accounts 🔒
Every Google account on this computer, by email.
grant_as 🔒
A grant, recorded under by_name (by_id). With no agent in the body it goes to yourself, which a caller from another machine has none of: it names the agent here.
grant_by_agent 🔒
grant_is_backed 🔒
Whether a token supporting supported (write, read or none) can back a grant at level.
grant_notice 🔒
“Naki-2 gave Agent5 Calendar read on me@example.com”, or “Naki-2 turned off Calendar for Agent5 on …”.
handle_google_calendar 🔒
POST /api/v1/google/calendar: { account, result }, or { error } with a sentence the agent can act on.
handle_google_disconnect 🔒
POST /api/v1/google/disconnect: end the connection to a Google account: Google’s grant is revoked first, then the saved token, the account’s grants and its log go. The same code as the window’s delete. Any agent may ask (the person only signs in); it is noticed in the windows.
handle_google_drive 🔒
POST /api/v1/google/drive: { account, result }, or { error } with a sentence the agent can act on.
handle_google_gmail 🔒
POST /api/v1/google/gmail: { account, result }, or { error } with a sentence the agent can act on.
handle_google_grant 🔒
POST /api/v1/google/grant: turn a service of a connected Google account on for an agent, or off. Any agent may do it (decided: “yes, agents can grant”); it is recorded as the agent that did it, in the account’s log the person reads. Sends, shares, invites and deletes still wait for the person in the host window, which no agent can answer.
handle_google_self_services 🔒
GET /api/v1/google/self/services: { account, accounts, services: [{ service, level, account }] } for the Google accounts the calling agent holds a grant on (account is the first); none when it has none.
handle_google_status 🔒
GET /api/v1/google/status: the Google accounts connected here, what each can be used for and who holds what, so an agent knows what to grant or to ask the person for.
handle_host_google 🔒
POST /api/v1/host/google: the account panel’s operations, from the host only. (Agents turn services on and off through POST /api/v1/google/grant.)
last_picks 🔒
pick_files 🔒
pick_files: open Google’s file picker in the person’s browser. The agent gets no ids back: it searches once the person has picked.
pick_for_person 🔒
pick_release 🔒
A picker that failed to open doesn’t count against the account.
pick_throttle 🔒
Take the account’s picker slot, or say it was taken a moment ago. The slot is held from the check, so two calls at once can’t both open a picker; pick_release gives it back when the picker didn’t open.
set_grant 🔒
set_grant_on_email 🔒
Set an agent’s grant on chosen, one of the connections of an email (same_email, all of them). The agent names an email, so one grant per email: the service is cleared on the email’s other connections, or an ungrant (or a change of level) would leave an older grant usable.
start_picker_for 🔒
Start the picker for account with the client it was made with; the session id is polled with account.oauth.poll.
status_for 🔒
The accounts, what each supports and who holds what. viewer is the agent asking, whose own level is added as yours; a caller from another machine has no agent here and gets the holders alone.
supported_level 🔒
The highest level the account’s token supports for service, from the scopes it was granted: write, read or none.