Where they come from
| machine | Terminals |
|---|---|
| A computer | Its own, through storage.terminals — unless you supply files, which replaces them |
| A phone | Never. The tool is not declared, whatever you pass |
| A cloud workspace | Only what you supply |
Passing terminals overrides the machine's own, wherever you are. That is what lets an application put the agent's servers where the user can see them.
The shape
const terminals = {
async list() { /* → [terminal] */ },
async get(id) { /* → terminal */ },
async create({ name, cwd, command, port }) { /* → terminal */ },
async remove(id) { /* → { ok: true } */ },
};
// A terminal
{
id, name, cwd, busy, url,
async run(line) { },
async output({ since } = {}) { /* → the lines */ },
async kill() { },
async interrupt() { },
}class Terminals:
def list(self): ... # → [terminal]
def get(self, terminal_id): ... # → terminal
def create(self, *, name="shell", cwd="", command=None, by="user"): ... # → terminal
def remove(self, terminal_id): ... # → {"ok": True}
# A terminal: id, name, status, busy, run(line), output(since=0), kill(), interrupt()
agent = api.agents.create(runtime="local", machine=pc, model=model, terminals=Terminals())It is the computer's own terminals' shape, so the agent's tool cannot tell where a shell is running.
Two categories in one tool
Reading what a server is printing should not require a prompt; stopping it should. The category is computed from the arguments.
What the agent is told to do with them
- Start servers with
bash { background: true }, never in the foreground. - Never detach with
nohup,&or a job — that hides them where the user cannot stop them. - List before starting one that may already be running.
- Pass
port, and make the server listen on all interfaces, so the address it reports actually answers. - Tell the user the URL.
They live in the process that holds the package
A terminal survives an answer, not a restart. Whatever carries the package owns them, and restarting it takes them with it — which is worth saying in an interface that shows them.