deep-agent-cli 0.1.1__tar.gz → 0.1.2__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.
- deep_agent_cli-0.1.2/PKG-INFO +202 -0
- deep_agent_cli-0.1.2/README.md +174 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/app.py +92 -21
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/previews.py +40 -43
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/rendering.py +67 -63
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/state.py +7 -0
- deep_agent_cli-0.1.2/agent/cli/working_messages.py +154 -0
- deep_agent_cli-0.1.2/agent/cli/working_messages.yaml +96 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/config.example.yaml +19 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/config.py +37 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/runner.py +5 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/sandbox.py +1 -1
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/stream.py +23 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/pyproject.toml +1 -1
- deep_agent_cli-0.1.1/PKG-INFO +0 -519
- deep_agent_cli-0.1.1/README.md +0 -491
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/.gitignore +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/LICENSE +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/__init__.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/attachments.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/bootstrap.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cancel.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/__init__.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/clipboard.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/commands.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/gitinfo.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/input.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/interactions.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/main.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/pasted_content.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/cli/session_controller.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/control.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/factory.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/file_mutation.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/llm.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/__init__.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/attachments.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/cancel_tools.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/pause.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/recovery.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/runtime_config.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/steering.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/tool_arg_hints.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/workspace_filesystem.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/middleware/write_operation.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/network.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/permission.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/session.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/session_lock.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/session_runtime.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/__init__.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/examples.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/execute.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/human_input.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/human_interaction.py +0 -0
- {deep_agent_cli-0.1.1 → deep_agent_cli-0.1.2}/agent/tools/web_search.py +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deep-agent-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A sandboxed coding agent CLI for Linux and WSL2
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Environment :: Console
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Topic :: Software Development
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: deepagents<0.8.0,>=0.7.17
|
|
14
|
+
Requires-Dist: httpx<1,>=0.27
|
|
15
|
+
Requires-Dist: langchain-core<2.0,>=1.0
|
|
16
|
+
Requires-Dist: langchain-openai<1.7.0,>=1.6.2
|
|
17
|
+
Requires-Dist: langchain<2.0,>=1.0
|
|
18
|
+
Requires-Dist: langgraph-checkpoint-sqlite<4,>=3.1.1
|
|
19
|
+
Requires-Dist: langgraph<2.0,>=1.0
|
|
20
|
+
Requires-Dist: prompt-toolkit<4.0,>=3.0.48
|
|
21
|
+
Requires-Dist: pyyaml<7.0,>=6.0
|
|
22
|
+
Requires-Dist: rich<15.0,>=13.9
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: build<2,>=1.2; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest<9.0,>=8.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: twine<7,>=6; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# deep-agent-cli
|
|
30
|
+
|
|
31
|
+
`deep-agent` 是一个在终端中运行的 Coding Agent,支持 Linux 和 WSL2。它把启动时所在的目录作为工作区,调用你配置的 OpenAI 兼容模型服务,并在 [Bubblewrap](https://github.com/containers/bubblewrap) 沙箱中执行命令。Agent 运行时基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 构建。
|
|
32
|
+
|
|
33
|
+
当前版本 0.1.1,处于早期开发阶段。第一个稳定版之前,配置格式、会话存储格式和 Python API 都可能出现不兼容变更。
|
|
34
|
+
|
|
35
|
+
## 功能
|
|
36
|
+
|
|
37
|
+
- **文件操作**:在工作区中列目录、读、写、编辑、搜索、删除文件。
|
|
38
|
+
- **命令执行**:在 Bubblewrap 沙箱中运行 shell 命令,默认没有网络;输出实时显示。
|
|
39
|
+
- **审批**:默认模式下,运行命令、写入、编辑、删除文件前都会请求你确认。
|
|
40
|
+
- **会话**:按工作区保存在本地 SQLite 中,可以随时恢复。
|
|
41
|
+
- **多模型**:在配置文件中定义多个模型,运行中切换模型和推理强度。支持 Chat Completions 和 Responses 两种接口。
|
|
42
|
+
- **流式输出**:思考内容和回答都流式显示。
|
|
43
|
+
- **运行中干预**:任务执行时可以追加指令、排队后续任务或取消。
|
|
44
|
+
- **图片输入**:向声明支持图片的模型发送图片。
|
|
45
|
+
- **结构化提问**:Agent 需要你做决定时,会弹出单选、多选、是/否或文本输入。
|
|
46
|
+
- **上下文压缩**:接近模型上下文窗口时自动摘要旧对话,也可以手动压缩。
|
|
47
|
+
- **可选扩展**:配置 Tavily API key 后可以搜索公开网页;从 `~/.deep-agent/skills/` 加载 Skills;读取工作区根目录的 `AGENTS.md` 作为项目说明。
|
|
48
|
+
|
|
49
|
+
## 运行要求
|
|
50
|
+
|
|
51
|
+
- Linux 或 WSL2。WSL1、原生 Windows 和 macOS 无法使用沙箱。
|
|
52
|
+
- Python 3.12 或更高版本(CI 测试 3.12 和 3.13)。
|
|
53
|
+
- Bubblewrap,并且系统允许非特权 user namespace。Ubuntu 24.04 默认限制这一点,处理方法见 [沙箱排查](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md#排查ubuntu--wsl2)。
|
|
54
|
+
- 一个 OpenAI 兼容的模型服务(本地或远程)及其 API key。
|
|
55
|
+
|
|
56
|
+
## 安装
|
|
57
|
+
|
|
58
|
+
Debian / Ubuntu:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
sudo apt install pipx bubblewrap
|
|
62
|
+
pipx ensurepath # 之后重新打开终端
|
|
63
|
+
pipx install deep-agent-cli
|
|
64
|
+
deep-agent --version
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
系统 Python 低于 3.12 时,安装一个新版本的 Python,然后指定解释器(不要替换发行版自带的 `/usr/bin/python3`):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pipx install --python /path/to/python3.12 deep-agent-cli
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
也可以装进虚拟环境:`python3 -m venv ~/.venvs/deep-agent && ~/.venvs/deep-agent/bin/pip install deep-agent-cli`。
|
|
74
|
+
|
|
75
|
+
## 快速开始
|
|
76
|
+
|
|
77
|
+
**1. 生成配置文件**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
deep-agent
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
首次运行会创建 `~/.deep-agent/config.yaml` 和 `~/.deep-agent/skills/`,然后退出。
|
|
84
|
+
|
|
85
|
+
**2. 配置模型**
|
|
86
|
+
|
|
87
|
+
编辑 `~/.deep-agent/config.yaml`,把 `llm` 部分改成你的服务:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
llm:
|
|
91
|
+
default: local/main # 启动时使用的模型:来源/模型键
|
|
92
|
+
models:
|
|
93
|
+
local: # 来源名,自定义
|
|
94
|
+
base_url: http://localhost:8000/v1
|
|
95
|
+
api_key: ${MY_API_KEY} # 也可以直接写密钥
|
|
96
|
+
provider: openai-compatible # 端点支持 Responses API 时可改为 qwen-responses
|
|
97
|
+
stream_usage: true
|
|
98
|
+
models:
|
|
99
|
+
main: # 模型键,自定义
|
|
100
|
+
model: your-model-name # 发给服务端的模型名
|
|
101
|
+
context_window: 128k
|
|
102
|
+
input: [text] # 支持图片时写 [text, image]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`provider` 未填写时默认为 `qwen-responses`(Responses API),只提供 Chat Completions 的服务需要显式写 `openai-compatible`。其他字段、推理强度和服务商示例见 [配置参考](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/configuration.md)。
|
|
106
|
+
|
|
107
|
+
**3. 在项目目录中启动**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd ~/projects/my-app
|
|
111
|
+
deep-agent
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
启动时会先检查沙箱是否可用;不可用时程序给出诊断信息并拒绝启动。界面中直接输入任务即可,以 `/` 开头的输入是命令。
|
|
115
|
+
|
|
116
|
+
**4. 恢复会话**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
deep-agent resume # 选择一个已保存的会话
|
|
120
|
+
deep-agent resume 01a08aae # 按 id 或前缀恢复
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
恢复只加载会话状态,不会自动继续执行未完成的任务。
|
|
124
|
+
|
|
125
|
+
## 常用操作
|
|
126
|
+
|
|
127
|
+
| 命令 | 作用 |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `/help` | 列出命令和快捷键 |
|
|
130
|
+
| `/status` | 当前模型、权限模式、沙箱状态 |
|
|
131
|
+
| `/model` | 选择模型和推理强度 |
|
|
132
|
+
| `/permission ask\|allow` | 切换审批模式 |
|
|
133
|
+
| `/resume`、`/new` | 切换到已有会话、新建会话 |
|
|
134
|
+
| `/compact` | 手动压缩上下文 |
|
|
135
|
+
| `/image <路径>` | 为下一条消息附加图片 |
|
|
136
|
+
| `/quit` | 退出 |
|
|
137
|
+
|
|
138
|
+
| 按键 | 作用 |
|
|
139
|
+
|---|---|
|
|
140
|
+
| `Enter` | 提交;任务运行中提交为追加指令 |
|
|
141
|
+
| `Ctrl+J` | 换行 |
|
|
142
|
+
| `Alt+Enter` | 排队,当前任务结束后执行 |
|
|
143
|
+
| `Esc` | 取消当前任务 |
|
|
144
|
+
| `F2` | 重新打开待处理的审批或提问 |
|
|
145
|
+
| `Ctrl+O` / `Ctrl+T` | 展开工具详情 / 思考内容 |
|
|
146
|
+
| `Ctrl+R` | 查看文件改动 |
|
|
147
|
+
| `Ctrl+P` | 切换到下一个模型 |
|
|
148
|
+
| `Ctrl+C` | 清空输入;连按两次退出 |
|
|
149
|
+
|
|
150
|
+
完整的命令、按键和界面行为见 [终端界面](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/tui.md)。
|
|
151
|
+
|
|
152
|
+
## 安全模型
|
|
153
|
+
|
|
154
|
+
| | 行为 |
|
|
155
|
+
|---|---|
|
|
156
|
+
| 命令能访问的文件 | 工作区(读写,在沙箱中为 `/workspace`)、`~/.deep-agent/skills/`(只读)、系统的 `/usr`、`/bin`、`/lib`(只读)。家目录的其余部分不可见 |
|
|
157
|
+
| 网络 | 命令默认无网络。模型可以为单条命令申请网络,此时它能访问互联网、`localhost` 和局域网 |
|
|
158
|
+
| 环境变量 | 只传入 `LANG`、`TERM` 等少量变量,其余需在配置中显式列出 |
|
|
159
|
+
| `ask` 模式(默认) | 运行命令、写入、编辑、删除文件前需要确认 |
|
|
160
|
+
| `allow` 模式 | 所有工具自动批准,所有命令都开放网络。仅在沙箱可用时可开启,开启时需输入 `ALLOW` |
|
|
161
|
+
| 沙箱不可用 | 拒绝启动。只有在配置中设置 `sandbox.allow_unsandboxed: true`,或在启动提示中输入 `UNSANDBOXED`,命令才会以当前用户身份直接在宿主机上运行,此时只能使用 `ask` 模式 |
|
|
162
|
+
|
|
163
|
+
细节见 [沙箱与权限](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md)。
|
|
164
|
+
|
|
165
|
+
## 已知限制
|
|
166
|
+
|
|
167
|
+
- 沙箱不限制 CPU、内存和磁盘用量。
|
|
168
|
+
- 沙箱中只有系统目录下的程序。安装在 `~/.local`、`~/.nvm`、`/opt` 等位置的工具链默认不可用,需要在配置中添加只读挂载。
|
|
169
|
+
- 文件工具在 `deep-agent` 进程中直接读写宿主文件,不经过沙箱,路径限定在工作区和 Skills 目录内。工作区里的所有内容 Agent 都能读写,包括 `.git/` 和 `.env`。
|
|
170
|
+
- 程序会在工作区中创建 `.deep-agent/`(命令输出超限时的日志)和 `.deepagents/`(上下文压缩时保存的历史),但不会修改 `.gitignore`。
|
|
171
|
+
- 不能在家目录或其上层目录启动,因为配置目录 `~/.deep-agent` 必须位于工作区之外。
|
|
172
|
+
- 只能在交互式终端中使用,没有非交互或批处理模式。
|
|
173
|
+
- 模型请求和 Tavily 请求不读取 `HTTP_PROXY`、`HTTPS_PROXY`、`ALL_PROXY` 等代理环境变量。
|
|
174
|
+
- 从剪贴板粘贴图片只支持 WSL;其他环境需要通过文件路径添加图片。
|
|
175
|
+
- 推理强度的可选值需要按服务商文档手动配置,程序不会自动探测。
|
|
176
|
+
- 不支持 MCP,也没有子 Agent。
|
|
177
|
+
- 同一个会话同一时间只能被一个进程打开。
|
|
178
|
+
|
|
179
|
+
## 文档
|
|
180
|
+
|
|
181
|
+
- [配置参考](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/configuration.md):所有配置项、模型与推理强度、Web 搜索、按键、环境变量
|
|
182
|
+
- [沙箱与权限](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md):隔离范围、网络、日志、Ubuntu / WSL2 排查
|
|
183
|
+
- [终端界面](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/tui.md):命令、快捷键、图片、会话、显示规则
|
|
184
|
+
- [作为 Python 库使用](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/library.md):`AgentRunner`、事件、自定义工具
|
|
185
|
+
- [架构](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/architecture.md):分层、中间件、会话存储、上下文压缩
|
|
186
|
+
- [开发](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/development.md):测试、冒烟脚本、CI 与发布
|
|
187
|
+
|
|
188
|
+
## 开发
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
git clone https://github.com/ADaozz/deep_agent_cli.git
|
|
192
|
+
cd deep_agent_cli
|
|
193
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
194
|
+
pip install -e ".[dev]"
|
|
195
|
+
pytest -q
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
自动测试不调用真实模型。欢迎提交 Issue 和 Pull Request;修改行为时请附带测试。更多说明见 [开发文档](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/development.md)。
|
|
199
|
+
|
|
200
|
+
## 许可证
|
|
201
|
+
|
|
202
|
+
[MIT](https://github.com/ADaozz/deep_agent_cli/blob/main/LICENSE)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# deep-agent-cli
|
|
2
|
+
|
|
3
|
+
`deep-agent` 是一个在终端中运行的 Coding Agent,支持 Linux 和 WSL2。它把启动时所在的目录作为工作区,调用你配置的 OpenAI 兼容模型服务,并在 [Bubblewrap](https://github.com/containers/bubblewrap) 沙箱中执行命令。Agent 运行时基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 构建。
|
|
4
|
+
|
|
5
|
+
当前版本 0.1.1,处于早期开发阶段。第一个稳定版之前,配置格式、会话存储格式和 Python API 都可能出现不兼容变更。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
- **文件操作**:在工作区中列目录、读、写、编辑、搜索、删除文件。
|
|
10
|
+
- **命令执行**:在 Bubblewrap 沙箱中运行 shell 命令,默认没有网络;输出实时显示。
|
|
11
|
+
- **审批**:默认模式下,运行命令、写入、编辑、删除文件前都会请求你确认。
|
|
12
|
+
- **会话**:按工作区保存在本地 SQLite 中,可以随时恢复。
|
|
13
|
+
- **多模型**:在配置文件中定义多个模型,运行中切换模型和推理强度。支持 Chat Completions 和 Responses 两种接口。
|
|
14
|
+
- **流式输出**:思考内容和回答都流式显示。
|
|
15
|
+
- **运行中干预**:任务执行时可以追加指令、排队后续任务或取消。
|
|
16
|
+
- **图片输入**:向声明支持图片的模型发送图片。
|
|
17
|
+
- **结构化提问**:Agent 需要你做决定时,会弹出单选、多选、是/否或文本输入。
|
|
18
|
+
- **上下文压缩**:接近模型上下文窗口时自动摘要旧对话,也可以手动压缩。
|
|
19
|
+
- **可选扩展**:配置 Tavily API key 后可以搜索公开网页;从 `~/.deep-agent/skills/` 加载 Skills;读取工作区根目录的 `AGENTS.md` 作为项目说明。
|
|
20
|
+
|
|
21
|
+
## 运行要求
|
|
22
|
+
|
|
23
|
+
- Linux 或 WSL2。WSL1、原生 Windows 和 macOS 无法使用沙箱。
|
|
24
|
+
- Python 3.12 或更高版本(CI 测试 3.12 和 3.13)。
|
|
25
|
+
- Bubblewrap,并且系统允许非特权 user namespace。Ubuntu 24.04 默认限制这一点,处理方法见 [沙箱排查](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md#排查ubuntu--wsl2)。
|
|
26
|
+
- 一个 OpenAI 兼容的模型服务(本地或远程)及其 API key。
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
Debian / Ubuntu:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
sudo apt install pipx bubblewrap
|
|
34
|
+
pipx ensurepath # 之后重新打开终端
|
|
35
|
+
pipx install deep-agent-cli
|
|
36
|
+
deep-agent --version
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
系统 Python 低于 3.12 时,安装一个新版本的 Python,然后指定解释器(不要替换发行版自带的 `/usr/bin/python3`):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pipx install --python /path/to/python3.12 deep-agent-cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
也可以装进虚拟环境:`python3 -m venv ~/.venvs/deep-agent && ~/.venvs/deep-agent/bin/pip install deep-agent-cli`。
|
|
46
|
+
|
|
47
|
+
## 快速开始
|
|
48
|
+
|
|
49
|
+
**1. 生成配置文件**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
deep-agent
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
首次运行会创建 `~/.deep-agent/config.yaml` 和 `~/.deep-agent/skills/`,然后退出。
|
|
56
|
+
|
|
57
|
+
**2. 配置模型**
|
|
58
|
+
|
|
59
|
+
编辑 `~/.deep-agent/config.yaml`,把 `llm` 部分改成你的服务:
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
llm:
|
|
63
|
+
default: local/main # 启动时使用的模型:来源/模型键
|
|
64
|
+
models:
|
|
65
|
+
local: # 来源名,自定义
|
|
66
|
+
base_url: http://localhost:8000/v1
|
|
67
|
+
api_key: ${MY_API_KEY} # 也可以直接写密钥
|
|
68
|
+
provider: openai-compatible # 端点支持 Responses API 时可改为 qwen-responses
|
|
69
|
+
stream_usage: true
|
|
70
|
+
models:
|
|
71
|
+
main: # 模型键,自定义
|
|
72
|
+
model: your-model-name # 发给服务端的模型名
|
|
73
|
+
context_window: 128k
|
|
74
|
+
input: [text] # 支持图片时写 [text, image]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`provider` 未填写时默认为 `qwen-responses`(Responses API),只提供 Chat Completions 的服务需要显式写 `openai-compatible`。其他字段、推理强度和服务商示例见 [配置参考](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/configuration.md)。
|
|
78
|
+
|
|
79
|
+
**3. 在项目目录中启动**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
cd ~/projects/my-app
|
|
83
|
+
deep-agent
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
启动时会先检查沙箱是否可用;不可用时程序给出诊断信息并拒绝启动。界面中直接输入任务即可,以 `/` 开头的输入是命令。
|
|
87
|
+
|
|
88
|
+
**4. 恢复会话**
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
deep-agent resume # 选择一个已保存的会话
|
|
92
|
+
deep-agent resume 01a08aae # 按 id 或前缀恢复
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
恢复只加载会话状态,不会自动继续执行未完成的任务。
|
|
96
|
+
|
|
97
|
+
## 常用操作
|
|
98
|
+
|
|
99
|
+
| 命令 | 作用 |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `/help` | 列出命令和快捷键 |
|
|
102
|
+
| `/status` | 当前模型、权限模式、沙箱状态 |
|
|
103
|
+
| `/model` | 选择模型和推理强度 |
|
|
104
|
+
| `/permission ask\|allow` | 切换审批模式 |
|
|
105
|
+
| `/resume`、`/new` | 切换到已有会话、新建会话 |
|
|
106
|
+
| `/compact` | 手动压缩上下文 |
|
|
107
|
+
| `/image <路径>` | 为下一条消息附加图片 |
|
|
108
|
+
| `/quit` | 退出 |
|
|
109
|
+
|
|
110
|
+
| 按键 | 作用 |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `Enter` | 提交;任务运行中提交为追加指令 |
|
|
113
|
+
| `Ctrl+J` | 换行 |
|
|
114
|
+
| `Alt+Enter` | 排队,当前任务结束后执行 |
|
|
115
|
+
| `Esc` | 取消当前任务 |
|
|
116
|
+
| `F2` | 重新打开待处理的审批或提问 |
|
|
117
|
+
| `Ctrl+O` / `Ctrl+T` | 展开工具详情 / 思考内容 |
|
|
118
|
+
| `Ctrl+R` | 查看文件改动 |
|
|
119
|
+
| `Ctrl+P` | 切换到下一个模型 |
|
|
120
|
+
| `Ctrl+C` | 清空输入;连按两次退出 |
|
|
121
|
+
|
|
122
|
+
完整的命令、按键和界面行为见 [终端界面](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/tui.md)。
|
|
123
|
+
|
|
124
|
+
## 安全模型
|
|
125
|
+
|
|
126
|
+
| | 行为 |
|
|
127
|
+
|---|---|
|
|
128
|
+
| 命令能访问的文件 | 工作区(读写,在沙箱中为 `/workspace`)、`~/.deep-agent/skills/`(只读)、系统的 `/usr`、`/bin`、`/lib`(只读)。家目录的其余部分不可见 |
|
|
129
|
+
| 网络 | 命令默认无网络。模型可以为单条命令申请网络,此时它能访问互联网、`localhost` 和局域网 |
|
|
130
|
+
| 环境变量 | 只传入 `LANG`、`TERM` 等少量变量,其余需在配置中显式列出 |
|
|
131
|
+
| `ask` 模式(默认) | 运行命令、写入、编辑、删除文件前需要确认 |
|
|
132
|
+
| `allow` 模式 | 所有工具自动批准,所有命令都开放网络。仅在沙箱可用时可开启,开启时需输入 `ALLOW` |
|
|
133
|
+
| 沙箱不可用 | 拒绝启动。只有在配置中设置 `sandbox.allow_unsandboxed: true`,或在启动提示中输入 `UNSANDBOXED`,命令才会以当前用户身份直接在宿主机上运行,此时只能使用 `ask` 模式 |
|
|
134
|
+
|
|
135
|
+
细节见 [沙箱与权限](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md)。
|
|
136
|
+
|
|
137
|
+
## 已知限制
|
|
138
|
+
|
|
139
|
+
- 沙箱不限制 CPU、内存和磁盘用量。
|
|
140
|
+
- 沙箱中只有系统目录下的程序。安装在 `~/.local`、`~/.nvm`、`/opt` 等位置的工具链默认不可用,需要在配置中添加只读挂载。
|
|
141
|
+
- 文件工具在 `deep-agent` 进程中直接读写宿主文件,不经过沙箱,路径限定在工作区和 Skills 目录内。工作区里的所有内容 Agent 都能读写,包括 `.git/` 和 `.env`。
|
|
142
|
+
- 程序会在工作区中创建 `.deep-agent/`(命令输出超限时的日志)和 `.deepagents/`(上下文压缩时保存的历史),但不会修改 `.gitignore`。
|
|
143
|
+
- 不能在家目录或其上层目录启动,因为配置目录 `~/.deep-agent` 必须位于工作区之外。
|
|
144
|
+
- 只能在交互式终端中使用,没有非交互或批处理模式。
|
|
145
|
+
- 模型请求和 Tavily 请求不读取 `HTTP_PROXY`、`HTTPS_PROXY`、`ALL_PROXY` 等代理环境变量。
|
|
146
|
+
- 从剪贴板粘贴图片只支持 WSL;其他环境需要通过文件路径添加图片。
|
|
147
|
+
- 推理强度的可选值需要按服务商文档手动配置,程序不会自动探测。
|
|
148
|
+
- 不支持 MCP,也没有子 Agent。
|
|
149
|
+
- 同一个会话同一时间只能被一个进程打开。
|
|
150
|
+
|
|
151
|
+
## 文档
|
|
152
|
+
|
|
153
|
+
- [配置参考](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/configuration.md):所有配置项、模型与推理强度、Web 搜索、按键、环境变量
|
|
154
|
+
- [沙箱与权限](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/sandbox.md):隔离范围、网络、日志、Ubuntu / WSL2 排查
|
|
155
|
+
- [终端界面](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/tui.md):命令、快捷键、图片、会话、显示规则
|
|
156
|
+
- [作为 Python 库使用](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/library.md):`AgentRunner`、事件、自定义工具
|
|
157
|
+
- [架构](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/architecture.md):分层、中间件、会话存储、上下文压缩
|
|
158
|
+
- [开发](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/development.md):测试、冒烟脚本、CI 与发布
|
|
159
|
+
|
|
160
|
+
## 开发
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
git clone https://github.com/ADaozz/deep_agent_cli.git
|
|
164
|
+
cd deep_agent_cli
|
|
165
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
166
|
+
pip install -e ".[dev]"
|
|
167
|
+
pytest -q
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
自动测试不调用真实模型。欢迎提交 Issue 和 Pull Request;修改行为时请附带测试。更多说明见 [开发文档](https://github.com/ADaozz/deep_agent_cli/blob/main/docs/development.md)。
|
|
171
|
+
|
|
172
|
+
## 许可证
|
|
173
|
+
|
|
174
|
+
[MIT](https://github.com/ADaozz/deep_agent_cli/blob/main/LICENSE)
|
|
@@ -7,6 +7,7 @@ from functools import partial
|
|
|
7
7
|
import logging
|
|
8
8
|
import os
|
|
9
9
|
import time
|
|
10
|
+
from time import monotonic
|
|
10
11
|
from collections.abc import Callable, Iterator
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Any
|
|
@@ -62,7 +63,8 @@ from agent.cli.rendering import (
|
|
|
62
63
|
)
|
|
63
64
|
from agent.cli.session_controller import SessionController
|
|
64
65
|
from agent.cli.state import CliState, ToolBlock
|
|
65
|
-
from agent.
|
|
66
|
+
from agent.cli.working_messages import WorkingMessageRotation, load_working_messages
|
|
67
|
+
from agent.config import DEFAULT_UI_DISPLAY_LIMITS, DEFAULT_UI_TIMEZONE, ModelProfile, require_keybindings_outside_workspace
|
|
66
68
|
from agent.permission import (
|
|
67
69
|
PERMISSION_ALLOW_WARNING,
|
|
68
70
|
PermissionMode,
|
|
@@ -73,7 +75,7 @@ from agent.permission import (
|
|
|
73
75
|
)
|
|
74
76
|
from agent.runner import AgentRunner, InterruptKind, RunEvent, RunResult, UnknownInterruptError
|
|
75
77
|
|
|
76
|
-
# Workspace/model
|
|
78
|
+
# Workspace/model and execution settings on the left; git/context on the right.
|
|
77
79
|
FOOTER_LINES = 2
|
|
78
80
|
|
|
79
81
|
|
|
@@ -378,7 +380,8 @@ class CliApplication:
|
|
|
378
380
|
self._selection_scroll_step = 0
|
|
379
381
|
self._selection_scroll_handle: asyncio.TimerHandle | None = None
|
|
380
382
|
timezone_name = runner.settings.ui_timezone if runner.settings is not None else DEFAULT_UI_TIMEZONE
|
|
381
|
-
|
|
383
|
+
display_limits = runner.settings.ui_display_limits if runner.settings is not None else DEFAULT_UI_DISPLAY_LIMITS
|
|
384
|
+
self._renderer = TranscriptRenderer(ZoneInfo(timezone_name), limits=display_limits)
|
|
382
385
|
self._git = GitProbe(self._workspace())
|
|
383
386
|
self._git_summary = self._git.summary
|
|
384
387
|
self._git_task: asyncio.Task[None] | None = None
|
|
@@ -414,8 +417,15 @@ class CliApplication:
|
|
|
414
417
|
text=self._footer_text, focusable=False, on_scroll=self.scroll_transcript,
|
|
415
418
|
on_select_outside=self._select_below_transcript,
|
|
416
419
|
)
|
|
420
|
+
messages_path = config_dir / "working_messages.yaml" if config_dir else None
|
|
421
|
+
self._working_messages = WorkingMessageRotation(load_working_messages(messages_path))
|
|
422
|
+
self.status_control = _ScrollableTextControl(
|
|
423
|
+
text=self._status_text, focusable=False, on_scroll=self.scroll_transcript,
|
|
424
|
+
on_select_outside=self._select_below_transcript,
|
|
425
|
+
)
|
|
417
426
|
self.back_to_bottom_control = _BackToBottomControl(
|
|
418
|
-
text="↓ Back to bottom · esc"
|
|
427
|
+
text=lambda: FormattedText([("class:back-to-bottom", "↓ Back to bottom · esc")])
|
|
428
|
+
if self.interaction is None and self.transcript_away_from_bottom() else FormattedText([]),
|
|
419
429
|
focusable=False,
|
|
420
430
|
on_scroll=self.scroll_transcript,
|
|
421
431
|
on_click=self.follow_transcript,
|
|
@@ -439,7 +449,9 @@ class CliApplication:
|
|
|
439
449
|
rows = self.application.output.get_size().rows
|
|
440
450
|
except Exception: # noqa: BLE001
|
|
441
451
|
rows = 30
|
|
442
|
-
|
|
452
|
+
# Keep at least one input row even in an extremely short terminal.
|
|
453
|
+
terminal_limit = max(1, rows // 3)
|
|
454
|
+
maximum = min(display_limits.editor_max_lines, terminal_limit)
|
|
443
455
|
return Dimension(min=1, preferred=min(lines, maximum), max=maximum)
|
|
444
456
|
|
|
445
457
|
def interaction_height() -> Any:
|
|
@@ -464,6 +476,16 @@ class CliApplication:
|
|
|
464
476
|
always_hide_cursor=True,
|
|
465
477
|
viewport=self,
|
|
466
478
|
)
|
|
479
|
+
self.interaction_divider_window = Window(height=1, char="─", style="class:interaction-divider")
|
|
480
|
+
self.interaction_hint_window = Window(
|
|
481
|
+
_BackToBottomControl(
|
|
482
|
+
text=FormattedText([("class:back-to-bottom", "↓ Back to bottom · esc")]),
|
|
483
|
+
focusable=False, on_scroll=self.scroll_transcript,
|
|
484
|
+
on_click=self.follow_transcript, on_select_outside=self._select_below_transcript,
|
|
485
|
+
),
|
|
486
|
+
height=1, dont_extend_height=True,
|
|
487
|
+
align=WindowAlign.CENTER,
|
|
488
|
+
)
|
|
467
489
|
body = HSplit([
|
|
468
490
|
self.transcript_window,
|
|
469
491
|
ConditionalContainer(
|
|
@@ -477,17 +499,11 @@ class CliApplication:
|
|
|
477
499
|
filter=attachments_visible,
|
|
478
500
|
),
|
|
479
501
|
ConditionalContainer(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
height=1,
|
|
483
|
-
dont_extend_height=True,
|
|
484
|
-
align=WindowAlign.CENTER,
|
|
485
|
-
style="class:back-to-bottom",
|
|
486
|
-
),
|
|
487
|
-
filter=back_to_bottom_visible,
|
|
502
|
+
self.interaction_hint_window,
|
|
503
|
+
filter=back_to_bottom_visible & interaction_visible,
|
|
488
504
|
),
|
|
489
505
|
ConditionalContainer(
|
|
490
|
-
|
|
506
|
+
self.interaction_divider_window,
|
|
491
507
|
filter=interaction_visible,
|
|
492
508
|
),
|
|
493
509
|
ConditionalContainer(
|
|
@@ -501,6 +517,28 @@ class CliApplication:
|
|
|
501
517
|
),
|
|
502
518
|
filter=interaction_visible,
|
|
503
519
|
),
|
|
520
|
+
ConditionalContainer(
|
|
521
|
+
Window(
|
|
522
|
+
self.status_control,
|
|
523
|
+
height=1,
|
|
524
|
+
wrap_lines=False,
|
|
525
|
+
always_hide_cursor=True,
|
|
526
|
+
dont_extend_height=True,
|
|
527
|
+
style="class:status",
|
|
528
|
+
),
|
|
529
|
+
filter=Condition(self._status_visible),
|
|
530
|
+
),
|
|
531
|
+
ConditionalContainer(
|
|
532
|
+
Window(height=1, char="─", style="class:interaction-divider"),
|
|
533
|
+
filter=Condition(lambda: self.state.status == "Waiting for input"),
|
|
534
|
+
),
|
|
535
|
+
ConditionalContainer(
|
|
536
|
+
Window(
|
|
537
|
+
self.back_to_bottom_control,
|
|
538
|
+
height=1, dont_extend_height=True, align=WindowAlign.CENTER,
|
|
539
|
+
),
|
|
540
|
+
filter=back_to_bottom_visible & ~interaction_visible,
|
|
541
|
+
),
|
|
504
542
|
ConditionalContainer(
|
|
505
543
|
HSplit([
|
|
506
544
|
Window(height=1, char=" ", style="class:editor"),
|
|
@@ -528,7 +566,7 @@ class CliApplication:
|
|
|
528
566
|
self.application: Application[None] = Application(
|
|
529
567
|
layout=Layout(FloatContainer(
|
|
530
568
|
content=body,
|
|
531
|
-
floats=[Float(xcursor=True, ycursor=True, content=CompletionsMenu(max_height=
|
|
569
|
+
floats=[Float(xcursor=True, ycursor=True, content=CompletionsMenu(max_height=display_limits.completion_menu_lines, scroll_offset=1))],
|
|
532
570
|
), focused_element=self.editor_control),
|
|
533
571
|
key_bindings=self.bindings,
|
|
534
572
|
full_screen=True,
|
|
@@ -541,6 +579,8 @@ class CliApplication:
|
|
|
541
579
|
"footer-workspace": "ansigreen",
|
|
542
580
|
"footer-resume-id": "ansicyan",
|
|
543
581
|
"footer-model": "ansiyellow",
|
|
582
|
+
"status": "ansicyan bold",
|
|
583
|
+
"status-message": "#aaaaaa nobold",
|
|
544
584
|
"interaction": "#d0d0d0",
|
|
545
585
|
"attachments": "#72d5e8",
|
|
546
586
|
"back-to-bottom": "bg:#163a5f #d7edff",
|
|
@@ -557,6 +597,8 @@ class CliApplication:
|
|
|
557
597
|
self.application.timeoutlen = 0.10
|
|
558
598
|
if self.keymap.warning:
|
|
559
599
|
self.state.add_system(self.keymap.warning, error=True)
|
|
600
|
+
if self._working_messages.config.warning:
|
|
601
|
+
self.state.add_system(self._working_messages.config.warning, error=True)
|
|
560
602
|
if self.runner.on_event is None:
|
|
561
603
|
self.runner.on_event = self._on_event_thread
|
|
562
604
|
|
|
@@ -881,7 +923,7 @@ class CliApplication:
|
|
|
881
923
|
return
|
|
882
924
|
self._compacting = True
|
|
883
925
|
self.state.running = True
|
|
884
|
-
self.set_status("Compacting context
|
|
926
|
+
self.set_status("Compacting context")
|
|
885
927
|
try:
|
|
886
928
|
result = await self._run_blocking(self.runner.compact_context)
|
|
887
929
|
except Exception as exc: # noqa: BLE001
|
|
@@ -1343,15 +1385,41 @@ class CliApplication:
|
|
|
1343
1385
|
fragments.append(("class:attachments", f" ▣ Image #{index} {ref.filename} · {size}\n"))
|
|
1344
1386
|
return FormattedText(fragments)
|
|
1345
1387
|
|
|
1346
|
-
def
|
|
1388
|
+
def _status_visible(self) -> bool:
|
|
1389
|
+
return bool(
|
|
1390
|
+
self.state.running or self.state.status != "Ready"
|
|
1391
|
+
or self.runner.control.pending_steering_count()
|
|
1392
|
+
or self.runner.control.pending_follow_up_count()
|
|
1393
|
+
)
|
|
1394
|
+
|
|
1395
|
+
def _status_text(self) -> FormattedText:
|
|
1396
|
+
if not self._status_visible():
|
|
1397
|
+
self._working_messages.reset()
|
|
1398
|
+
return FormattedText([])
|
|
1347
1399
|
pending = self.runner.control.pending_steering_count() + self.runner.control.pending_follow_up_count()
|
|
1348
|
-
|
|
1400
|
+
active = self.state.running and self.interaction is None and not self.state.status.startswith("Cancelling")
|
|
1401
|
+
now = monotonic()
|
|
1402
|
+
message = self._working_messages.current(active, now)
|
|
1403
|
+
spinner = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"[int(now * 10) % 10] + " " if self.state.running else ""
|
|
1404
|
+
width = self._width()
|
|
1405
|
+
label = self.state.status if self.state.running or self.state.status != "Ready" else ""
|
|
1406
|
+
if (self._compacting or self.state.compacting) and not label.startswith("Cancelling"):
|
|
1407
|
+
label = "Compacting context"
|
|
1408
|
+
if pending:
|
|
1409
|
+
label = f"{label} · queued {pending}" if label else f"queued {pending}"
|
|
1410
|
+
status = _truncate_cells(f" {spinner}{label}", width)
|
|
1411
|
+
fragments = [("class:status", status)]
|
|
1412
|
+
remaining = width - get_cwidth(status)
|
|
1413
|
+
if message is not None and remaining > 3:
|
|
1414
|
+
fragments.append(("class:status-message", " · " + _truncate_cells(message.display, remaining - 3)))
|
|
1415
|
+
return FormattedText(fragments)
|
|
1416
|
+
|
|
1417
|
+
def _footer_text(self): # type: ignore[no-untyped-def]
|
|
1349
1418
|
mode = self.runner.prepared.execution_mode.value
|
|
1350
1419
|
perm = self.runner.permission_mode().value
|
|
1351
1420
|
pending_permission = self.runner.pending_permission_mode()
|
|
1352
1421
|
if pending_permission is not None:
|
|
1353
1422
|
perm += f"→{pending_permission.value}(pending)"
|
|
1354
|
-
spinner = " ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"[int(time.monotonic() * 10) % 11] if self.state.running else ""
|
|
1355
1423
|
width = self._width()
|
|
1356
1424
|
model = self.runner.current_model()
|
|
1357
1425
|
model_label = model_display_name(model) if model is not None else "fixed model"
|
|
@@ -1365,10 +1433,10 @@ class CliApplication:
|
|
|
1365
1433
|
resume_id = self.runner.thread_id[:8]
|
|
1366
1434
|
context = format_context_usage(self.state.usage, self.runner.context_window())
|
|
1367
1435
|
# Row 1: workspace · model · resume on the left, git on the right.
|
|
1368
|
-
# Row 2:
|
|
1436
|
+
# Row 2: sandbox/permission on the left, context on the right.
|
|
1369
1437
|
# The left side always truncates before the right side.
|
|
1370
1438
|
git = self._git_summary.label() or "⎇ no git"
|
|
1371
|
-
status = f" {
|
|
1439
|
+
status = f" {mode} · perm:{perm}"
|
|
1372
1440
|
git_fit = _truncate_cells(git, width)
|
|
1373
1441
|
available = max(1, width - get_cwidth(git_fit) - 1)
|
|
1374
1442
|
fragments: list[tuple[str, str]] = []
|
|
@@ -1707,6 +1775,7 @@ class CliApplication:
|
|
|
1707
1775
|
self.state.add_user(text, attachments=image_refs)
|
|
1708
1776
|
self.state.attachments.clear()
|
|
1709
1777
|
self.state.running = True
|
|
1778
|
+
self._working_messages.reset()
|
|
1710
1779
|
self.set_status("Working… Esc to cancel")
|
|
1711
1780
|
|
|
1712
1781
|
async def work() -> None:
|
|
@@ -1861,6 +1930,8 @@ class CliApplication:
|
|
|
1861
1930
|
|
|
1862
1931
|
def _apply_event(self, event: RunEvent, *, announce: bool = True) -> None:
|
|
1863
1932
|
self.state.apply(event)
|
|
1933
|
+
if event.type in {"run_started", "run_cancelling"} or not self.state.running:
|
|
1934
|
+
self._working_messages.reset()
|
|
1864
1935
|
if event.type == "runtime_config_applied" and isinstance(event.result, dict):
|
|
1865
1936
|
changes = []
|
|
1866
1937
|
if event.result.get("model_changed"):
|