Overview
The Terminal API provides persistent PTY-based terminals on the Allternit Factory pane engine. Each terminal session is a real shell process owned by the pane engine: it survives API restarts and UI reconnects, replays its scrollback (the last 2 MiB) to every new stream, and reports its exit code. A terminal is a pane like any Factory agent pane: it shows in the agent wall asterm-<session_id>, and an agent started in it is detected there.
Base URL
Authorization header. See Authentication for details.
The API reaches the pane engine over its Unix domain socket (on Windows, a named pipe: \\.\pipe\ followed by the path ensure reports). It finds the socket with allternit-factory pane tty ensure, which also starts the pane engine when it isn’t running. To check terminals on Windows against a released Desktop installer, run the windows-terminal-smoke.yml workflow (gh workflow run windows-terminal-smoke.yml -R Allternit/allternit-platform). ALLTERNIT_FACTORY_BIN names the binary (default: allternit-factory next to allternit-api, then on PATH; Allternit Desktop sets it), and ALLTERNIT_FACTORY_PANE_SOCKET names the socket directly. See allternit-mux (folded into the Factory) for the socket methods.
Endpoints
Create terminal
command runs that program (with args) instead of the shell, and shell is then ignored. env is added to the terminal’s environment over the fixed TERM=xterm-256color and COLORTERM=truecolor; a key that is empty or contains = or a NUL character returns 400. title is the terminal’s name in the agent wall and in the list.
If shell is empty, or is an absolute path that doesn’t exist on that computer (zsh on a Linux cloud computer, for example), the terminal runs that computer’s $SHELL, else bash, else its default shell, instead of failing with ENOENT. On Windows an empty shell or any Unix path runs PowerShell. The app asks for /bin/zsh and, if an older server still answers ENOENT, asks again with an empty shell.
Response:
List terminals
preview is optional: when set (clamped to 1-40), each terminal also carries the last N rows of its visible screen as plain text (ANSI stripped).
pane_idis the pane engine’s id for the terminal’s pane (the id the Factory agent wall shows). Use it to match an agent-wall pane to its terminal. It isnullwhen the engine reports none.titleis thetitlegiven at create, else the terminal’s own title (set by the program running in it), else the last folder ofcwd, elseTerminal.cwdis the live working directory from the terminal’s pane, else the one it was created with.commandandcreated_atare known only for terminals created through this API since it started; for otherscommandis[]andcreated_atisnull.previewis left out for a terminal whose pane could not be read in time. That never fails the list.- Errors:
503when the pane engine cannot be reached.
Send input
Resize terminal
Close terminal
Stream output
text/event-stream. The server first replays the kept scrollback, then streams live output. Ping events are emitted every 15 seconds when no output is available.
Example event:
EventSource doesn’t reconnect and replay the scrollback again. Clients that don’t know the exit type ignore it.
exit_code is null when the pane engine couldn’t read it.
Cloud computers
On a cloud computer (or a Mac runningallternit-node with Desktop quit), the same routes reach the computer’s allternit-node daemon through the runtime relay. It serves them in one of two ways:
- Pane engine (the computer’s
allternit-factory pane serveranswers): the same service and JSON as on Desktop. Terminals survive anallternit-noderestart,/terminal/listreturns titles,previewrows andpane_id, create takescommand/args/env/title, andclosetakes{"graceful": true}. - Fallback (no pane engine on the image, for example Orgo, headless or older images): the node runs the terminals itself. Create takes the same body, and
/terminal/listreturns them withpane_id: nulland nopreview. These terminals end whenallternit-noderestarts, and a graceful close is a plain close.
/terminal/list on a cloud computer also returns a top-level engine field that says which one is serving:
engine is "pane" or "missing". The node never starts the pane engine. While none has answered, it checks again at most every 30 seconds. See cmd/allternit-node/README.md for the socket paths it checks.
Browser computer
The browser computer (see Browser computer) does not use these endpoints. Its Terminal attaches to the pty inside the browser tab, so there is no server websocket and no session on the pane engine. It does not appear in/terminal/list.
Error codes
Input and resize on a terminal whose shell already exited succeed and do nothing, as typing into a closed terminal does. Close always succeeds.