Skip to content

Pull CAPTCHA, hosted launch, and database locking into shared abstractions - #41

Open
matthewnanas wants to merge 8 commits into
mainfrom
matt/abstractions
Open

matthewnanas wants to merge 8 commits into
mainfrom
matt/abstractions

Conversation

@matthewnanas

@matthewnanas matthewnanas commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Stack: 1 of 2. This PR is the base; #42 (repo-wide Prettier formatting) sits on top of it.

Summary

  • Browser session: CAPTCHA gating moves to server/browser/captcha-gate.ts and the Browserbase launch/reattach/release flow moves to server/browser/browserbase-launch.ts. All page work, including withHostedPage and secureLogin, now shares one operation lock.
  • CAPTCHA transitions: these are reported through a single onCaptchaTransition callback. The runtime queues them and applies them to task state inside the running operation, so they always land on the turn that's running.
  • Database: advisory locking is one shared withAdvisoryLock helper in server/postgres.ts, used by the link, 1Password, and private-browser callers. Watch SQL moves onto MonitorStore.
  • Personal-browser mode: this now requires the ONEPASSWORD_ENABLED rollout flag. The private-browser quarantine check and the reattach metadata check still run when the flag is off but the extension is configured. With the flag off, a saved personal session gets replaced instead of reattached.

Behavior notes

  • Cancellation is checked again after taking the browser operation lock and before starting the browser, so a cancelled call never launches a session.
  • secureLogin start and CAPTCHA-gate failures stay redacted ("Secure login failed") and record a vault.login error trace.
  • markDispatchUnresolved now runs its two updates in one transaction, so the status change and the reconcile update succeed or fail together.

Testing

  • pnpm lint and pnpm typecheck pass, apart from a local install missing standardwebhooks, which Add Parallel public-web search #37 added.
  • pnpm test: 393 passed, 61 skipped. New tests cover:
    • CAPTCHA events landing on the running turn
    • cancellation while waiting for the lock
    • redacting secure-login start failures
    • the private-browser guard with the rollout flag off
    • replacing a personal browser with the flag off
  • The database-backed suites and the monitor tests (tests/monitors.test.ts, tests/monitor-http.test.ts) did not run locally. They need a database and a fresh pnpm install.

🤖 Generated with Claude Code

matthewnanas and others added 8 commits November 3, 2026 11:35
A leftover extension upload id was enough to change hosted launches and disable reusable Contexts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Link, 1Password, and the browser locks each owned a slightly different unlock path, so a failed lock could return a broken connection to the pool.

Co-authored-by: Cursor <cursoragent@cursor.com>
The service was a second writer for status, inbox, and scan updates, including a create-failure path that could commit only one of its two statements.

Co-authored-by: Cursor <cursoragent@cursor.com>
The session and the durable task state each parsed the timeout and kept a second copy of the transition, and the runtime polled every 50ms to join them.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Queue CAPTCHA transitions and commit them inside the running operation.
- Keep the private-browser guard and reattach checks independent of the rollout flag.
- Re-check cancellation after taking the operation lock, before starting the browser.
- Keep secure-login start and CAPTCHA failures redacted.
- Restore the monitor pool's 10s idle timeout and drop an unused re-export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to emit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matthewnanas
matthewnanas requested a review from a team as a code owner November 3, 2026 20:09
@matthewnanas
matthewnanas added this pull request to stack #43 November 3, 2026 20:12
@shriyatheunicorn
shriyatheunicorn self-requested a review November 3, 2026 20:27
runtime.browser = createRuntimeBrowser(
sessionId,
runtime.state,
runtime.captchaTransitions,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give each replacement browser a fresh CAPTCHA transition queue here and in selectBrowserContext?

if a CAPTCHA starts and errors between tool calls, createBrowserContext closes the old browser but passes its pending events into the replacement. the next snapshot succeeds on the new browser, then draining the old queue marks the task waiting_for_user for a challenge in the closed browser.

i reproduced this locally; the regression test passes at the merge base and fails on this PR. replacing the queue when replacing the browser also keeps late callbacks from the retired browser out of the new queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants