feat: add standalone CLI project

This commit is contained in:
mmc
2026-03-19 07:36:14 +08:00
commit 26b238ec25
16 changed files with 6103 additions and 0 deletions

191
README.md Normal file
View File

@@ -0,0 +1,191 @@
# Standalone OpenAI Pool CLI
一个纯 CLI 版的 OpenAI Pool Orchestrator可直接从 `/root/standalone_cli` 运行,不依赖原仓库路径。
## 目录结构
```text
/root/standalone_cli/
|- main.py # 主 CLI 入口
|- run.py # 便捷启动脚本
|- support.py # 配置/同步/状态辅助逻辑
|- requirements.txt # 运行依赖
|- README.md # 使用说明
|- config/
| `- sync_config.example.json # 配置模板
|- data/
| |- sync_config.json # 实际运行配置
| |- state.json # 成功/失败统计
| `- tokens/ # 本地 token 文件
`- openai_pool_orchestrator/
|- register.py # 注册核心逻辑
|- pool_maintainer.py # CPA/Sub2Api 维护逻辑
`- mail_providers.py # 邮箱提供商适配
```
## 安装依赖
```bash
cd /root/standalone_cli
pip install -r requirements.txt
```
如果你想用可编辑安装:
```bash
cd /root/standalone_cli
pip install -e .
openai-pool-standalone --help
```
## 初始化配置
```bash
python3 /root/standalone_cli/main.py config init
```
初始化后请编辑:
- `/root/standalone_cli/data/sync_config.json`
至少按需填写:
- `proxy`
- `cpa_base_url`
- `cpa_token`
- `base_url`
- `bearer_token``email` + `password`
- 邮箱提供商配置 `mail_provider_configs`
模板里的 URL 现在使用了更明确的占位值:
- `https://your-cpa.example.com`
- `https://your-sub2api.example.com`
留空的字段表示需要你自行填写真实值,例如:
- `cpa_token`
- `bearer_token`
- `password`
- `proxy_pool_api_key`
## 常用命令
### 查看帮助
```bash
python3 /root/standalone_cli/main.py --help
python3 /root/standalone_cli/run.py --help
```
### 查看当前配置
```bash
python3 /root/standalone_cli/main.py --json config show
```
### 单次注册
```bash
python3 /root/standalone_cli/main.py register --once
```
### 循环注册
```bash
python3 /root/standalone_cli/main.py register --sleep-min 5 --sleep-max 30
```
### 指定代理注册
```bash
python3 /root/standalone_cli/main.py register --proxy http://127.0.0.1:7897 --once
```
### 查看本地 token
```bash
python3 /root/standalone_cli/main.py tokens --limit 20
```
### CPA 维护
```bash
python3 /root/standalone_cli/main.py cpa status
python3 /root/standalone_cli/main.py cpa check
python3 /root/standalone_cli/main.py cpa maintain
python3 /root/standalone_cli/main.py cpa upload-all
```
### Sub2Api 维护
```bash
python3 /root/standalone_cli/main.py sub2api status
python3 /root/standalone_cli/main.py sub2api check
python3 /root/standalone_cli/main.py sub2api sync-all
python3 /root/standalone_cli/main.py sub2api maintain
python3 /root/standalone_cli/main.py sub2api dedupe --apply
```
### 统计信息
```bash
python3 /root/standalone_cli/main.py stats
```
## 运行方式
两种方式等价:
```bash
python3 /root/standalone_cli/main.py --help
python3 /root/standalone_cli/run.py --help
```
其中 `python3 /root/standalone_cli/run.py` 在不带参数时会自动显示帮助,更适合首次使用。
安装为命令行后也可以这样运行:
```bash
openai-pool-standalone --help
openai-pool-standalone register --once
```
## Docker
构建镜像:
```bash
cd /root/standalone_cli
docker build -t openai-pool-standalone .
```
运行容器:
```bash
docker run --rm -it \
-v /root/standalone_cli/data:/app/data \
openai-pool-standalone config show
```
或使用 compose
```bash
cd /root/standalone_cli
docker compose up --build
```
## 验证命令
```bash
python3 -m compileall /root/standalone_cli
python3 /root/standalone_cli/main.py --json config show
python3 /root/standalone_cli/main.py --json stats
python3 /root/standalone_cli/run.py --help
```
## 说明
- 这个目录现在已经包含独立的核心代码,不再依赖 `/root/openai_pool_orchestrator-main`
- 运行配置与 token 只写入 `/root/standalone_cli/data/`
- 不要把真实密钥、token、邮箱密码提交到版本库