EelApi: Taking Your Plugin From Local to WSL and Dev Containers
Read full transcript 43 segments
-
To start with, let's start with the title. What do we mean by project environment? Why should you care about them as a plugin developer? And why do we need Eel API when we already have APIs for written files and started processes and all that? So let's walk through it starting with a local project. So let's say we have a LaunchQL, a small TypeScript app, for planning team launches. Our IDE plugin reads its package.json and runs project's checks using pnpm, the project's package manager. So here by project's environment, I mean where the project files live and where tools run for this project. Here, IDEA, the project and its tools are all on the user's laptop. JDK's file and process APIs reach the same environment as the project.
-
For this local case, this is quite straightforward. But let's say the company provides Windows laptop and LaunchQL is deployed to Linux service. The developer checks out the project inside Ubuntu in WSL. So it's another environment, a Linux one, at his user's directory, LaunchQL. The user still won't use IDEA to run on Windows alongside their other desktop applications. The company proxy and certificates are configured there on Windows too. And actually Windows exposes the Linux files through a UNC path. Like the one below, you see WSL local host, Ubuntu, et cetera. Historically, and in the present time, Windows file access went through a Windows 9P client to a server started by WSL init inside the distribution, like a bit of technical detail.
-
So IDEA could open Linux files without itself running on Linux, just using this UNC path. But that Windows view was not equivalent to Linux file system access. So for example, pnpm dependency can be a symlink to another directory. Linux tools can follow it and read the package sources and as they run also on Linux. But the problem is that when you access this path using UNC opening that link could fail. The IDE could see the dependency entry yet fail to read the sources behind it. This is what happens. Model resolution, navigation and completion could break in this case for IDEA. Metadata has a similar boundary because 9P servers supports Linux metadata including permissions.
-
But ordinary Windows file APIs still do not provide the full POSIX view for these files, such as numeric users and group IDs and mode bits. And we should not assume that a Windows owner or read only flag means the same thing. Also, starting tools needed a WSL exam. So, and as well as network connections inside this WSL virtual machines also needed their own integration. And a host process builder available from JDK doesn't start Linux tool just because the project's files are in WSL. So file access, process execution, network connections, each had a separate route into the same environment. (Mumbles) Now puts it further.
-
Like suppose the user wants to develop his LaunchQL application in a dev container. As a sort of experiment, actually as like, it is what is happens, assumes that there's no bind mount and no published application port for the Docker container. Docker engine manage the container on the Docker host. The container is not inside of the engine process. We can copy and archive with docker cp, but IDE needs to list children, for example, read attributes, follow links and edit individual files. So this support has its limitation. Also, we need to start some processes like pnpm as well as we need to reach some services run inside this dev container for debugging or just getting some information from it.
-
So we are assembling a container specific integration for every operation and this is getting complicated. We have another solution. So we have remote development that already puts operation in the right place, run an IDE backend in WSL or container and connects IDE client to it. So, but backend brings its runtime and plugins these can memory use and also a client session to manage. And the connection to the backend. So those cost matter for new local environments on our laptop. So you need to run at least two processes quite big enough like JetBrains IDE client and the backend. And there's a question, could we leave the full IDE on the laptop and put only a small binary native one besides the projects files to run tools and access project files.
-
So, return to the Linux symlink problem. We started with, actually this is a journey we did. Instead of asking Windows to interpret Linux files, let's send requests to this binary, some agent inside Linux. To get attributes, results link and reads the content content of the files. So we need like small, like few things, native binary, efficient RPC protocol with a like optimized transport and also a new file system provider to turn file operation into requests, like to give the like some transparency for new file operations. Fortunately, we already have such kind of a binary in our Fleet, Fleet product, Fleet IDE.
-
So this was a great start. And but like there's a lot of work to optimize the needs to make it even simpler that it was. And finally, we come up with such binary and code agent like intelligent platform agent that access files and start processes. So for example, for WSL scenario, IDE copies the Linux binary, this one, agent binary into Ubuntu inside the WSL and start is there. The launcher here also wsl.exe that we used previously to start the processes, but we start now only one process, this is agent. After starting the agent, we can keep like our RPC channel which essentially a channel on top of a stdin and stdout transport of the agent process, we started with wsl.exe.
-
As an optimization, we also uses Hyper- V sockets on Windows specifically for WSL, for example, to optimize bulk file operations. So we can use several transports to access the agent and the default one is just standard input and outputs. The color like here on this diagram platform and plugin code inside the IDE. So basically they can use like the JDK NIO file operations which goes through agent NIO provider and each this provider directs these file operations to the agent API, to the agent API to perform this operations like getting attributes, reading files in chunks and so on.
-
Also, we have this ability to call agent API directly. For example, for starting processes, like we have two ways. Yeah, and let's zoom in how we handle these file operations. We start with a string containing double cell UNC pass, pass off creates new pass through the ID runtime routine file system. But what happens when user wants to read the file? So basically at this point, we need to route this operation and the with this path to the correct NIO provider. And this is done by matching the NIO path prefix to the registered file providers.
-
Then for each this request, we call some RPC methods to the agent and agents rise file system called makes Linux kernel syscalls and returns the result. The routing applies to platform and plugin calls inside the JVM IDE. Also, we have NIO paths of course, but actually there is a lot of obsolete and legacy code and third party libraries that uses java.io.File calls and the brain from time. There was also big work that passes Java io.File calls through NIO. So this code also can operate. Agent also starts PMPM in the environment and returns the process identity and output.
-
The IDE stays on host, files and tools stays with the project in WSL in this case. A process lifetime termination and output handling still needs work, but we have a place to implement them. The same arrangement works in a dev container. So basically, yeah, we can deploy and run agent also inside the Docker container, connects to it through the standard input and output and like do the same RPC calls with it. This is great. We can use NIO for files and ask agent to start processes, but let's look at how we start these processes. If this is WSL, then we need to obtain agent and execute some commands.
-
Otherwise we need to do something else like start the local process. Now when we have dev containers, we need add another switch and obtain agent from the Docker and another branch with a local execution. So environment variables and platform information needs the same choice. This is a plugin developers problem as well. Your users choose the project environment and should every plugin have to maintain all these integrations? So the answer is we need to eliminate the branching and we need a common API that included the local environment as well. So here on the diagram, we have the project, essentially the user project that is located somewhere.
-
And we have this chain of methods execution, get your descriptor to ill API. And this chain actually returns the light API for set project environment, whereas the project is located. As the caller sees the Eel API interface and then uses the return instance. So now consider WSL project. The return API is backed by that distributions agent, the agent that is deployed to the WSL distribution. For dev container, it's the same, it's backed by the agent inside the dev container. And they can use the same implementation classes with different sessions and descriptors, life cycles, environment selection happens during acquisition of this API from the descriptor and not as a local or remote branch inside each operation.
-
So this gives plugin authors the same API the platform uses as a common one. And let's now the right plugin features it. Back to our run project checks section of our support for the LaunchQL project. Our plugins called Kotlin code runs inside the IDE JVM. It reads the user's package JSON, finds the check script. Then it runs this pnpm run check and shows output and exit status. The TypeScript code stays in the user project. The plugin calls the IntelliJ platforms in the API to work in that project environment. The user may have a local checkout, a WSL project or a dev container. So let's implement this section so it follows their choice.
-
First, so here is our Kotlin code. First, we need to get this API. The action for this check, like we delegate to project checks, a project level service like defined in our and coded in our plugin. The platform supplies its coroutine scope. So our work has an owner from the start. You can see the coroutine scope in the constructor of the project checks. First, get the project descriptor. It identifies access through a particular personal namespace. This exact method call doesn't perform IO yet. The descriptor can still exist after a container stops even before it is, for example, recreated. Then when we get a link guide with methods to LEPI, it's obtains access for that namespace particular one.
-
This methods suspense and may connect, deploy an agent and may fail at some point. For local project, it won't fail. It returns just a local implementations based on just JDK calls. So, EelMachine, like we have Eel descriptor, EelApi and EelMachine. EelMachine here identifies the machine behind the namespace, like result one useful when sharing some resources. Several descriptors like the descriptor of a dev container and the Docker container, particular one, can refer actually to one machine. Next, let's prepare a path for the file reads and to launch like quiet input one. Our plugin now prepares the user project path.
-
Yeah, we need to start with something. Suppose root is a project absolute NIO path in Ubuntu. So it will look like this, that was your local host, Ubuntu, et cetera. On Windows, its strings include WSL prefix, like it's essentially UNC bus. This is the IDE-facing representation. We can resolve package JSON and read it through NIO. Here, like eel files provides optimized helpers with the same behavior as the corresponding Files calls, but one can use Files calls as well. But looking at this path, this path wants the tool that you run inside WSL needs another path actually.
-
It sees this as an absolute Linux path, like home Alex launch queue. And we need the conversion between them. So as eel path converts roots into eel path, for example, here for the working directory. A path that passed as a command arguments needs a target side string too, like as a, for example, a path passed to some tool. asNioPath converts this path back, so preserving the descriptor namespace that is safe to use with NIO file methods operations to get an attributes to reading files and so on. And also to, for example, to serializing this path in some configuration. So with conversions runs inside the IDE, they change how the path is represented, but neither with the file sends RPC requests and like none of them does some IO operations.
-
Now take a dev container opened from a Linux IDE. So the path here is a bit, looks a bit different. It has some quite tricky prefix, but that is like one is registered and supposed to be used from the IDE perspective. So this path starts with this prefix. And so as eel path gives the tool without the roots in prefix and as new path restores this representation. And so yeah, so you need to keep in mind where to use the absolute path and where to use the NIO path for your, when you work with your, when you develop your plugin. So we have this working directory, but first we need to find the tool that we need to start in the project environment.
-
This example is about some WSL installation. If the tool is not found, like you have to offer as a plugin developer to configuration. Language as the car provider, language as the KMA provide its own discovery and launcher and windows command scripts need a proper launcher too. Another options that you need some environmental variables. So this is how they are can be received using the LPI. For example, user may set node options inside double cell and we need these options. We need to receive these options on the ID side to put a tag on it, like to log it or make something from it.
-
It's large from our project service creates one text job. I mean the coroutine job. The folded line prepares a BI path environment values. We like saw earlier, we launched the result executable with run and check as separate arguments you see. The working directory uses the target path and supplies target variables, overriding inheritance values runs as I'm clearing them. Notice scope this. This method belongs to the launch builder. It says the scope for the process is a coroutine scope. We are about to start. Here's the launch coroutine scope. So we will look at the ownership like life cycle ownership next. The tech needs no output. So we close the stdin right away. We have a collection helper as a treats as to doubt and as today are concurrently holding a file by blocking the tool.
-
So yeah, this tool just returns a byte arrays and the exit code. This particular method buffers output in memory and can return a partial output after a stream copy error. So, but your plugin may use a streaming reader for larger outputs and reports read failure like when like complete diagnostics matters for you. Yeah, let's get back to what I mentioned about the current scope. We have several lifetimes. The platform supplies our project services coroutine scope. Closing the project, unloading the plugin cancels that work. Like for example, the scope we saw earlier in our service. Each check is a child operation.
-
Like it is performed on some scope. It's on its process and the work reading the output. In the previous code, this refers to that checks launcher receiver. So the scope method is on the launch builder, not on the returned process. Binding to the whole service, the process, but binding the process to the whole service instead I would let it cancel check, leave it still running until the service ended. Sometimes it is expected, but mostly not. And for example, the process binding waits for exit. If its scope is canceled, it involves process cleanup. The stream collectors must also finished or be canceled. Awaiting an exit code alone doesn't establish this ownership.
-
So the environment session has a separate lifetime. Other IDE features may still need it when our check finished. Release our operations resources and let the platform manage shared access in this case. Yeah, also we might face several outcomes of running like our process. So run methods returns as a launch job. If the check completes, then just show its output and status. A non-zero exit code means a tool ran and found a problem. Yes, this is expected. The cancel action cancels that check's job. Closing the project unloading the plugin cancels its owner too, like the second one ownership.
-
Like the big one. Because we bound the process to the job, cancellation invokes process cleanup. Canceling an exit code wait alone would not establish that relationship. And we know also to remember to preserve cancellation exception and propagate it to the stack trace above us. Yes, other option is when a dev container stops or we, for example, this happens, WSL just stop responding. And this is another problem. And this is not something that the plugin developer should try to work with. He just needs to report that the check could not complete and reports that connection to the environment, to the project environment just failed.
-
Yeah, we have owned work, but it still needs the right execution context, like a small note. So captures required project inputs inputs in a short UI or model stack. So this operation includes blocking work, like to elipi and three string. And this should be launched in this case on the IO dispatcher. Yeah, when the result is received, we just switch to another dispatcher UI to this will is a report. This is straightforward and just the reminder. Now take some exists and local feature, like some code snippet that can be used to run this pn pn run check.
-
And let's see how it actually evolves into the EEL API execution. So basically it's a bit bigger. It's require some lifetime management, but it's actually quite straightforward and it's API helps you not to fall in some error that's in some place. So basically this is some complete piece of implementation that you can see that you can use in your plugin. Also, like as a part of this support, we understand that using this new EEL API might be a problem and we keep working on their kits that will help you migrate to this new EEL API.
-
So for example, it will add some nodes you using some kind of the wrong path inside another environment that is not expected to be run it. So like here, for example, you use the ProcessBuilder that would run only local process with like the EelPath that essentially is a path on some environment and not the local one. It could be known on the local one. So just a few moments, we have another APIs. So EEL APIs that is covered here, it's access files, tools and resources and project environment. But we also have targets API. This essentially helps your to run your local projects inside another environment.
-
So the local and this project and the environment are different ones. And this is another, like this is not the contradiction to EEL API, but another it's orthogonal to it. Also we have a split mode. It's like, this is something that is, for example, like remote developer, remote development is backed by. And you need here, for example, you might need to split your plugin into front end and backend parts. And here you might need to use EEL API, for example, on the backend parts. To access the project files, as you did with just JPK calls, JPK matters beforehand. So Eel API also fits in this option, but mostly in the backend part.
-
So like the small suggestion, we encourage you to, like as a plugin developer to check how your plugin will work with this Eel API. So suppose you have a feature set, select one feature that runs some tool or access some files and let's start with getting the project environment. Check what's best tools it uses, what environment variables it requires. Then if the operation and owner, like test completion, cancellation, project close and lost access, you need to think about it. And then try the same feature with local project, WSL and inside dev container.
-
This will be a practical first migration. One feature might cover like all these cases and you will get some notion how well it works for you. Yeah. And this is it. And I'm looking for your questions. Okay, thank you very much. Questions, Patrick, do we have any questions? I got a question. So I didn't know about Eel API until recently because some of our community members, a well-known community member started using it, I think in the Bash support, which is a pretty big plugin. So, and I think one of the questions I could only answer with a workaround that I got with the help of AI and my research agent was about storing some paths that are used on a local machine and so on and so forth.
-
So what it turns out is that Joachim Ansorg is his name, looked into it and he found that in the PyCharm, I think plugin, we're using some internal stuff, which is EL machine dot internal name, which is internal and cannot be used. So my question is, how fixed is the API right now? And if we have such, let's say, use cases that might be supported for plugin or might be good for plugin developers, can we reach out to you and ask, hey, is there a workaround or if there's no workaround, how are plugin developers going to solve this problem? Would that be, would there be a way? Yeah, for sure. Yeah, so I hear several questions, one quite like particular one, like Soshen one, and the other one is general about, and maybe more important about what plans do we have for Eel API.
-
So it is now in experimental mode, say Eel API itself. We are in the process of stabilizing it of like reading it out, process of writing the documentation and like putting it down into IntelliJ Platform SDK. We understand that plugin developers need something quite stable, not to like to deal with migration stuff and so on, nobody likes it. Yeah, and this is the planned work and this is like our first priority, I would say. Yeah, and what I need to also add, this is experimental. So the IntelliJ platform uses it widely.
-
So for example, IDEA, in two 6.1, I believe, dev containers receives the native support in IDEA. So like build tools, Git and other integrations, like I believe Spring integrations and so on, these are now uses Eel API. And this is painful for us to modify it as well as for like plugin authors. So, and we are quite sure that it won't be modified a lot. Do we have any time constraints for that? I mean, when we can make it public for plugin developers? This is public. So we have API experimental on it, on top of it, the annotation that's like gives you the nodes that it could be changed, but it could be used.
-
It's not internal. The ones that Patrick mentioned about internal name, we have parts of API that internal, but it's mostly something that you don't need to use. So for example, for serializing paths, you have just NIO paths and you can serialize them right away. And as we have like a lot of usages in the platform, anyway, in any case, we need some migration mechanism to like to provide for us and for plugin authors in case we change something. Yeah. I got another question, if no one has one. So in the bigger picture of where we're heading to, right? So we have a remote development and I think EEL API is a bit orthogonal to that, right? So we have dev containers and stuff.
-
What is your, I don't want to say prediction, but let's say what is your prediction will be used in the future more. You mean in contradiction to remote development? Yeah, I mean, we have, so from my point of view, I usually have everything local. It's a file on my machine, right? I have a simple plugin or my IDE I can work on it. And so I don't need a big setup where I have a server running because I don't have the capability or the processing power here locally. So we had that, I had that in the past, right? So what would you say is the industry really going to do more remote development or will it be dev containers that you set up locally? So what would you say is basically right the direction we're heading to? That would be my question.
-
Yeah, just a really good one. I'm not sure I have like specific answer for this. I believe both approaches has its, like it has its users now and it will be so. So laptops keeps getting like more and more efficient. Like, I don't know is my like laptop MacBook cam. It's unbelievable, unbelievable how our like big repo can be compiled like in like tens of minutes. So it's in some, so yeah, local development will stay definitely. I believe the isolation layer also is for, for example, like dev containers is also really important like as an AI era, because you can just spawn several dev containers with like worktrees and maybe work independently to run pods inside it without really without a lot of restrictions because it's isolated.
-
Yeah, you have encapsulated everything. And if something burns down, it's your dev container and not your laptop or your desktop. Yeah, yeah. So basically this is a real worst scenario and it will keep evolving and as well as for remote development. So yeah, I believe we will have two worlds and different tasks will like require different approaches. Thanks a lot. So I don't have any question. Let's check charts. So the same thing I believe. Yeah, yeah. There are no questions in the chat either. So do we even have someone here who wants to do another raffle quiz question? I don't know if. How many raffles? Here we have, we have a couple of dozens of people here. Still. How many raffles have we got left?
-
I think three, right? Ah, somebody said yes. So there are folks that are still with us. Thank you. Okay. Okay, so let's go with the first one. Let's go with a related question, right? Yeah, exactly. So here comes the question. Which of these is not an environment that Eel API abstracts away? Local machine, WSL, dev container, Game Boy. Ooh. (Laughing) Okay, yeah. So I think the first one was BOW, it happened so quickly. BOW HD. So I think this one goes to you. So, well, we got another one. So because I see some new names and I think we can do it. So let's do the next one right away because it's also very fitting into the topic. IJent is faster than WSL's built-in file access.
-
Which protocol does that file access use? FTP, SMB, 9P, NFS. It wasn't your presentation, so what? No, it's not FTP. (Laughing) No, it's not FTP. Okay, we have the correct answer. We have the correct answer, right? There it is, it's called 9P. So I never heard of that actually. So Alex, could you say three sentences about that? It's quite an old, I had quite an old protocol actually.
-
Windows, I believe it's reanimated it like for this file synchronization between the WSL file system and the Windows one. I'm not sure how many like other utilities uses it. I believe not that much. And the sentence actually is, this sentence statement was not really true. Like that's IJent is faster than 9P. It's faster only, I believe in batch operations when you need to, like as 9P provides only just file, access and now our agent provides some RPC protocol that's like we can get the flow files and this is where we, for example, speed up our indexing.
-
And yeah, in this case, it became faster. Okay. Lovely, so I think that is almost the end of it, right? So let's thank Alexander again for dropping by and giving this nice presentation. Thanks a lot, Alex.
Summary
This presentation explores the complexities of project environments for plugin developers, specifically addressing the challenges of cross-platform file access, process execution, and metadata discrepancies between host operating systems and environments like WSL or dev containers. Key subjects covered include JDK file APIs, Linux symlinks, POSIX metadata, and the architectural limitations of traditional remote development backends. The practical conclusion is the introduction of the Eel API and a lightweight native agent deployed directly within the target environment, which uses an optimized RPC protocol to handle file operations and process execution transparently without the high resource cost of full remote IDE backends.