> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyberun.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Cyberun CLI

> 使用 cyberun 命令行工具，从终端运行团队的工作流。

`cyberun` CLI 让你从终端运行团队的工作流：提交任务、轮询至完成、下载结果、管理代理 —— 全程不离开 shell。它是仪表板的脚本化搭档，适合本地实验、cron 任务和 CI。

CLI 走独立的发布通道，与仪表板分开，所以它的版本独立演进。

## 安装

<CodeGroup>
  ```bash Linux / macOS theme={null}
  curl -sL https://releases.cyberun.cloud/cli/install.sh | bash
  ```

  ```powershell Windows theme={null}
  & ([scriptblock]::Create((irm https://releases.cyberun.cloud/cli/install.ps1)))
  ```
</CodeGroup>

安装器在 Linux 和 macOS 上把二进制文件放入 `~/.cyberun/bin`,在 Windows 上放入 `~/.cyberun\bin` —— 无需 `sudo`。用 `--install-dir` 覆盖位置;指向像 `/usr/local/bin` 这样 root 拥有的目录时,仅在最后的移动步骤使用 `sudo`:

```bash theme={null}
curl -sL https://releases.cyberun.cloud/cli/install.sh | bash -s -- --install-dir /usr/local/bin
```

想直接获取二进制文件？逐平台的构建发布在 `releases.cyberun.cloud/cli/<os>-<arch>/latest/` 下,并有一个共享的 `cli/checksums.txt`,覆盖 Linux、macOS 和 Windows 的 `amd64` 与 `arm64`。

验证安装：

```bash theme={null}
cyberun --version
```

## 登录

全新安装尚未配置 API 主机，所以先把 CLI 指向 Cloud API —— 用环境变量或 `--api-host` 标志都行：

```bash theme={null}
export CYBERUN_API_URL=https://core.cyberun.cloud
```

然后登录：

```bash theme={null}
cyberun auth login
```

`auth login` 会替你保存主机，所以你只需设置一次。（如果你不想设置环境变量，也可以在命令上改用 `--api-host https://core.cyberun.cloud`。）

这会将你的机器与团队配对。CLI 会打印一个短码并打开浏览器，让你在登录 [app.cyberun.cloud](https://app.cyberun.cloud) 的状态下确认它；在那里批准后，CLI 会把凭证保存在本地。配对会签发一个用于 API 调用的设备凭证（`dk-`）**以及**一个配套代理凭证（`ak-`）—— 也就是[凭证](/zh/cloud/concepts/credentials)中描述的同一个配套代理，它让这台机器能够运行工作流。

检查或结束会话：

```bash theme={null}
cyberun auth status   # profile, API host, signed-in user
cyberun auth logout   # revoke the device credential, then clear local state
```

`cyberun auth logout` 会在服务端撤销设备凭证 —— 这也会一并撤销其配套代理 —— 然后从本机移除已保存的凭证。

## 运行工作流

最快的方式是用一条命令提交工作流并等待结果：

```bash theme={null}
cyberun run --slug my-workflow --params '{"prompt": "a red bicycle"}'
```

`run` 接受 `--slug` 或 `--id`，通过 `--params` 以 JSON 对象形式传入参数，将完成的任务以 JSON 打印出来，并在任务失败或被取消时以非零退出。加上 `--download` 可在任务完成时获取结果文件（默认写入 `<task-id>.bin`，或用 `--output <path>` 指定），用 `--poll-interval` 可更改检查频率（默认 `3s`）：

```bash theme={null}
cyberun run --slug my-workflow \
  --params '{"prompt": "a red bicycle"}' \
  --download --output bike.png
```

若只想提交而不等待，改用 `workflow run` —— 它会立即返回任务 id：

```bash theme={null}
cyberun workflow run --slug my-workflow --params '{}'
```

## 查看工作流和任务

```bash theme={null}
cyberun workflow list                 # runtime workflows for the team
cyberun workflow get --slug my-workflow
cyberun workflow get --id <workflow-id>
```

`workflow` 也可写作 `wf` 或 `workflows`。

```bash theme={null}
cyberun task list                     # recent tasks
cyberun task get --id <task-id>       # status and metadata
cyberun task cancel --id <task-id>
cyberun task download --id <task-id> --output result.png
```

`task` 也可写作 `tasks`。若省略 `--output`，`download` 会写入 `<task-id>.bin`，且仅在任务完成后才可用。

## 运行本地代理

如果你登录所在的机器有可共享的 GPU，可以把它变成团队的代理：

```bash theme={null}
cyberun agent serve --tool comfyui
```

这会使用登录时保存的配套代理凭证连接，并持续流式接收任务，直到你停止它（`Ctrl-C`）。网关端点由你的 API host 推导而来；如有需要可用 `--gateway-url` 覆盖。用 `cyberun agent list` 列出团队已连接的代理。

`agent serve` 是绑定到你已登录会话的前台工作进程 —— 适合从你正在使用的机器上临时共享。对于**专用或无人值守的 GPU 主机**，你需要的是托管的、常驻运行的服务：改用[连接代理](/zh/cloud/guides/connect-agent)中介绍的独立代理安装器。

## 配置

CLI 把状态保存在 `~/.cyberun/cyberun` 下（或设置了 `$XDG_CONFIG_HOME` 时为 `$XDG_CONFIG_HOME/cyberun`）—— `cyberun auth login` 会替你写入，通常无需手动编辑。

用 **profile** 在同一台机器上保留多个账户或团队。每条命令都接受 `--profile <name>`；如果 profile 不存在，`auth login` 会创建它。

无需编辑任何文件，你就能把 CLI 指向不同的 API host 或网关 —— 为单条命令传入标志，或为当前会话设置环境变量：

| 设置          | 标志                                 | 环境变量                  |
| ----------- | ---------------------------------- | --------------------- |
| API host    | `--api-host`                       | `CYBERUN_API_URL`     |
| Gateway URL | `--gateway-url`（在 `agent serve` 上） | `CYBERUN_GATEWAY_URL` |
| Profile     | `--profile`                        | —                     |

## 相关

* [凭证](/zh/cloud/concepts/credentials) —— CLI 在登录时保存的 `dk-` 和
  `ak-`。
* [连接代理](/zh/cloud/guides/connect-agent) —— 面向专用 GPU 主机的独立
  安装器。
* [运行你的第一个任务](/zh/cloud/getting-started/first-task) —— 在仪表板上
  做同样的事。
* [API 参考](/zh/api-reference/introduction) —— CLI 调用的 HTTP API。
