Bridges

terminals

terminals: { list, get, create, remove }

Shells that outlive an answer — a dev server, a watcher. Supply them and the terminal tool appears; on a computer they come from the machine itself.

never on a phonecloud needs it suppliedlist is read, kill is exec
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Where they come from

machineTerminals
A computerIts own, through storage.terminals — unless you supply files, which replaces them
A phoneNever. The tool is not declared, whatever you pass
A cloud workspaceOnly what you supply
A supplied set is the one that is used

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

ActionCategory
list · outputread — free
killexec — asked

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.