Repository navigation
feat(terminal): Linux on unkernel; the agent runs commands directly, with no approval prompts - #5
Merged
Merged
Conversation
…on and Node) The Terminal window now boots unkernel (a Linux 7.3 kernel compiled to wasm, npm unkernel 0.2.0-261123-8f039c5) with Alpine 3.24 in a Web Worker, offline, and connects a shell on a pty to the existing xterm.js. v86 stays in place until it is removed in a later milestone. - prepare-terminal.mjs vendors the SDK, the kernel and alpine.erofs from the pinned GitHub release (SHA-256 checked against catalog.yaml and distros.json) into /pc/vendor/unkernel/. - scripts/pc/terminal/prebake.mjs (Node 24, --experimental-wasm-jspi; never in CI) installs the pinned python3 3.14.10-r1 and nodejs 24.22.3-r0, checks both offline, and exports the data disk as a gzipped kwsparse template (39.7 MB, SHA-256 pinned in packages.json). The browser seeds its IndexedDB disk from it. - The page fetches the 4 MB image whole and gives the worker a blob: URL: GitHub Pages gzips byte-range responses for binary files (the range then applies to the compressed bytes), which broke the SDK's lazy Range reads and dropped the guest into its safe mode. - Browsers without JSPI get a clear status message. Checked in Chrome on a server that compresses ranges like GitHub Pages: first boot 3.3 s, 0.86 s after a reload; python3 3.14.10 with sqlite 3.53.4 and node v24.22.3 with no network; a file kept across a reload; the desktop at 60 fps (longest frame gap 17 ms) during a CPU-heavy command.
…vm.exec() The Terminal now runs only on unkernel (Alpine 3.24, aarch64, in a Web Worker, offline). v86 is removed: its prepare stage, Docker recipe, worker, checkpoint code, BIOS and x86 image, and its notices. The site is 777 MB, from 934 MB. - prepare-terminal.mjs downloads the pre-baked Python and Node data disk from the terminal-data-v1 release of this repo (SHA-256 pinned in packages.json and catalog.yaml), so CI needs no pre-bake. The catalog's terminal entry records unkernel's sources and its wasm build command (./setup.sh, from its README at the pinned tag). - Buddy's exec bridge (BroadcastChannel webpc-terminal) answers with vm.exec(): sh -c, python3 -c and node -e, the same request and reply contract, a SIGKILL timeout and the output cap. Code with a NUL is refused as invalid. terminal.status reads the page's state; terminal.save_session is retired (files persist automatically). - One tab owns the disk: a Web Lock on the IndexedDB store. A second tab boots a snapshot copy, says "Not saved: open in another tab", and its writes are not kept; after the owner closes, a restart takes the lock back. - The kernel's boot log no longer prints into the terminal; the header sentence is chips; the 40 MB disk downloads only on first use. - Typed input is held until the shell settles, and xterm's cursor report is passed through on its own: busybox sh drops keystrokes that arrive in the same read as that report (the first 9 or 10 characters of a command typed as the prompt appears). - Restart no longer leaves an empty terminal (the shell attached while a closing flag was still set), and an old kernel exiting late can no longer clear the new one. Checked: unit 1139/1139; the Terminal specs (boot, tools, Ctrl+C, a file kept across a reload, two tabs, the exec bridge) 12/12 over three repeats; the full browser suite 80/81, the one failure a Docs reload test that passed 4/4 when rerun alone.
…del; Enter clears the box - Buddy runs every catalog tool without asking: no approval cards, no taint or repeat-approval tracking, no file write or background-removal confirms. The only rule left is that a cloud model touches Files only inside granted folders. - The Terminal runs Buddy's commands at once through vm.exec(), without the "Another app wants to run this in Linux" prompt. Only the tab that holds the saved disk runs them; a snapshot tab replies not-running. Buddy's exec-cancel stops a run in flight. - A Craft app opened by a tool skips the unsaved-changes confirm; the user's own opens keep it. - Send with no model loaded starts (or joins) the load and sends once the model is ready; the empty box says the message is waiting. Enter clears the box at once and the text comes back only if the send fails before the message reaches the chat. - Tool descriptions and skills no longer tell the model to ask first; the hazard stays as a fact.
Every catalog call now runs on every backend with no policy gate: a cloud model reaches the whole Files store like a local one. policy.mjs and its tests are gone, and createAgent takes no policy. Grants still scope the search index and the image tools' Files paths; the Settings help and the docs say so.
terminal.start opens the Terminal and presses Start Linux; terminal.status names the guest running, starting, stopped, busy or unavailable and, until it is running, says to call system.sleep and check again; system.sleep waits 1 to 30 seconds and stops on Stop. The not-running and no-reply errors point the model at those tools instead of asking the user to press Start Linux. The run-code skill is start, sleep, status, run. Eval task C16 starts from a stopped guest and checks the real uname output through a new terminal_output check.
Every name a person or the model reads says WebPC Agent: the panel and taskbar, the welcome, the page title, help text, the system prompt, tool and skill text, the Terminal's 'Running ... from' line and the Docs change author. Internal ids (ai-agent, data-buddy-toggle, #pc-buddy), file names, storage keys and saved chats are unchanged.
On eval task C16 lfm3-1.7b never reached terminal.run: find_tool returned files.find for 'uname' and the Craft run_command tools for 'run command'. Once found, it ignored the not-running hint and repeated terminal.run, and it put the arguments under the wrong key (query=, arg=lang=sh code=...). terminal.run's purpose, when-text and examples now carry the words people use (shell command, uname, ls), so it ranks first for those searches; it starts a stopped guest itself and waits for it to run; lang defaults to sh. checkArgs now repairs two argument mistakes for every tool: an unknown key whose value spells the tool's own key=value pairs is split into them, and a single unknown key fills a single missing required string or text parameter. C16 now passes 4 of 5 runs (it was 0 of 3).
Asked which network inspection commands the terminal has, the agent searched WebPC's tool catalog and listed the Packet Viewer's packets.* tools; asked again, it listed the terminal.* tools. The agent rules now say that anything inside Linux (its commands, programs, packages, files or versions) is answered by running a shell command with terminal.run; a new terminal skill, List what is installed in Linux, runs ls /bin /sbin /usr/bin /usr/sbin; terminal.run gains an example worded like these questions, so find_tool ranks it first for 'network inspection commands'. The run-code skill is now the single terminal.run step, since terminal.run starts a stopped guest itself. A copied <key> placeholder on a parameter with a default now takes the default. New eval task C17 checks the real output: 3 of 3 runs pass with lfm3-1.7b (0 of 3 before).
…atus The agent app posts its counts (0, 0) in the same step that enables New chat; on a slow run that post landed after the spec's fake ones and reset the button's label. The spec now waits for New chat to be enabled before posting. 15 of 15 with --repeat-each=3.
…minal The agent's runs are separate vm.exec() sessions, so the user saw only the status line. Each finished run now draws a block into the xterm above the user's prompt: a cyan 'WebPC Agent $ <command>' header (python and node show at most 6 code lines), the output (at most 200 lines, with a note that the agent got all of it) and a dim footer ([exit N · M ms], [timed out], [cancelled] or [error: ...]). The prompt row and cursor column are restored in the same write; nothing reaches the pty, so the shell keeps working.
…if confirmed The close button refused outright when an app's pcBeforeClose() returned false (unsaved Craft and Docs edits, a Files upload in flight), with only a screen-reader announcement. It now asks '<App> has changes that are not saved. Close it anyway and lose them?': OK closes, Cancel keeps the window and says so. Windows with nothing unsaved close as before; the agent's desktop.close still refuses unless forced. Checked on the real GridCraft and DeckCraft after an edit through their own APIs.
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.
The Terminal runs Linux on unkernel instead of v86: Alpine 3.24 in a Web Worker, with Python 3 and Node.js offline, and files kept in the browser. The assistant, renamed from Buddy to WebPC Agent, runs its commands there directly through
vm.exec()and starts Linux itself when it is stopped. Buddy no longer asks for approval on any tool call and has no policy gate left, Send loads the model when none is loaded, and Enter clears the box at once.What changes
Terminal on unkernel (pinned
unkernel@0.2.0-261123-8f039c5)terminal-data-v1, 39.7 MB, SHA-256 pinned inscripts/pc/terminal/packages.json).prepare-terminal.mjsdownloads it and checks the hash. The guest has no network.blob:URL.public/third-party/terminal/. The catalogterminalentry gets unkernel's realwasm.buildcommand.The agent starts Linux and runs commands directly
WebPC Agent $ <command>line, the output (at most 200 lines; the agent gets all of it) and a dim[exit N · M ms]footer, drawn above the user's prompt, which comes back as it was. Nothing is typed into the user's shell.terminal.startopens the Terminal and presses Start Linux;terminal.statusreports running, starting, stopped, busy or unavailable, and until the guest is running says to callsystem.sleep(1 to 30 s, stopped by Stop) and check again. The not-running error now names those steps instead of asking the user to press Start Linux.terminal.runstarts a stopped guest itself and waits for it, because a small model does not follow that hint (LFM3 calledterminal.run14 times in a row). Its description now uses the words people search with (shell command, uname, ls), sofind_toolranks it first for "uname" and "run command" instead offiles.findand the Craft apps'run_command;langdefaults tosh.terminal.run, and a new skill, List what is installed in Linux, runsls /bin /sbin /usr/bin /usr/sbin. The run-code skill is oneterminal.runstep.key=valuepairs is split into them (arg=lang=sh code=uname -a), and a single unknown key fills a single missing required text parameter (query=uname -abecomescode); a copied<key>placeholder on a parameter with a default takes the default.terminal.runwithsh,pythonornoderuns as onevm.exec()call and returns the output and exit code. The old path typed base64 into the v86 serial console and read the screen back between markers.not-running. Buddy's Stop, New chat and its wall timer cancel a run in flight. The output cap (64 KiB), the timeout and the busy reply are unchanged.No approval prompts (the user's ruling: "remove all of them", "remove approvals for ALL tool calls")
policy.mjs): a cloud model reaches the whole Files store like a local one. Grants still scope the search index and the image tools' Files paths.Closing an app with unsaved changes
Buddy is now WebPC Agent
ai-agent,data-buddy-toggle,#pc-buddy), file names, storage keys and saved chats are unchanged.Send and the message box
How it was checked
Source: this branch, 11 commits on main 32a6f2f (
6a00896,922d6d3,dd37919,7a9dec7,9fed56e,2d83bd9,309cbd0,cd764e9,90cdc6c,76e2213,cde4075).node --test tests/*.test.mjs: PASS, 1152/1152 oncde4075(the 10 policy tests went with the policy; the start, sleep, auto-start, argument-repair and eval-check tests are new).npm run build: PASS, dist 777 MB (was 934 MB with v86; budget 990 MB).npx playwright test --config scripts/qa/playwright.config.mjs): PASS, 84/84 on the final tree (cde4075). The taskbar status spec raced the app's own first status on a slow run; it now waits for it (15 of 15 with--repeat-each=3).pc-terminal-exec.spec.mjs, which includes the two-tab case, also passed 3 of 3 runs alone.node scripts/agent/eval.mjs --model lfm3-1.7b --set A --limit 3: 3/3, median 6.4 s (A03 writes a file, which no longer needs an approval click).unameoutput): 4 of 5 runs pass with lfm3-1.7b, 8 to 17 s each; the fifth answered without calling a tool. Before the search and repair fixes it was 0 of 3.which ping ip netstat nslookup wget nc); 0 of 3 before.terminal.start,system.sleepandterminal.statustwice,terminal.run): from a stopped guest toLinux unkernel 7.3.4+ ... aarch64 Linuxin 9 s, no page errors.uname -a; the terminal showed theWebPC Agent $ uname -aline, the output and[exit 0 · 5 ms], then the~ $prompt (screenshot read). The spec checks a marker built only by the output, the prompt row, and that a command typed afterwards still runs.cell.setand DeckCraft afterslide.new(their own APIs) each reported unsaved changes; Cancel kept the window, OK closed it; Media Player closed with no warning.Not run: a cloud model (no key on this machine; the runtime no longer knows the backend, and the unit suite covers the Files calls), Firefox and Safari (unkernel needs JSPI; only Chrome was tested), a physical phone, and the eval beyond the first 3 tasks of set A.