Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/internal/agent-rules/toolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@<version>`, or a checkout at tag `v<version>` 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` |
Expand Down
4 changes: 2 additions & 2 deletions e2e/slow-agent-device.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-"));
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 19 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/agent-device/edge-release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("<html>bad gateway</html>");
Expand Down
21 changes: 17 additions & 4 deletions src/agent-device/edge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -108,21 +109,22 @@ 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" },
});
});

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: <reason>`, 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");
Expand All @@ -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 });
Expand Down Expand Up @@ -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: "{}" });
Expand All @@ -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 <id> is not one of yours`, and a malformed header is refused `the x-agent-device-lease-id header is not a lease id`", async () => {
Expand Down
9 changes: 8 additions & 1 deletion src/agent-device/gateway-front-lease-header.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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/<id>` and a diagnostics `GET`, each with the header, reach the lease's worker", async () => {
Expand Down
14 changes: 7 additions & 7 deletions src/agent-device/host/agent-device-supervisor-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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}`);
});
Expand All @@ -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);
Expand Down Expand Up @@ -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" },
Expand Down
12 changes: 6 additions & 6 deletions src/agent-device/host/agent-device-supervisor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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([]);
});
Expand Down Expand Up @@ -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`)] });
Expand All @@ -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()] });
Expand Down
Loading
Loading