@@ -15,7 +15,7 @@ import type {
1515import type { SettingsUpdateOptions } from '@agent-device/contracts/client' ;
1616import { AppError } from '@agent-device/kernel/errors' ;
1717import { resolveCliOptions } from '../cli/resolve-cli-options.ts' ;
18- import { mkdtempForTestSync } from '@agent-device/test-kit' ;
18+ import { mkdtempForTestSync , createTestHostEnvironment } from '@agent-device/test-kit' ;
1919import { createStubClientLeases } from './test-utils/client-lease-fixtures.ts' ;
2020import { withCapturedOutput , withCapturedStdoutAsync } from './test-utils/stream-capture.ts' ;
2121
@@ -42,6 +42,7 @@ test('install-from-source forwards URL and repeated headers to client.apps.insta
4242 } ) ;
4343
4444 const handled = await tryRunClientBackedCommand ( {
45+ host : createTestHostEnvironment ( ) ,
4546 command : 'install-from-source' ,
4647 positionals : [ 'https://example.com/app.apk' ] ,
4748 flags : {
@@ -84,6 +85,7 @@ test('install-from-source forwards GitHub Actions artifact flag to client.apps.i
8485 } ) ;
8586
8687 const handled = await tryRunClientBackedCommand ( {
88+ host : createTestHostEnvironment ( ) ,
8789 command : 'install-from-source' ,
8890 positionals : [ ] ,
8991 flags : {
@@ -120,6 +122,7 @@ test('install-from-source preserves colons in GitHub Actions artifact names', as
120122 } ) ;
121123
122124 await tryRunClientBackedCommand ( {
125+ host : createTestHostEnvironment ( ) ,
123126 command : 'install-from-source' ,
124127 positionals : [ ] ,
125128 flags : {
@@ -153,6 +156,7 @@ test('install-from-source forwards configured GitHub Actions artifact name to cl
153156 } ) ;
154157
155158 const handled = await tryRunClientBackedCommand ( {
159+ host : createTestHostEnvironment ( ) ,
156160 command : 'install-from-source' ,
157161 positionals : [ ] ,
158162 flags : {
@@ -189,6 +193,7 @@ test('install-from-source rejects malformed header syntax', async () => {
189193 await assert . rejects (
190194 ( ) =>
191195 tryRunClientBackedCommand ( {
196+ host : createTestHostEnvironment ( ) ,
192197 command : 'install-from-source' ,
193198 positionals : [ 'https://example.com/app.apk' ] ,
194199 flags : {
@@ -216,6 +221,7 @@ test('install-from-source rejects headers with GitHub Actions artifact sources',
216221 await assert . rejects (
217222 ( ) =>
218223 tryRunClientBackedCommand ( {
224+ host : createTestHostEnvironment ( ) ,
219225 command : 'install-from-source' ,
220226 positionals : [ ] ,
221227 flags : {
@@ -268,6 +274,7 @@ test('metro prepare forwards normalized options to client.metro.prepare', async
268274
269275 const stdout = await withCapturedStdoutAsync ( async ( ) => {
270276 const handled = await tryRunClientBackedCommand ( {
277+ host : createTestHostEnvironment ( ) ,
271278 command : 'metro' ,
272279 positionals : [ 'prepare' ] ,
273280 flags : {
@@ -330,6 +337,7 @@ test('metro prepare rejects when no public or proxy base URL is provided', async
330337 await assert . rejects (
331338 ( ) =>
332339 tryRunClientBackedCommand ( {
340+ host : createTestHostEnvironment ( ) ,
333341 command : 'metro' ,
334342 positionals : [ 'prepare' ] ,
335343 flags : {
@@ -366,6 +374,7 @@ test('metro reload forwards host, port, bundle URL, and timeout to client.metro.
366374
367375 const stdout = await withCapturedStdoutAsync ( async ( ) => {
368376 const handled = await tryRunClientBackedCommand ( {
377+ host : createTestHostEnvironment ( ) ,
369378 command : 'metro' ,
370379 positionals : [ 'reload' ] ,
371380 flags : {
@@ -420,6 +429,7 @@ test('events prints a parsed session timeline from the generic CLI route', async
420429
421430 const output = await withCapturedOutput ( async ( ) => {
422431 const handled = await tryRunClientBackedCommand ( {
432+ host : createTestHostEnvironment ( ) ,
423433 command : 'events' ,
424434 positionals : [ ] ,
425435 flags : {
@@ -461,6 +471,7 @@ test('screenshot forwards --overlay-refs to the client capture API', async () =>
461471 } ) ;
462472
463473 const handled = await tryRunClientBackedCommand ( {
474+ host : createTestHostEnvironment ( ) ,
464475 command : 'screenshot' ,
465476 positionals : [ '/tmp/screenshot.png' ] ,
466477 flags : {
@@ -510,6 +521,7 @@ test('diff screenshot forwards --surface to live client screenshot capture', asy
510521
511522 await withCapturedStdoutAsync ( async ( ) => {
512523 const handled = await tryRunClientBackedCommand ( {
524+ host : createTestHostEnvironment ( ) ,
513525 command : 'diff' ,
514526 positionals : [ 'screenshot' ] ,
515527 flags : {
@@ -554,6 +566,7 @@ test('open forwards macOS surface to the client apps API', async () => {
554566 } ) ;
555567
556568 const handled = await tryRunClientBackedCommand ( {
569+ host : createTestHostEnvironment ( ) ,
557570 command : 'open' ,
558571 positionals : [ 'MenuBarApp' ] ,
559572 flags : {
@@ -589,6 +602,7 @@ test('open forwards launch console option to the client apps API', async () => {
589602 } ) ;
590603
591604 const handled = await tryRunClientBackedCommand ( {
605+ host : createTestHostEnvironment ( ) ,
592606 command : 'open' ,
593607 positionals : [ 'Agent Device Tester' ] ,
594608 flags : {
@@ -622,6 +636,7 @@ test('apps command defaults to user-installed and prints discovery hint', async
622636
623637 const output = await withCapturedOutput ( async ( ) => {
624638 const handled = await tryRunClientBackedCommand ( {
639+ host : createTestHostEnvironment ( ) ,
625640 command : 'apps' ,
626641 positionals : [ ] ,
627642 flags : {
@@ -669,6 +684,7 @@ test('screenshot reports annotated ref count in non-json mode', async () => {
669684
670685 const stdout = await withCapturedStdoutAsync ( async ( ) => {
671686 const handled = await tryRunClientBackedCommand ( {
687+ host : createTestHostEnvironment ( ) ,
672688 command : 'screenshot' ,
673689 positionals : [ '/tmp/screenshot.png' ] ,
674690 flags : {
@@ -703,6 +719,7 @@ click text="Continue"
703719
704720 const stdout = await withCapturedStdoutAsync ( async ( ) => {
705721 const handled = await tryRunClientBackedCommand ( {
722+ host : createTestHostEnvironment ( ) ,
706723 command : 'replay' ,
707724 positionals : [ 'export' , sourcePath ] ,
708725 flags : {
@@ -784,6 +801,7 @@ test('replay rejects extra plain replay paths before daemon dispatch', async ()
784801 await assert . rejects (
785802 async ( ) =>
786803 await tryRunClientBackedCommand ( {
804+ host : createTestHostEnvironment ( ) ,
787805 command : 'replay' ,
788806 positionals : [ 'one.ad' , 'two.ad' ] ,
789807 flags : {
@@ -814,6 +832,7 @@ test('wait keeps CLI bare text behavior through the typed client command API', a
814832 } ;
815833
816834 const handled = await tryRunClientBackedCommand ( {
835+ host : createTestHostEnvironment ( ) ,
817836 command : 'wait' ,
818837 positionals : [ 'Continue' , '1500' ] ,
819838 flags : {
@@ -848,6 +867,7 @@ test('keyboard status prints Android input ownership in human output', async ()
848867
849868 const stdout = await withCapturedStdoutAsync ( async ( ) => {
850869 const handled = await tryRunClientBackedCommand ( {
870+ host : createTestHostEnvironment ( ) ,
851871 command : 'keyboard' ,
852872 positionals : [ 'status' ] ,
853873 flags : {
@@ -880,6 +900,7 @@ test('metro prepare wraps output in the standard success envelope for --json', a
880900
881901 const stdout = await withCapturedStdoutAsync ( async ( ) => {
882902 const handled = await tryRunClientBackedCommand ( {
903+ host : createTestHostEnvironment ( ) ,
883904 command : 'metro' ,
884905 positionals : [ 'prepare' ] ,
885906 flags : {
@@ -953,6 +974,7 @@ test('metro prepare with --remote-config loads profile defaults', async () => {
953974
954975 const stdout = await withCapturedStdoutAsync ( async ( ) => {
955976 const handled = await tryRunClientBackedCommand ( {
977+ host : createTestHostEnvironment ( ) ,
956978 command : 'metro' ,
957979 positionals : [ 'prepare' ] ,
958980 flags : parsed . flags ,
@@ -993,6 +1015,7 @@ test('install prints command-owned success output in human mode', async () => {
9931015
9941016 const stdout = await withCapturedStdoutAsync ( async ( ) => {
9951017 const handled = await tryRunClientBackedCommand ( {
1018+ host : createTestHostEnvironment ( ) ,
9961019 command : 'install' ,
9971020 positionals : [ 'Demo' , '/tmp/Demo.app' ] ,
9981021 flags : {
@@ -1023,6 +1046,7 @@ test('settings location set forwards coordinates to client settings update', asy
10231046 } ) ;
10241047
10251048 const handled = await tryRunClientBackedCommand ( {
1049+ host : createTestHostEnvironment ( ) ,
10261050 command : 'settings' ,
10271051 positionals : [ 'location' , 'set' , '37.3349' , '-122.009' ] ,
10281052 flags : {
@@ -1064,6 +1088,7 @@ test('settings location set rejects invalid coordinates before client call', asy
10641088 await assert . rejects (
10651089 ( ) =>
10661090 tryRunClientBackedCommand ( {
1091+ host : createTestHostEnvironment ( ) ,
10671092 command : 'settings' ,
10681093 positionals,
10691094 flags : {
0 commit comments