Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Works with Claude Code, Codex, Cursor, Windsurf, Cline, Goose, and any agent tha
Install the CLI and check setup. It requires Node.js 22.12 or newer; web automation requires Node.js 24 or newer. See [Installation](https://agent-device.dev/docs/installation) for target requirements.

```bash
npm install -g agent-device@latest
npm install -g agent-device@nightly-0.22
agent-device doctor
agent-device help workflow
```
Expand Down Expand Up @@ -156,7 +156,7 @@ The same session and evidence model works at every step: the agent explores the
| --- | --- | --- |
| Local | Trying commands and debugging apps on simulators, emulators, physical devices, macOS, and Linux. | Follow the Quick Start. |
| CI/CD | Automated pull request and merge validation with replay scripts and captured artifacts. | Try the [EAS workflow template](https://github.com/callstackincubator/eas-agent-device/blob/main/.eas/workflows/agent-qa-mobile.yml). |
| Cloud / remote | Linux runners, managed devices, and remote jobs. | Set up a [remote proxy](https://agent-device.dev/docs/remote-proxy), connect a [device cloud](https://agent-device.dev/docs/device-clouds) (BrowserStack and TestMu AI through `agent-device plugins add`, AWS Device Farm after its plugin is published, or Limrun), or [contact Callstack](mailto:hello@callstack.com) for team QA. |
| Cloud / remote | Linux runners, managed devices, and remote jobs. | Set up a [remote proxy](https://agent-device.dev/docs/remote-proxy), connect a [device cloud](https://agent-device.dev/docs/device-clouds) (BrowserStack, AWS Device Farm, and TestMu AI through `agent-device plugins add`, or Limrun), or [contact Callstack](mailto:hello@callstack.com) for team QA. |

## How it works

Expand Down
6 changes: 4 additions & 2 deletions packages/provider-aws-device-farm/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# AWS Device Farm for agent-device

This plugin is private and not yet published. After publication, install it on the daemon host:
Install the plugin on the daemon host.

```sh
agent-device plugins add @agent-device/aws-device-farm
agent-device plugins add @agent-device/aws-device-farm@nightly-0.22
```

Run `agent-device help remote` to see the install command for your CLI.

Configure AWS CLI credentials and connect using your Device Farm project and device ARNs. See the [AWS Device Farm guide](https://agent-device.dev/docs/aws-device-farm).
8 changes: 5 additions & 3 deletions packages/provider-browserstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
Use BrowserStack App Automate Android and iOS devices with [agent-device](https://agent-device.dev).
You need a BrowserStack account with App Automate access.

Install the plugin on the daemon host, then connect with your BrowserStack credentials.

```sh
npm install -g agent-device
agent-device plugins add @agent-device/browserstack
agent-device plugins add @agent-device/browserstack@nightly-0.22
export BROWSERSTACK_USERNAME=your-username
export BROWSERSTACK_ACCESS_KEY=your-access-key
agent-device connect browserstack --session checkout-android --platform android --device "Google Pixel 8" --provider-os-version 14.0 --provider-app bs://app-id
```

Run `agent-device help remote` to see the install command for your CLI.

See the [BrowserStack guide](https://agent-device.dev/docs/browserstack) for setup and supported operations.
To update the plugin, run `agent-device plugins update @agent-device/browserstack`.

After you add or update the plugin, close your sessions and run `agent-device daemon stop --state-dir <path>` for your daemon before reconnecting.

Expand Down
90 changes: 88 additions & 2 deletions src/cli/commands/connection-plugin-guidance.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { test } from 'vitest';
import { afterEach, test, vi } from 'vitest';
import { pluginHome, selectV2Plugin, v2RegistrationSource } from '@agent-device/test-kit';
import { readVersion } from '@agent-device/host-kit/version';
import { runCliCapture } from '../../__tests__/cli-capture.ts';
import { usageForCommand } from '../parser/args.ts';

vi.mock('@agent-device/host-kit/version', async (importOriginal) => {
const original = await importOriginal<typeof import('@agent-device/host-kit/version')>();
return { ...original, readVersion: vi.fn(original.readVersion) };
});

afterEach(() => {
// Restores the real reader this checkout's version reports, so no case hands its channel to
// the next one.
vi.mocked(readVersion).mockReset();
});

// The release `scripts/release-version.mjs` stamps on the 0.22 source branch. Its provider plugins
// publish at the same version, and their `latest` tag stays the staged placeholder.
const NIGHTLY_0_22 = '0.22.0-nightly-0-22.20261118.187';

test('connect names a missing provider plugin and returns installation guidance before dispatch', async () => {
const { home, env } = pluginHome();
Expand All @@ -27,6 +44,7 @@ test('connect names a missing provider plugin and returns installation guidance
});

test('connect browserstack without its plugin names the package, even with credentials set', async () => {
vi.mocked(readVersion).mockReturnValue('0.22.0-dev');
const { home, env } = pluginHome();
const result = await runCliCapture(
['connect', 'browserstack', '--platform', 'android', '--session', 'checkout', '--json'],
Expand All @@ -44,7 +62,7 @@ test('connect browserstack without its plugin names the package, even with crede
reason: 'plugin-not-installed',
provider: 'browserstack',
package: '@agent-device/browserstack',
installCommand: 'agent-device plugins add @agent-device/browserstack',
installCommand: 'agent-device plugins add @agent-device/browserstack@nightly-0.22',
});
assert.match(error.hint, /agent-device plugins add @agent-device\/browserstack/);
});
Expand Down Expand Up @@ -113,6 +131,74 @@ test('connect does not call a selected plugin missing when it has no connection
assert.equal(JSON.parse(result.stdout).error.details.reason, 'plugin-unavailable');
});

// A channel plugin's `latest` tag is the staged placeholder, so an unversioned selector installs a
// package that exports no factory and the plugin manager refuses it as `incompatible_plugin`. The
// guidance has to name the release built with the running core.
test('a 0.22 nightly core prescribes the matching channel plugin release', async () => {
vi.mocked(readVersion).mockReturnValue(NIGHTLY_0_22);
const { home, env } = pluginHome();
const result = await runCliCapture(
['connect', 'browserstack', '--platform', 'android', '--session', 'checkout', '--json'],
{ cwd: home, env, stateDirPrefix: 'connect-nightly-browserstack-' },
);
assert.equal(result.code, 1);
assert.deepEqual(result.calls, []);
const { error } = JSON.parse(result.stdout);
assert.deepEqual(error.details, {
reason: 'plugin-not-installed',
provider: 'browserstack',
package: '@agent-device/browserstack',
installCommand: `agent-device plugins add @agent-device/browserstack@${NIGHTLY_0_22}`,
});
assert.match(error.hint, new RegExp(`plugins add @agent-device/browserstack@${NIGHTLY_0_22}`));
assert.match(error.hint, /If a local daemon is already running/);
const help = await usageForCommand('remote');
assert.ok(help?.includes(`${error.details.installCommand}\n`));
});

test('a main-channel 0.22 nightly repairs a failed BrowserStack selection with the matching release', async () => {
const version = '0.22.0-nightly.20261118.186';
vi.mocked(readVersion).mockReturnValue(version);
const { home, env } = pluginHome();
selectV2Plugin(home, '@agent-device/browserstack', 'throw new Error("Plugin failed to load.");');
const result = await runCliCapture(
['connect', 'browserstack', '--platform', 'android', '--session', 'checkout', '--json'],
{ cwd: home, env, stateDirPrefix: 'connect-nightly-broken-browserstack-' },
);
assert.equal(result.code, 1);
assert.deepEqual(result.calls, []);
const { error } = JSON.parse(result.stdout);
assert.equal(error.details.reason, 'plugin-unavailable');
assert.ok(error.hint.includes(`plugins add @agent-device/browserstack@${version}`));
});

test('a stable core prescribes the plain package for the same plugin', async () => {
vi.mocked(readVersion).mockReturnValue('0.22.0');
const { home, env } = pluginHome();
const result = await runCliCapture(
['connect', 'browserstack', '--platform', 'android', '--session', 'checkout', '--json'],
{ cwd: home, env, stateDirPrefix: 'connect-stable-browserstack-' },
);
assert.equal(result.code, 1);
const { error } = JSON.parse(result.stdout);
assert.equal(error.details.installCommand, 'agent-device plugins add @agent-device/browserstack');
const help = await usageForCommand('remote');
assert.ok(help?.includes(`${error.details.installCommand}\n`));
});

test('a 0.22 nightly core still prescribes the plain package for a full-channel plugin', async () => {
vi.mocked(readVersion).mockReturnValue(NIGHTLY_0_22);
const { home, env } = pluginHome();
const result = await runCliCapture(
['connect', 'testmu', '--platform', 'android', '--session', 'checkout', '--json'],
{ cwd: home, env, stateDirPrefix: 'connect-nightly-testmu-' },
);
assert.equal(result.code, 1);
assert.deepEqual(result.calls, []);
const { error } = JSON.parse(result.stdout);
assert.equal(error.details.installCommand, 'agent-device plugins add @agent-device/testmu');
});

test('connect reports an unreadable plugin selection instead of prescribing a new installation', async () => {
const { home, env } = pluginHome();
fs.writeFileSync(path.join(home, 'config.json'), JSON.stringify({ plugins: [] }));
Expand Down
12 changes: 8 additions & 4 deletions src/cli/connection/provider-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
primePluginConnections,
} from '@agent-device/plugins/connection';
import { AppError } from '@agent-device/kernel/errors';
import { getProviderPluginDeclaration } from '../../commands/provider-plugin-catalog.ts';
import {
getProviderPluginDeclaration,
providerPluginInstallCommand,
providerPluginRepairCommand,
} from '../../commands/provider-plugin-catalog.ts';
import {
BUILTIN_CONNECT_PROVIDER_IDS,
BUILTIN_PROVIDER_IDS,
Expand Down Expand Up @@ -87,10 +91,10 @@ export function unavailableConnectPluginError(
provider,
package: declaration.package,
...(failures.length > 0 ? { failedPlugins: failures } : {}),
hint: `Run agent-device plugins list --json to inspect the plugin, fix its configuration or run agent-device plugins update ${declaration.package}, then retry your original command.`,
hint: `Run agent-device plugins list --json to inspect the plugin, fix its configuration or run ${providerPluginRepairCommand(declaration)}, then retry your original command.`,
});
}
const installCommand = `agent-device plugins add ${declaration.package}`;
const installCommand = providerPluginInstallCommand(declaration);
return new AppError(
'UNSUPPORTED_OPERATION',
`${declaration.label} requires the ${declaration.package} plugin.`,
Expand All @@ -99,7 +103,7 @@ export function unavailableConnectPluginError(
provider,
package: declaration.package,
installCommand,
hint: `${declaration.unpublished ? 'This plugin is private and not yet published. After publication, install' : 'Install'}:\n ${installCommand}\nThen retry your original command. If a local daemon is already running, close its sessions and run agent-device daemon stop with the same --state-dir before retrying.`,
hint: `Install:\n ${installCommand}\nThen retry your original command. If a local daemon is already running, close its sessions and run agent-device daemon stop with the same --state-dir before retrying.`,
},
);
}
Expand Down
68 changes: 68 additions & 0 deletions src/commands/provider-plugin-catalog.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import assert from 'node:assert/strict';
import { test } from 'vitest';
import {
getProviderPluginDeclaration,
providerPluginHelp,
providerPluginInstallCommand,
} from './provider-plugin-catalog.ts';

const NIGHTLY_0_22 = '0.22.0-nightly-0-22.20261118.187';
const MAIN_NIGHTLY_0_22 = '0.22.0-nightly.20261118.186';

function declaration(provider: string) {
const found = getProviderPluginDeclaration(provider);
assert.ok(found, `Expected ${provider} in the provider plugin catalog`);
return found;
}

test.each([NIGHTLY_0_22, MAIN_NIGHTLY_0_22])(
'0.22 nightly core %s names the plugin release built with it',
(coreVersion) => {
for (const provider of ['browserstack', 'aws-device-farm']) {
assert.equal(
providerPluginInstallCommand(declaration(provider), coreVersion),
`agent-device plugins add @agent-device/${provider}@${coreVersion}`,
);
}
},
);

test('a 0.22 source checkout names the nightly tag', () => {
assert.equal(
providerPluginInstallCommand(declaration('browserstack'), '0.22.0-dev'),
'agent-device plugins add @agent-device/browserstack@nightly-0.22',
);
});

test('a core outside the 0.22 nightlies keeps the plain package selector', () => {
for (const coreVersion of ['0.21.40-nightly.20261118.186', '0.22.0', '0.0.0']) {
assert.equal(
providerPluginInstallCommand(declaration('aws-device-farm'), coreVersion),
'agent-device plugins add @agent-device/aws-device-farm',
`core ${coreVersion} must not name a release it cannot match`,
);
}
});

test('a plugin that ships every release ignores the channel of the core', () => {
for (const provider of ['testmu', 'revyl', 'webos', 'tizen']) {
assert.equal(
providerPluginInstallCommand(declaration(provider), NIGHTLY_0_22),
`agent-device plugins add @agent-device/${provider}`,
);
assert.equal(
providerPluginInstallCommand(declaration(provider), '0.21.39'),
`agent-device plugins add @agent-device/${provider}`,
);
}
});

test('help gives nightly and stable users the same plugin selectors as recovery', () => {
const nightly = providerPluginHelp(NIGHTLY_0_22);
const stable = providerPluginHelp('0.22.0');
for (const provider of ['browserstack', 'aws-device-farm']) {
assert.ok(nightly.includes(`connect ${provider}; @agent-device/${provider}@${NIGHTLY_0_22})`));
assert.ok(stable.includes(`connect ${provider}; @agent-device/${provider})`));
}
assert.match(nightly, /TestMu AI \(connect testmu; @agent-device\/testmu\)/);
});
67 changes: 56 additions & 11 deletions src/commands/provider-plugin-catalog.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import { readVersion } from '@agent-device/host-kit/version';

type ProviderPluginDeclaration = Readonly<{
provider: string;
package: string;
label: string;
unpublished?: boolean;
// A 0.22.x-dev version carries no source branch. Use the 0.22 branch's nightly tag
// as the shared default for development builds, including main checkouts.
nightlyTag?: 'nightly-0.22';
}>;

export const AWS_DEVICE_FARM: ProviderPluginDeclaration = {
provider: 'aws-device-farm',
package: '@agent-device/aws-device-farm',
label: 'AWS Device Farm',
nightlyTag: 'nightly-0.22',
};

export const BROWSERSTACK: ProviderPluginDeclaration = {
provider: 'browserstack',
package: '@agent-device/browserstack',
label: 'BrowserStack',
nightlyTag: 'nightly-0.22',
};

const PROVIDER_PLUGIN_CATALOG: readonly ProviderPluginDeclaration[] = [
{
provider: 'aws-device-farm',
package: '@agent-device/aws-device-farm',
label: 'AWS Device Farm',
unpublished: true,
},
{ provider: 'browserstack', package: '@agent-device/browserstack', label: 'BrowserStack' },
AWS_DEVICE_FARM,
BROWSERSTACK,
{ provider: 'revyl', package: '@agent-device/revyl', label: 'Revyl' },
{ provider: 'testmu', package: '@agent-device/testmu', label: 'TestMu AI' },
{ provider: 'webos', package: '@agent-device/webos', label: 'LG webOS' },
Expand All @@ -25,11 +38,43 @@ export function getProviderPluginDeclaration(
return PROVIDER_PLUGIN_CATALOG.find((plugin) => plugin.provider === provider);
}

// One line for the whole catalog keeps help remote's first screen fixed as plugins are added.
export function providerPluginHelp(): string {
// The release workflow stamps the core and its public plugins with the same nightly version.
const NIGHTLY_0_22_VERSION = /^0\.22\.\d+-nightly(?:-0-22)?\.\d{8}\.[1-9]\d*$/;
const DEVELOPMENT_0_22_VERSION = /^0\.22\.\d+-dev$/;

function providerPluginSelector(
declaration: ProviderPluginDeclaration,
coreVersion: string,
): string {
if (declaration.nightlyTag === undefined) return declaration.package;
const version = coreVersion.trim();
if (NIGHTLY_0_22_VERSION.test(version)) return `${declaration.package}@${version}`;
if (DEVELOPMENT_0_22_VERSION.test(version)) {
return `${declaration.package}@${declaration.nightlyTag}`;
}
Comment thread
thymikee marked this conversation as resolved.
Resolved
return declaration.package;
}
Comment thread
thymikee marked this conversation as resolved.
Resolved

export function providerPluginInstallCommand(
declaration: ProviderPluginDeclaration,
coreVersion: string = readVersion(),
): string {
return `agent-device plugins add ${providerPluginSelector(declaration, coreVersion)}`;
}

export function providerPluginRepairCommand(
declaration: ProviderPluginDeclaration,
coreVersion: string = readVersion(),
): string {
const selector = providerPluginSelector(declaration, coreVersion);
const action = selector === declaration.package ? 'update' : 'add';
return `agent-device plugins ${action} ${selector}`;
}

export function providerPluginHelp(coreVersion: string = readVersion()): string {
const plugins = PROVIDER_PLUGIN_CATALOG.map(
(plugin) =>
`${plugin.label} (connect ${plugin.provider}; ${plugin.package}${plugin.unpublished ? '; unpublished' : ''})`,
`${plugin.label} (connect ${plugin.provider}; ${providerPluginSelector(plugin, coreVersion)})`,
).join(', ');
return ` Plugins, installed separately: ${plugins}. Run agent-device plugins add <package>, then retry agent-device connect <provider> with your original arguments.`;
}
2 changes: 1 addition & 1 deletion src/commands/schema/cli-help-topics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ test('usageForCommand resolves remote help topic', async () => {
);
assert.match(
help,
/AWS Device Farm: the @agent-device\/aws-device-farm plugin is private and unpublished/,
/AWS Device Farm \(plugin, install separately\): install the @agent-device\/aws-device-farm plugin/,
);
assert.match(help, /Limrun: agent-device connect limrun/);
assert.match(help, /It does not create an App Automate session/);
Expand Down
Loading
Loading