Skip to content

feat(terminal): Linux on unkernel; the agent runs commands directly, with no approval prompts - #5

Merged
codemug merged 11 commits into
mainfrom
feat/terminal-unkernel
Nov 26, 2026
Merged

codemug merged 11 commits into
mainfrom
feat/terminal-unkernel

Conversation

@codemug

@codemug codemug commented Nov 25, 2026

Copy link
Copy Markdown
Owner

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)

  • Linux 7.3 compiled to wasm runs in a worker, so the desktop stays at 60 fps while a command runs. No cross-origin isolation is needed.
  • Python 3.14.10 and Node v24.22.3 come pre-baked on the starting data disk, which is a release asset (terminal-data-v1, 39.7 MB, SHA-256 pinned in scripts/pc/terminal/packages.json). prepare-terminal.mjs downloads it and checks the hash. The guest has no network.
  • Files persist in IndexedDB. One tab owns the saved disk through a Web Lock; a second tab runs a copy in memory and shows a "Not saved" chip.
  • The header is chips; the RAM and storage detail moved into Help. The boot log no longer prints into the shell.
  • Two shell fixes: Restart no longer leaves an empty terminal, and keys typed while the shell starts are held and sent together, so the first command keeps its opening characters.
  • GitHub Pages gzips byte-range responses for binary files, which breaks the SDK's lazy reads, so the Terminal fetches the guest image whole and hands the worker a blob: URL.
  • v86 is removed: its Docker recipe, BIOS files, worker, checkpoint code, catalog sources and notices. The unkernel licences and the Alpine package notice are in public/third-party/terminal/. The catalog terminal entry gets unkernel's real wasm.build command.

The agent starts Linux and runs commands directly

  • Each command the agent runs is shown in the terminal once it finishes: a cyan 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.start opens the Terminal and presses Start Linux; terminal.status reports running, starting, stopped, busy or unavailable, and until the guest is running says to call system.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.run starts a stopped guest itself and waits for it, because a small model does not follow that hint (LFM3 called terminal.run 14 times in a row). Its description now uses the words people search with (shell command, uname, ls), so find_tool ranks it first for "uname" and "run command" instead of files.find and the Craft apps' run_command; lang defaults to sh.
  • Questions about what Linux has are answered from Linux. Asked which network inspection commands the terminal has, the agent used to list WebPC's Packet Viewer tools; the agent rules now say that anything inside Linux (commands, programs, packages, files, versions) is answered by running a command with terminal.run, and a new skill, List what is installed in Linux, runs ls /bin /sbin /usr/bin /usr/sbin. The run-code skill is one terminal.run step.
  • Argument repair for every tool: an unknown key whose value spells the tool's own key=value pairs is split into them (arg=lang=sh code=uname -a), and a single unknown key fills a single missing required text parameter (query=uname -a becomes code); a copied <key> placeholder on a parameter with a default takes the default.
  • terminal.run with sh, python or node runs as one vm.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.
  • Only the tab that holds the saved disk runs Buddy's commands; a snapshot tab replies 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")

  • Buddy runs every catalog tool without asking: no approval cards, no extra checks after it reads web or file content, no confirm before a file write or a background-removal save.
  • The Terminal runs Buddy's commands without the "Another app wants to run this in Linux" prompt.
  • When a tool opens a file in a Craft app with unsaved changes, the unsaved-changes confirm is skipped; the user's own opens keep it. Buddy's tools do not reach the other Craft confirms (the overwrite prompt in the Files copy and the Docs replace prompt), so those stay as they are.
  • Tool descriptions and skills no longer tell the model to ask first; each keeps the hazard as a fact (what is replaced, how to undo it).
  • The cloud-model Files grant rule is gone too, and with it the policy layer (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

  • The close button used to refuse silently when an app had unsaved changes (Craft apps, Docs, a Files upload in flight). It now asks " has changes that are not saved. Close it anyway and lose them?": OK closes, Cancel keeps the window. Windows with nothing unsaved close as before.

Buddy is now WebPC Agent

  • Every name a person or the model reads says WebPC Agent: the panel and taskbar, the welcome, the system prompt, help text, 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.

Send and the message box

  • With no model loaded, Send or Enter starts the load (or joins one already running) and sends the message once the model is ready. While it waits, the empty box says "Your message sends when the model is ready…". A failed load shows its error and puts the text back.
  • Enter clears the box at once. The text comes back only if the send fails before the message reaches the chat.
  • Send is enabled whenever the box has text and the chat is idle, so the eval runner and the specs now wait for the model state ("Ready") instead of an enabled Send.

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 on cde4075 (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).
  • Full browser suite on the production build (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.
  • Real model (LFM3 on WebGPU, Chrome, a local preview): with Linux running and no model loaded, "Use the terminal to run this Python code and tell me the output: print(6*7)" plus Enter cleared the box at once, showed the waiting placeholder and started the load. Once the model was ready the message sent, the Terminal showed "Command finished · exit 0 · 923 ms" with no prompt, and Buddy answered 42. No approval card appeared at any point and there were no page errors.
  • Eval: 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).
  • Eval task C16 (new: "Run uname -a in the Linux terminal" with Linux stopped, checked by the real uname output): 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.
  • Eval task C17 (new: "What network inspection commands does the Linux terminal have?", checked by the real output): 3 of 3 runs pass with lfm3-1.7b, 15 to 16 s each (the agent ran which ping ip netstat nslookup wget nc); 0 of 3 before.
  • The start flow against the real Terminal with a scripted model (terminal.start, system.sleep and terminal.status twice, terminal.run): from a stopped guest to Linux unkernel 7.3.4+ ... aarch64 Linux in 9 s, no page errors.
  • Terminal measurements from M1, on a server that gzips byte ranges like GitHub Pages: first boot 3.3 s, 0.86 s after a reload; Python and Node ran with no network; a file survived a reload; the desktop held 60 fps during a 3.7 s CPU-heavy command.
  • The agent's runs in the terminal: a scripted agent ran uname -a; the terminal showed the WebPC Agent $ uname -a line, 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.
  • The close warning on the real apps: GridCraft after cell.set and DeckCraft after slide.new (their own APIs) each reported unsaved changes; Cancel kept the window, OK closed it; Media Player closed with no warning.
  • Renamed panel opened and read at 1440x900 light and dark and 390x844 light: no horizontal or header overflow, no page errors.
  • No en or em dashes added.

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.

…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.
@codemug
codemug merged commit 950ece0 into main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant