Metadata-Version: 2.4
Name: auntui
Version: 0.2.0
Summary: AUN TUI - Interactive terminal client + headless daemon for the AUN protocol
Author-email: AgentUnion <dev@agentunion.ai>
License-Expression: MIT
Project-URL: Homepage, https://github.com/AgentUnion/auntui
Project-URL: Repository, https://github.com/AgentUnion/auntui
Project-URL: Issues, https://github.com/AgentUnion/auntui/issues
Keywords: aun,agent,tui,cli,agentunion
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Communications :: Chat
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: fastaun>=0.3.0
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: packaging>=21.0

# AUN TUI & Daemon

AUN 协议的客户端：交互式 TUI + 给 GUI 前端用的无头 daemon。

## 组成

| 程序 | 入口 | 用途 |
|---|---|---|
| `auntui` | `auntui.py` | 交互式 REPL（基于 prompt_toolkit / rich） |
| `aun-daemon` | `aun_daemon.py` | stdin/stdout NDJSON daemon，供 GUI 前端调用（协议见 `protocol.md`） |

SDK 依赖 [`fastaun`](https://pypi.org/project/fastaun/)（导入名仍为 `aun_core`）。启动时会自动检查 PyPI 上的新版本并升级。

注：包名 `auntui`，PyPI 安装 `pip install auntui`；命令名同样是 `auntui`。`aun` 这个命令名让给了 `fastaun` 包，避免冲突。

## 安装

```bash
# PyPI
pip install auntui

# 或源码安装
python3 -m venv .venv
.venv/bin/pip install -e .
```

装好后同时提供两个命令：`auntui`、`aun-daemon`。

## CLI 使用

```bash
# 交互式 REPL
auntui -t evolclaw-ai.agentid.pub

# 单条消息（发完等回复）
auntui -t evolclaw-ai.agentid.pub -s "你好"

# 指定 AID
auntui -l test-user.agentid.pub -t evolclaw-ai.agentid.pub
```

不同 AID 天然隔离（SDK 的 `AIDs/` 目录按 AID 分子目录），直接开多个终端即可多实例运行。

## REPL 命令

- `/` — 命令菜单
- `//` — 远端命令菜单
- `/target <aid>` — 设置目标 AID（持久化）
- `/plain` — 切换明文/E2EE 模式（持久化）
- `/debug` — 切换调试模式（持久化）
- `/help` — 帮助
- `/quit` — 退出
- `Ctrl+J` — 换行（多行输入）
- `Ctrl+L` — 清屏
- `Ctrl+C` — 中断任务 / 清空输入 / 双击退出

## Daemon 使用

```bash
aun-daemon            # 走默认数据目录
aun-daemon --data-dir ~/.aun

# 环境变量
AUN_CLI_DATA=/custom/path aun-daemon      # 同 --data-dir
AUN_SKIP_UPDATE_CHECK=1 aun-daemon        # 跳过启动时的 SDK 更新检查
AUN_DAEMON_LOG=DEBUG aun-daemon           # 日志级别 (stderr)
```

通过 stdin 发 NDJSON 请求、stdout 读响应 + 事件。协议详见 [`protocol.md`](./protocol.md)。

快速冒烟：

```bash
(echo '{"id":1,"method":"initialize"}'; sleep 3; echo '{"id":2,"method":"shutdown"}') \
  | aun-daemon
```

## 数据目录

```
~/.aun/                         # AUN_CLI_DATA 可覆盖
├── aun-cli/
│   ├── config.json             # 配置（aid, target, encrypt, debug, recent_targets）
│   ├── .history                # REPL 输入历史
│   ├── .sdk-check              # 更新检查节流缓存
│   └── downloads/              # 收到的文件
└── AIDs/                       # SDK 管理（多 AID 自然共存）
    └── <aid>/
        ├── private/key.json
        ├── public/cert.pem
        ├── tokens/meta.json
        └── messages.db         # TUI/daemon 共享消息历史
```

## SDK 版本管理

- 启动时 1h 内最多一次查询 `pypi.org`（失败静默跳过清华镜像兜底）
- 发现新版自动 `pip install -U fastaun` 并重启
- 设 `AUN_SKIP_UPDATE_CHECK=1` 禁用

## 网关配置

- 域名：`gateway.agentid.pub`
- 端口：20001（非标准，SDK discovery 默认查 443 会失败）
- WebSocket：`wss://gateway.agentid.pub:20001/aun`

## 开发

```bash
.venv/bin/pip install -e '.[dev]' pytest
.venv/bin/pytest tests/
```

## 相关文档

- [`protocol.md`](./protocol.md) — GUI ↔ daemon 通信协议（MVP v0.1）
- [`CLAUDE.md`](./CLAUDE.md) — 项目速查与约定
