Eve Server
eve, runs on a workstation and on a server: it executes scripts, receives commands from scripts and from other machines, serves web pages and data over HTTP, and offers an API to AI assistants. This chapter shows how a machine is set up, how it is controlled from far away, how it serves HTTP with service scripts, and how two projects, a client and a server, work together.
plan/design-service.md of the Eve repository.The Eve Machine
There is one Eve machine, the program eve, and it has one mode. It starts locally, on the computer of the user, or remotely, on a server; in both places it is the same program with the same commands. What a machine does depends only on the commands it receives and on its configuration.
- A local machine runs scripts, answers the prompt
eve:>, and may serve web pages onlocalhost; - A remote machine is an
evethat listens on a port: it waits for commands, runs uploaded projects, schedules drivers and serves HTTP to other computers; - A machine talks to another machine by sending it commands and reading the answers.
The parts of eve
eve is one program with one version, but inside it has four parts. The first word after eve chooses one; without such a word, eve works as in the rest of this page:
| Part | Command | Does | Example |
|---|---|---|---|
| runtime | eve vm, or plain eve | runs scripts, the prompt, the machine and its IPC door | eve sales.eve, eve --listen |
| compiler | eve cp | checks, documents and compiles; makes projects; runs nothing | eve cp --check sales.eve |
| database | eve db | the database commands, the stored procedures, the database door | eve db proc list |
| UI | eve ux | the web door, the Workbench, AI agents | eve ux start |
A direct command, such as eve sales.eve, uses the parts it needs inside its own process and ends. A machine that stays active is described in The serving machine. In the Eve repository, ./run.sh evevm, evecp, evedb and evewp are shortcuts for these four commands, and you can write your own start scripts with the options your project needs.
Command channels
A machine is driven by commands: load, run, check, doc, serve, setup and the others listed in Commands. The same commands arrive through several channels, and a command gives the same answer whatever its channel:
| Channel | Example | What happens |
|---|---|---|
| Execute a file | eve -x sales.eve | a new machine parses and executes the script, then exits |
| Prompt | eve, then eve:> load sales.eve | the machine waits for commands typed by a person |
| Command | eve -c "run sales.eve" | the command is sent to a running machine, which answers |
| Another machine | send prod "run sales.eve" | a machine sends a command to another machine |
| AI assistant | eve --api | the commands become tools of an MCP server (see Eve API for AI) |
Commands from scripts
A shell script or a Python script controls a running machine with eve -c. Each call sends one command, prints the answer and ends with the exit status of that command. A sequence of commands is a sequence of calls to the same machine, which keeps its state between them:
eve --listen & ** start a machine that waits for commands eve -c "load sales.eve" ** first command eve -c "run sales.eve" ** a new command, same machine, same state eve -c "report" eve -c "stop" ** the machine ends
# drive an Eve machine from Python
import subprocess
for command in ["load sales.eve", "run sales.eve", "report"]:
result = subprocess.run(["eve", "-c", command], capture_output=True, text=True)
print(result.stdout)
if result.returncode != 0:
break
Machine Setup
A machine is its configuration, and its configuration lives in a folder: the machine folder. Without any configuration, eve still works: the default values are built in, and it does its best to execute the command.
Machine folder
eve --setup <folder> (short -e) chooses the machine. If the folder holds a configuration, the machine reads it. If not, --setup creates the folder, the configuration file eve.cfg and the sub-folders: a new machine, named after the folder, with the default values and ports that are free on this computer.
eve --setup ./evemachine/local ** creates the machine "local", or reads it eve --setup ./evemachine/server --listen ** creates or reads "server", then starts it
| Item | Content |
|---|---|
eve.cfg | the configuration of the machine |
web/ | the pages that serve returns: HTML, CSS, images, WebAssembly |
out/ | output: run logs, files written by drivers, the checksum of the configuration |
data/ | input data |
lib/, asp/ | modules and aspects of the project |
A machine folder is a project folder: the drivers, aspects, modules and services of one project, and the one machine that runs them. Another project is another machine.
Configuration
The configuration file holds system variables, one per line. Every value has a default built into eve:
| Variable | Meaning | Default |
|---|---|---|
$EVE_NAME | the label of the machine, used by people, logs and remote commands | the folder name, or eve |
$EVE_DOMAIN | where the machine lives: localhost, a domain name or an IP address | localhost |
$EVE_PORT | port for commands, uploads and data | 4042 |
$EVE_HTTP_PORT | port of serve, for HTML | 8042 |
$EVE_WEB | folder of the pages that serve returns | web |
$EVE_OUT | output folder | out |
$EVE_TOKEN | the secret a remote client must present | none: only local commands |
Identity
The identity of a machine is its address, domain and port: localhost:4042, etl1.example.com:4142. Two programs can't use the same port on one computer, so the address is unique. $EVE_NAME is only a label.
- Start:
--listenor--servefirst checks that the domain and the ports are free. If one is taken, by another machine or another program,eveends with an error; - Checksum: when a machine reads its configuration, it keeps a checksum of the file outside the file, in
out/<name>.sum, and never writes intoeve.cfg. So the file can be kept under version control; - Changes: a running machine reads its configuration again on the command
setup. It applies the changes without a restart, as long as its identity stays the same. A new domain or port describes another machine, which is started on its own.
Client and server projects
A client/server application is two projects, a client and a server, each with its machine. They can stay in the same repository, with the README at its root:
sales_app/ ** one repository
README.md ** what the application does, how to start both machines
client/ ** project and machine "client"
eve.cfg ** localhost:4042, serve 8042
sales_load.eve ** driver: reads files, sends batches to the server
asp/ lib/ data/ out/ web/
server/ ** project and machine "server"
eve.cfg ** etl1.example.com:4142, serve 8142
orders_api.eve ** service
asp/ lib/ data/ out/ web/
To test on one computer, both machines use localhost with different ports. In production, the configuration of the server names its domain.
Remote Control
A machine that listens on a port can be controlled from far away: by a script, by a person at the prompt of another machine, or by another machine.
Listening
eve --listen (or eve:> listen) starts a machine that stays active and accepts commands on $EVE_PORT, 4042 by default. It keeps running until it receives stop. It binds to $EVE_DOMAIN, which is localhost unless the configuration names another address, and a remote client must present the token $EVE_TOKEN.
Doors: IPC and HTTP
A machine is a singleton: it is identified by its domain and its port, and on one port there is only one machine. On localhost a second machine may run on another port. A machine has two doors to the same virtual machine, and you choose which ones to open:
| Start | IPC door | HTTP door | Use |
|---|---|---|---|
eve --listen | yes | no | the commands of this computer, with no web at all |
eve --serve | no | yes | the pages of the web folder, and scripts sent over HTTP |
eve --listen --serve | yes | yes | both: the CLI uses IPC, the browser and the remote machines use HTTP |
The IPC door is a Unix socket named from the domain and the port, and the CLI that finds it gets its answer at once. Both doors speak JSON-RPC 2.0, one message per line on IPC and in POST /rpc on HTTP, so a command is the same on both. The machine prints what it opened and stays active:
$ eve --listen --serve eve: ipc localhost:4042 eve: http http://localhost:8042
If a machine already runs on that address, the second start fails with eve: already running and the exit code 75. The two doors take the same words: start (the default), stop, restart and status. eve --listen stop and eve --listen status speak to the machine through its IPC door only; eve --serve stop and status try the IPC door, then the web door:
$ eve --listen status machine: localhost ipc=4042 http=8042 ipc: listening http: listening runs: 3 $ eve --listen stop eve: stopped
The ports come from eve.cfg (ipc_port, http_port). A second machine on the same computer has its own file: eve -e second.cfg --listen.
Two options say where a command goes. -loc (--local) is local and never touches the network: with a machine on the IPC door the script runs there, and without one the command starts a new machine inside the process, runs, and exits. -rem (--remote) sends the command to the HTTP door of another machine, and it fails with the exit code 69 when nobody answers; it never falls back to a local run. A command with neither option is local, and eve -x file.eve alone is the fast way to run a script: it looks for no IPC socket and no HTTP port, and executes the file at once in its own process. The two client options have three letters, so they read as words: -loc local, -rem remote.
eve -loc -x report.eve ** local: IPC if a machine listens, else by itself eve -rem etl1.example.com:8042 -x report.eve ** remote: the script is sent as text over HTTP eve -rem etl1.example.com:8042 --serve status
The machine runs one script at a time, each in a session of its own. The output of the script comes back to your terminal, an error that nobody recovers comes back on the error output, and the exit code of eve is the exit code of the script. The normative rules are in spec/library/machine.md of the specification.
The serving machine
A machine that stays active is one process. Its parts run inside it side by side, as tasks, and call each other directly, never through a socket. A part becomes active when its door opens, or when another part needs it: a script that opens a database wakes the database part. Each part has its own door to the outside world:
| Part | Door | Speaks |
|---|---|---|
| runtime | IPC, the socket of --listen | the machine API, vm.* |
| database | IPC, a socket of its own | the database API, db.* |
| UI | HTTP and WebSocket; ACP | pages and POST /rpc for the browser; the Agent Client Protocol for AI agents (AI agents) |
Scripts run in sessions. A session has its own interpreter and its own memory, so two sessions never share a value. At first the machine runs one script at a time; several sessions at once come later. On a serving machine the database part owns the database files of the project: eve -x still opens them in its own process, and eve -loc -x sends the script to the machine, which opens them for it.
The machine API
The JSON-RPC methods of a machine are named by their part: vm. for the runtime and db. for the database. The methods ping, status, run and stop that the machine answers today are the first names of vm.ping, vm.stat, vm.run and vm.stop:
| Method | Does |
|---|---|
vm.ping, vm.stat | is the machine there; its doors, parts, sessions and runs |
vm.run | runs a script and returns its exit code, output and errors |
vm.eval | evaluates an expression or a statement in a session that stays open: the prompt over the wire |
vm.suspend, vm.resume | stops a session at its next statement, and lets it go on: the debugger |
vm.inspect | the variables or the stack of a session |
vm.cancel, vm.stop | ends a run; ends the machine |
db.query, db.execute, db.call | direct SQL; an Eve stored procedure of proc/ (Eve procedures) |
db.proc.list, db.proc.reload, db.stat | the stored procedures; the connections and transactions |
$ echo '{"jsonrpc":"2.0","id":1,"method":"vm.stat"}' | curl -s -d @- http://localhost:8042/rpc
eve vm, cp, db and ux, and the methods vm.ping, vm.stat, vm.run and vm.stop work, with their first names ping, status, run and stop (test e95_test4). The serving machine with its parts in one process, the other methods and db.* are decided (D-163 to D-165) and not implemented yet.Sending commands
eve -c <command> (or --command) sends one command to the machine of the configuration and prints its answer. -rem (--remote) names another machine, by its address or by a name defined in the configuration:
eve -s ./evemachine/server -c "run sales.eve" ** the machine of that folder eve -c "run sales.eve" -rem etl1.example.com:4142 ** a remote machine by address eve -c "run sales.eve" -rem prod ** a remote machine by name
A machine can do the same: it keeps one connection to each partner and sends them commands, on different ports and domain names. At the prompt: eve:> send prod "report". The first version of the protocol is plain: one command per line, the same text as at the prompt; the answer is the text the prompt would show, followed by the exit status.
Login and credentials
One local machine works with many remote machines at once, and enters each one with its own credentials. A person logs in once per machine, preferably by single sign-on: the browser shows the page of the identity provider of the company, the person signs in there, and the remote machine receives a proof of identity, never the password. A machine without single sign-on has its own accounts, with a user name and a password. Scripts and schedules use the token of a machine, $EVE_TOKEN, as before.
The local machine names its remote machines in its configuration, with the way to log in to each, and never a secret:
machine prod at "etl1.example.com:4042" login sso machine etl2 at "etl2.example.com:4042" login password machine test at "localhost:4142" login token
After the first login, the local machine keeps the credentials that the remote machine gave back in the keyring of the operating system: the Credential Manager of Windows, the Secret Service of Linux. The keyring is opened by the login of the person on the computer, so the next connection needs no form. The password itself is never stored.
eve:> login prod ** first time: the single sign-on page opens in the browser eve:> whoami prod ** ana, developer, single sign-on eve:> send prod "report" eve:> logout prod ** ends the session and deletes the stored credentials eve:> forget prod ** deletes the stored credentials only
Users and roles live on each remote machine, in its core database: the same person can be a developer on one machine and only read on another. The admin of a machine manages its users with commands, from the prompt or from the dashboard of the Eve Web Portal.
Upload and run
eve -u <file> (or --upload) sends a source file to a machine, like a load on that machine. The remote machine compiles the file itself, under its own rules, and keeps it for the next commands:
eve -u sales_load.eve -rem prod ** upload: the remote machine compiles it eve -c "run sales_load.eve" -rem prod ** run it there eve -c "dismiss sales_load.eve" -rem prod ** free its memory
Sessions
One machine has one state, shared by all the commands it receives. Two independent sessions in parallel are two machines, with two configurations. Inside a machine, every driver has its own driver memory space (DMS): its globals, its modules and the state of its aspects.
load sales.evecreates the DMS of the driver. It stays untildismiss sales.eve, so a secondrunsees what the first one left: open connections, caches;run other.evefor a driver that is not loaded creates a temporary DMS, runs the driver and frees the DMS at the end;- A machine can hold several loaded drivers; they never see each other's memory.
Rules of a remote machine
Code received by a machine runs under the rules of that machine. A machine that listens is stricter than a person at the prompt:
| Rule | At the prompt or eve -x | Listening machine |
|---|---|---|
| Console | print and read work | print goes to the log; read is an error |
panic | at the prompt: back to the prompt; with eve -x: the process ends, exit code 1 | ends the request or the job; the machine goes on listening, and eve -c ends with exit code 1 |
halt, debug mode | allowed | never |
Shell (call) | allowed | only if the configuration allows it |
| Files | any path the user can open | only the folders of the machine |
| Network, databases | any | only those listed in the configuration |
Serving HTTP
eve:> serve (or eve --serve) starts an HTTP server inside the machine, at http://localhost:8042 by default ($EVE_HTTP_PORT). The prompt stays usable while the machine serves, and serve stop ends the HTTP server.
Static pages
Without any code, serve returns the files of the web folder: a request for /reports/today.html returns web/reports/today.html. A driver that writes an HTML report into web/ publishes it at once to every browser that can reach the machine.
The web folder is the frontend of a single page application: index.html at the top and the folders css/, js/ and img/ under it, in plain HTML, CSS and JavaScript, while the backend is written in Eve. The first page of the test e95_web_hello is only this: web/index.html says Hello World and This is Eve, and a JavaScript test fetches / and looks for the text. The type of a file comes from its extension; a path outside the web folder, eve.cfg for example, is 404. The port and the folder are set in eve.cfg: http_port = 8042 and web = "web".
Services
A service is a script that answers requests. It is a fourth kind of script, next to driver, aspect and module. It has no process main: it declares routes. A route joins an HTTP method and a path to the code that answers. Every request gets a new state, so two requests never share variables. A service has the shape of a module: declarations, initialize and finalize, closed by end name;.
A route has two forms. The block form holds the code that answers, with the request and the response as its parameters:
# orders service
service orders_api is
from "lib" use (orders);
route get_order(req: Request, @res: Response) on get "/orders/{id}" is
new o := orders.find(req.params["id"]);
if o == null do
let res.status := 404;
else
let res.body := o.json();
done;
end get_order;
route create_order(req: Request, @res: Response) on post "/orders" is
new id := orders.create!(req.json());
let res.status := 201;
let res.body := {"id": id}.json();
end create_order;
initialize
orders.connect($ORDERS_DB);
finalize
orders.disconnect();
end orders_api;
The one-line form names an aspect, written in its own file, that answers the request. The same aspect can also be applied by a driver:
route get "/orders" apply list_orders;
Notes
- The method is any HTTP method:
get(read),post(create),put(replace),patch(change a part),delete; - A path starts with
/, so it is a regex literal (see Regular Expressions): it keeps its text as written,{id}is a route parameter and never a placeholder. A route given as a regular expression is possible for the same reason; its rules are not designed yet; {id}in the path becomesreq.params["id"]; the body of apost,putorpatchisreq.body, andreq.json()reads it as a DataMap;- The routes of a service run in parallel, one per request. A request that waits for a database gives its core away;
- The private state of a service is shared by all requests: it follows the rule of modules, written in
initializeand then only by unsafe methods (!). Most services keep their state in a database; - An error that a route does not recover becomes the response
500; the message goes to the log, not to the browser.
Service Mode
Until now you ran eve in a terminal (the command line and the prompt) or in a window (eve -ux, eve -tx). A server has no one at the keyboard. eve -s starts the machine as a service: no prompt, nothing written on the screen, the doors of eve.cfg open, and a log file to read later. On Windows it is a service of the system; on Linux it is a daemon.
eve -s ** the machine starts in a process of its own, silent; the command ends with status 0
eve -s eve.cfg ** the same, with this configuration file
eve --serve status ** the machine answers: ipc and http are listening
eve --serve stop ** stop it (also: sc stop eve, kill -TERM, systemctl stop eve)
A word after -s that ends in .cfg is the configuration file of the service. -s means the service and nothing else: to give a configuration to a script or a command, write -e (eve -e eve.cfg check a.eve). Two files tell you what the service did: <runtime>/eve-localhost-4042.log (the doors, one line for each request, the stop) and eve-localhost-4042.pid (the number of the process, for an init system).
| You start it | What runs |
|---|---|
eve -s in a shell or a console | a new process, detached from the terminal; the command waits until the door answers and ends silent. A second eve -s says already running (status 75) |
| the Windows Service Control Manager | the process itself is the service: sc create eve binPath= "C:\eve\bin\eve.exe -s C:\eve\eve.cfg" start= auto, then sc start eve |
EVE_SERVICE=foreground eve -s | the process is the machine, in the foreground: for a container or a systemd unit of Type=simple; it ends on SIGTERM |
| systemd, the plain form | Type=forking, ExecStart=/opt/eve/bin/eve -s /etc/eve/eve.cfg, PIDFile=/run/eve-localhost-4042.pid |
A service reads and writes as the user it runs as, not as you: give that user the folders of the project. The machine does not change its user or write to the Event Log yet (open points in plan/design-service.md section 17).
Eve API for AI
eve --api starts the machine as an MCP server (Model Context Protocol, an open protocol based on JSON-RPC 2.0). An AI assistant connects to it, on its standard input and output, or over HTTP on the path /mcp of the serve port, and works with Eve directly: it checks a script, runs it, reads the errors and the run log, and generates the documentation. Every command of the machine is a tool of the API, for example:
| Tool | Command | Result |
|---|---|---|
eve_check | check | ok, or the syntax errors with line and column |
eve_run | run | exit code, output and errors |
eve_doc | doc | the documentation pages written |
eve_inspect | inspect | the introspection report of a loaded script |
eve_runlog | (read) | the lines of a run log |
The API follows the rules of the machine: an AI gets the same rights as a person at the prompt of that machine, no more.
AI agents: ACP
The UI part of eve speaks the Agent Client Protocol (ACP), the protocol that editors use to talk with AI coding agents. It works in two directions:
- An agent in the Workbench. The UI part starts an AI agent and opens a session on your project. It gives the agent the eve skills: the MCP server of the machine, whose tools are the methods
vm.*anddb.*. You chat with the agent in the browser, see what it plans, and approve each action it wants to take; - An IDE that speaks ACP. An editor with an agent panel can talk to the UI part as to an agent: what you ask about your project becomes calls of the machine API, on the local machine or on a remote one.
Either way the agent never gets more than the machine API offers, and the API key or the login of the agent's provider stays in the keyring of your computer, never in the browser. eve -rem works the same way without a browser: it turns your command into the calls of the machine API of the remote machine.
Security
- Local first:
--listen,serveand the API bind tolocalhostunless the configuration opens them to the network; - Authentication: a person logs in to each remote machine, by single sign-on or with an account of that machine, and the local machine keeps the credentials in the keyring of the computer (see Login and credentials); scripts and machines present the token of the machine,
$EVE_TOKEN; over a network the connection uses HTTPS, given by a reverse proxy (below); - Authorization: the configuration says which routes are public and who may upload and run code;
- Secrets: passwords and keys are never written in scripts; the machine gives them to a project from its configuration, and they never travel back to a client.
Remote access through a reverse proxy
eve has no TLS server of its own. Its doors speak plain JSON-RPC and plain HTTP, and they listen only on a Unix socket or on localhost. To reach a machine from another computer, put a reverse proxy in front of it, such as Nginx, Caddy or Cloudflare Tunnel: the proxy speaks HTTPS with the world and forwards to the local port of the machine, WebSocket included.
# Caddyfile: HTTPS for etl1.example.com, forwarded to the machine on localhost
etl1.example.com {
reverse_proxy localhost:8042
}
- The machine still checks the login and the token of every request: the proxy carries the bytes, it does not decide who may run what;
- A machine listens on another address than
localhostonly when itseve.cfgsays that a proxy is in front of it, so a plain door is never opened to the network by mistake; - The client side needs no proxy:
eve -rem https://etl1.example.comspeaks HTTPS itself.
Commands
| Command | Option | Meaning |
|---|---|---|
setup | -e, --setup <folder> | choose the machine of a folder, create it when missing, or read its configuration again |
execute | -x <file> | parse and execute a script at once in this process, then exit; no machine is looked for |
| (any command) | -c, --command "<command>" | send one command to a running machine and print its answer |
upload | -u, --upload <file> | send a source file to a machine, which compiles and keeps it |
| — | -rem, --remote <machine> | the machine that receives -c or -u: an address or a name of the configuration |
listen | --listen [start|stop|restart|status] | wait for commands on $EVE_PORT |
| — | -loc, --local | run the command in the local machine through IPC, or in this process; never the network |
serve | --serve | serve HTTP on $EVE_HTTP_PORT; serve stop ends it |
api | --api | start the MCP server for AI assistants |
send | — | send a command to another machine: send prod "report" |
login, logout | — | log in to a remote machine (single sign-on, an account, or a token), or end the session; forget deletes the stored credentials, whoami shows the user and the role |
load, dismiss | — | create, or free, the memory space of a driver |
stop | — | end the machine |
Read next: Eve Web Portal