diff --git a/docs/internal/agent-rules/toolchain.md b/docs/internal/agent-rules/toolchain.md index e91edab39..e78a6e814 100644 --- a/docs/internal/agent-rules/toolchain.md +++ b/docs/internal/agent-rules/toolchain.md @@ -214,7 +214,7 @@ The machine can run a line only if: | Android | `command -v emulator adb` finds both | | iOS window | the iOS check; `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Devices'"` prints a path; `stat -f %Su /dev/console` is not `root` (someone is logged in); `pgrep -x DeviceHub` finds nothing (the test starts DeviceHub itself with `-shutdownStartedDevicesOnQuit NO` and quits it at the end). Run `scripts/slow-e2e.sh e2e/slow-ios-window.test.ts` | | Physical iOS | `uname -s` is `Darwin`; `SIMLOCK_PHYSICAL_IOS` is the UDID of an iPhone on USB (trusted, Developer Mode on, unlocked, Auto-Lock Never); `SIMLOCK_PHYSICAL_IOS_APP` is a `.app` signed for it. `/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" /Library/Developer/PrivateFrameworks/CoreDevice.framework/Resources/Info.plist` prints a version whose major is 642 or later (streaming a phone needs the CoreDevice of Xcode 27 or later; the framework is machine-wide and does not follow `xcode-select`). DeviceHub and Xcode are not running during the lane. The stream cases need the iPhone on iOS 27 or later; an older iPhone runs the refusal case instead. Run `scripts/slow-e2e.sh --physical e2e/slow-ios-physical.test.ts` | -| iOS foldable | the iOS check; `xcrun simctl list runtimes` lists iOS 27.1 or later and `xcrun simctl list devicetypes` lists `iPhone Duo`; `SIMLOCK_E2E_AGENT_DEVICE` names agent-device 0.21.35 or later; `command -v ffmpeg` finds it. Run `scripts/slow-e2e.sh e2e/slow-ios-foldable.test.ts` | +| iOS foldable | the iOS check; `xcrun simctl list runtimes` lists iOS 27.1 or later and `xcrun simctl list devicetypes` lists `iPhone Duo`; `SIMLOCK_E2E_AGENT_DEVICE` names agent-device 0.21.40 or later; `command -v ffmpeg` finds it. Run `scripts/slow-e2e.sh e2e/slow-ios-foldable.test.ts` | | iOS simulator input | the iOS check; `xcrun simctl list runtimes` lists an iOS 27 or later runtime; `uname -m` is `arm64`; `SIMLOCK_E2E_AGENT_DEVICE` names the agent-device the lane pins (agent-device through simlock row). Run `scripts/slow-e2e.sh e2e/slow-ios-input.test.ts` | | agent-device through simlock | `node -v` is 22.12.0 or later (agent-device's own minimum); the iOS check and `uname -m` is `arm64` (the fixture app is arm64 only), or the Android check; `SIMLOCK_E2E_AGENT_DEVICE` (in `.slow-lane.env`) is the absolute path of `bin/agent-device.mjs` in an install of the agent-device version `package.json` pins for `@agent-device/proxy` (`npm install -g agent-device@`, or a checkout at tag `v` built with `pnpm install && pnpm build && pnpm build:android`, the last building the Android snapshot helper); room for two devices: `node -p "os.totalmem() / 2**30"` prints at least 7 for iOS or 12 for Android (simlock's 4 GiB OS reserve plus two of its default 1.5 GiB iOS or 4 GiB Android per-device budgets). Run `scripts/slow-e2e.sh e2e/slow-agent-device.test.ts` or `scripts/slow-e2e.sh e2e/slow-agent-device-gateway.test.ts` | | Physical Android | `command -v adb` finds it; `adb devices -l` lists `$SIMLOCK_PHYSICAL_ANDROID` on a USB transport (a `usb:` field) in state `device`; `SIMLOCK_PHYSICAL_ANDROID_APK` names an APK; `SIMLOCK_PHYSICAL_ANDROID_NETWORK` beside it names an address `adb devices -l` lists in state `device` with no `usb:` field, for the network case. Run `scripts/slow-e2e.sh --physical e2e/slow-android-physical.test.ts` | diff --git a/e2e/slow-agent-device.test.ts b/e2e/slow-agent-device.test.ts index 534ee988c..37935319f 100644 --- a/e2e/slow-agent-device.test.ts +++ b/e2e/slow-agent-device.test.ts @@ -620,7 +620,7 @@ function defineSuite(target: Target): void { ); leasingCase( - "with capabilities.agent-device.command pointing at an agent-device that reports 0.9.2, the daemon starts and grants a plain simlock lease --detach; an agent's open fails with agent-device is not available on this simlock: found 0.9.2, need 0.21.28 or later; simlock doctor reports module-unavailable with found 0.9.2, need 0.21.28 or later", + "with capabilities.agent-device.command pointing at an agent-device that reports 0.9.2, the daemon starts and grants a plain simlock lease --detach; an agent's open fails with agent-device is not available on this simlock: found 0.9.2, need 0.21.40 or later; simlock doctor reports module-unavailable with found 0.9.2, need 0.21.40 or later", { timeout: 900_000 }, async () => { const root = await mkdtemp(join(tmpdir(), "simlock-ad-old-")); @@ -632,7 +632,7 @@ function defineSuite(target: Target): void { await writeFile(join(root, "dist/src/daemon.js"), ""); await writeFile(entry, '#!/usr/bin/env node\nconsole.log("0.9.2");\n'); await chmod(entry, 0o755); - const message = "found 0.9.2, need 0.21.28 or later"; + const message = "found 0.9.2, need 0.21.40 or later"; await env.withConfig({ capabilities: { "agent-device": { command: entry } } }, async () => { const a = await agent("a"); diff --git a/package.json b/package.json index 6fbabb251..7a7fef0ac 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "openapi": "TURBO_TELEMETRY_DISABLED=1 turbo run //#build:daemon:run && node scripts/openapi.mjs" }, "dependencies": { - "@agent-device/proxy": "0.21.36", + "@agent-device/proxy": "0.21.41", "@hono/node-server": "2.1.6", "@hono/zod-openapi": "1.6.3", "@modelcontextprotocol/sdk": "1.32.2", diff --git a/packages/e2e/package.json b/packages/e2e/package.json index 42d7e87d0..8ed96e727 100644 --- a/packages/e2e/package.json +++ b/packages/e2e/package.json @@ -35,12 +35,12 @@ }, "devDependencies": { "@e2e-dev/mobile": "0.12.7", - "agent-device": "0.21.37", + "agent-device": "0.21.41", "e2e": "0.23.1" }, "peerDependencies": { "@e2e-dev/mobile": ">=0.12.5 <1", - "agent-device": ">=0.21.37" + "agent-device": ">=0.21.40" }, "engines": { "node": ">=22.13" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dab49e818..401fcdd40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -173,8 +173,8 @@ importers: .: dependencies: '@agent-device/proxy': - specifier: 0.21.36 - version: 0.21.36 + specifier: 0.21.41 + version: 0.21.41 '@hono/node-server': specifier: 2.1.6 version: 2.1.6(hono@4.13.17) @@ -315,8 +315,8 @@ importers: specifier: 0.12.7 version: 0.12.7(e2e@0.23.1) agent-device: - specifier: 0.21.37 - version: 0.21.37 + specifier: 0.21.41 + version: 0.21.41 e2e: specifier: 0.23.1 version: 0.23.1 @@ -326,8 +326,8 @@ packages: '@adobe/css-tools@4.5.0': resolution: {integrity: sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==} - '@agent-device/proxy@0.21.36': - resolution: {integrity: sha512-p9Vhhe8CiuwTZI3zZ8jwlcpKZkMFDM/JUWGwuUmf+/dCe763aT4GHR3zvD6VzLDg6X5zMSYdq2f7EEzqxfIy3g==} + '@agent-device/proxy@0.21.41': + resolution: {integrity: sha512-VAuqR/hyshzeohHaUMhFrgf7y/A7c2DbThfyB1n+rmSaAkXe4TWHj2OEvBLJtu5loeVOa62K9zWRPUHCdeWdNA==} engines: {node: '>=22.12'} '@ai-sdk/provider@4.0.37': @@ -2082,6 +2082,16 @@ packages: ai: optional: true + agent-device@0.21.41: + resolution: {integrity: sha512-VQMYEXzcNBwCPLrWHDM0ic1pWD+GroWukj0jHCzS9zob9eeHSVYJTVSgydLaDn2c2aMH3NuCHr1vLvZ2Bgl7Uw==} + engines: {node: '>=22.12'} + hasBin: true + peerDependencies: + ai: ^6.0.0 || ^7.0.0 + peerDependenciesMeta: + ai: + optional: true + ajv-draft-04@1.0.0: resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} peerDependencies: @@ -4307,7 +4317,7 @@ snapshots: '@adobe/css-tools@4.5.0': {} - '@agent-device/proxy@0.21.36': {} + '@agent-device/proxy@0.21.41': {} '@ai-sdk/provider@4.0.37': dependencies: @@ -5786,6 +5796,8 @@ snapshots: agent-device@0.21.37: {} + agent-device@0.21.41: {} + ajv-draft-04@1.0.0(ajv@8.20.0): optionalDependencies: ajv: 8.20.0 diff --git a/src/agent-device/edge-release.test.ts b/src/agent-device/edge-release.test.ts index af3f4dfa2..c41808b9f 100644 --- a/src/agent-device/edge-release.test.ts +++ b/src/agent-device/edge-release.test.ts @@ -80,14 +80,14 @@ describe("the agent-device front, through the whole worker daemon", () => { expect(allocatesReceived(bare, 2)).toEqual([]); }); - it("an agent-device allocate with no usable reply (an unreachable daemon, a non-JSON body) releases the simlock lease and answers `COMMAND_FAILED`; when agent-device answers the follow-up release with a scope error, the simlock lease stays until its TTL, and when it answers `LEASE_NOT_FOUND`, the simlock lease is released", async () => { + it("an agent-device allocate to an unreachable daemon answers the proxy's `UNKNOWN` error and one with a non-JSON body answers `COMMAND_FAILED`, and each releases the simlock lease; when agent-device answers the follow-up release with a scope error, the simlock lease stays until its TTL, and when it answers `LEASE_NOT_FOUND`, the simlock lease is released", async () => { const rig: Rig = await setUp(); expect((await envelopeOf(await allocate(rig, 1))).result).toMatchObject({ ok: true }); rig.fake.setUnreachable(true); const unreachable = await envelopeOf(await allocate(rig, 2)); rig.fake.setUnreachable(false); - expect(unreachable.error?.data?.code).toBe("COMMAND_FAILED"); + expect(unreachable.error?.data).toMatchObject({ code: "UNKNOWN", message: "fetch failed" }); await expect.poll(async () => (await leases(rig)).map((lease) => lease.id)).toEqual([hex(1)]); rig.fake.answerNextAllocateWith("bad gateway"); diff --git a/src/agent-device/edge.test.ts b/src/agent-device/edge.test.ts index f1b8a617a..30de0f747 100644 --- a/src/agent-device/edge.test.ts +++ b/src/agent-device/edge.test.ts @@ -8,6 +8,7 @@ import { MemoryLogSink, ScriptedProcessRunner, } from "../ports/index.js"; +import { AGENT_DEVICE_RPC_PROTOCOL_VERSION } from "./shared/compatibility.js"; import { FakeAgentDevice, FakeAgentDeviceHealth } from "./testing.js"; import { AgentDeviceSupervisor } from "./host/agent-device-supervisor.js"; import { SupervisorAgentDeviceUpstream } from "./host/upstream.js"; @@ -108,13 +109,14 @@ describe("the agent-device front, through the whole worker daemon", () => { expect(rig.fake.requests).toHaveLength(received); }); - it("/v1/agent-device/health with a simlock token answers the proxy's health, with the agent-device daemon's health under `upstream`", async () => { + it("/v1/agent-device/health with a simlock token answers the proxy's health on the RPC protocol simlock requires, with the agent-device daemon's health under `upstream`", async () => { const rig = await setUp(); const response = await send(rig, "/health"); expect(response.status).toBe(200); expect(await response.json()).toMatchObject({ + rpcProtocolVersion: AGENT_DEVICE_RPC_PROTOCOL_VERSION, service: "agent-device-proxy", upstream: { service: "agent-device-daemon" }, }); @@ -122,7 +124,7 @@ describe("the agent-device front, through the whole worker daemon", () => { it("with capabilities.agent-device.enabled true and agent-device unavailable, /health, /rpc and an upload each answer `agent-device is not available on this simlock: `, nothing is leased, and POST /v1/lease-requests still grants a device", async () => { const rig = await setUp(); - const reason = "found 0.20.3, need 0.21.28 or later"; + const reason = "found 0.20.3, need 0.21.40 or later"; rig.fake.setUnavailable(reason); const health = await send(rig, "/health"); @@ -147,7 +149,7 @@ describe("the agent-device front, through the whole worker daemon", () => { }); for (const [version, reason, retriable] of [ ["0.20.3", "wrong-version", false], - ["0.21.28", "start-failed", true], + ["0.21.40", "start-failed", true], ] as const) { const supervisorUpstream = await unavailableSupervisor(version, reason); const supervised = await setUp({ supervisorUpstream }); @@ -229,7 +231,7 @@ describe("the agent-device front, through the whole worker daemon", () => { await expect.poll(() => rig.fake.abortedCommands).toEqual(["snapshot"]); }); - it("an upload preflight answers a ticket URL under `/v1/agent-device/upload/direct/` on simlock's own origin, carrying the agent's own simlock token, and a `PUT` to it reaches the agent-device daemon", async () => { + it("an upload preflight answers a ticket URL under `/v1/agent-device/upload/direct/` on simlock's own origin (`https` when the request carries `x-forwarded-proto: https`), carrying the agent's own simlock token, and a `PUT` to it reaches the agent-device daemon", async () => { const rig = await setUp(); const preflight = await send(rig, "/upload/preflight", { body: "{}" }); @@ -252,6 +254,17 @@ describe("the agent-device front, through the whole worker daemon", () => { expect(put.status).toBe(200); expect(rig.fake.uploads).toEqual(["artifact bytes"]); + + const behindTls = await send(rig, "/upload/preflight", { + body: "{}", + headers: { "x-forwarded-proto": "https, http" }, + }); + const tlsTicket = ((await behindTls.json()) as { upload: { url: string } }).upload; + expect( + tlsTicket.url.startsWith( + `${rig.origin.replace("http:", "https:")}/v1/agent-device/upload/direct/`, + ), + ).toBe(true); }); it("on a worker, an upload preflight and an artifact download follow the `x-agent-device-lease-id` header to the daemon of the lease it names, go to the simulator daemon with no header, and a header naming another token's lease is refused 403 `refused: lease is not one of yours`, and a malformed header is refused `the x-agent-device-lease-id header is not a lease id`", async () => { diff --git a/src/agent-device/gateway-front-lease-header.test.ts b/src/agent-device/gateway-front-lease-header.test.ts index b5435ec7c..4ece0e591 100644 --- a/src/agent-device/gateway-front-lease-header.test.ts +++ b/src/agent-device/gateway-front-lease-header.test.ts @@ -55,7 +55,7 @@ describe("the agent-device front, through a gateway: the lease header", { timeou expect(pathsReceived(other)).toEqual(before); }); - it("the preflight's ticket URL names the gateway's origin, its `upload.headers` carry the caller's own `authorization`, W2 received its own daemon's token in `authorization` and `x-agent-device-token` and none of the caller's credentials, and a `PUT` to it with the lease header and those headers reaches W2", async () => { + it("the preflight's ticket URL names the gateway's origin, its `upload.headers` carry the caller's own `authorization`, W2 received its own daemon's token in `authorization` and `x-agent-device-token` and none of the caller's credentials, and a `PUT` to it with the lease header and those headers reaches W2, and behind `x-forwarded-proto: https` the ticket URL is `https`", async () => { const rig = await twoLeasesOnTwoWorkers(); const target = holderOf(rig, 2); @@ -88,6 +88,13 @@ describe("the agent-device front, through a gateway: the lease header", { timeou expect(put.status).toBe(200); expect(target.fake.uploads).toEqual(["artifact bytes"]); expect(holderOf(rig, 1).fake.uploads).toEqual([]); + + const behindTls = await send(rig, "/upload/preflight", { + body: "{}", + headers: { ...leased(2), "x-forwarded-proto": "https" }, + }); + const tlsTicket = ((await behindTls.json()) as { upload: { url: string } }).upload; + expect(tlsTicket.url.startsWith(`${rig.origin.replace("http:", "https:")}/v1/`)).toBe(true); }); it("a finalize, a `POST /upload`, a `GET artifacts/` and a diagnostics `GET`, each with the header, reach the lease's worker", async () => { diff --git a/src/agent-device/host/agent-device-supervisor-state.test.ts b/src/agent-device/host/agent-device-supervisor-state.test.ts index fbcb19020..4d6a07a46 100644 --- a/src/agent-device/host/agent-device-supervisor-state.test.ts +++ b/src/agent-device/host/agent-device-supervisor-state.test.ts @@ -154,7 +154,7 @@ describe("AgentDeviceSupervisor pid record", () => { }); describe("AgentDeviceSupervisor readiness", () => { - it("is running with the version, base URL, token and generation 1 once daemon.json names the child, the port listens and /health answers protocol 2", async () => { + it("is running with the version, base URL, token and generation 1 once daemon.json names the child, the port listens and /health answers protocol 3", async () => { const harness = await run(); expect(harness.availability()).toEqual({ @@ -164,7 +164,7 @@ describe("AgentDeviceSupervisor readiness", () => { platforms: ["ios", "android"], state: "running", token, - version: "0.21.28", + version: "0.21.40", }); expect(harness.health.reads).toContain(`http://127.0.0.1:${httpPort}`); }); @@ -178,7 +178,7 @@ describe("AgentDeviceSupervisor readiness", () => { const pid = harness.children[0]?.pid; await harness.filesystem.writeFileAtomic( daemonJsonPath, - JSON.stringify({ httpPort, pid, token, version: "0.21.28" }), + JSON.stringify({ httpPort, pid, token, version: "0.21.40" }), ); harness.probe.startListening(httpPort); await advanceUntil(harness, () => stateOf(harness) === "running", 10_000); @@ -211,17 +211,17 @@ describe("AgentDeviceSupervisor readiness", () => { expect(stateOf(harness)).toBe("running"); }); - it("stops the child and reports wrong-version naming both protocols when /health answers protocol 3", async () => { + it("stops the child and reports wrong-version naming both protocols when /health answers protocol 2", async () => { const harness = await arrange(); - harness.health.respondWith({ rpcProtocolVersion: 3, service: "agent-device-daemon" }); + harness.health.respondWith({ rpcProtocolVersion: 2, service: "agent-device-daemon" }); await advancing(harness, harness.begin()); expect(unavailable(harness)).toMatchObject({ - message: "agent-device 0.21.28 speaks RPC protocol 3, need 2", + message: "agent-device 0.21.40 speaks RPC protocol 2, need 3", reason: "wrong-version", }); - expect(unavailable(harness).remedy).toContain("RPC protocol 2"); + expect(unavailable(harness).remedy).toContain("RPC protocol 3"); for (const phrase of restartCommand) expect(unavailable(harness).remedy).toContain(phrase); expect(harness.processes.signals).toEqual([ { pid: harness.children[0]?.pid, signal: "SIGTERM" }, diff --git a/src/agent-device/host/agent-device-supervisor.test.ts b/src/agent-device/host/agent-device-supervisor.test.ts index dba74280f..3e4a26871 100644 --- a/src/agent-device/host/agent-device-supervisor.test.ts +++ b/src/agent-device/host/agent-device-supervisor.test.ts @@ -112,7 +112,7 @@ describe("AgentDeviceSupervisor finding agent-device", () => { platforms: ["ios", "android"], state: "running", token, - version: "0.21.28", + version: "0.21.40", }); expect(commandsRun(harness)[0]).toEqual([nodePath, realCli, "--version"]); expect(daemonSpawns(harness)[0]?.[1]).toBe(internalEntry); @@ -130,7 +130,7 @@ describe("AgentDeviceSupervisor finding agent-device", () => { reason: "not-found", }); expect(unavailable(harness).remedy).toContain("capabilities.agent-device.command"); - expect(unavailable(harness).remedy).toContain("0.21.28 or later"); + expect(unavailable(harness).remedy).toContain("0.21.40 or later"); for (const phrase of restartCommand) expect(unavailable(harness).remedy).toContain(phrase); expect(harness.runner.calls).toEqual([]); }); @@ -219,14 +219,14 @@ describe("AgentDeviceSupervisor checking the install", () => { const harness = await run({ expectations: [versionRun("0.20.3\n")] }); expect(unavailable(harness)).toMatchObject({ - message: "found 0.20.3, need 0.21.28 or later", + message: "found 0.20.3, need 0.21.40 or later", reason: "wrong-version", }); - expect(unavailable(harness).remedy).toContain("0.21.28 or later"); + expect(unavailable(harness).remedy).toContain("0.21.40 or later"); for (const phrase of restartCommand) expect(unavailable(harness).remedy).toContain(phrase); }); - it.each(["abc", "0.21", "0.9.100", "0.21.27", "0.21.28-nightly.20261013.49"])( + it.each(["abc", "0.21", "0.9.100", "0.21.39", "0.21.40-nightly.20261119.1"])( "reports %s as wrong-version", async (printed) => { const harness = await run({ expectations: [versionRun(`${printed}\n`)] }); @@ -236,7 +236,7 @@ describe("AgentDeviceSupervisor checking the install", () => { }, ); - it.each(["0.21.28", "0.21.28+build.7", "0.21.29-dev", "0.22.0", "0.100.0", "1.0.0+build.7"])( + it.each(["0.21.40", "0.21.40+build.7", "0.21.41-dev", "0.22.0", "0.100.0", "1.0.0+build.7"])( "starts a daemon for the version %s", async (printed) => { const harness = await run({ expectations: [versionRun(`${printed}\n`), daemonSpawn()] }); diff --git a/src/agent-device/host/host.ts b/src/agent-device/host/host.ts index d2d229d04..900b33ded 100644 --- a/src/agent-device/host/host.ts +++ b/src/agent-device/host/host.ts @@ -145,6 +145,8 @@ export class AgentDeviceHost { authenticate: (tagged) => this.authenticate(tagged), upstreamBaseUrl: current.baseUrl, upstreamFetch: (upstream) => this.#upstreamFetch(upstream), + // why: unset, @agent-device/proxy 0.21.41 leaves an RPC call to the agent-device daemon as long as the client waits (only health and transfers keep their own limits); 0.21.36 cut every upstream call at 300 s. + upstreamTimeoutMs: 300_000, upstreamToken: current.token, }), }; @@ -179,6 +181,9 @@ export class AgentDeviceHost { if (url.pathname === FRONT_PREFIX || url.pathname.startsWith(`${FRONT_PREFIX}/`)) { url.pathname = PROXY_BASE_PATH + url.pathname.slice(FRONT_PREFIX.length); } + // why: simlock serves plain HTTP behind a TLS tunnel, and since 0.21.41 the proxy builds the upload ticket URL from `request.url` alone, so the tunnel's scheme (the first `x-forwarded-proto`) goes into it. + const forwarded = request.headers.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase(); + if (forwarded === "http" || forwarded === "https") url.protocol = forwarded; return new Request(url, { headers: request.headers, method: request.method, diff --git a/src/agent-device/host/test-agent-device-supervisor.ts b/src/agent-device/host/test-agent-device-supervisor.ts index 9da4473a1..c2f7af9e1 100644 --- a/src/agent-device/host/test-agent-device-supervisor.ts +++ b/src/agent-device/host/test-agent-device-supervisor.ts @@ -43,7 +43,7 @@ export const httpPort = 4310; export const token = "daemon-token"; -export const healthyBody = { rpcProtocolVersion: 2, service: "agent-device-daemon" }; +export const healthyBody = { rpcProtocolVersion: 3, service: "agent-device-daemon" }; export const restartCommand = ["simlock daemon stop", "simlock daemon start"]; @@ -172,7 +172,7 @@ export async function arrange(options: Options = {}) { httpPort, pid: mode === "ready" ? pid : pid + 1_000, token, - version: "0.21.28", + version: "0.21.40", }), ); } @@ -267,7 +267,7 @@ async function installAgentDevice( await options.layout?.(filesystem); } -export function versionRun(output = "0.21.28\n", extra: Partial = {}) { +export function versionRun(output = "0.21.40\n", extra: Partial = {}) { return { match: { args: [realCli, "--version"], command: nodePath }, result: { code: 0, stderr: "", stdout: output }, diff --git a/src/agent-device/host/upstream.test.ts b/src/agent-device/host/upstream.test.ts index d72a82e05..e4ebf128b 100644 --- a/src/agent-device/host/upstream.test.ts +++ b/src/agent-device/host/upstream.test.ts @@ -31,7 +31,7 @@ async function arrange(version: string) { const filesystem = new MemoryFilesystem(); const probe = new FakeTcpProbe(); const health = new FakeAgentDeviceHealth(); - health.respondWith({ rpcProtocolVersion: 2, service: "agent-device-daemon" }); + health.respondWith({ rpcProtocolVersion: 3, service: "agent-device-daemon" }); await filesystem.mkdirp(home); await filesystem.mkdirp("/usr/local/bin"); await filesystem.mkdirp(`${packageRoot}/bin`); @@ -106,7 +106,7 @@ async function started(harness: Awaited>): Promise { it("reports running with the supervisor's base URL, token, generation and the ceiling", async () => { - const harness = await arrange("0.21.28"); + const harness = await arrange("0.21.40"); await started(harness); const availability = harness.supervisor.availability(); if (availability.state !== "running") throw new Error(`got ${availability.state}`); @@ -122,7 +122,7 @@ describe("the agent-device upstream adapter over the supervisor", () => { }); it("reports unavailable with starting while the supervisor starts", async () => { - const harness = await arrange("0.21.28"); + const harness = await arrange("0.21.40"); const starting = harness.supervisor.start(); starting.catch(() => undefined); diff --git a/src/agent-device/shared/compatibility.ts b/src/agent-device/shared/compatibility.ts index 3d7657ce0..2d0e59f05 100644 --- a/src/agent-device/shared/compatibility.ts +++ b/src/agent-device/shared/compatibility.ts @@ -1,6 +1,6 @@ -// why: 0.21.28 is the first agent-device release with every change the edge relies on (tenant authenticate, caller-chosen lease ids, allocate by spec, the iOS device set, session end with the lease, release after close, the lease on uploads). -export const MIN_AGENT_DEVICE_VERSION = "0.21.28"; -export const AGENT_DEVICE_RPC_PROTOCOL_VERSION = 2; +// why: 0.21.40 is the first agent-device release on RPC protocol 3, and a client refuses a daemon or proxy on any other protocol; 0.21.28 brought what the edge relies on (tenant authenticate, caller-chosen lease ids, allocate by spec, the iOS device set, session end with the lease, release after close, the lease on uploads). +export const MIN_AGENT_DEVICE_VERSION = "0.21.40"; +export const AGENT_DEVICE_RPC_PROTOCOL_VERSION = 3; export const MIN_NODE_VERSION = "22.12.0"; interface ParsedVersion { diff --git a/src/agent-device/testing.ts b/src/agent-device/testing.ts index 5bf05fd45..f2af57224 100644 --- a/src/agent-device/testing.ts +++ b/src/agent-device/testing.ts @@ -440,13 +440,14 @@ export class FakeAgentDevice implements AgentDeviceUpstream { const tenantHeader = request.headers.get("x-agent-device-tenant") ?? undefined; if (url.pathname === "/health") { this.requests.push({ method: request.method, path: url.pathname, tenant: tenantHeader }); - return Response.json({ ok: true, rpcProtocolVersion: 2, service: "agent-device-daemon" }); + return Response.json({ ok: true, rpcProtocolVersion: 3, service: "agent-device-daemon" }); } if (url.pathname === "/upload/preflight") { this.preflightHeaders.push(Object.fromEntries(request.headers)); this.requests.push({ method: request.method, path: url.pathname, tenant: tenantHeader }); return Response.json({ ok: true, + uploadId: "ticket-1", upload: { headers: {}, url: `${this.baseUrl}/upload/direct/ticket-1` }, }); } diff --git a/src/daemon/main-agent-device.test.ts b/src/daemon/main-agent-device.test.ts index 9f4d9b6c9..3cd8682c0 100644 --- a/src/daemon/main-agent-device.test.ts +++ b/src/daemon/main-agent-device.test.ts @@ -94,7 +94,7 @@ describe("startDaemon with the agent-device edge", () => { function versionAndDaemon(directory: string, role?: "phones"): ScriptedProcessRunner { const version = { match: { args: [realCli, "--version"], command: process.execPath }, - result: { code: 0, stderr: "", stdout: "0.21.28\n" }, + result: { code: 0, stderr: "", stdout: "0.21.40\n" }, }; const daemon = (marker: readonly string[]) => ({ hangs: true, @@ -204,12 +204,12 @@ describe("startDaemon with the agent-device edge", () => { it("stops both agent-device daemons when the worker stops, the phone daemon and the simulator daemon each by its own pid", async () => { const setup = await setUp({ capabilities: { "agent-device": { command, enabled: true } } }); const health = new FakeAgentDeviceHealth(); - health.respondWith({ rpcProtocolVersion: 2, service: "agent-device-daemon" }); + health.respondWith({ rpcProtocolVersion: 3, service: "agent-device-daemon" }); const tcpProbe = new FakeTcpProbe(); const processSupervisor = new KillingSupervisor(); const version = { match: { args: [realCli, "--version"], command: process.execPath }, - result: { code: 0, stderr: "", stdout: "0.21.28\n" }, + result: { code: 0, stderr: "", stdout: "0.21.40\n" }, }; const daemonAt = (stateDirName: string, pid: number, port: number, marker: string[]) => ({ hangs: true, @@ -543,7 +543,7 @@ describe("startDaemon with the agent-device edge", () => { .toMatchObject({ kind: "module-unavailable", module: "agent-device", - message: expect.stringContaining("found 0.20.3, need 0.21.28 or later"), + message: expect.stringContaining("found 0.20.3, need 0.21.40 or later"), remedy: expect.any(String), }); await expect(daemon.dispatch("lease.request", lease, agent)).resolves.toMatchObject({ @@ -565,7 +565,7 @@ describe("startDaemon with the agent-device edge", () => { ): ScriptedProcessRunner { if (simulator === "missing") return new ScriptedProcessRunner([]); return new ScriptedProcessRunner([ - version(simulator === "running" ? "0.21.28\n" : simulator), + version(simulator === "running" ? "0.21.40\n" : simulator), { hangs: true, match: { args: [entry, `--simlock-home=${setup.directory}`], command: process.execPath }, @@ -577,7 +577,7 @@ describe("startDaemon with the agent-device edge", () => { tcpProbe.startListening(4310); }, }, - version(phones === undefined || phones === "unstartable" ? "0.21.28\n" : phones), + version(phones === undefined || phones === "unstartable" ? "0.21.40\n" : phones), ]); } @@ -637,7 +637,7 @@ describe("startDaemon with the agent-device edge", () => { }, }); const health = new FakeAgentDeviceHealth(); - health.respondWith({ rpcProtocolVersion: 2, service: "agent-device-daemon" }); + health.respondWith({ rpcProtocolVersion: 3, service: "agent-device-daemon" }); const tcpProbe = new FakeTcpProbe(); const runner = scriptedDaemons(setup, tcpProbe, simulator, phones); const { clock, daemon } = await startEdge(setup, { diff --git a/website/src/content/docs/docs/using-devices/agent-device.mdx b/website/src/content/docs/docs/using-devices/agent-device.mdx index 0a66425b4..778da8e96 100644 --- a/website/src/content/docs/docs/using-devices/agent-device.mdx +++ b/website/src/content/docs/docs/using-devices/agent-device.mdx @@ -23,11 +23,13 @@ agent-device close | Where | Needs | | --- | --- | -| Each worker | agent-device 0.21.28 or later, runnable by the user who runs the Simlock daemon. Simlock never installs or updates it. | +| Each worker | agent-device 0.21.40 or later, runnable by the user who runs the Simlock daemon. Simlock never installs or updates it. | | Each worker | HTTP on. A standalone worker has it on by default. | -| Each agent's machine | agent-device 0.21.28 or later. | +| Each agent's machine | agent-device 0.21.40 or later. | | Each agent | Its own agent token, unless it runs on the worker's own Mac ([On the same Mac](#on-the-same-mac)). | +agent-device 0.21.40 moved its daemon to RPC protocol 3, and a client refuses a farm on another protocol. Update the workers and every agent's machine together. In a gateway fleet, update the gateway and every worker (Simlock and agent-device) together too: a client may read `/health` from one worker and get its lease on another. + For agents on other machines, the worker or gateway must be reachable over HTTPS. Simlock does not serve HTTPS itself; see [Turn on the web console and HTTP](/simlock/docs/worker/console-and-http). ## Turn it on (operator) @@ -76,7 +78,7 @@ For agents on other machines, the worker or gateway must be reachable over HTTPS **Check:** `simlock worker list` ends each worker's line with `agent-device available`. `agent-device off` or `agent-device unavailable:` with a reason means it does not work there; `simlock doctor` says how to fix it: ```text -agent-device fail found 0.20.3, need 0.21.28 or later; install agent-device 0.21.28 or later, then restart the daemon (`simlock daemon stop`, then `simlock daemon start`) +agent-device fail found 0.20.3, need 0.21.40 or later; install agent-device 0.21.40 or later, then restart the daemon (`simlock daemon stop`, then `simlock daemon start`) ``` If agent-device is missing or too old, Simlock keeps running without it, and every agent-device request answers `agent-device is not available on this simlock:` with the reason. Restart the daemon after you fix it. @@ -236,6 +238,7 @@ Sign-in errors (`UNAUTHENTICATED`, `FORBIDDEN`) and errors from outside Simlock, | `refused: agent-device through simlock needs an agent token` | You used an operator token. Create an agent token. | | `refused: this agent-device is too old for simlock; upgrade it` | Update agent-device on the agent's machine. | | `refused: this agent-device is too old to use through a gateway; update it` | Update agent-device on the agent's machine. | +| `Remote daemon RPC protocol is incompatible` | The agent's agent-device and the farm's speak different RPC protocols. Use agent-device 0.21.40 or later on the agent's machine; if the farm is older, ask the operator to update Simlock and the workers' agent-device. | | `refused: name --platform ios or android` | Pass `--platform` to `open`. | | `refused: boot names no lease; open a device first` | Run `open` before `boot`. | | `refused: this lease has ended; open a device` | Run `open` again. | diff --git a/website/src/content/docs/docs/using-devices/ci.mdx b/website/src/content/docs/docs/using-devices/ci.mdx index 8e7d33cf0..c01039096 100644 --- a/website/src/content/docs/docs/using-devices/ci.mdx +++ b/website/src/content/docs/docs/using-devices/ci.mdx @@ -37,7 +37,7 @@ This page uses the [`e2e` runner](https://www.npmjs.com/package/@e2e-dev/mobile) npm install --save-dev @simlock/e2e agent-device simlock ``` - `agent-device` 0.21.37 or newer is a peer dependency: the provider uses your copy of its client. `@simlock/e2e` has the version number of the Simlock release it was tested with; use the one that matches your farm. `simlock` is for the cleanup step. + `agent-device` 0.21.40 or newer is a peer dependency: the provider uses your copy of its client. `@simlock/e2e` has the version number of the Simlock release it was tested with; use the one that matches your farm. `simlock` is for the cleanup step. 5. **Configure the runner:**