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

> ## Agent Instructions
> Read the relevant procedure and prerequisites before suggesting commands. Cite the section and give an observable check. Treat sample data as illustrative. Report product actions and results only when verified in the user's environment.

# CLI 快速开始

> 在终端用 aiv 登录并选择空间，接入 Codex，完成新任务后用 CLI 核对本次 Trace。

在运行 Codex 的 macOS 或 Linux 主机（x64 或 arm64）上，用 `aiv` 登录已有平台、确认目标空间并接入 Codex。完成一次新任务后，在同一空间读回本次 Trace。想从网页开始，可用[网页快速开始](https://aivision.mintlify.site/zh-CN/web-quickstart.md)。[Windows x64 客户端](https://aivision.mintlify.site/zh-CN/guides/install-cli.md#install-windows-x64)可以查询已有平台记录。运行 `aiv connect` 需使用上述受支持的主机。

> [!NOTE]
>
> 接入命令在运行 Agent 的机器上执行。首次接入默认 Full，会采集支持的输入、输出和工具内容；如需过滤内容，请先阅读[隐私模式](https://aivision.mintlify.site/zh-CN/guides/privacy.md)，并使用 `--collection-mode privacy`。

## 1. 准备平台和客户端

已有平台时，[安装 aiv CLI](https://aivision.mintlify.site/zh-CN/guides/install-cli.md)。个人首次自托管可以用 [All-in-One 个人版](https://aivision.mintlify.site/zh-CN/deployment/all-in-one.md)，安装时按 Agent 机器架构选择配套的 `aiv`。其他自托管场景见[部署方式](https://aivision.mintlify.site/zh-CN/deployment/overview.md)。先在 Agent 机器上配置好宿主 Agent，再按接入方式准备运行时。

**准备完成：** `aiv --version` 能显示版本，Agent 能独立完成任务，平台提供与主机匹配的安装器和插件产物，你知道平台地址和账号。

## 2. 登录并选择空间

将示例地址替换为浏览器使用的平台 Web 地址（本机默认 `http://127.0.0.1:5174`），并替换邮箱。根据账号状态只执行下面一个标签页，密码在交互提示中输入。

> [tab] 已有账号
>
> ```bash theme={null}
> aiv auth login --endpoint https://vision.example.com --email you@example.com
> ```

> [tab] 新账号
>
> 按提示输入姓名和自选密码；仅在服务端允许公开注册时使用。注册成功后会自动登录并选择个人空间。
>
> ```bash theme={null}
> aiv auth register --endpoint https://vision.example.com --email you@example.com
> ```

成功后检查账号与空间：

```bash theme={null}
aiv auth status
aiv space list
```

首次登录通常选择个人空间；同一平台、同一账号重新登录时，可能保留上次空间。核对登录输出的 `Current space` 和 `aiv space list`，需要切换时执行 `aiv space use <space-uuid>`。

## 3. 接入并执行任务

```bash theme={null}
aiv connect codex --dry-run
aiv connect codex
```

重启 Codex，检查并信任新 hook，然后开启一个新会话，完成一个熟悉的小任务。其他 Agent 和网页安装入口见 [Agent 接入](https://aivision.mintlify.site/zh-CN/integrations/agents.md)。

安装失败时，修复报错后在同一机器、同一账号和空间重新执行 `aiv connect codex`。完成安装后再重启宿主、创建新会话；重复安装会复用空间内同类型 Agent。

## 4. 查看真实记录

在平台选择对应空间、Agent 和时间范围，打开任务 Trace。也可以配置查询 Key 后从 CLI 检查：

> [accordion] 可选：用 CLI 查询同一条记录
>
> ```bash theme={null}
> aiv key create --name cli
> # 无创建权限时使用 aiv key import 导入获授权的 Key。
> aiv query trace list --since 1h --limit 5 --agent-product Codex
> aiv agent status codex
> ```
>
> 管理员和开发者可创建 Key。无创建权限时，使用 `aiv key import`，按隐藏输入提示导入获授权的 Key。

只有真实 Trace 才能确认采集链路；`--dry-run` 成功不代表宿主已运行 hook 或已上报数据。没有记录时查看[无数据排查](https://aivision.mintlify.site/zh-CN/help/no-data.md)。

## 完成检查

* 平台中选择的空间与 CLI 当前空间一致。
* 能找到本次新任务的 Trace，而不是其他机器的旧记录。
* 能打开调用记录，检查状态、耗时及已上报用量；Privacy 模式下内容被过滤是预期行为。

在任务对应的记录中选一个调用，记下名称、状态和耗时，并核对已采集的输入或输出。这条能回到原始记录核对的观察，是本次接入的完成结果；具体阅读方法见 [Trace 指南](https://aivision.mintlify.site/zh-CN/guides/traces.md)。

需要脚本查询或批量导出时，继续 [CLI 查询](https://aivision.mintlify.site/zh-CN/guides/cli.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.