> For the complete documentation index, see [llms.txt](https://docs.telys.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telys.ai/cli/environment-and-exit-codes.md).

# Environment & exit codes

Every `telys` command is configured through the environment and reports its outcome through a small, stable set of exit codes. For the full catalogue of SDK-level variables (kernel paths, license issuer/audience, verify-key overrides), see [Environment variables](/operations/environment-variables.md).

## Exit codes

The CLI uses three exit codes consistently across commands:

| Code | Name                    | When you see it                                                                                                                                                        |
| ---- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0`  | success                 | The command completed. Bare `telys` (help) also exits `0`.                                                                                                             |
| `1`  | not ready               | A well-defined "not ready" state — for example, `telys runtime status` when no runtime is installed, or a command that needs the runtime when it is missing.           |
| `2`  | usage / not implemented | A malformed invocation (missing required flag, no transport for `serve`), or a command that is not implemented — `telys runtime update` is the one stub and exits `2`. |

Branch on outcomes in scripts:

```bash
if telys runtime status; then
  echo "runtime ready"
else
  telys runtime install
fi
```

## Environment variables the CLI honors

### On-disk state

| Variable            | Default           | Effect                                                                              |
| ------------------- | ----------------- | ----------------------------------------------------------------------------------- |
| `TELYS_HOME`        | `~/.telys`        | Root of all on-disk state: cached credentials, device key, installed runtime.       |
| `TELYS_MEMORY_PATH` | `~/.telys/memory` | Memory directory used by the MCP server and `telys mem` when `--path` is not given. |

### Credentials and licensing

| Variable             | Default | Effect                                                             |
| -------------------- | ------- | ------------------------------------------------------------------ |
| `TELYS_TOKEN`        | —       | Control-plane auth token override (used by `login` and API calls). |
| `TELYS_API_KEY`      | —       | Telys API key override.                                            |
| `TELYS_LICENSE`      | —       | License token read by `telys serve` (with `--require-license`).    |
| `TELYS_ACCESS_TOKEN` | —       | Bearer token for `telys serve` over TCP.                           |

### Runtime selection

| Variable        | Default     | Effect                                                                   |
| --------------- | ----------- | ------------------------------------------------------------------------ |
| `TELYS_RUNTIME` | `""` (auto) | Force the runtime backend: `native` or `local`. Empty means auto-select. |

### Control-plane and download hosts

| Variable             | Default                     | Effect                                                        |
| -------------------- | --------------------------- | ------------------------------------------------------------- |
| `TELYS_ACCOUNTS_URL` | `https://accounts.thyn.ai`  | Identity portal for device-code sign-in.                      |
| `TELYS_API_URL`      | `https://api.telys.ai`      | Control plane for keys, device approval, and licensing.       |
| `TELYS_PACKAGES_URL` | `https://packages.telys.ai` | Signed-runtime download host used by `telys runtime install`. |

{% hint style="info" %}
`$TELYS_TOKEN` and `$TELYS_API_KEY` override the credentials cached by `telys login`, letting a provisioned CI job skip the interactive flow entirely. Point the three `*_URL` variables at your own hosts to run against a self-managed control plane.
{% endhint %}

## Where each variable is used

| Command                            | Reads                                                                                                     |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [`telys login`](/cli/login.md)     | `TELYS_HOME`, `TELYS_ACCOUNTS_URL`, `TELYS_API_URL`, `TELYS_PACKAGES_URL`, `TELYS_TOKEN`, `TELYS_API_KEY` |
| [`telys runtime`](/cli/runtime.md) | `TELYS_HOME`, `TELYS_PACKAGES_URL`, `TELYS_RUNTIME`                                                       |
| [`telys serve`](/cli/serve.md)     | `TELYS_ACCESS_TOKEN`, `TELYS_LICENSE`, `TELYS_RUNTIME`                                                    |
| [`telys mcp`](/cli/mcp.md)         | `TELYS_MEMORY_PATH`, `TELYS_HOME`, `TELYS_RUNTIME`                                                        |
| [`telys mem`](/cli/mem.md)         | `TELYS_MEMORY_PATH`, `TELYS_HOME`, `TELYS_RUNTIME`                                                        |

## See also

* [Environment variables](/operations/environment-variables.md) — the full list, including kernel paths and verify-key overrides.
* [On-disk layout](/operations/on-disk-layout.md) — what lives under `$TELYS_HOME`.
* [CLI overview](/cli/overview.md) — the command tree these variables configure.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.telys.ai/cli/environment-and-exit-codes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
