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
Merged
thymikee
merged 21 commits into
fix/0.22-plugin-connection-admission
from
feat/0.22-aws-device-farm-plugin
Nov 17, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cdecce1
Extract AWS Device Farm provider plugin
thymikee f0e642e
refactor(aws-device-farm): consolidate WebDriver imports
thymikee 4d007df
test(aws-device-farm): colocate connection coverage
thymikee 0007ab2
Test packed AWS provider error boundary
thymikee ebb2759
refactor(provider-webdriver): remove unused extraction scaffolding
thymikee 00c580d
chore(gates): register the AWS packed smoke entry
thymikee 319ef2a
chore(gates): verify the explicit WebDriver plugin subpath
thymikee 2964f1d
test(layering): update WebDriver export boundary
thymikee 29e2a70
chore(gates): separate root dependency ownership from workspace refer…
thymikee c534bb9
chore(gates): check workspace declarations in script test imports
thymikee adb8ec5
fix(plugins): defer host command execution imports
thymikee 5348c3e
refactor(webdriver): remove unused provider exports
thymikee 8272e3f
fix(plugins): preserve supplied command host context
thymikee 9a5dc22
fix: address AWS plugin review findings
thymikee d2c0f9f
fix(aws-device-farm): publish typed plugin entrypoints
thymikee 6182cfe
test(docs): resolve installed workspace plugins
thymikee 2579246
fix(ci): select moved snapshot differential test
thymikee d138084
refactor(aws): import host capability types from the plugin SDK
thymikee ce76aa0
test(aws): cover routed plugin admission
thymikee 22c9a79
test(aws): register provider for stored lease fixtures
thymikee 8c5fabc
chore(aws): enable package publication
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'agent-device': minor | ||
| --- | ||
|
|
||
| AWS Device Farm moves to a private, unpublished plugin. After publication, CLI hosts can install it with `agent-device plugins add @agent-device/aws-device-farm`; finish sessions, stop the detached daemon for its matching state directory, and retry. Embedded hosts import the factory, pass it to `startAgentDevice({ plugins: [awsDeviceFarm()] })`, and close and recreate the runtime after changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,42 @@ | ||
| 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<{ | ||
| /** Host-supplied command environment. Include PATH, HOME and provider inputs when needed. */ | ||
| env: Readonly<Record<string, string | undefined>>; | ||
| options: Readonly<Record<string, unknown>>; | ||
| clientVersion: string; | ||
| createError(code: AppErrorCode, message: string, details?: AppErrorDetails): AppError; | ||
| /** Runs in the supplied host cwd/env; ambient process values are not added. */ | ||
| 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, | ||
| timeoutMs: 30_000, | ||
| }); | ||
|
thymikee marked this conversation as resolved.
Resolved
|
||
| return { stdout }; | ||
| }, | ||
| } satisfies ProviderPluginHost); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.