# task_start

Start a command in a terminal on the machine. It keeps running when the call (or the conversation) ends; read it with task_output, end it with task_stop. For a one-shot command whose exit code you need, use exec_run.

**In short:** Risk class [`exec`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `task_start`; over HTTP send `"tool": "task_start"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `argv` | `string[]` | no | Program and arguments, run directly without a shell. Give this or `command`. |
| `cols` | `integer` | no | Terminal width (default 120). |
| `command` | `string` | no | A shell command line, run as `/bin/sh -c <command>` in the terminal. Give this or `argv`. |
| `cwd` | `string` | no | Working folder. Default: the machine program's folder. |
| `rows` | `integer` | no | Terminal height (default 40). |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `pid` | `integer` | yes |  |
| `task` | `integer` | yes | The task's id: pass it to task_output and task_stop. |

## Examples

**MCP**

```json
{
  "name": "task_start",
  "arguments": {
    "machine": "<machine>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.ai/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"task_start","args":{}}'
```

## Limits

The call times out after 10 s (`timed_out`). Available since version 0.0.1. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).
