Write a front end
A front end is what a person uses to give tasks and follow the work. It is a program of its own, in any language, that speaks the Agent Frontend Protocol with the rumbo host. The terminal UI, the plain printer, and the desktop app are all front ends, and none of them gets a shortcut.
Write one to bring rumbo into an editor, a chat bot, a web page, or a workflow of your own.
Two ways to connect
Section titled “Two ways to connect”Messages are JSON-RPC 2.0 objects, one per line, the same either way:
| Who starts whom | The front end reads from | The front end writes to |
|---|---|---|
rumbo starts a registered front end (rumbo -f <name>) |
file descriptor 3 | file descriptor 4 |
The front end starts rumbo serve, as an editor would |
the host’s stdout | the host’s stdin |
A front end rumbo starts keeps the terminal on stdin and stdout, so it can draw and read keys freely. Closing the connection ends the host: it cancels the runs in progress, records them, and stops its providers.
The shape of it
Section titled “The shape of it”initialize: the host speaks first, with the directory, the session, the provider, and the model the front end is attached to, and the task given on the command line, if any.run: the front end sends a task. The host answers when the run is over: done, failed, or cancelled.eventnotifications report the run while it works: the model’s text, the tool calls and their results, the tokens spent, and diagnostics.steertells a run something while it works, andcancelstops it.
A front end can also ask the host what it and the provider offer (describe), call their functions
(invoke), show what a session held before it was opened (history), and bring back what the
person asked before (recall).
A complete example
Section titled “A complete example”examples/frontend.py is a whole
front end in one Python file: it asks for tasks with input() and prints events as they arrive.
def run(objective, request_id): """Send one objective and show events until the host answers the request.""" send({"id": request_id, "method": "run", "params": {"objective": objective}})
for line in from_host: frame = json.loads(line)
if frame.get("method") == "event": show(frame["params"]) elif frame.get("id") == request_id: result = frame["result"] print(f"\n[{result['status']}] {result.get('error', '')}") returnRegister and use it:
rumbo frontend add simple python3 /path/to/examples/frontend.pyrumbo -f simpleIn Go, the protocol package has the
types and DialFrontend, a ready-made connection.
Commands without knowing them
Section titled “Commands without knowing them”Everything a person can do beyond giving a task, such as changing session, model, or settings, the host offers as described functions, and so does each provider. A front end builds its commands, forms, and pickers from those descriptions, so it works with a provider it has never seen, and gains a new function without a change. A function that cannot be undone says so, for the front end to ask the person first; a provider’s function can ask the person a question, whose answer may be secret and must then be neither shown nor kept.
The use cases list what a front end must and can do, and the protocol specifies every message.