AI SDK
Use agent-device/ai-sdk to give an AI SDK agent a typed set of tools for navigating and inspecting an app. The tools run in-process, share one named session, and by default cover the core loop of reading the screen and acting on it.
Make an iOS simulator or device available to agent-device, then configure an AI SDK model. String model IDs use AI Gateway by default:
Alternatively, pass a model from your configured AI SDK provider. See the AI SDK guide to choosing a provider.
Set AI_MODEL to a model available through your configured AI SDK provider. The agent decides which device tools to call to complete the prompt. The returned client targets the same session; close it in finally so the device is released even if generation fails.
Choose tools and approvals
set: 'core' is the default. It exposes the perceive-and-act loop: open, close, snapshot, click, press, fill, type, get, is, find, wait, back, scroll, swipe, alert, and screenshot.
- Pass
set: 'all'when the agent also needs device-management or observability commands. - Pass
approval: { close: 'user-approval' }to require user approval before a command runs.createAgentDeviceTools()returns the map astoolApproval, ready to pass toToolLoopAgent.
Use the Node.js API when your application needs deterministic setup or other direct device control outside the agent loop. See the AI SDK reference for ToolLoopAgent.
