# terminals

Canonical URL: https://developers.iagenify.com/sdk/agent/bridges/terminals/
Language: en

`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.

Status: never on a phone · cloud needs it supplied · list is read, kill is exec

## Where they come from {#where}

| 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 |

> **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 {#shape}

```javascript
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()                  { },
}
```

It is [the computer's own terminals](/sdk/ref/connected-storage/terminals)' shape, so the agent's tool cannot tell where a shell is running.

## Two categories in one tool {#categories}

| Action | Category |
| --- | --- |
| `list` · `output` | [read](/sdk/agent/permissions/categories/read) — free |
| `kill` | [exec](/sdk/agent/permissions/categories/exec) — 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 {#servers}

- 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 {#lifetime}

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.

- [terminal](/sdk/agent/tools/terminal): The tool.
- [terminals](/sdk/ref/connected-storage/terminals): A computer's own.

```python
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())
```
