Repository navigation
feat(computer): compose apps onto a Windows computer - #540
Merged
Merged
Conversation
…app servers on loopback - session.py picks the OS's way: _session_posix (Linux, macOS, as before) or _session_windows, sharing _reaping. - On Windows an app launches through _job, a standard-library helper that holds a Job object named for its pid: the app and all it starts are in it, it outlives the server, and a server finds it by name to stop it (its windows asked to close, then the job ended) or pause it (each process suspended). Windows are listed with EnumWindows, by program, class and title; the menu launcher is a Start Menu shortcut. - served.py: an app's server answers on its folder's Unix socket, or on Windows on a loopback port it writes with a token, which it checks on every request and WebSocket; the driver's apps and svc, the launcher and the page driver reach it either way, through no proxy the environment names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reading its pipes to their end Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nstall under windows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… name the window buffers' sizes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…posed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…app's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, whose pid names its job A venv's python.exe on Windows is a launcher that runs the interpreter as a child, so the pid a launch held wasn't the helper's, and pausing, stopping and finding the job found none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/windows-apps-compose
…', as /opt/agentenv is root's C:\agentenv inherited the access C:\ gives every user to change what's under it, so the session user could change a driver's or an app's files. Composing now leaves it the admins': every user reads and runs it, and the session user writes only the services' logs and each app's own folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s no process Ending a job returns before its processes have, and a reset puts the app's files back once its stop returns, which a process still holding one open would refuse. The session's windows are listed off the event loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/windows-apps-compose
…not while the job is there Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/windows-apps-compose
A fixture plans the app bundle whole, so a Windows env there composed Windows, ISO and all, wherever KVM was; the Windows bundle is run only where its media is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a server's error A 504 from GitHub failed a compose that a retry a few seconds later passes; the base's setup already retries its downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s setup does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tops apps on a real Windows computer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… one module, and key the apps folder by OS On Windows an app's server is reached on the address it wrote, and one that hasn't written it isn't answering, which every caller handles; it used to fall back to a Unix socket, which Windows has none of, so a readiness check raised instead of saying the server hadn't started or why it failed. Served opens an app's WebSocket too, so svc no longer knows either transport, and app.py keeps the paths, so an app's own code still imports no websockets. apps_folder(os) says where a computer of each OS keeps its apps, which composing uses for the computer it composes rather than the OS it runs on. _Win32 names its DLLs, and kernel32's calls are typed in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/windows-apps-compose # Conflicts: # src/agent_env/env/envs/computer/utils/composer.py # src/agent_env/env/envs/computer/utils/windows_disk.py
…o have exited Its job's list of processes says only that one is no longer in the job; its own handle says it has exited, so none still writes once a stop returns and a reset puts the app's files back. Once in about 27 windowless stops on a real Windows computer, a file still grew after the stop returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/windows-apps-compose
…e and reports them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s-apps-compose # Conflicts: # src/agent_env/env/envs/computer/utils/composer.py # src/agent_env/env/envs/computer/utils/windows_disk.py
… error Retrying 30 times, 10 s apart, made a wrong URL take five minutes to fail; a 4xx but a timeout or rate limit now fails the first time, while a server's error, a timeout and a refused connection are still tried again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… granted by named accounts The Windows compose takes an app's folder from its staged layer, as _stage_app already puts it under apps_folder; the well-known SIDs are named and one helper writes a folder's access alone; write() takes its user, build settings and image by name. A test reads what a provision line writes with one helper, and the scripts the Windows bundle's verifiers run inside the computer are checked to be Python, which no linter sees in a string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of FD-5329. Follows #538 (an app's server on Windows), now merged.
A Windows computer can now have apps composed onto it, the same way Linux and macOS computers do. Until now
_composed_windows_diskrefused any app.What changes
Composing apps. Each app becomes a layer of its own in
provision.ps1, underC:\agentenv\apps\<name>, following its[install.windows]:[app]extra (this checkout's source, or the version pinned to this release);.agentenvfolder;The server runs as
venv\Scripts\python.exe -m agentenv_protocol.computer.serve_app <file>:<Class>withENVIRONMENT_NAMEset. Program names come fromgate.programs, as on the other OSes.windows_disk.Partgainsservedandsteps, andwrite()takes the session user.C:\agentenvis now only writable by Administrators, as/opt/agentenvis root's. Until nowC:\agentenvinherited fromC:\the right for every user to change what's under it. The session user, which is what an agent acts as, could therefore edit a driver's or an app's files. After installing every layer, provisioning:This changes every Windows disk's provision script, so a driver-only disk gets a new key and recomposes once.
An app's
.agentenvfolder is the session user's only. The server writes its loopback port and token to.agentenv\server.json. The folder is created with inheritance removed and only the session user, SYSTEM and Administrators granted, soserver.jsongets those permissions the moment it exists. This answers Greptile's token finding on #538, and matches Linux, where only the session user can reach the server's socket.Gate 1 refuses session-scope install steps on Windows. Composing installs each layer over ssh as
agentadmin, so a step meant to run as the session user can't run. Gate 1 refuses such an app with a reason, both when the app env is put against a Windows computer and when it's composed into one. A step limited to other OSes (os="linux") still passes.Where the served class is quoted.
_Layer.servednow holds the raw<file>:<Class>. Each shell command quotes it where it's used: the Linux Dockerfile, the macOS provision script and supervisord/launchd programs. Windows uses it unquoted, as one argv entry. Linux and macOS produce the same text as before.A Windows notes test app in the Windows test bundle. It has:
.ps1run script that records whether it ran elevated;The bundle also gains a
notes-deskenv (notes onwindows-11with cua-driver) and anotestask: deploy, verify, run the session checks, reset, verify.windows_test.pyruns it.The session step runs #538's Windows session inside the computer and checks:
These are the chaos checks that caught #538's three bugs, kept as a regression test.
It lives in the Windows bundle, not the app bundle, because a module fixture plans the app bundle whole. The first CI run composed a Windows env there on the runners, which have KVM: it fetched the 7 GB ISO and hit the 20-minute timeout. The Windows bundle is only run where its media is.
A compose retries a failed download. The provision script's
Fetchnow tries 30 times, 10 s apart, as the base'ssetup.ps1does. During this work, GitHub's release downloads returned 504 for several minutes and failed a compose.Tests
Unit (
tst/unit/env/envsplus the protocol suite: 2112 passed on a Linux box; ruff clean):C:\agentenvlockdown lines;E2E on a Linux box with KVM. Four rounds ran the same task from the app bundle, as it was then. A fifth ran on this PR's head from the Windows bundle (
agent-env run tst/integration/computer/windows --task notes):notes-deskcomposed in 4 min 55 s, gate 3 passed, andbefore: 1, after: 1(85 s), with the chaos below repeated. The fourth round:data/getand exports through cua-driver;before: 1, after: 1).Each round of the verifier saw:
app notesok;.notes.jsonholding the deploy's settings, the secret resolved (-- Ada,t0ken,pro);pythonw.exe/TkTopLevel/Notes;notes.lnk, and that the app launched;run.txtreadingelevated True in C:\agentenv\apps\notes, andinstalled.txtreadingpro;.agentenvandserver.jsonlimited to Administrators, SYSTEM and the session user;pytest tst/integration/computer/windows_test.py -k notespassed on the box in 177 s, withbefore: 1, session: 1, after: 1.Chaos on the deployed desk:
no window with title 'Notes', and launching from the Start Menu shortcut brings it back ready.data/reset: the reset waits out the 10 s stop timeout, ends the job and relaunches the app (new pid), and the computer is ready again.data/addthendata/get: returns the note.C:\agentenv\apps\notesis now Administrators and SYSTEM full control, Users read and run.The first rounds caught three bugs in #538's Windows session, fixed there:
alivewas true for an emptied job.On
modal_vm: the same task (from the app bundle, as it was then) with--sandbox modal_vm. The composed disk deployed on Modal in 130 s, the reset took 57 s, and it passedbefore: 1, after: 1(194 s). Its sandbox was torn down.Agent trial: the Windows bundle's Notepad task, with
C:\agentenvlocked. Its cua-driver desktop recomposed in 3 min 45 s, gate 3 passed, and an agent (Sonnet 5.5) saved the line in Notepad through cua-driver's tools:passed (check: 1), 73.9 s.🤖 Generated with Claude Code


Confidence Score: 5/5
The changes since the last review appear safe to merge.Summary
The PR lets Windows computers compose apps alongside their driver.
The changes since the last review preserve app paths and permission commands while sharing helpers. No new actionable issues were found. No previous review threads were supplied, and no tests were run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Windows base] --> B[Install driver] B --> C[Install each app] C --> D[Create app venv and private folder] D --> E[Run installation scripts and steps] E --> F[Write server and service commands] F --> G[Restrict installed file access] G --> H[Pack disk and probe]Reviews (12) · Last reviewed commit: "refactor(computer): a Windows app's fold..." · Reviewed by Greptile