fix(mobile): name the agent-device session for device-cloud leases

Merged
TH
14d ago
+27-7

What and why

  • agent-device is about to refuse provider-lease requests from a Node client that names no session (REMOTE_SESSION_REQUIRED, callstack/agent-device#4177): on a shared daemon, an unnamed client lands on the default session and can act through another agent's lease.
  • Four e2e clients hit that today: the BrowserStack/TestMu AI lease allocate and heartbeat in packages/mobile/src/lease/, and Limrun's allocate and apps.install in packages/limrun/src/driver.ts. Limrun's heartbeat reuses the binding's client.
  • Each now names a session, e2e-lease-<8 hex of the lease's stateDir>. One daemon holds one lease, so the name only has to be stable per stateDir. The worker engine still sets its own session over the lease client's (packages/mobile/src/engine.ts).
  • Limrun inlines the same one-line hash instead of importing it, so @e2e-dev/mobile gains no public export.
  • Works with the pinned agent-device 0.21.35 as is, so e2e can bump past #4177 without a break.

Issue

No e2e issue: this prepares for callstack/agent-device#4177, planned for agent-device 0.22.

Verified

Ran it locally: yes

  • pnpm check passes; @e2e-dev/mobile unit tests 484 passed, @e2e-dev/limrun 17 passed.
  • On a real daemon, mirroring the lease driver (private stateDir, socket transport, leaseProvider: 'proxy', allocate then heartbeat):
--- agent-device #4177 head (3707e6277c)
unnamed: refused INVALID_ARGS reason=REMOTE_SESSION_REQUIRED
named: allocate+heartbeat ok (session e2e-lease-fbf28664, lease 2861f02a4e07980798a6afef58c2f492)
--- agent-device 0.21.35 (e2e pin)
unnamed: allocate+heartbeat ok (session none, lease 671c6f9fa6e0b968260b1d2587f727e7)
named: allocate+heartbeat ok (session e2e-lease-3ca37d1f, lease 13eac357ffe4280dbb7fa005a7503172)
  • Not run against live BrowserStack, TestMu AI, or Limrun devices.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: not applicable.
  • Docs updated in the same PR: no change needed, the docs do not describe the lease client's session.
  • Contract change: not applicable.
  • Engine contract change: not applicable.

šŸ¤– Generated with Claude Code