Repository navigation
feat: multiple Google Workspace connectors per organization — each member signs in to each, agent picks by name - #3427
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Member
Author
Photo roll — google-workspace-multi-account✅ 4/4 frames passed · 0 failed · 0 unvalidated · 8 expectations passed · 0 failed 1. Acme Robotics is visibly listed as a Google Workspace connection this person can sign in to
2. Acme Robotics and Acme Labs are both visible, as two separate Google Workspace connections
3. A Google Workspace connection detail visibly offers connecting this person's own account
4. OpenWork visibly shows that Acme Labs browser authorization is in progress
Roll created 2026-08-02T11:54:22.092Z · Source: |
benjaminshafii
enabled auto-merge (squash)
August 2, 2026 13:38
… chooser, and stop deep-linking to u/0 Foundation for multiple Google Workspace connectors per organization. No user-visible multi-account behavior yet; every change here is additive and backward compatible. - external_mcp_connection gains kind + native_provider_key so a row can represent a native OAuth connector instead of an external MCP server (migration 0050, additive, no constraints and no backfill) - the native OAuth callback now resolves the account's email from the id_token, falling back to the provider's userinfo endpoint, and persists it as externalAccountId. Resolution is strictly best-effort: a missing claim, a failed fetch, or a junk response still completes the connect exactly as before - Google's authorize prompt becomes "consent select_account" so a member who is already signed in is actually offered the account chooser - Gmail draft and thread links use authuser=<email> instead of the hardcoded mail/u/0, which resolves to whichever Google account happens to be first in the browser. Falls back to the exact previous u/0 output when the email is unknown The redirect_uri, every route path, and all generated capability names are unchanged.
`pnpm fraimz --all` runs every file in evals/flows on the nightly lane, so a scaffolded flow whose frames are still `ctx.assert(false)` turns nightly red until the feature lands. New app-driving proof belongs in evals/specs as a photo-roll spec (see org-connector-two-members.slow.test.ts and the pr-photo-roll skill), which the nightly spec lane runs separately and which publishes evidence to the PR. The voiceover script stays as the approved narration for that spec.
…aces it needs Writes the proof before the feature. The spec enacts the approved narration in evals/voiceovers/google-workspace-multi-account.md and encodes the definition of done, including the halves that are easy to skip: - the mailbox is the witness: the supplier draft must appear in the Labs mailbox AND the Robotics mailbox must be empty - the two connectors' drafts must not share a credential token - the user-facing request must not contain either connector id, so "the agent picked the right connector" cannot pass by being told the answer - the Gmail link must carry authuser= and must not be /mail/u/0/ - a single-domain organization must still see exactly one card and one button Six primitives it needs do not exist yet. They are declared here as typed stubs that throw a message naming the primitive and how to build it, so the spec compiles and fails for the right reason instead of failing to compile: startMockGoogle, createNativeConnector, readSessionToolCalls, provisionOrg. openConnectionsSurface/waitForConnectionCard/revealText are promoted out of org-connector-two-members rather than stubbed, since working copies existed. Gated behind OPENWORK_EVAL_GOOGLE_MULTI_ACCOUNT_SPEC so an unconfigured run skips cleanly; it is .slow, so it never enters the PR lane.
…ll two accounts apart The first of the six primitives the multi-account spec needs. Written as a focused mock beside scripts/mock-oauth-mcp-server.mjs rather than an extension of it: six existing eval flows depend on that script's single-account behaviour, and the safest way to not regress them is to leave it byte-unchanged. The fixture provides what the old one structurally could not: - an id_token carrying the authorizing account's email, plus /userinfo, so Den can record WHICH account connected - a real chooser page when prompt contains select_account, with chooseAccount() resolving only once the callback has actually been served, never on a timer - per-account mailboxes, every draft attributed to the credential that created it, so a spec can assert the draft landed in one inbox and not the other draftsFor() returns promptly with [] for an empty mailbox instead of blocking for the full timeout, because the negative half of the isolation assertion is the half that matters and a primitive that makes it slow is a primitive that makes it get dropped.
…rganization An organization can now register more than one Google Workspace connector. A connector is an external_mcp_connection row with kind='native_provider': its OAuth client lives in org_oauth_client and each member's tokens live in connected_account, both keyed by the connector row id. The existing (org_membership_id, provider_id) unique index then makes per-connector isolation automatic rather than something to enforce. Backward compatibility is by alias, not migration. An organization that already configured Google keeps provider_id='google-workspace' literally in both tables and keeps appearing with id "google-workspace". Nothing is rewritten, because rewriting provider_id would look like an OAuth client rotation and revoke every member's tokens. The redirect URI stays keyed by provider, not by connector, so customers do not have to touch the Google Cloud Console entry they already pasted. The connector id travels in the signed OAuth state instead. Native rows are fenced out of every MCP handshake path — transport, catalog, tool calls, connect/start discovery, the external OAuth callback binding, and plugin MCP requirement binding — since a Google connector has no MCP server behind it and would otherwise fail deep inside a handshake. Capability namespacing is deliberately not here: un-namespaced Google capability names still resolve to the organization's default connector. test(evals): implement provisionOrg, and make the local Den reproducible provisionOrg creates a real isolated organization with a known shape so a spec can assert that a single-domain company still sees exactly one card. evals/scripts/dev-den.ts captures the setup that previously took manual archaeology: db:push rather than db:migrate (the chain cannot build a database from scratch), an isolated port and database, and the trusted origins that otherwise fail as a 403 at sign-in looking like a product bug.
…hat exists The spec was requesting a "gmail" scope feature that the provider registry does not define, and the route correctly rejected it. The first fix attempt added "gmail" to NATIVE_OAUTH_PROVIDERS as an alias for the compose scope, which is product code bending to fit a test; reverted. The spec now asks for gmailDraft, which is the real feature name for creating drafts. createNativeConnector posts the connector and its OAuth client through the route that landed with the server work, and deleteConnection is confirmed to work on native rows so the spec's onTestFinished cleanup is real.
Two fixes found by running the spec against the real app rather than reasoning about it. The DOM assertions passed while the frames failed: the connection card was in the document but not on screen, so the vision model saw a truncated workspace name instead. Every screenshot now reveals its subject first, which is what revealText exists for — waitForText proves the DOM contains it, a frame proves pixels. The first frame also claimed Acme Robotics was "set up", which conflated the admin having registered the connector with the member having connected their own account. At that point in the story Jordan has not connected, and the app correctly offers her a sign-in. The claim now says what a person would see. Frames 1 and 2 pass: two separate Google connections visible side by side.
…idental layout claim Two more corrections found by running against the real app. The list surface offers each connection a "Sign in" next action and opens a detail panel to authorize; "Connect your account" (mcp.org_connection_connect_action) only exists in that panel. The third frame was asserting the panel's wording against the list, so it counted zero buttons. It now asserts the two cards plus the sign-in affordance, and the later connect flow already goes through the detail panel correctly. The second frame claimed the two connections were "side by side". They are stacked vertically, and the vision model was right to say so — it passed once and then failed on the same pixels, because the claim asserted incidental layout rather than the fact being proven. Claims should describe what a human would verify, or they are flaky by construction.
…h account is signed in The member card for a native connector was anonymous: an admin names it "Acme Robotics", and nothing on screen said Google Workspace. The vision check caught this as a real product gap — it passed or failed depending on whether the model credited the G favicon, which is what a human reviewer would waver on too. The usable-connections entries now carry nativeProviderKey (both the toConnectionResponse mapper and buildNativeProviderEntry — native rows are served by the latter, which is why fixing only the former changed nothing), plus the caller's connected account email. The desktop prefixes the card description with the service name and, once connected, appends "Signed in as <email>." — keeping the existing sentence intact as a prefix because other specs wait for it verbatim. Also: frames now assert prompt CONTAINS select_account (the product correctly sends "consent select_account"), the detail-panel frame replaces a pixel-duplicate list frame, and openConnectionsSurface steers back in a loop — the app opens a freshly created session on its own, and a single navigation followed by a 60s wait parks the spec on /session forever. Its failure now reports what was actually on screen.
"Connected" alone cannot tell two Google sign-ins apart, and the approved demo narration promises the list shows the real email behind each connector. The connected badge now reads "Connected — [email protected]" when the account identity is known. The spec's both-emails frame closes the Labs panel first and waits for both addresses on the list before framing it.
…landed its own 0050
benjaminshafii
force-pushed
the
feat/google-workspace-multi-account
branch
from
August 2, 2026 14:19
70c1d61 to
3c50e9f
Compare
…(connect/start, callback, status, disconnect, default resolution) Warden NPN-7MR: an ungranted member could begin OAuth on a native connector and back un-namespaced Google capabilities with it. Every member-facing resolution of a connector row now goes through the grant-aware listing; the legacy org_oauth_client-only alias keeps its implicitly org-wide behavior unchanged.
Contributor
There was a problem hiding this comment.
Warden security clearance: clear. No new security issues found in this diff (45c4e5d708058bfd5512c26235146f683950d63f). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
benjaminshafii
added a commit
that referenced
this pull request
Aug 2, 2026
…, drop the duplicate module
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




An organization can now register N Google Workspace connectors (e.g. one per Google domain). Each is its own row with its own OAuth client; each member connects their own account to each; capabilities are namespaced
native:<connectionId>:<tool>so the agent picks the right inbox by connector name — no account parameter.Backward compatibility (by design, not migration)
provider_id = "google-workspace"literally (alias): no credential rewrite, no token revocation, no Google Console edit.getCapabilitiesGoogleWorkspace*names still resolve to the default connector (asserted by existing tests).Also fixes (standalone value)
Connected — [email protected], description names the service.consent select_account— a second connect gets a real account chooser instead of silently reusing the signed-in account.authuser=<email>instead of hardcodedmail/u/0(wrong mailbox for anyone signed into multiple Googles). Exactu/0fallback when email unknown.Tests run (commands + results)
pnpm --filter @openwork-ee/den-api exec tsc --noEmit— cleangoogle-workspace-capabilities29/29 ·native-capabilities(new) 7/7 incl. credential-isolation crux (two tokens, right one hits fake Google API, asserted on Authorization header) ·native-provider-scopes6/6 ·gmail-draft, rotation, revocation — greennative-provider-connections2 fails,mcp-connections-tools4,mcp-connections-edit8 — all reproduce on dev): zero introduced failurespnpm evals:typecheck,pnpm evals:spec(PR lane) green; eval package tests 117/117mail/u/0;"Connected with your own account."kept intact as prefix; badge checks areincludes("Connected")E2E evidence (partial — stated honestly)
App-driving spec
evals/specs/google-workspace-multi-account.slow.test.ts(enacts the approved voiceover): best run validated 4/8 frames against the real Electron app + real Den + mock Google (two connectors listed, service named on card, detail panel, Labs authorize with real account chooser witnessed by the mock). Photo roll posted below.Known-incomplete: frames 5–8 (both-emails list, agent-picks-Labs e2e, wrong-mailbox-empty witness, single-domain no-regression) are unit-proven server-side but have no green app-driven run yet. The spec is
.slow+ opt-in (OPENWORK_EVAL_GOOGLE_MULTI_ACCOUNT_SPEC=1) and skips cleanly in PR CI and nightly — same precedent asorg-connector-two-members.To un-gate the spec (follow-up): bound every helper wait; fresh sign-in before teardown (long runs hit
403 fresh_auth_required); provision script that boots Den withDEN_GOOGLE_OAUTH_*/DEN_GOOGLE_API_BASE_URLpointed at the mock (the one genuinely missing infra piece); nightly model+key for the agent turn.Repro for reviewers:
evals/scripts/dev-den.ts+ set the fourDEN_GOOGLE_*vars to the mock (startMockGoogle, port 3980), then run the spec opted-in.