Repository navigation
feat: extract AWS Device Farm provider plugin #4617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/a1-extraction-unused-import-20261116
Are you sure you want to change the base?
Changes from all commits
b92e657
e8fa3a9
6173054
db4ec80
086d2d6
410d9a4
4dbfd87
2b67e2f
639c74a
2327e51
7e64f8f
f9a0b34
98dfddb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'agent-device': minor | ||
| --- | ||
|
|
||
| Install AWS Device Farm support with `agent-device plugins add @agent-device/aws-device-farm`. Close existing sessions and stop the daemon for its state directory before reconnecting after upgrading. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -151,7 +151,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, 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`, Limrun), or [contact Callstack](mailto:hello@callstack.com) for team QA. | | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This parenthetical makes Prompt for AI agents
Suggested change
|
||||||
|
|
||||||
| ## How it works | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import { expect, test } from 'vitest'; | ||
| import { withCommandExecutorOverride } from '@agent-device/host-kit/command'; | ||
| import { createPluginHost } from './host.ts'; | ||
|
|
||
| test('plugin host runs commands with the AWS command bounds', async () => { | ||
| await withCommandExecutorOverride( | ||
| async (command, args, options) => { | ||
| expect(command).toBe('aws'); | ||
| expect(args).toEqual(['devicefarm', 'get-project']); | ||
| expect(options.maxBuffer).toBe(10 * 1024 * 1024); | ||
| expect(options.timeoutMs).toBe(30_000); | ||
| return { stdout: '{"project":{}}', stderr: '', exitCode: 0 }; | ||
| }, | ||
| async () => { | ||
| await expect( | ||
| createPluginHost({ env: {}, cwd: '/' }, undefined).runHostCommand('aws', [ | ||
| 'devicefarm', | ||
| 'get-project', | ||
| ]), | ||
| ).resolves.toEqual({ stdout: '{"project":{}}' }); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| test('commands use the supplied host and overlay request environment without ambient values', async () => { | ||
| const { mkdtempForTestSync } = await import('@agent-device/test-kit'); | ||
| const { realpathSync } = await import('node:fs'); | ||
| const { withCommandHost } = await import('@agent-device/host-kit/command'); | ||
| const cwd = realpathSync(mkdtempForTestSync('plugin-command-host-')); | ||
| const host = { cwd, env: { PLUGIN_VALUE: 'host', HOST_ONLY: 'present' } }; | ||
| const pluginHost = createPluginHost(host, undefined); | ||
| const args = [ | ||
| '-e', | ||
| 'process.stdout.write(JSON.stringify({cwd:process.cwd(), value:process.env.PLUGIN_VALUE, hostOnly:process.env.HOST_ONLY, ambient:process.env.PLUGIN_AMBIENT}))', | ||
| ]; | ||
| const previous = process.env.PLUGIN_AMBIENT; | ||
| process.env.PLUGIN_AMBIENT = 'ambient'; | ||
| try { | ||
| const plain = await pluginHost.runHostCommand(process.execPath, args); | ||
| expect(JSON.parse(plain.stdout)).toEqual({ cwd, value: 'host', hostOnly: 'present' }); | ||
| const scoped = await withCommandHost({ host, requestEnv: { PLUGIN_VALUE: 'request' } }, () => | ||
| pluginHost.runHostCommand(process.execPath, args), | ||
| ); | ||
| expect(JSON.parse(scoped.stdout)).toEqual({ cwd, value: 'request', hostOnly: 'present' }); | ||
| } finally { | ||
| if (previous === undefined) delete process.env.PLUGIN_AMBIENT; | ||
| else process.env.PLUGIN_AMBIENT = previous; | ||
| } | ||
| }); | ||
|
|
||
| test('connection resolve and verify use each call host independently', async () => { | ||
| const { mkdtempForTestSync } = await import('@agent-device/test-kit'); | ||
| const { realpathSync } = await import('node:fs'); | ||
| const { resolveProviderPlugins } = await import('./registry.ts'); | ||
| const dirs = [ | ||
| realpathSync(mkdtempForTestSync('plugin-resolve-')), | ||
| realpathSync(mkdtempForTestSync('plugin-verify-')), | ||
| ]; | ||
| const observed: unknown[] = []; | ||
| const run = async (host: import('./host.ts').ProviderPluginHost) => { | ||
| const result = await host.runHostCommand(process.execPath, [ | ||
| '-e', | ||
| 'process.stdout.write(JSON.stringify([process.cwd(), process.env.CONNECTION_VALUE]))', | ||
| ]); | ||
| observed.push(JSON.parse(result.stdout)); | ||
| }; | ||
| const { connections } = await resolveProviderPlugins([ | ||
| { | ||
| source: 'embedder', | ||
| load: () => ({ | ||
| apiVersion: 2, | ||
| provider: 'example', | ||
| credentials: { variables: [] }, | ||
| setup: () => ({}), | ||
| connection: { | ||
| capabilities: { | ||
| leaseKind: 'direct-device-provider', | ||
| requiresAppAttachment: false, | ||
| requiresRemoteDaemon: false, | ||
| supportsArtifacts: true, | ||
| supportsDeferredAppSelection: false, | ||
| supportsDirectPortReverse: false, | ||
| usesCloudWebDriverLease: true, | ||
| }, | ||
| resolve: async ({ host }: { host: import('./host.ts').ProviderPluginHost }) => { | ||
| await run(host); | ||
| return { profile: { leaseProvider: 'example', platform: 'ios' } }; | ||
| }, | ||
| verify: async ({ host }: { host: import('./host.ts').ProviderPluginHost }) => { | ||
| await run(host); | ||
| return { provider: 'example', service: 'example', verificationMessage: 'ok' }; | ||
| }, | ||
| }, | ||
| }), | ||
| }, | ||
| ]); | ||
| const connection = connections.get('example')!; | ||
| const flags = { json: false, help: false, version: false }; | ||
| await connection.resolve({ | ||
| flags, | ||
| stateDir: dirs[0]!, | ||
| cwd: dirs[0]!, | ||
| env: { CONNECTION_VALUE: 'resolve' }, | ||
| }); | ||
| await connection.verify({ flags, cwd: dirs[1]!, env: { CONNECTION_VALUE: 'verify' } }); | ||
| expect(observed).toEqual([ | ||
| [dirs[0], 'resolve'], | ||
| [dirs[1], 'verify'], | ||
| ]); | ||
| }); | ||
|
|
||
| test('provider registry setup receives its supplied command host', async () => { | ||
| const { mkdtempForTestSync } = await import('@agent-device/test-kit'); | ||
| const { realpathSync } = await import('node:fs'); | ||
| const { resolveProviderPlugins, startProviderRegistry } = await import('./registry.ts'); | ||
| const cwd = realpathSync(mkdtempForTestSync('plugin-setup-host-')); | ||
| let observed: unknown; | ||
| const resolved = await resolveProviderPlugins([ | ||
| { | ||
| source: 'embedder', | ||
| load: () => ({ | ||
| apiVersion: 2, | ||
| provider: 'example', | ||
| credentials: { variables: [] }, | ||
| setup: async (host: import('./host.ts').ProviderPluginHost) => { | ||
| const result = await host.runHostCommand(process.execPath, [ | ||
| '-e', | ||
| 'process.stdout.write(JSON.stringify([process.cwd(), process.env.SETUP_VALUE]))', | ||
| ]); | ||
| observed = JSON.parse(result.stdout); | ||
| return { webDriver: { provider: 'example' } }; | ||
| }, | ||
| }), | ||
| }, | ||
| ]); | ||
| const registry = await startProviderRegistry( | ||
| resolved, | ||
| { cwd, env: { SETUP_VALUE: 'supplied' } }, | ||
| { | ||
| adaptWebDriver: async () => { | ||
| throw new Error('not needed for host assertion'); | ||
| }, | ||
| }, | ||
| ); | ||
| expect(observed).toEqual([cwd, 'supplied']); | ||
| await registry.close(); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,40 @@ | ||
| import type { HostEnvironment } from '@agent-device/kernel/source-value'; | ||
| import { AppError, type AppErrorCode, type AppErrorDetails } from '@agent-device/kernel/errors'; | ||
| import { readVersion } from '@agent-device/host-kit/version'; | ||
|
|
||
| export type HostCommandResult = Readonly<{ stdout: string }>; | ||
|
|
||
| export type RunHostCommand = ( | ||
| command: string, | ||
| args: readonly string[], | ||
| ) => Promise<HostCommandResult>; | ||
|
|
||
| export type ProviderPluginHost = Readonly<{ | ||
| env: Readonly<Record<string, string | undefined>>; | ||
| options: Readonly<Record<string, unknown>>; | ||
| clientVersion: string; | ||
| createError(code: AppErrorCode, message: string, details?: AppErrorDetails): AppError; | ||
| runHostCommand: RunHostCommand; | ||
| }>; | ||
|
|
||
| export function createPluginHost( | ||
| env: NodeJS.ProcessEnv, | ||
| host: HostEnvironment, | ||
| options: Record<string, unknown> | undefined, | ||
| ): ProviderPluginHost { | ||
| return Object.freeze({ | ||
| env: Object.freeze({ ...env }), | ||
| env: Object.freeze({ ...host.env }), | ||
| options: Object.freeze({ ...options }), | ||
| clientVersion: readVersion(), | ||
| createError: (code, message, details) => new AppError(code, message, details), | ||
| runHostCommand: async (command, args) => { | ||
| const { runCmd } = await import('@agent-device/host-kit/command'); | ||
| const { stdout } = await runCmd(command, [...args], { | ||
| cwd: host.cwd, | ||
| env: host.env, | ||
| maxBuffer: 10 * 1024 * 1024, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This Prompt for AI agents |
||
| timeoutMs: 30_000, | ||
| }); | ||
| return { stdout }; | ||
| }, | ||
| } satisfies ProviderPluginHost); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This upgrade instruction is misleading for both current availability and embedded SDK hosts: the package is still unpublished, and embedded runtimes neither read the CLI plugin store nor support
daemon stop. State the publication prerequisite, then give CLI hosts the store/restart path and embedded hosts thestartAgentDevice({ plugins })plus close/recreate path.Prompt for AI agents