@@ -2,7 +2,6 @@ import { bindTestCommandHost } from '@agent-device/test-kit';
22import { afterAll , beforeEach , test } from 'vitest' ;
33import assert from 'node:assert/strict' ;
44import { pressLinux } from '../input-actions.ts' ;
5- import { resetInputToolCache } from '../linux-env.ts' ;
65import { createLocalLinuxToolProvider , withLinuxToolProvider } from '../tool-provider.ts' ;
76
87bindTestCommandHost ( ) ;
@@ -14,12 +13,12 @@ beforeEach(() => {
1413 Object . defineProperty ( process , 'platform' , { value : 'linux' } ) ;
1514 process . env [ 'XDG_SESSION_TYPE' ] = 'x11' ;
1615 delete process . env [ 'WAYLAND_DISPLAY' ] ;
17- resetInputToolCache ( ) ;
1816} ) ;
1917
2018test ( 'scoped Linux tool provider handles input discovery and command execution' , async ( ) => {
2119 const commands : Array < [ string , string [ ] ] > = [ ] ;
2220 const provider = createLocalLinuxToolProvider ( {
21+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
2322 whichCommand : async ( cmd ) => cmd === 'xdotool' ,
2423 runCommand : async ( cmd , args ) => {
2524 commands . push ( [ cmd , args ] ) ;
@@ -42,6 +41,7 @@ test('scoped Linux tool provider handles input discovery and command execution',
4241test ( 'xdotool press skips the --sync move when the pointer already sits on the target' , async ( ) => {
4342 const commands : Array < [ string , string [ ] ] > = [ ] ;
4443 const provider = createLocalLinuxToolProvider ( {
44+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
4545 whichCommand : async ( cmd ) => cmd === 'xdotool' ,
4646 runCommand : async ( cmd , args ) => {
4747 commands . push ( [ cmd , args ] ) ;
@@ -64,6 +64,7 @@ test('xdotool press skips the --sync move when the pointer already sits on the t
6464test ( 'scoped Linux input provider handles semantic input without host tool discovery' , async ( ) => {
6565 const inputCalls : Array < [ string , string , string , string ] > = [ ] ;
6666 const provider = createLocalLinuxToolProvider ( {
67+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
6768 whichCommand : async ( cmd ) => {
6869 throw new Error ( `unexpected input discovery: ${ cmd } ` ) ;
6970 } ,
@@ -92,10 +93,18 @@ test('scoped Linux input provider handles semantic input without host tool disco
9293
9394test ( 'Linux tool provider scopes do not share cached input tool resolution' , async ( ) => {
9495 const providerA = createLocalLinuxToolProvider ( {
96+ host : {
97+ env : { ...process . env , XDG_SESSION_TYPE : 'x11' , WAYLAND_DISPLAY : '' } ,
98+ cwd : process . cwd ( ) ,
99+ } ,
95100 whichCommand : async ( cmd ) => cmd === 'xdotool' ,
96101 runCommand : async ( ) => ( { exitCode : 0 , stdout : '' , stderr : '' } ) ,
97102 } ) ;
98103 const providerB = createLocalLinuxToolProvider ( {
104+ host : {
105+ env : { ...process . env , XDG_SESSION_TYPE : 'wayland' , WAYLAND_DISPLAY : 'wayland-0' } ,
106+ cwd : process . cwd ( ) ,
107+ } ,
99108 whichCommand : async ( cmd ) => cmd === 'ydotool' ,
100109 runCommand : async ( ) => ( { exitCode : 0 , stdout : '' , stderr : '' } ) ,
101110 } ) ;
@@ -110,6 +119,10 @@ test('Linux tool provider scopes do not share cached input tool resolution', asy
110119
111120 await withLinuxToolProvider (
112121 createLocalLinuxToolProvider ( {
122+ host : {
123+ env : { ...process . env , XDG_SESSION_TYPE : 'wayland' , WAYLAND_DISPLAY : 'wayland-0' } ,
124+ cwd : process . cwd ( ) ,
125+ } ,
113126 ...providerB ,
114127 runCommand : async ( cmd , args ) => {
115128 commands . push ( [ cmd , args ] ) ;
@@ -130,6 +143,7 @@ test('Linux tool provider scopes do not share cached input tool resolution', asy
130143test ( 'local Linux desktop provider translates semantic lifecycle calls to host tools' , async ( ) => {
131144 const commands : Array < [ string , string [ ] , boolean | undefined ] > = [ ] ;
132145 const provider = createLocalLinuxToolProvider ( {
146+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
133147 whichCommand : async ( cmd ) => cmd === 'wmctrl' ,
134148 runCommand : async ( cmd , args , options ) => {
135149 commands . push ( [ cmd , args , options ?. allowFailure ] ) ;
@@ -151,6 +165,7 @@ test('local Linux desktop provider translates semantic lifecycle calls to host t
151165test ( 'local Linux desktop provider falls back to pkill when wmctrl is unavailable' , async ( ) => {
152166 const commands : Array < [ string , string [ ] , boolean | undefined ] > = [ ] ;
153167 const provider = createLocalLinuxToolProvider ( {
168+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
154169 whichCommand : async ( ) => false ,
155170 runCommand : async ( cmd , args , options ) => {
156171 commands . push ( [ cmd , args , options ?. allowFailure ] ) ;
@@ -166,6 +181,7 @@ test('local Linux desktop provider falls back to pkill when wmctrl is unavailabl
166181test ( 'local Linux screenshot provider translates capture to available host tool' , async ( ) => {
167182 const commands : Array < [ string , string [ ] ] > = [ ] ;
168183 const provider = createLocalLinuxToolProvider ( {
184+ host : { env : { ...process . env , XDG_SESSION_TYPE : 'x11' } , cwd : process . cwd ( ) } ,
169185 whichCommand : async ( cmd ) => cmd === 'scrot' ,
170186 runCommand : async ( cmd , args ) => {
171187 commands . push ( [ cmd , args ] ) ;
0 commit comments