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/quickstart-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ The provider selects the runtime that owns the navigation loop:
| `anthropic` | Claude Code through `@anthropic-ai/claude-agent-sdk` 0.3.285 and its platform-native package | `ANTHROPIC_API_KEY` |
| `openai` | Codex app-server from `@openai/codex` 0.159.2 and its platform-native package | `OPENAI_API_KEY` |

Both runtimes use Explore's device tools to operate the existing Expo Simulators session through official `agent-device` 0.21.29-nightly.20261018.74. The runtime and native binaries come from the pinned tools installation. CI does not use the development-only `node_modules/.bin/claude` executable or an interactive subscription login.
Both runtimes use Explore's device tools to operate the existing Expo Simulators session through official `agent-device` 0.21.40. The runtime and native binaries come from the pinned tools installation. CI does not use the development-only `node_modules/.bin/claude` executable or an interactive subscription login.

Create and commit the nonempty English prose file named by `agent.instructions`. The shared setup skill authors it from source and asks for missing test data or environment inputs. Describe how to reach the app's screens, necessary prerequisites, the representative state to use on both revisions, readiness signals, and actions to avoid. This file guides the runtime agent; it is not a list of mandatory YAML steps or a second screen inventory.

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@types/react-dom": "^19.2.4",
"@vitejs/plugin-react": "^4.7.0",
"@xyflow/react": "^12.11.3",
"agent-device": "0.21.29-nightly.20261018.74",
"agent-device": "0.21.40",
"babel-plugin-react-compiler": "^1.0.0",
"eslint": "^10.12.0",
"eslint-plugin-react-hooks": "^7.1.1",
Expand Down
29 changes: 20 additions & 9 deletions src/binary/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createLocalCiAgentSession } from "../capture/agent/session-local.js";
import type { CiAgentProviderName } from "../capture/agent/provider.js";
import { assertReplayFits, createReplaySession, parseReplayPlan, replaySetup, type ReplayPlan } from "./replay.js";
import { CONTROLLER_SESSION, baseEnvironment, isRecord } from "../capture/common.js";
import { controllerData, defaultRunner, openedSimulatorDevice } from "../capture/controller.js";
import { controllerData, controllerFailureReason, defaultRunner, loneBackDismissControl, openedSimulatorDevice, runnerBusyRefusal } from "../capture/controller.js";
import type { CommandRequest, CommandResult } from "../capture/run.js";
import { executeCaptureSetup } from "../capture/setup-actions.js";
import { SIMULATOR_DOTENV_FILE_NAME, SIMULATOR_DOTENV_HEADER, assertSimulatorSessionIdentity, assertSimulatorStopped, readSimulatorDotenvHandoff,
Expand All @@ -29,7 +29,7 @@ import { packageBin } from "../shared/package-paths.js";
import { assertDecodedPng, solidColour } from "../shared/png-evidence.js";
import { CONTRACT, type ExploreMap, type Platform } from "../types.js";
import { assertEmulatorCompatible, extractIosBundle, inspectArchive, type ArchiveKind, type InspectedArchive, readArchiveIcon } from "./archive.js";
import { runBlackBoxExploration, type BlackBoxExplorerResult, type BlackBoxFrame, SYSTEM_DIALOG_PACKAGES } from "./explorer.js";
import { riskOf, runBlackBoxExploration, screenEvidenceKey, type BlackBoxExplorerResult, type BlackBoxFrame, SYSTEM_DIALOG_PACKAGES } from "./explorer.js";

export const DEFAULT_IOS_DEVICE = "iPhone 17 Pro";
export const DEFAULT_BINARY_PROJECT = "expo-explore";
Expand Down Expand Up @@ -502,11 +502,23 @@ export async function exploreConnectedSession(ctx: ConnectedSessionExploration):
const bounds = frameBounds(frame.nodes);
controller(["press", String(Math.round(action.x * bounds.width)), String(Math.round(action.y * bounds.height)), "--level", "full", "--json"], 120_000);
} else if (action.action === "back") {
// Onboarding steps, tabs and sheets have no back control; the platform gesture (iOS edge swipe, Android back) still works.
// On iOS agent-device's in-app back already falls back to the edge swipe, and names a modal's one dismiss
// control when that changed nothing. The Argent bridge sends nothing without a back control; Android's
// system back still works there.
try { controller(["back", "--in-app", "--level", "full", "--json"], 120_000); }
catch (error) {
if (!(error instanceof Error) || !/in-app back control is not available/.test(error.message)) throw error;
controller(["back", "--system", "--level", "full", "--json"], 120_000);
const control = loneBackDismissControl(error);
if (control && riskOf(control.label, allowDestructive ?? []) === "safe") {
// As in source-driven capture, the press counts as back only when the screen changed.
const before = screenEvidenceKey((await observe(false)).nodes);
controller(["press", "--level", "full", "--json", "--", control.selector], 120_000);
await settled();
// A "Discard changes?" confirmation changes the screen too, but leaves it in place.
const after = (await observe(false)).nodes;
if (screenEvidenceKey(after) === before || after.some(node => node.type === "Alert")) throw error;
}
else if (controllerFailureReason(error) === "back_swipe_not_dispatched") controller(["back", "--system", "--level", "full", "--json"], 120_000);
else throw error;
}
}
else if (action.action === "dismiss-keyboard") await dismissKeyboard();
Expand All @@ -516,7 +528,7 @@ export async function exploreConnectedSession(ctx: ConnectedSessionExploration):
};
const dismissKeyboard = async () => {
try { controller(["keyboard", "dismiss", "--level", "full", "--json"], 120_000); return; }
catch (error) { if (!(error instanceof Error) || !/Unable to dismiss the iOS keyboard/.test(error.message)) throw error; }
catch (error) { if (controllerFailureReason(error) !== "keyboard_dismiss_unavailable") throw error; }
// The iOS keyboard has no dismiss key and agent-device never taps the background; its return key (next/done/go) closes it without touching the app.
const nodes = (await observe(false)).nodes;
// In a multi-line editor the return key inserts a newline instead of ending editing.
Expand Down Expand Up @@ -875,8 +887,6 @@ async function easLoggedIn(runner: typeof defaultRunner, environment: NodeJS.Pro
/** Schemes the OS routes to a browser, the store, Settings, or another app: opening one hands the session away from the app under test. */
const SYSTEM_URL_SCHEMES = /^(https?|ftp|file|javascript|data|blob|mailto|tel|telprompt|facetime(-audio)?|sms|mms|imessage|itms(-apps|-services|-beta)?|macappstore|app-settings|prefs|shortcuts|maps|music|videos|photos-redirect|x-apple-[a-z-]+|market|intent|content|android-app|geo|package):$/i;

/** The model may only open app-owned URLs; an https page or a store link would hand the session to another app. */
const RUNNER_BUSY = /still finishing a previous command/i;
const sleepSync = (ms: number): void => { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); };

/**
Expand All @@ -888,12 +898,13 @@ export function retryWhileBusy<T>(run: () => T, pause: (ms: number) => void, bud
for (;;) {
try { return run(); }
catch (error) {
if (!RUNNER_BUSY.test(error instanceof Error ? error.message : String(error)) || clock() - started >= budgetMs) throw error;
if (!runnerBusyRefusal(error) || clock() - started >= budgetMs) throw error;
pause(stepMs);
}
}
}

/** The model may only open app-owned URLs; an https page or a store link would hand the session to another app. */
export function assertAppUrl(url: string, appSchemes: readonly string[] = []): void {
let parsed: URL;
try { parsed = new URL(url); } catch { throw binaryError("AGENT_URL_INVALID", `Not a URL: ${url}`, "Pass a custom-scheme app URL."); }
Expand Down
12 changes: 6 additions & 6 deletions src/capture/argent-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const failure = (code: string, message: string, details?: Record<string, unknown
* agent-device's answer when its pre-flight health check fails, which Explore resends because the command was
* provably never sent (controller.ts remoteDaemonUnavailable). The bridge gives it only on the same proof.
*/
const remoteUnavailable = () => failure("COMMAND_FAILED", "Remote daemon is unavailable");
const remoteUnavailable = () => failure("COMMAND_FAILED", "Remote daemon is unavailable", { reason: "remote_daemon_unavailable", dispatched: "no" });

/** Flags agent-device takes after a command; the bridge needs the platform only from its own context. */
const VALUE_FLAGS = new Set(["--session", "--device", "--platform", "--level", "--udid", "--scope", "--bundle-id", "--serial", "--timeout"]);
Expand Down Expand Up @@ -613,17 +613,17 @@ export async function runBridgeCommand(argv: readonly string[], context: ArgentB
await beforeAction();
if (platform === "android") await call("button", { button: "back" });
else {
// agent-device taps the keyboard's own dismiss control, and fails with this message when there is none, which
// agent-device taps the keyboard's own dismiss control, and refuses with this reason when there is none, which
// callers answer with the return key. Only a key in the keyboard's area counts: an app's "Done" above it is not one.
const key = flatten(current).find(node => KEYBOARD_DISMISS_LABELS.includes(node.label ?? "") && node.frame && node.frame.y >= KEYBOARD_TOP);
if (!key) return failure("COMMAND_FAILED", "Unable to dismiss the iOS keyboard: the keyboard exposes no dismiss control.");
if (!key) return failure("UNSUPPORTED_OPERATION", "Unable to dismiss the keyboard: it exposes no dismiss key.", { reason: "keyboard_dismiss_unavailable", dispatched: "no" });
const size = current.screen ?? await screen();
await tap(...Object.values(centre({ x: key.frame!.x * size.width, y: key.frame!.y * size.height,
width: key.frame!.width * size.width, height: key.frame!.height * size.height }, size)) as [number, number]);
}
await context.sleep(500);
const visible = (await tree()).keyboardVisible === true;
if (visible && platform === "ios") return failure("COMMAND_FAILED", "Unable to dismiss the iOS keyboard: it is still showing after its dismiss key was pressed.");
if (visible && platform === "ios") return failure("COMMAND_FAILED", "Unable to dismiss the keyboard: it is still showing after its dismiss key was pressed.", { reason: "keyboard_dismiss_unavailable" });
return success({ platform, action: "dismiss", wasVisible: true, dismissed: !visible, visible });
}
case "scroll": {
Expand Down Expand Up @@ -666,7 +666,7 @@ export async function runBridgeCommand(argv: readonly string[], context: ArgentB
await tap(button.frame.x + button.frame.width / 2, button.frame.y + button.frame.height / 2);
return success({ action: "back", mode: "in-app" });
}
if (flags["in-app"] === true || platform === "ios") return failure("COMMAND_FAILED", "in-app back control is not available");
if (flags["in-app"] === true || platform === "ios") return failure("COMMAND_FAILED", "in-app back control is not available", { reason: "back_swipe_not_dispatched", dispatched: "no" });
await call("button", { button: "back" });
return success({ action: "back", mode: "system" });
}
Expand Down Expand Up @@ -776,7 +776,7 @@ export async function runBridgeCommand(argv: readonly string[], context: ArgentB
if (error instanceof BridgeFailure) return failure(error.code, error.message);
if (error instanceof ArgentCallError) {
// Never "Remote daemon is unavailable" here: the request may have run, so Explore must not resend it.
return failure(error.sent ? "ARGENT_TOOL_FAILED" : "COMMAND_FAILED", error.sent ? error.message : "Remote daemon is unavailable");
return error.sent ? failure("ARGENT_TOOL_FAILED", error.message) : remoteUnavailable();
}
return failure("ARGENT_BRIDGE_FAILED", error instanceof Error ? error.message : String(error));
}
Expand Down
Loading