feat(web): run concurrent web sessions on one host

Geschlossen
#4,190 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #4191 von @kacper-mikolajczak — gemerged

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
18/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
backend, cli

Rechercherichtung

Start in packages/contracts/src/device-inventory.ts, where the fixed agent-browser-chrome web device is defined, then follow the three per-device checks in packages/daemon/src/sessions/session-lifecycle/internal/session-open-execution.ts and the device:<id> lock in packages/daemon/src/server/request-binding.ts. Done means two differently named web sessions open and run in parallel, the same name still returns DEVICE_IN_USE, and the router tests the issue lists pass. Pull request #4191 is already open against this issue, so check it before starting.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement

Purpose

Let several agents drive isolated browsers on one host at the same time, the way they already can with one emulator each. Today a host runs only one agent-device web session.

The backend already supports this. agent-browser --session <name> runs isolated browsers in parallel, each with its own browser process, cookies, storage, and history. agent-device already passes the session name through as --session (agent-browser-provider.ts L430). Only agent-device's device model blocks it.

Current behavior (0.21.33)

agent-device open about:blank --platform web --session a
agent-device open https://example.com --platform web --session b
# Error (DEVICE_IN_USE): Device is already in use by session "a".

AGENT_DEVICE_STATE_DIR=$(mktemp -d) agent-device open https://example.com --platform web --session c
# Error (DEVICE_IN_USE): web device agent-browser-chrome is owned by session "a" in workspace "..."

Web inventory returns one fixed device, agent-browser-chrome (device-inventory.ts L53-L60). Three per-device rules then block a second session:

Today's only workaround gives each session its own AGENT_DEVICE_STATE_DIR and AGENT_DEVICE_CLAIMS_DIR. That turns off host-wide device claims for the second daemon and needs a second managed backend install.

Required behavior

  • Each web session holds its own device, agent-browser-chrome:session:<name>. Device selection derives the id before any lock is taken. The conflict check, the claim, and the device:<id> lock then apply unchanged. This mirrors the app devices of ADR 0035 (#3323).
  • Web sessions with different names can open, run commands, batch, and replay in parallel in one daemon.
  • The same name still gets DEVICE_IN_USE, both in one daemon and across daemons that share a claims directory.
  • The device id uses the same normalized session name as the backend's --session. A name the id cannot carry unambiguously is refused with a typed reason.
  • Network dump, audio probe, and recording use only the request's own web provider, never another session's browser or the default one.
  • Closing a web session, or expiring it when idle, closes only that session's browser.

CLI example

agent-device open https://example.com --platform web --session a
agent-device open https://www.iana.org/help/example-domains --platform web --session b
agent-device snapshot --session a   # Page: https://example.com
agent-device snapshot --session b   # Page: https://www.iana.org/help/example-domains

Completion conditions

  • A router test opens two web sessions with different names in parallel. The same name conflicts, including from a second daemon on the same claims directory.
  • A router test runs two fresh web batches and two fresh web replays with different names in parallel.
  • Unit tests cover session-name normalization, teardown closing only its own browser, and network dump and audio probe refusing without a request-scoped provider.
  • The web help topic documents parallel sessions.

Dependencies

None. ADR 0035 and ADR 0029 (policy admission) describe app devices only. If this is accepted, they need an amendment or a new ADR.

Related: #817, #2031, #1868.

Vorherrschende Sprache
TypeScript
Sterne
5.3k
Forks
377
Ø Merge
13 Std. 58 Min.
Gemergte PRs (30 T.)
654

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus callstack/agent-device

Alle Issues in callstack/agent-device

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.