Repository navigation
feat(computer): run a computer app's server on Windows - #538
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>
…, 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>
…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>
…not while the job is there Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
E2E on a real Windows 11 computer: the notes app composed onto
With those fixes, running inside the computer as the session user:
Through the app's server:
Gate 3's full probe and the deploy, verify, reset, verify task pass. Details are in the core PR. |
… 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>
…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>
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.
An app's own server (
serve_app) now runs on Windows. Composing apps onto a Windows computer comes in the core PR stacked on this one.What changes
Transport (
served.py). On Linux and macOS, an app's server listens on the Unix socket in its folder, as before. Windows asyncio can't serve a Unix socket, so there the server:.agentenv/server.json, atomically;x-agentenv-app-tokenheader, and removes the header before the app sees the request.Everything that reaches an app picks its route the same way:
served(folder)checks whetherserver.jsonexists. That coversapps,svcforward and relay,launchand the page driver. Clients skip any proxy set in the environment (trust_env=False, websocketsproxy=None).svcdrops a token header that came from outside, so the token can't be forged.Session (
session.py→_session_posix.py|_session_windows.py).session.pyis now a facade that imports the module for the current OS. The POSIX module is the oldsession.py, moved withgit mv; only its exit bookkeeping changed. On Windows:_job.py, a stdlib-only helper (python -I -S). The helper creates a Job object named for its own pid, with KILL_ON_JOB_CLOSE, joins it, and then starts the app, so the app and everything it starts belong to the job. It reportsstarted, or why it couldn't start the app. It exits only when the job holds nothing but itself, and exits with the app's code. As on POSIX, the app outlives the server that launched it, and a restarted server finds the job by its name.data/get): NtSuspendProcess on each process in the job except the helper, resumed on the way out, even if the block raises.Launch.windowmatches against on Windows..lnk, written with PowerShell'sWScript.Shell.Exit bookkeeping (
_reaping.py). The exit-code tracking both session modules use. It reaps withcommunicate(), so a launch's pipes close together with the process.Declaring a Windows app (
app.py). New@windows(...)decorator andWindowsmodel: files, python, downloads,.ps1run scripts, services, ports. Windows-only constants:LAUNCHEDsits under the temp dir andAPPSisC:/agentenv/apps.Why these choices
These are the six W2.1 decisions, as agreed:
data/get, the Windows counterpart of SIGSTOP.Launch.window's fields and give each one its Windows meaning.Tests
test_computer_served.py:test_computer_svc_forward.pyruns over both transports and checks that a forged token header is dropped.test_computer_session_windows.pyfakes Win32 and checks:test_computer_serve.pyserves on loopback through the real uvicorn path.main, so it isn't from this change.The real Win32 path (
_job.pyand_Win32) runs end to end on a Windows computer in the core PR's e2e (notes plus cua-driver: probe, reset, chaos). I'll post the results here.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge with PR #540 providing the required private token-folder permissions.Summary
Adds Windows app servers over token-protected loopback connections and a Windows session backed by Job objects.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Driver[Driver or launcher] --> Route{App server transport} Route -->|Linux or macOS| Socket[Unix socket] Route -->|Windows| Guard[Loopback token check] Guard --> Server[App server] Socket --> Server Server --> Session{Session} Session -->|Windows| Helper[Job helper] Helper --> App[App and child processes]Reviews (7) · Last reviewed commit: "fix(computer): a Windows app's stop wait..." · Reviewed by Greptile