UNPKG

agent-device

Version:

Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.

26 lines (17 loc) • 10.7 kB
import{v as e}from"./sdk-contracts.js";import{O as t,T as n,k as r,l as i,o as a}from"./src3.js";const o={plugins:{text:{summary:`Manage installed provider plugins`,description:`Install, list, update, or remove npm provider plugins in AGENT_DEVICE_HOME (default ~/.agent-device). Changes take effect after restarting the local daemon. list works offline and, when a daemon is running for --state-dir, also reports the providers it registered. Use --json for structured results.`},usageOverride:`plugins list [--state-dir <path>]|add <package[@version]>|update <package>|remove <package>`,listUsageOverride:`plugins`,positionalArgs:[`list|add|update|remove`,`package?`],flagsByAction:{list:[`stateDir`],add:[],update:[],remove:[]},supportedFlags:[`stateDir`]},cdp:{text:{summary:`Inspect CDP targets, JS heap, and leaks`,description:`Run CDP commands for React Native diagnostics, JS heap usage, heap snapshots, and leak analysis`},usageOverride:`cdp [...args]`,listUsageOverride:`cdp`,positionalArgs:[`args?`],allowsExtraPositionals:!0,supportedFlags:n},auth:{text:{summary:`Manage cloud login state`,description:`Manage cloud login state used by remote daemon and cloud device workflows.`},usageOverride:`auth status|login|logout`,listUsageOverride:`auth`,positionalArgs:[`status|login|logout`],supportedFlags:[`remoteConfig`,`stateDir`]},daemon:{text:{summary:`Stop a local daemon or show the providers it registered`,description:`stop stops a local daemon after verifying its PID/start-time identity. Use --clean to remove retained Apple runner processes and leases owned by that daemon. status reads the daemon record without contacting the daemon and lists every provider plugin it registered, built in or installed, with the reason any plugin failed to register. Use --json for structured results.`},usageOverride:`daemon stop [--clean] [--state-dir <path>] | daemon status [--state-dir <path>]`,usageFlags:[],listUsageOverride:`daemon stop|status`,positionalArgs:[`stop|status`],allowedFlags:[`clean`],flagsByAction:{stop:[`clean`],status:[]},supportedFlags:[`stateDir`]},device:{text:{summary:`Inspect and recover enforced local device ownership without a daemon`,description:`Inspect enforced host-local device ownership claims without starting or contacting a daemon; status --stale only inspects proven-stale claims. release --stale settles a provably dead owner through exact-owner resource reconciliation and clears its claim last — live and uncertain owners always fail closed. Automatic reclamation still occurs during open and daemon startup.`},usageOverride:`device status|release [--platform <platform>] [--udid <udid>] [--serial <serial>]`,listUsageOverride:`device status`,positionalArgs:[`status|release`],allowedFlags:[`stale`],supportedFlags:[`platform`,`device`,`udid`,`serial`],explicitOnlyFlags:[`platform`,`device`,`udid`,`serial`]},connect:{text:{summary:`Configure remote or provider state`,description:`Configure remote access without allocating a device. Direct providers validate credentials/resources before saving state and print the exact device/app preparation needed before open. AGENT_DEVICE_CLOUD_BASE_URL is the bridge/control-plane API origin; use AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_... for CI/service-token automation.`},usageOverride:`connect [provider] [--remote-config <path>] [--daemon-base-url <url>] [--tenant <id>] [--run-id <id>] [--lease-id <id>] [--lease-backend <backend>] [--force] [--no-login]`,usageFlags:[],listUsageOverride:`connect`,positionalArgs:[`provider?`],allowedFlags:[`remoteConfig`,`daemonBaseUrl`,`tenant`,`runId`,`leaseId`,`leaseBackend`,`providerApp`,`providerOsVersion`,`providerDeviceType`,`providerProject`,`providerBuild`,`providerSessionName`,`providerDeviceOrientation`,`providerGeoLocation`,`providerTimezone`,`providerAppiumVersion`,`providerLanguage`,`providerLocale`,`providerNetworkProfile`,`providerCustomNetwork`,`providerNoResignApp`,`providerNetworkLogs`,`providerNetworkHosts`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,...t,`force`,`noLogin`],supportedFlags:[`stateDir`,`daemonAuthToken`,`session`,`platform`,`device`,...r,`launchUrl`]},connection:{text:{summary:`Inspect the saved remote connection`,description:`Inspect active remote connection state`},usageOverride:`connection status`,listUsageOverride:`connection`,positionalArgs:[`status`],supportedFlags:[`remoteConfig`,`stateDir`,`session`]},disconnect:{text:{summary:`Clear remote connection state and release leases`,description:`Disconnect remote daemon state, stop owned Metro companion, and release lease`},listUsageOverride:`disconnect`,allowedFlags:[`shutdown`],supportedFlags:[`remoteConfig`,`stateDir`,`session`]},mcp:{text:{summary:`Start MCP server`,description:`Start the official stdio MCP server. It exposes command tools backed by the agent-device client. Tool results are compact text by default; a non-default AGENT_DEVICE_RESPONSE_LEVEL or AGENT_DEVICE_COST returns JSON text. With --structured, tools also advertise output schemas and return structuredContent, including errors, for clients that read results as data. It accepts no other flags or arguments besides --structured, --help, and --version; configure it with AGENT_DEVICE_* environment variables or AGENT_DEVICE_CONFIG.`},allowedFlags:[`mcpStructured`]},proxy:{text:{summary:`Expose a local daemon through an HTTP tunnel`,description:`Expose the local daemon HTTP contract through a tunnel-friendly reverse proxy. Run this on the host that has access to simulators/devices, expose the printed local proxy URL through a tunnel, then point another machine at the tunnel URL with connect proxy. The proxy starts or reuses a local HTTP daemon, accepts /health, /rpc, /upload and resumable /upload/* routes, and /artifacts plus /artifacts/*, and also accepts the same routes under /agent-device/*. Health is unauthenticated for reachability probes. Other routes require the generated bearer token printed at startup, or the explicit --daemon-auth-token value when provided. The proxy rewrites authorized client requests to the upstream daemon token instead of exposing the local daemon token. For a TLS-terminated tunnel, set --public-origin to the public HTTP(S) origin, for example --public-origin https://public.example:8443. Forwarded and X-Forwarded-* headers do not select upload ticket origins. For an ephemeral tunnel, obtain its public name first, then configure and restart the proxy. Without a fixed origin, Node uses the actual socket scheme and validated Host. Use the /agent-device base path when connecting through cloudflared, ngrok, or another shared origin. Treat the bearer token as a secret; anyone with it can control the proxied daemon. This direct proxy flow does not use agent-device auth. Remote captures write generated artifacts on the daemon. Screenshot, recording, performance, and trace paths select downloads on the client; they never select host files. Direct RPC callers download returned artifact IDs through /artifacts/<id>. Remote requests ignore client cwd and refuse host tooling paths and --launch-console. A fresh open --save-script=<path> arms recording; after each recorded action the client refreshes that caller file, and close writes the final script there. Remote session save-script, close/replay --save-script, and --save-script in batch steps remain refused. Examples: cloudflared tunnel --url http://127.0.0.1:4310 agent-device proxy --port 4310 --public-origin https://example.trycloudflare.com agent-device connect proxy --daemon-base-url https://example.trycloudflare.com/agent-device --daemon-auth-token <token>`},listUsageOverride:`proxy`,allowedFlags:[`proxyHost`,`proxyPort`,`publicOrigin`,`daemonAuthToken`,`stateDir`]},takeover:{text:{summary:`Pause agent interactions while a person controls a device`,description:`Temporarily hand control of the active remote lease device to a person. The foreground command pauses state-changing agent commands, renews the hold until Ctrl+C, and then releases it. Read-only diagnostics remain available. Uses the active connection and --session, with normal tenant and lease admission. status lists holds on that device; release removes a hold owned by the admitted lease. The host-only /admin/human-control/holds API uses the separate local daemon token. Holds do not survive daemon restart. Local takeover without a remote device lease is not supported.`},usageOverride:`takeover [status | release <hold-id>] [--session <name>]`,listUsageOverride:`takeover [status|release]`,positionalArgs:[`status|release?`,`hold-id?`],supportedFlags:[`stateDir`,`session`,`remoteConfig`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`tenant`,`runId`,`leaseId`,`leaseBackend`,`sessionIsolation`]},"react-devtools":{text:{summary:`React Native components, props/state/hooks, and render profiling`,description:`Inspect React Native components and profile their renders through the Metro dev server`},usageOverride:`react-devtools tree [@ref|Name]|find <Name>|inspect <@ref|Name>|errors|profile start|stop|report [Component]|commit [N]`,listUsageOverride:`react-devtools`,positionalArgs:[`args?`],allowsExtraPositionals:!0,supportedFlags:n},web:{text:{summary:`Manage web automation backend`,description:`Install and inspect the managed web automation backend used by --platform web. First-run flow: agent-device web setup agent-device open "https://example.com" --platform web agent-device snapshot -i --platform web agent-device close --platform web Runtime web commands do not install the backend implicitly. If the managed backend is missing, run agent-device web setup. The backend is resolved only from the managed install in the effective agent-device state dir. Use web setup to install or reuse the pinned backend. Use web doctor after setup to verify browser backend health.`},usageOverride:`web setup | web doctor`,listUsageOverride:`web setup|doctor`,positionalArgs:[`setup|doctor`],supportedFlags:[`stateDir`]}},s=i();function c(e){return Object.hasOwn(o,e)?o[e]:void 0}function l(e){return Object.hasOwn(s,e)?s[e]:void 0}const u=new Map(a().map(e=>[e.name,{supportedFlags:n}]));function d(e){if(e)return m(e)}function f(e){let t=m(e);if(!t)throw Error(`Missing command schema for ${e}`);return t}function p(t,n,r){let i=d(t);if(!t||!i||i.allowsExtraPositionals)return;let a=i.positionalArgs?.length??0;if(n.length<=a)return;let o=r?`${r} ${t}`:t;throw new e(`INVALID_ARGS`,`${o} accepts at most ${a} positional argument(s), received ${n.length}: ${n.join(` `)}`)}function m(e){let t=c(e);if(t)return t;let n=u.get(e),r=l(e);if(!(!n||!r))return{...n,...r}}export{f as n,d as r,p as t};