nonebot-plugin-codex 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nonebot_plugin_codex/__init__.py +165 -0
- nonebot_plugin_codex/config.py +84 -0
- nonebot_plugin_codex/native_client.py +419 -0
- nonebot_plugin_codex/service.py +2338 -0
- nonebot_plugin_codex/telegram.py +650 -0
- nonebot_plugin_codex-0.1.0.dist-info/METADATA +167 -0
- nonebot_plugin_codex-0.1.0.dist-info/RECORD +10 -0
- nonebot_plugin_codex-0.1.0.dist-info/WHEEL +4 -0
- nonebot_plugin_codex-0.1.0.dist-info/entry_points.txt +4 -0
- nonebot_plugin_codex-0.1.0.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: nonebot-plugin-codex
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Telegram bridge plugin for driving Codex from NoneBot
|
|
5
|
+
Author-Email: ttiee <469784630@qq.com>
|
|
6
|
+
License: GPL-3.0-or-later
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: nonebot2>=2.4.4
|
|
9
|
+
Requires-Dist: nonebot-adapter-telegram>=0.1.0b20
|
|
10
|
+
Requires-Dist: tomli>=2.0.1; python_version < "3.11"
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
|
|
15
|
+
# nonebot-plugin-codex
|
|
16
|
+
|
|
17
|
+
_✨ 在 Telegram 里驱动 Codex CLI 的 NoneBot 插件 ✨_
|
|
18
|
+
|
|
19
|
+
<a href="./LICENSE">
|
|
20
|
+
<img src="https://img.shields.io/github/license/ttiee/nonebot-plugin-codex.svg" alt="license">
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-codex">
|
|
23
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-codex.svg" alt="pypi">
|
|
24
|
+
</a>
|
|
25
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="python">
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
## 介绍
|
|
30
|
+
|
|
31
|
+
`nonebot-plugin-codex` 把本机 `codex` CLI 包装成 Telegram 里的对话式插件。
|
|
32
|
+
|
|
33
|
+
它保留了原 `codex_bridge` 的主要能力:
|
|
34
|
+
|
|
35
|
+
- Telegram 命令面板和普通消息续聊
|
|
36
|
+
- `resume/native` 与 `exec` 双模式
|
|
37
|
+
- 每个聊天独立的会话、模型、推理强度、权限、工作目录
|
|
38
|
+
- 目录浏览器与历史会话浏览器
|
|
39
|
+
- 兼容现有 `data/codex_bridge/preferences.json` 偏好文件和 `~/.codex/*` 历史数据
|
|
40
|
+
|
|
41
|
+
## 安装
|
|
42
|
+
|
|
43
|
+
### 使用 nb-cli
|
|
44
|
+
|
|
45
|
+
在 NoneBot 项目根目录执行:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
nb plugin install nonebot-plugin-codex
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 使用包管理器
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install nonebot-plugin-codex
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
或:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pdm add nonebot-plugin-codex
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
然后在 `pyproject.toml` 的 `[tool.nonebot]` 中启用:
|
|
64
|
+
|
|
65
|
+
```toml
|
|
66
|
+
plugins = ["nonebot_plugin_codex"]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 前置条件
|
|
70
|
+
|
|
71
|
+
- Python 3.10+
|
|
72
|
+
- NoneBot 2.4.4+
|
|
73
|
+
- `nonebot-adapter-telegram`
|
|
74
|
+
- 本机已安装并可直接执行 `codex`
|
|
75
|
+
|
|
76
|
+
## 配置
|
|
77
|
+
|
|
78
|
+
推荐使用以下正式配置名:
|
|
79
|
+
|
|
80
|
+
```toml
|
|
81
|
+
[tool.nonebot]
|
|
82
|
+
plugins = ["nonebot_plugin_codex"]
|
|
83
|
+
|
|
84
|
+
[tool.nonebot.plugin_config]
|
|
85
|
+
codex_binary = "codex"
|
|
86
|
+
codex_workdir = "/home/yourname"
|
|
87
|
+
codex_kill_timeout = 5.0
|
|
88
|
+
codex_progress_history = 6
|
|
89
|
+
codex_diagnostic_history = 20
|
|
90
|
+
codex_chunk_size = 3500
|
|
91
|
+
codex_stream_read_limit = 1048576
|
|
92
|
+
codex_models_cache_path = "/home/yourname/.codex/models_cache.json"
|
|
93
|
+
codex_codex_config_path = "/home/yourname/.codex/config.toml"
|
|
94
|
+
codex_preferences_path = "data/codex_bridge/preferences.json"
|
|
95
|
+
codex_session_index_path = "/home/yourname/.codex/session_index.jsonl"
|
|
96
|
+
codex_sessions_dir = "/home/yourname/.codex/sessions"
|
|
97
|
+
codex_archived_sessions_dir = "/home/yourname/.codex/archived_sessions"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
兼容旧配置名:现有 `codex_bridge_*` 配置项仍然可用。
|
|
101
|
+
|
|
102
|
+
## 命令
|
|
103
|
+
|
|
104
|
+
- `/codex [prompt]` 连接 Codex;带 prompt 时直接发送
|
|
105
|
+
- `/mode [resume|exec]` 查看或切换默认模式
|
|
106
|
+
- `/exec <prompt>` 用一次性 `exec` 模式执行
|
|
107
|
+
- `/new` 清空当前聊天绑定的会话
|
|
108
|
+
- `/stop` 断开当前聊天的 Codex 会话
|
|
109
|
+
- `/models` 查看可用模型
|
|
110
|
+
- `/model [slug]` 查看或切换模型
|
|
111
|
+
- `/effort [high|xhigh]` 查看或切换推理强度
|
|
112
|
+
- `/permission [safe|danger]` 查看或切换权限模式
|
|
113
|
+
- `/pwd` 查看当前工作目录和当前设置
|
|
114
|
+
- `/cd [path]` 直接切目录;不带参数时打开目录浏览器
|
|
115
|
+
- `/home` 将工作目录重置到 Home
|
|
116
|
+
- `/sessions` 打开历史会话浏览器
|
|
117
|
+
|
|
118
|
+
在 `/codex` 连接后,普通文本消息会自动续聊当前会话。
|
|
119
|
+
|
|
120
|
+
## 模式说明
|
|
121
|
+
|
|
122
|
+
### `resume`
|
|
123
|
+
|
|
124
|
+
- 优先使用 `codex app-server`
|
|
125
|
+
- 为同一聊天维持 native thread
|
|
126
|
+
- 更适合持续对话
|
|
127
|
+
|
|
128
|
+
### `exec`
|
|
129
|
+
|
|
130
|
+
- 使用 `codex exec --json`
|
|
131
|
+
- 支持恢复已有 exec thread
|
|
132
|
+
- 恢复失败时会自动新开会话并提示
|
|
133
|
+
|
|
134
|
+
## 目录与历史浏览
|
|
135
|
+
|
|
136
|
+
- `/cd` 会打开目录浏览器,可逐级进入、切换 Home、显示隐藏目录,并将当前浏览目录设为工作目录
|
|
137
|
+
- `/sessions` 会列出 native 与 exec 历史会话
|
|
138
|
+
- 历史会话恢复时会尝试切回原始工作目录;目录不存在时会保留当前目录并提示
|
|
139
|
+
|
|
140
|
+
## 兼容说明
|
|
141
|
+
|
|
142
|
+
- 默认偏好文件仍然是 `data/codex_bridge/preferences.json`
|
|
143
|
+
- 历史会话仍然读取 `~/.codex/session_index.jsonl`、`~/.codex/sessions`、`~/.codex/archived_sessions`
|
|
144
|
+
- 这意味着可以从现有 `~/tg_bot/plugins/codex_bridge` 平滑迁入,不需要额外迁移脚本
|
|
145
|
+
|
|
146
|
+
## 发布
|
|
147
|
+
|
|
148
|
+
仓库自带 GitHub Actions:
|
|
149
|
+
|
|
150
|
+
- `test.yml` 负责安装依赖并运行测试
|
|
151
|
+
- `release.yml` 在打 `v*` tag 时执行 `pdm publish` 并上传构建产物
|
|
152
|
+
|
|
153
|
+
发布前请先在 PyPI 的 Trusted Publishing 中添加:
|
|
154
|
+
|
|
155
|
+
- Project name: `nonebot-plugin-codex`
|
|
156
|
+
- Owner: `ttiee`
|
|
157
|
+
- Repository name: `nonebot-plugin-codex`
|
|
158
|
+
- Workflow name: `release.yml`
|
|
159
|
+
|
|
160
|
+
## 开发
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pdm sync -G:all
|
|
164
|
+
pdm run pytest
|
|
165
|
+
pdm run ruff check .
|
|
166
|
+
pdm build
|
|
167
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
nonebot_plugin_codex-0.1.0.dist-info/METADATA,sha256=ghLnQ330SIrQbgmCDbjAPx-m8yzbA_1MJWdhggcZwiE,4620
|
|
2
|
+
nonebot_plugin_codex-0.1.0.dist-info/WHEEL,sha256=Wb0ASbVj8JvWHpOiIpPi7ucfIgJeCi__PzivviEAQFc,90
|
|
3
|
+
nonebot_plugin_codex-0.1.0.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
|
4
|
+
nonebot_plugin_codex-0.1.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
nonebot_plugin_codex/__init__.py,sha256=RvUr0PTCMa71JtGIjEEOh2m6jjclxcoUatoSzEGJiTU,6109
|
|
6
|
+
nonebot_plugin_codex/config.py,sha256=VOtgMf7Z882fa5Au-QszWQDtozUuC6wa4CIkYESVs2g,2884
|
|
7
|
+
nonebot_plugin_codex/native_client.py,sha256=4_fcAIv2jsR5lUtv_hPVspitqOyYuXe6ISwCcOnxahc,14071
|
|
8
|
+
nonebot_plugin_codex/service.py,sha256=17e5LZuwIFTryPp6bc3xZfilsGpgnsrHOKVUT22FsCc,85942
|
|
9
|
+
nonebot_plugin_codex/telegram.py,sha256=hEnOInQ9cnGLDuXTXcn213e9h6TJoSpUgghdj0c-rf0,26188
|
|
10
|
+
nonebot_plugin_codex-0.1.0.dist-info/RECORD,,
|