nonebot-plugin-codex 0.1.4__tar.gz → 0.1.6__tar.gz

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.
Files changed (27) hide show
  1. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/PKG-INFO +15 -4
  2. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/README.md +14 -3
  3. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/pyproject.toml +1 -1
  4. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/__init__.py +15 -0
  5. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/config.py +1 -1
  6. nonebot_plugin_codex-0.1.6/src/nonebot_plugin_codex/native_client.py +799 -0
  7. nonebot_plugin_codex-0.1.6/src/nonebot_plugin_codex/protocol_io.py +131 -0
  8. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/service.py +482 -46
  9. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/telegram.py +481 -73
  10. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/telegram_commands.py +6 -1
  11. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/telegram_rendering.py +14 -1
  12. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_config.py +6 -0
  13. nonebot_plugin_codex-0.1.6/tests/test_native_client.py +1734 -0
  14. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_service.py +498 -3
  15. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_telegram_commands.py +4 -2
  16. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_telegram_handlers.py +636 -11
  17. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_telegram_rendering.py +11 -0
  18. nonebot_plugin_codex-0.1.4/src/nonebot_plugin_codex/native_client.py +0 -419
  19. nonebot_plugin_codex-0.1.4/tests/test_native_client.py +0 -128
  20. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/LICENSE +0 -0
  21. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/src/nonebot_plugin_codex/runtime.py +0 -0
  22. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/__init__.py +0 -0
  23. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/conftest.py +0 -0
  24. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_plugin_entry.py +0 -0
  25. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_plugin_meta.py +0 -0
  26. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_release_notes.py +0 -0
  27. {nonebot_plugin_codex-0.1.4 → nonebot_plugin_codex-0.1.6}/tests/test_runtime.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-codex
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Telegram bridge plugin for driving Codex from NoneBot
5
5
  Author-Email: ttiee <469784630@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -40,6 +40,13 @@ _✨ 在 Telegram 里驱动 Codex CLI 的 NoneBot 插件 ✨_
40
40
 
41
41
  </div>
42
42
 
43
+ <p align="center">
44
+ <img src="docs/images/readme/1.jpg" width="24%" alt="nonebot-plugin-codex screenshot 1">
45
+ <img src="docs/images/readme/2.jpg" width="24%" alt="nonebot-plugin-codex screenshot 2">
46
+ <img src="docs/images/readme/3.jpg" width="24%" alt="nonebot-plugin-codex screenshot 3">
47
+ <img src="docs/images/readme/4.jpg" width="24%" alt="nonebot-plugin-codex screenshot 4">
48
+ </p>
49
+
43
50
  ## 项目介绍
44
51
 
45
52
  `nonebot-plugin-codex` 是一个面向 Telegram 场景的 NoneBot 插件,用来把本机 `codex` CLI 暴露为可对话、可续聊、可管理工作目录的聊天式开发助手。
@@ -59,6 +66,7 @@ _✨ 在 Telegram 里驱动 Codex CLI 的 NoneBot 插件 ✨_
59
66
  - **聊天即入口**:`/codex` 连接后,普通文本消息可直接续聊当前会话。
60
67
  - **双模式工作流**:持续对话用 `resume`,一次性任务用 `exec`。
61
68
  - **细粒度会话隔离**:不同聊天各自持有模型、权限、工作目录与历史绑定。
69
+ - **稳健流式展示**:同一聊天内按 chat 级节流更新;超长流式回复会保留 agent 标题,取消时补发已生成全文。
62
70
  - **目录浏览能力**:支持在 Telegram 内切换目录、设定 Home、查看隐藏目录。
63
71
  - **历史会话恢复**:可浏览 native 与 exec 历史,并尽量恢复原始工作目录。
64
72
  - **兼容迁移**:可以沿用旧配置文件与 Codex 历史目录,减少迁移成本。
@@ -180,8 +188,8 @@ codex_diagnostic_history = 20
180
188
  # 单条 Telegram 消息的分片长度,过长回复会自动拆分
181
189
  codex_chunk_size = 3500
182
190
 
183
- # 读取 Codex stdout / stderr 的缓冲区大小
184
- codex_stream_read_limit = 1048576
191
+ # 单条 Codex 协议消息允许的最大字节数
192
+ codex_stream_read_limit = 8388608
185
193
 
186
194
  ```
187
195
 
@@ -189,7 +197,8 @@ codex_stream_read_limit = 1048576
189
197
 
190
198
  - `codex_binary`:如果宿主机不是直接执行 `codex`,改成实际绝对路径。
191
199
  - `codex_workdir`:默认工作目录,也是 `/cd` 相对路径解析与目录浏览器 Home 的基准。
192
- - 其余项分别控制停止超时、进度保留条数、诊断输出条数、Telegram 分片长度和流读取上限。
200
+ - `codex_stream_read_limit`:限制单条 Codex 协议帧的最大字节数,不是 Telegram 消息分片长度。
201
+ - 其余项分别控制停止超时、进度保留条数、诊断输出条数和 Telegram 分片长度。
193
202
  - 插件自己的配置数据由 `nonebot-plugin-localstore` 自动管理。
194
203
  - 模型缓存、Codex CLI 配置和历史会话目录默认读取 `~/.codex/*`,属于插件内部实现路径。
195
204
 
@@ -214,6 +223,7 @@ codex_stream_read_limit = 1048576
214
223
  | `/cd [path]` | 切换目录或打开目录浏览器 |
215
224
  | `/home` | 将工作目录重置到 Home |
216
225
  | `/sessions` | 打开历史会话浏览器 |
226
+ | `/compact` | 压缩当前 `resume` 会话上下文 |
217
227
 
218
228
  ## 模式说明
219
229
 
@@ -224,6 +234,7 @@ codex_stream_read_limit = 1048576
224
234
  - 优先使用 `codex app-server`
225
235
  - 为同一聊天维持 native thread
226
236
  - 更适合连续编码、持续追问和多轮调试
237
+ - 支持在 Telegram 中用 `/compact` 压缩较早对话上下文
227
238
 
228
239
  ### `exec`
229
240
 
@@ -27,6 +27,13 @@ _✨ 在 Telegram 里驱动 Codex CLI 的 NoneBot 插件 ✨_
27
27
 
28
28
  </div>
29
29
 
30
+ <p align="center">
31
+ <img src="docs/images/readme/1.jpg" width="24%" alt="nonebot-plugin-codex screenshot 1">
32
+ <img src="docs/images/readme/2.jpg" width="24%" alt="nonebot-plugin-codex screenshot 2">
33
+ <img src="docs/images/readme/3.jpg" width="24%" alt="nonebot-plugin-codex screenshot 3">
34
+ <img src="docs/images/readme/4.jpg" width="24%" alt="nonebot-plugin-codex screenshot 4">
35
+ </p>
36
+
30
37
  ## 项目介绍
31
38
 
32
39
  `nonebot-plugin-codex` 是一个面向 Telegram 场景的 NoneBot 插件,用来把本机 `codex` CLI 暴露为可对话、可续聊、可管理工作目录的聊天式开发助手。
@@ -46,6 +53,7 @@ _✨ 在 Telegram 里驱动 Codex CLI 的 NoneBot 插件 ✨_
46
53
  - **聊天即入口**:`/codex` 连接后,普通文本消息可直接续聊当前会话。
47
54
  - **双模式工作流**:持续对话用 `resume`,一次性任务用 `exec`。
48
55
  - **细粒度会话隔离**:不同聊天各自持有模型、权限、工作目录与历史绑定。
56
+ - **稳健流式展示**:同一聊天内按 chat 级节流更新;超长流式回复会保留 agent 标题,取消时补发已生成全文。
49
57
  - **目录浏览能力**:支持在 Telegram 内切换目录、设定 Home、查看隐藏目录。
50
58
  - **历史会话恢复**:可浏览 native 与 exec 历史,并尽量恢复原始工作目录。
51
59
  - **兼容迁移**:可以沿用旧配置文件与 Codex 历史目录,减少迁移成本。
@@ -167,8 +175,8 @@ codex_diagnostic_history = 20
167
175
  # 单条 Telegram 消息的分片长度,过长回复会自动拆分
168
176
  codex_chunk_size = 3500
169
177
 
170
- # 读取 Codex stdout / stderr 的缓冲区大小
171
- codex_stream_read_limit = 1048576
178
+ # 单条 Codex 协议消息允许的最大字节数
179
+ codex_stream_read_limit = 8388608
172
180
 
173
181
  ```
174
182
 
@@ -176,7 +184,8 @@ codex_stream_read_limit = 1048576
176
184
 
177
185
  - `codex_binary`:如果宿主机不是直接执行 `codex`,改成实际绝对路径。
178
186
  - `codex_workdir`:默认工作目录,也是 `/cd` 相对路径解析与目录浏览器 Home 的基准。
179
- - 其余项分别控制停止超时、进度保留条数、诊断输出条数、Telegram 分片长度和流读取上限。
187
+ - `codex_stream_read_limit`:限制单条 Codex 协议帧的最大字节数,不是 Telegram 消息分片长度。
188
+ - 其余项分别控制停止超时、进度保留条数、诊断输出条数和 Telegram 分片长度。
180
189
  - 插件自己的配置数据由 `nonebot-plugin-localstore` 自动管理。
181
190
  - 模型缓存、Codex CLI 配置和历史会话目录默认读取 `~/.codex/*`,属于插件内部实现路径。
182
191
 
@@ -201,6 +210,7 @@ codex_stream_read_limit = 1048576
201
210
  | `/cd [path]` | 切换目录或打开目录浏览器 |
202
211
  | `/home` | 将工作目录重置到 Home |
203
212
  | `/sessions` | 打开历史会话浏览器 |
213
+ | `/compact` | 压缩当前 `resume` 会话上下文 |
204
214
 
205
215
  ## 模式说明
206
216
 
@@ -211,6 +221,7 @@ codex_stream_read_limit = 1048576
211
221
  - 优先使用 `codex app-server`
212
222
  - 为同一聊天维持 native thread
213
223
  - 更适合连续编码、持续追问和多轮调试
224
+ - 支持在 Telegram 中用 `/compact` 压缩较早对话上下文
214
225
 
215
226
  ### `exec`
216
227
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-codex"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  description = "Telegram bridge plugin for driving Codex from NoneBot"
5
5
  authors = [
6
6
  { name = "ttiee", email = "469784630@qq.com" },
@@ -102,6 +102,7 @@ if _runtime_ready:
102
102
  cd_cmd = on_command("cd", priority=10, block=True)
103
103
  home_cmd = on_command("home", priority=10, block=True)
104
104
  sessions_cmd = on_command("sessions", priority=10, block=True)
105
+ compact_cmd = on_command("compact", priority=10, block=True)
105
106
  follow_up = on_message(priority=20, block=True, rule=handlers.is_active_follow_up)
106
107
  browser_callback = on_type(
107
108
  CallbackQueryEvent,
@@ -133,6 +134,12 @@ if _runtime_ready:
133
134
  block=True,
134
135
  rule=handlers.is_workspace_callback,
135
136
  )
137
+ status_callback = on_type(
138
+ CallbackQueryEvent,
139
+ priority=10,
140
+ block=True,
141
+ rule=handlers.is_status_callback,
142
+ )
136
143
 
137
144
  @codex_cmd.handle()
138
145
  async def _handle_codex(
@@ -218,6 +225,10 @@ if _runtime_ready:
218
225
  async def _handle_sessions(bot: Bot, event: MessageEvent) -> None:
219
226
  await handlers.handle_sessions(bot, event)
220
227
 
228
+ @compact_cmd.handle()
229
+ async def _handle_compact(bot: Bot, event: MessageEvent) -> None:
230
+ await handlers.handle_compact(bot, event)
231
+
221
232
  @browser_callback.handle()
222
233
  async def _handle_browser_callback(bot: Bot, event: CallbackQueryEvent) -> None:
223
234
  await handlers.handle_browser_callback(bot, event)
@@ -242,6 +253,10 @@ if _runtime_ready:
242
253
  ) -> None:
243
254
  await handlers.handle_workspace_callback(bot, event)
244
255
 
256
+ @status_callback.handle()
257
+ async def _handle_status_callback(bot: Bot, event: CallbackQueryEvent) -> None:
258
+ await handlers.handle_status_callback(bot, event)
259
+
245
260
  @follow_up.handle()
246
261
  async def _handle_follow_up(bot: Bot, event: MessageEvent) -> None:
247
262
  await handlers.handle_follow_up(bot, event)
@@ -12,4 +12,4 @@ class Config(BaseModel):
12
12
  codex_progress_history: int = 6
13
13
  codex_diagnostic_history: int = 20
14
14
  codex_chunk_size: int = 3500
15
- codex_stream_read_limit: int = 1024 * 1024
15
+ codex_stream_read_limit: int = 8 * 1024 * 1024