deep-agent-cli 0.2.0__tar.gz → 0.2.1__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.2.0 → deep_agent_cli-0.2.1}/PKG-INFO +10 -7
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/README.md +9 -6
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/app.py +14 -6
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/previews.py +17 -1
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/rendering.py +34 -14
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/state.py +25 -1
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/config.example.yaml +38 -24
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/config.py +42 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/control.py +18 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/factory.py +96 -6
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/llm_stream.py +10 -0
- deep_agent_cli-0.2.1/agent/middleware/current_time.py +33 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/runner.py +22 -8
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/session.py +18 -3
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/session_runtime.py +8 -3
- deep_agent_cli-0.2.1/agent/subagents/__init__.py +1 -0
- deep_agent_cli-0.2.1/agent/subagents/log_store.py +90 -0
- deep_agent_cli-0.2.1/agent/subagents/manager.py +50 -0
- deep_agent_cli-0.2.1/agent/subagents/runtime.py +212 -0
- deep_agent_cli-0.2.1/agent/tools/subagent_logs.py +20 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/pyproject.toml +1 -1
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/.gitignore +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/LICENSE +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/__init__.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/attachments.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/bootstrap.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cancel.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/__init__.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/clipboard.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/commands.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/gitinfo.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/input.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/input_actions.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/interactions.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/lifecycle.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/main.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/mcp_controller.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/mcp_ui.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/pasted_content.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/session_controller.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/skills.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/working_messages.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/cli/working_messages.yaml +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/environment.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/file_mutation.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/http_environment.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/llm.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/__init__.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/adapter.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/bridge.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/config.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/content.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/logging.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/manager.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/middleware.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/names.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/oauth.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/oauth_storage.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/mcp/tools.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/__init__.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/attachments.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/cancel_tools.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/pause.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/recovery.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/runtime_config.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/steering.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/tool_arg_hints.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/usage.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/workspace_filesystem.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/middleware/write_operation.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/network.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/performance.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/permission.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/run_events.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/sandbox.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/sandbox_mounts.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/sandbox_pool.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/sandbox_worker.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/session_lock.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/stream.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/__init__.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/_grep_worker.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/examples.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/execute.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/grep.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/human_input.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/human_interaction.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/tools/web_search.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/agent/version.py +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}/assets/readme/runtime-map.svg +0 -0
- {deep_agent_cli-0.2.0 → deep_agent_cli-0.2.1}//347/273/210/347/253/257.png" +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deep-agent-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A sandboxed coding agent CLI for Linux and WSL2
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -46,20 +46,21 @@ OpenAI 兼容接口 · Bubblewrap
|
|
|
46
46
|
<img src="终端.png" width="760" alt="deep-agent 真实终端空闲界面,底栏显示工作区、模型来源、SANDBOXED 和 perm:ask。">
|
|
47
47
|
</p>
|
|
48
48
|
|
|
49
|
-
`deep-agent` 是基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 的终端 Coding Agent
|
|
49
|
+
`deep-agent` 是基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 的终端 Coding Agent。它在当前项目中工作,主 Agent 默认在文件变更、命令执行和网页搜索前请求批准,通过 [Bubblewrap](https://github.com/containers/bubblewrap) 隔离命令执行。
|
|
50
50
|
|
|
51
51
|
在项目目录运行 `deep-agent` 进入交互式终端,用 `deep-agent resume` 恢复已有会话。要在其他 Python 程序里复用同一套运行核心,使用 [Python API](docs/library.md)。
|
|
52
52
|
|
|
53
|
-
> 当前版本 **0.2.
|
|
53
|
+
> 当前版本 **0.2.1**,处于早期开发阶段。稳定版前,配置、会话存储格式和 Python API 可能出现不兼容变更。
|
|
54
54
|
|
|
55
55
|
## 能做什么
|
|
56
56
|
|
|
57
57
|
- **查代码、改文件** — 浏览、读取、正则搜索、编辑和删除;`Ctrl+R` 审阅完整改动,`F2` 处理审批。
|
|
58
58
|
- **运行项目命令** — 实时查看输出,会话内复用持久沙箱;默认审批、隔离直接 IP 网络。
|
|
59
59
|
- **随时介入任务** — 追加指令、排队后续任务、暂停、取消,以及结构化人工输入。
|
|
60
|
+
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2 个,主 Agent 同步等待最终结果。TUI 为每个子任务显示独立卡片、状态及可展开的完整返回结果,内部思考和工具输出保持隔离。
|
|
60
61
|
- **保留工作上下文** — SQLite 会话恢复、模型与推理强度切换、上下文压缩;支持图片输入的模型可接收附件。
|
|
61
62
|
|
|
62
|
-
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。
|
|
63
|
+
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。SubAgent 配置、独立思考强度及日志查询见 [SubAgent 委派](docs/configuration.md#subagent-委派)。
|
|
63
64
|
|
|
64
65
|
## 快速开始
|
|
65
66
|
|
|
@@ -199,6 +200,8 @@ SQLite 保存会话状态。模型工具表不包含 `grep` 和 `glob`。代码
|
|
|
199
200
|
| **沙箱 + `ask`**(默认) | 文件变更、命令、网页搜索、MCP 调用及增删服务需批准 | 默认隔离直接 IP 网络;`network=true` 获批后共享宿主网络 |
|
|
200
201
|
| 沙箱 + `allow` | 所有工具免审批,包括 MCP 工具、`mcp_add`、`mcp_remove` | 所有 execute 共享宿主网络 |
|
|
201
202
|
|
|
203
|
+
SubAgent 共享已验证的沙箱 Backend 和 Pool,使用独立的 `allow` 权限,即使主 Agent 处于 `ask` 也不弹出子任务审批;子 Agent 不装载 MCP、人工输入或递归委派工具。其默认思考强度使用子模型原生默认,不继承主 Agent 的强度。
|
|
204
|
+
|
|
202
205
|
只读文件工具免审批;`/permission` 统一控制原生与 MCP 工具审批,`allow` 仅限沙箱模式。MCP 在宿主进程中运行,不经过 Bubblewrap,也不受沙箱网络策略限制。配置在 `~/.deep-agent/mcp.json`,根级 `enabled` 是全局开关(默认开启);用 `/mcp`、`/mcp enable`、`/mcp disable` 或 `mcp_add` / `mcp_remove` 管理。全局关闭时不连接、不启动 stdio、不打开 OAuth,也不把 MCP 工具交给模型;配置和令牌缓存仍保留。**工作区内的 `.env`、`.git` 同样可访问,取消不回滚已发生的副作用。**
|
|
203
206
|
|
|
204
207
|
全局开关打开时,启动会自动连接各服务里 `enabled: true` 的项。OAuth 优先使用加密缓存并刷新令牌,无法刷新时打开浏览器授权;无需鉴权的服务直接连接。`/mcp` 先显示 `MCP: Enabled` 或 `MCP: Disabled`,开启时再列出 `服务名 状态 N tools`;`connected` 为绿色,其余状态为红色。连接恢复、附件处理和后台日志见 [MCP 配置](docs/configuration.md#mcpmcpjson),命令和状态说明见 [TUI 文档](docs/tui.md#mcp-服务)。
|
|
@@ -206,10 +209,10 @@ SQLite 保存会话状态。模型工具表不包含 `grep` 和 `glob`。代码
|
|
|
206
209
|
<details>
|
|
207
210
|
<summary>更多边界与当前限制</summary>
|
|
208
211
|
|
|
209
|
-
- **网络与进程**:无网命名空间不阻断通过共享 Unix socket、FIFO 或文件实现的间接通信。有网实例可访问互联网、localhost 和局域网;切回 `ask`
|
|
212
|
+
- **网络与进程**:无网命名空间不阻断通过共享 Unix socket、FIFO 或文件实现的间接通信。有网实例可访问互联网、localhost 和局域网;切回 `ask` 不停止此前的后台进程。模型与会话切换复用 Pool,关闭 Runner 或更换文件系统模式时清理沙箱。
|
|
210
213
|
- **挂载与资源**:用户可通过现有挂载列表扩大或缩小文件系统可见范围,审批逻辑保持独立。只读挂载仍允许读取其中的敏感文件。没有 CPU、内存、磁盘或进程数硬配额。Skills、`AGENTS.md` 和提示词不是操作系统安全边界。
|
|
211
|
-
-
|
|
212
|
-
- **客户端**:模型、MCP、Tavily 和子进程统一使用全局 [`trust_env`](docs/configuration.md#全局网络环境trust_env) 配置,默认忽略代理与 CA 环境变量;剪贴板图片仅支持 WSL,其他环境通过文件添加。MCP 支持 Streamable HTTP 和 stdio 工具调用及工具返回的内嵌资源;不提供独立 Resources / Prompts 接口、Sampling 回调、旧式服务端 Elicitation、MCP Apps UI
|
|
214
|
+
- **本地状态**:SubAgent 执行摘要独立保存在受保护配置目录的 `subagents/` 下,仅记录任务起止、工具状态和有界最终结果,不保存模型 Token、思考或原始工具输出,只精确替换已知模型及 Tavily Key;同一会话只允许一个进程持有;工作区可能产生 `.deep-agent/` 命令日志和 `.deepagents/` 压缩历史,程序不修改 `.gitignore`。
|
|
215
|
+
- **客户端**:模型、MCP、Tavily 和子进程统一使用全局 [`trust_env`](docs/configuration.md#全局网络环境trust_env) 配置,默认忽略代理与 CA 环境变量;剪贴板图片仅支持 WSL,其他环境通过文件添加。MCP 支持 Streamable HTTP 和 stdio 工具调用及工具返回的内嵌资源;不提供独立 Resources / Prompts 接口、Sampling 回调、旧式服务端 Elicitation、MCP Apps UI。MCP 工具仅向主 Agent 提供。
|
|
213
216
|
|
|
214
217
|
完整隔离范围与环境变量见 [沙箱与权限](docs/sandbox.md)。
|
|
215
218
|
|
|
@@ -15,20 +15,21 @@ OpenAI 兼容接口 · Bubblewrap
|
|
|
15
15
|
<img src="终端.png" width="760" alt="deep-agent 真实终端空闲界面,底栏显示工作区、模型来源、SANDBOXED 和 perm:ask。">
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
-
`deep-agent` 是基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 的终端 Coding Agent
|
|
18
|
+
`deep-agent` 是基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 的终端 Coding Agent。它在当前项目中工作,主 Agent 默认在文件变更、命令执行和网页搜索前请求批准,通过 [Bubblewrap](https://github.com/containers/bubblewrap) 隔离命令执行。
|
|
19
19
|
|
|
20
20
|
在项目目录运行 `deep-agent` 进入交互式终端,用 `deep-agent resume` 恢复已有会话。要在其他 Python 程序里复用同一套运行核心,使用 [Python API](docs/library.md)。
|
|
21
21
|
|
|
22
|
-
> 当前版本 **0.2.
|
|
22
|
+
> 当前版本 **0.2.1**,处于早期开发阶段。稳定版前,配置、会话存储格式和 Python API 可能出现不兼容变更。
|
|
23
23
|
|
|
24
24
|
## 能做什么
|
|
25
25
|
|
|
26
26
|
- **查代码、改文件** — 浏览、读取、正则搜索、编辑和删除;`Ctrl+R` 审阅完整改动,`F2` 处理审批。
|
|
27
27
|
- **运行项目命令** — 实时查看输出,会话内复用持久沙箱;默认审批、隔离直接 IP 网络。
|
|
28
28
|
- **随时介入任务** — 追加指令、排队后续任务、暂停、取消,以及结构化人工输入。
|
|
29
|
+
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2 个,主 Agent 同步等待最终结果。TUI 为每个子任务显示独立卡片、状态及可展开的完整返回结果,内部思考和工具输出保持隔离。
|
|
29
30
|
- **保留工作上下文** — SQLite 会话恢复、模型与推理强度切换、上下文压缩;支持图片输入的模型可接收附件。
|
|
30
31
|
|
|
31
|
-
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。
|
|
32
|
+
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。SubAgent 配置、独立思考强度及日志查询见 [SubAgent 委派](docs/configuration.md#subagent-委派)。
|
|
32
33
|
|
|
33
34
|
## 快速开始
|
|
34
35
|
|
|
@@ -168,6 +169,8 @@ SQLite 保存会话状态。模型工具表不包含 `grep` 和 `glob`。代码
|
|
|
168
169
|
| **沙箱 + `ask`**(默认) | 文件变更、命令、网页搜索、MCP 调用及增删服务需批准 | 默认隔离直接 IP 网络;`network=true` 获批后共享宿主网络 |
|
|
169
170
|
| 沙箱 + `allow` | 所有工具免审批,包括 MCP 工具、`mcp_add`、`mcp_remove` | 所有 execute 共享宿主网络 |
|
|
170
171
|
|
|
172
|
+
SubAgent 共享已验证的沙箱 Backend 和 Pool,使用独立的 `allow` 权限,即使主 Agent 处于 `ask` 也不弹出子任务审批;子 Agent 不装载 MCP、人工输入或递归委派工具。其默认思考强度使用子模型原生默认,不继承主 Agent 的强度。
|
|
173
|
+
|
|
171
174
|
只读文件工具免审批;`/permission` 统一控制原生与 MCP 工具审批,`allow` 仅限沙箱模式。MCP 在宿主进程中运行,不经过 Bubblewrap,也不受沙箱网络策略限制。配置在 `~/.deep-agent/mcp.json`,根级 `enabled` 是全局开关(默认开启);用 `/mcp`、`/mcp enable`、`/mcp disable` 或 `mcp_add` / `mcp_remove` 管理。全局关闭时不连接、不启动 stdio、不打开 OAuth,也不把 MCP 工具交给模型;配置和令牌缓存仍保留。**工作区内的 `.env`、`.git` 同样可访问,取消不回滚已发生的副作用。**
|
|
172
175
|
|
|
173
176
|
全局开关打开时,启动会自动连接各服务里 `enabled: true` 的项。OAuth 优先使用加密缓存并刷新令牌,无法刷新时打开浏览器授权;无需鉴权的服务直接连接。`/mcp` 先显示 `MCP: Enabled` 或 `MCP: Disabled`,开启时再列出 `服务名 状态 N tools`;`connected` 为绿色,其余状态为红色。连接恢复、附件处理和后台日志见 [MCP 配置](docs/configuration.md#mcpmcpjson),命令和状态说明见 [TUI 文档](docs/tui.md#mcp-服务)。
|
|
@@ -175,10 +178,10 @@ SQLite 保存会话状态。模型工具表不包含 `grep` 和 `glob`。代码
|
|
|
175
178
|
<details>
|
|
176
179
|
<summary>更多边界与当前限制</summary>
|
|
177
180
|
|
|
178
|
-
- **网络与进程**:无网命名空间不阻断通过共享 Unix socket、FIFO 或文件实现的间接通信。有网实例可访问互联网、localhost 和局域网;切回 `ask`
|
|
181
|
+
- **网络与进程**:无网命名空间不阻断通过共享 Unix socket、FIFO 或文件实现的间接通信。有网实例可访问互联网、localhost 和局域网;切回 `ask` 不停止此前的后台进程。模型与会话切换复用 Pool,关闭 Runner 或更换文件系统模式时清理沙箱。
|
|
179
182
|
- **挂载与资源**:用户可通过现有挂载列表扩大或缩小文件系统可见范围,审批逻辑保持独立。只读挂载仍允许读取其中的敏感文件。没有 CPU、内存、磁盘或进程数硬配额。Skills、`AGENTS.md` 和提示词不是操作系统安全边界。
|
|
180
|
-
-
|
|
181
|
-
- **客户端**:模型、MCP、Tavily 和子进程统一使用全局 [`trust_env`](docs/configuration.md#全局网络环境trust_env) 配置,默认忽略代理与 CA 环境变量;剪贴板图片仅支持 WSL,其他环境通过文件添加。MCP 支持 Streamable HTTP 和 stdio 工具调用及工具返回的内嵌资源;不提供独立 Resources / Prompts 接口、Sampling 回调、旧式服务端 Elicitation、MCP Apps UI
|
|
183
|
+
- **本地状态**:SubAgent 执行摘要独立保存在受保护配置目录的 `subagents/` 下,仅记录任务起止、工具状态和有界最终结果,不保存模型 Token、思考或原始工具输出,只精确替换已知模型及 Tavily Key;同一会话只允许一个进程持有;工作区可能产生 `.deep-agent/` 命令日志和 `.deepagents/` 压缩历史,程序不修改 `.gitignore`。
|
|
184
|
+
- **客户端**:模型、MCP、Tavily 和子进程统一使用全局 [`trust_env`](docs/configuration.md#全局网络环境trust_env) 配置,默认忽略代理与 CA 环境变量;剪贴板图片仅支持 WSL,其他环境通过文件添加。MCP 支持 Streamable HTTP 和 stdio 工具调用及工具返回的内嵌资源;不提供独立 Resources / Prompts 接口、Sampling 回调、旧式服务端 Elicitation、MCP Apps UI。MCP 工具仅向主 Agent 提供。
|
|
182
185
|
|
|
183
186
|
完整隔离范围与环境变量见 [沙箱与权限](docs/sandbox.md)。
|
|
184
187
|
|
|
@@ -1912,6 +1912,11 @@ class CliApplication:
|
|
|
1912
1912
|
message = self._working_messages.current(active, now)
|
|
1913
1913
|
spinner = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"[int(now * 10) % 10] + " " if self.state.running else ""
|
|
1914
1914
|
width = self._width()
|
|
1915
|
+
counter = ""
|
|
1916
|
+
if self.state.subagent_count:
|
|
1917
|
+
count = self.state.subagent_count
|
|
1918
|
+
counter = _truncate_cells(f"{count} subagent" + ("s" if count != 1 else ""), width)
|
|
1919
|
+
left_width = max(0, width - get_cwidth(counter) - 1) if counter else width
|
|
1915
1920
|
label = self.state.status if self.state.running or self.state.status != "Ready" else ""
|
|
1916
1921
|
if (self._compacting or self.state.compacting) and not label.startswith("Cancelling"):
|
|
1917
1922
|
label = "Compacting context"
|
|
@@ -1920,16 +1925,19 @@ class CliApplication:
|
|
|
1920
1925
|
queue_label = f"queued {pending} · Ctrl+B collapse" if self.state.messages_expanded else f"queued {pending}: {preview}"
|
|
1921
1926
|
label = f"{label} · {queue_label}" if label else queue_label
|
|
1922
1927
|
raw_status = f" {spinner}{label}"
|
|
1923
|
-
if pending and not self.state.messages_expanded and get_cwidth(raw_status) >
|
|
1924
|
-
hint = " · Ctrl+B expand" if
|
|
1925
|
-
status = _truncate_cells(raw_status, max(1,
|
|
1926
|
-
status = _truncate_cells(status,
|
|
1928
|
+
if pending and not self.state.messages_expanded and get_cwidth(raw_status) > left_width and left_width >= 20:
|
|
1929
|
+
hint = " · Ctrl+B expand" if left_width >= 32 else " · Ctrl+B"
|
|
1930
|
+
status = _truncate_cells(raw_status, max(1, left_width - get_cwidth(hint))) + hint
|
|
1931
|
+
status = _truncate_cells(status, left_width)
|
|
1927
1932
|
else:
|
|
1928
|
-
status = _truncate_cells(raw_status,
|
|
1933
|
+
status = _truncate_cells(raw_status, left_width)
|
|
1929
1934
|
fragments = [("class:status", status)]
|
|
1930
|
-
remaining =
|
|
1935
|
+
remaining = left_width - get_cwidth(status)
|
|
1931
1936
|
if message is not None and remaining > 3:
|
|
1932
1937
|
fragments.append(("class:status-message", " · " + _truncate_cells(message.display, remaining - 3)))
|
|
1938
|
+
if counter:
|
|
1939
|
+
used = sum(get_cwidth(text) for _, text in fragments)
|
|
1940
|
+
fragments.append(("class:status", " " * max(0, width - used - get_cwidth(counter)) + counter))
|
|
1933
1941
|
return FormattedText(fragments)
|
|
1934
1942
|
|
|
1935
1943
|
def _footer_text(self): # type: ignore[no-untyped-def]
|
|
@@ -401,7 +401,9 @@ def aggregate_file_mutations(
|
|
|
401
401
|
rows = [PreviewLine("")]
|
|
402
402
|
previous_order = previous_edit = None
|
|
403
403
|
for order, (edit_index, line) in selected:
|
|
404
|
-
if
|
|
404
|
+
if edit_index != previous_edit:
|
|
405
|
+
rows.append(PreviewLine(f"Edit {edit_index + 1} · snippet line numbers", "dim"))
|
|
406
|
+
elif previous_order is not None and order != previous_order + 1:
|
|
405
407
|
rows.append(PreviewLine(" ⋮", "dim"))
|
|
406
408
|
rows.append(line)
|
|
407
409
|
previous_order, previous_edit = order, edit_index
|
|
@@ -601,7 +603,19 @@ def build_generic_preview(block: ToolBlock) -> ToolPreview:
|
|
|
601
603
|
)
|
|
602
604
|
|
|
603
605
|
|
|
606
|
+
def build_task_preview(block: ToolBlock) -> ToolPreview:
|
|
607
|
+
"""A bounded single-line title; the actual delegation stays untouched."""
|
|
608
|
+
description = " ".join(str(block.arguments.get("description") or "Delegated task").split())
|
|
609
|
+
title = description if len(description) <= 120 else description[:119] + "…"
|
|
610
|
+
return ToolPreview(
|
|
611
|
+
kind="task", verb="SubAgent", target=title,
|
|
612
|
+
detail=str(block.arguments.get("subagent_type") or "general-purpose"),
|
|
613
|
+
summary=f"SubAgent · {title}", action="expand",
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
|
|
604
617
|
_PREVIEW_BUILDERS: dict[str, PreviewBuilder] = {
|
|
618
|
+
"task": build_task_preview,
|
|
605
619
|
"ls": build_ls_preview,
|
|
606
620
|
"read_file": build_read_preview,
|
|
607
621
|
"grep": build_grep_preview,
|
|
@@ -690,6 +704,8 @@ def build_failure_preview(block: ToolBlock, *, limits: UiDisplayLimits = DEFAULT
|
|
|
690
704
|
|
|
691
705
|
|
|
692
706
|
def build_tool_preview(block: ToolBlock, *, limits: UiDisplayLimits = DEFAULT_UI_DISPLAY_LIMITS) -> ToolPreview:
|
|
707
|
+
if block.name == "task":
|
|
708
|
+
return build_task_preview(block)
|
|
693
709
|
if block.name == "execute":
|
|
694
710
|
return build_execute_preview(block)
|
|
695
711
|
if block.is_error:
|
|
@@ -431,6 +431,7 @@ def render_review(calls: list[tuple[str, dict[str, Any]]], width: int) -> str:
|
|
|
431
431
|
elif mutation.operation == "delete":
|
|
432
432
|
parts.append(Text(f"delete {diff.path}", style="dim"))
|
|
433
433
|
else:
|
|
434
|
+
parts.append(Text(f"edit {diff.path} · snippet line numbers", style="dim"))
|
|
434
435
|
parts.append(Group(*_numbered_diff(diff.full_diff, width)))
|
|
435
436
|
if len(parts) == 2:
|
|
436
437
|
parts.append(Text("Nothing to review.", style="dim"))
|
|
@@ -733,12 +734,16 @@ def render_tool_preview(
|
|
|
733
734
|
suffix = (
|
|
734
735
|
" — waiting for input" if block.status == "waiting"
|
|
735
736
|
else " — interrupted (completion unconfirmed)" if block.status == "interrupted"
|
|
737
|
+
else " — cancelled" if block.status == "cancelled"
|
|
738
|
+
else " — failed" if preview.kind == "task" and block.is_error
|
|
736
739
|
else ""
|
|
737
740
|
)
|
|
738
741
|
verb = preview.verb
|
|
739
742
|
if block.status == "running":
|
|
740
743
|
verb = {"edit_file": "Editing", "write_file": "Writing", "delete": "Deleting"}.get(block.name, verb)
|
|
741
744
|
summary = f"{verb} {preview.target}".strip()
|
|
745
|
+
if preview.kind == "task":
|
|
746
|
+
summary = f"{'Running SubAgent' if block.status == 'running' else 'SubAgent'} · {preview.target}"
|
|
742
747
|
title = Text.assemble((f"{symbol} ", color), (summary, "bold"))
|
|
743
748
|
mutation = preview.file_mutation
|
|
744
749
|
if mutation is not None and mutation.operation == "modify" and mutation.diff is not None:
|
|
@@ -751,6 +756,10 @@ def render_tool_preview(
|
|
|
751
756
|
title.append(f" {preview.detail}", style="bold")
|
|
752
757
|
title.append(suffix, style="dim")
|
|
753
758
|
body: list[Any] = [title]
|
|
759
|
+
if preview.kind == "task":
|
|
760
|
+
body.append(Text(f" {preview.detail}", style="dim"))
|
|
761
|
+
if block.output:
|
|
762
|
+
body.append(Text(" └ result", style="dim"))
|
|
754
763
|
if preview.group == "mutation":
|
|
755
764
|
body.extend(_mutation_body(preview, width))
|
|
756
765
|
elif preview.lines:
|
|
@@ -763,14 +772,10 @@ def render_tool_preview(
|
|
|
763
772
|
else:
|
|
764
773
|
output = block.output.strip()
|
|
765
774
|
if output:
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
lines = [f"… {skipped} output lines hidden · {EXPAND_HINT}", *lines[-limit:]]
|
|
771
|
-
body.append(Text(
|
|
772
|
-
"\n".join(f" {line}" for line in lines),
|
|
773
|
-
style="dim" if not block.is_error else "red",
|
|
775
|
+
body.extend(_output_tail(
|
|
776
|
+
output.splitlines(), Console(width=max(20, width)), width,
|
|
777
|
+
expanded=expanded, limit=limits.tail_lines, indent=2,
|
|
778
|
+
style="dim" if not block.is_error else "red", earlier=False,
|
|
774
779
|
))
|
|
775
780
|
return Padding(Group(*body), (0 if after_user else 1, 0, 0, 0), expand=False)
|
|
776
781
|
|
|
@@ -831,15 +836,11 @@ def _command_card(
|
|
|
831
836
|
"", display_output,
|
|
832
837
|
)
|
|
833
838
|
lines = display_output.strip().splitlines()
|
|
834
|
-
if not expanded and len(lines) > limits.tail_lines:
|
|
835
|
-
hidden = len(lines) - limits.tail_lines
|
|
836
|
-
lines = [f"… {hidden} earlier output lines hidden · {EXPAND_HINT}", *lines[-limits.tail_lines:]]
|
|
837
839
|
if not lines and status not in {"running", "waiting", "interrupted"}:
|
|
838
840
|
lines = ["(no output)"]
|
|
839
841
|
if lines:
|
|
840
842
|
body.extend(_wrap_failure_line(Text(" └ output", style="dim"), console, width))
|
|
841
|
-
|
|
842
|
-
body.extend(_wrap_failure_line(Text(f" {line}", style="dim"), console, width, indent=4))
|
|
843
|
+
body.extend(_output_tail(lines, console, width, expanded=expanded, limit=limits.tail_lines))
|
|
843
844
|
|
|
844
845
|
if preview.truncated:
|
|
845
846
|
if preview.log_error:
|
|
@@ -894,6 +895,25 @@ def _failure_code(block: ToolBlock) -> int:
|
|
|
894
895
|
return block.exit_code if isinstance(block.exit_code, int) and not isinstance(block.exit_code, bool) else 1
|
|
895
896
|
|
|
896
897
|
|
|
898
|
+
def _output_tail(
|
|
899
|
+
lines: list[str], console: Console, width: int, *, expanded: bool, limit: int,
|
|
900
|
+
indent: int = 4, style: str = "dim", earlier: bool = True,
|
|
901
|
+
) -> list[Text]:
|
|
902
|
+
"""Apply the output budget after terminal wrapping, preserving the full output."""
|
|
903
|
+
rows = [
|
|
904
|
+
row for line in lines
|
|
905
|
+
for row in _wrap_failure_line(Text(f"{' ' * indent}{line}", style=style), console, width, indent=indent)
|
|
906
|
+
]
|
|
907
|
+
if expanded or len(rows) <= limit:
|
|
908
|
+
return rows
|
|
909
|
+
hidden = len(rows) - limit
|
|
910
|
+
notice = f"… {hidden} {'earlier ' if earlier else ''}output lines hidden · {EXPAND_HINT}"
|
|
911
|
+
return [
|
|
912
|
+
*_wrap_failure_line(Text(f"{' ' * indent}{notice}", style=style), console, width, indent=indent),
|
|
913
|
+
*rows[-limit:],
|
|
914
|
+
]
|
|
915
|
+
|
|
916
|
+
|
|
897
917
|
def _wrap_failure_line(line: Text, console: Console, width: int, *, indent: int = 2) -> list[Text]:
|
|
898
918
|
"""Keep the first prefix and indent continuations within the terminal margin."""
|
|
899
919
|
available = max(1, width - 2)
|
|
@@ -915,7 +935,7 @@ def _tool_status_marker(status: str, is_error: bool = False) -> tuple[str, str]:
|
|
|
915
935
|
return _spinner(), "green"
|
|
916
936
|
if status == "waiting":
|
|
917
937
|
return "•", "yellow"
|
|
918
|
-
if status in {"error", "interrupted"} or is_error:
|
|
938
|
+
if status in {"error", "interrupted", "cancelled"} or is_error:
|
|
919
939
|
return "•", "#888888"
|
|
920
940
|
return "•", "green"
|
|
921
941
|
|
|
@@ -7,7 +7,7 @@ from uuid import uuid4
|
|
|
7
7
|
|
|
8
8
|
from agent.attachments import ImageAttachmentRef
|
|
9
9
|
from agent.runner import RunEvent, TurnTiming
|
|
10
|
-
from agent.session import TranscriptBlock
|
|
10
|
+
from agent.session import TranscriptBlock, subagent_result_status
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
@dataclass
|
|
@@ -75,6 +75,18 @@ class CliState:
|
|
|
75
75
|
# Clearing the visible transcript must not reset this session property.
|
|
76
76
|
context_pristine: bool = True
|
|
77
77
|
|
|
78
|
+
@property
|
|
79
|
+
def subagent_count(self) -> int:
|
|
80
|
+
"""Count the same running task cards rendered in the transcript.
|
|
81
|
+
|
|
82
|
+
Scheduler admission/cleanup and graph tool results arrive separately;
|
|
83
|
+
using scheduler counts here can disagree with the visible task states.
|
|
84
|
+
"""
|
|
85
|
+
return sum(
|
|
86
|
+
isinstance(block, ToolBlock) and block.name == "task" and block.status == "running"
|
|
87
|
+
for block in self.blocks
|
|
88
|
+
)
|
|
89
|
+
|
|
78
90
|
def add_user(
|
|
79
91
|
self,
|
|
80
92
|
text: str,
|
|
@@ -141,6 +153,10 @@ class CliState:
|
|
|
141
153
|
))
|
|
142
154
|
|
|
143
155
|
def apply(self, event: RunEvent) -> None:
|
|
156
|
+
if event.type == "subagents_changed":
|
|
157
|
+
# Runtime accounting remains available to other event consumers.
|
|
158
|
+
# Presentation counts follow task card transitions instead.
|
|
159
|
+
return
|
|
144
160
|
if event.type in {"run_started", "run_completed", "run_failed", "run_cancelled", "interaction_requested"}:
|
|
145
161
|
self.compacting = False
|
|
146
162
|
if event.type == "run_started":
|
|
@@ -224,6 +240,10 @@ class CliState:
|
|
|
224
240
|
tool.output = event.content
|
|
225
241
|
tool.is_error = event.is_error
|
|
226
242
|
tool.status = "error" if event.is_error else "completed"
|
|
243
|
+
if tool.name == "task":
|
|
244
|
+
tool.output = event.content
|
|
245
|
+
tool.status = subagent_result_status(event.content, is_error=event.is_error)
|
|
246
|
+
tool.is_error = tool.status in {"error", "cancelled"}
|
|
227
247
|
if event.name == "execute" and completed_artifact is not None:
|
|
228
248
|
code = completed_artifact.get("exit_code")
|
|
229
249
|
tool.exit_code = code if isinstance(code, int) and not isinstance(code, bool) else None
|
|
@@ -280,6 +300,10 @@ class CliState:
|
|
|
280
300
|
for block in self.blocks:
|
|
281
301
|
if isinstance(block, ToolBlock) and block.status == "running":
|
|
282
302
|
touch(block)
|
|
303
|
+
if block.name == "task":
|
|
304
|
+
block.status = "cancelled"
|
|
305
|
+
block.is_error = True
|
|
306
|
+
continue
|
|
283
307
|
block.status = "error"
|
|
284
308
|
block.is_error = True
|
|
285
309
|
block.exit_code = 1
|
|
@@ -18,13 +18,26 @@ agent:
|
|
|
18
18
|
# 优先使用中文回答。
|
|
19
19
|
instructions: null
|
|
20
20
|
|
|
21
|
+
# 仅当问题可分解为多个独立、互不干扰的子问题时,主 Agent 才应派生 SubAgent。
|
|
22
|
+
subagents:
|
|
23
|
+
enabled: true
|
|
24
|
+
max_concurrent: 2
|
|
25
|
+
# model 为 null:继承主 Agent 当前模型;否则必须是 llm.models 中的完整 ID。
|
|
26
|
+
model: null
|
|
27
|
+
# 默认填写 default;省略此项或旧配置 null 也使用子模型原生默认强度。
|
|
28
|
+
# default 不向 API 发送推理强度参数,不继承主 Agent 的 high/low 等强度。
|
|
29
|
+
# 可显式填写目标模型支持的 low/high 等强度;暂不支持 auto。
|
|
30
|
+
reasoning_effort: default
|
|
31
|
+
# 只支持 allow;必须使用已经验证的 Bubblewrap 沙箱,无法使用时 task 明确失败。
|
|
32
|
+
permission: allow
|
|
33
|
+
|
|
21
34
|
tools:
|
|
22
35
|
# 启动时从模型请求中隐藏的工具名。这里隐藏上下文压缩工具;/compact 仍可使用。
|
|
23
36
|
hidden:
|
|
24
37
|
- compact_conversation
|
|
25
38
|
|
|
26
39
|
ui:
|
|
27
|
-
#
|
|
40
|
+
# 回答结束时间和系统提示词中当前日期所使用的 IANA 时区。
|
|
28
41
|
timezone: Asia/Shanghai
|
|
29
42
|
# 内容折叠时保留的开头行数和末尾行数,均为正整数。
|
|
30
43
|
# 命令、写入、差异和失败摘要使用 head_lines;思考和工具输出使用 tail_lines。
|
|
@@ -39,25 +52,25 @@ ui:
|
|
|
39
52
|
completion_menu_lines: 8
|
|
40
53
|
|
|
41
54
|
llm:
|
|
42
|
-
default:
|
|
55
|
+
default: deepseek/deepseek-flash
|
|
43
56
|
# 所有模型共用的 HTTP 首字节超时(秒)。限制连接,以及等到第一批响应数据。
|
|
44
57
|
# 响应开始之后,整轮生成可以继续。不要写到单个模型上。
|
|
45
58
|
timeout: 60
|
|
46
59
|
models:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
# --- 百炼 Token Plan:可选来源,设置 TOKEN_PLAN_API_KEY 后取消注释 ---
|
|
61
|
+
# token-plan:
|
|
62
|
+
# base_url: https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
|
|
63
|
+
# api_key: ${TOKEN_PLAN_API_KEY}
|
|
64
|
+
# api: chat_completions
|
|
65
|
+
# # 额外重试次数;0 表示禁用,可在模型项中覆盖。
|
|
66
|
+
# max_retries: 5
|
|
67
|
+
# # 流式无进展超时(秒);0 表示禁用,可在模型项中覆盖。
|
|
68
|
+
# stream_chunk_timeout: 120
|
|
69
|
+
# reasoning_efforts: [none, low, medium, xhigh]
|
|
70
|
+
# models:
|
|
71
|
+
# qwen3.8-flash:
|
|
72
|
+
# input: [text, image]
|
|
73
|
+
# context_window: 1m
|
|
61
74
|
# --- 阿里云百炼:官方端点 ---
|
|
62
75
|
# 设置 ALIYUN_API_KEY 环境变量,取消下列注释即可添加百炼来源。
|
|
63
76
|
# 北京公共域名仍可使用,也可替换为官方业务空间专属域名。
|
|
@@ -81,13 +94,13 @@ llm:
|
|
|
81
94
|
#
|
|
82
95
|
# --- DeepSeek 官方:Chat Completions API ---
|
|
83
96
|
# https://api-docs.deepseek.com/zh-cn/api/create-chat-completion/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
deepseek:
|
|
98
|
+
api_key: ${DEEPSEEK_API_KEY}
|
|
99
|
+
base_url: https://api.deepseek.com/v1
|
|
100
|
+
api: chat_completions
|
|
101
|
+
reasoning_efforts: [none, low, high, max]
|
|
102
|
+
models:
|
|
103
|
+
deepseek-flash: {}
|
|
91
104
|
#
|
|
92
105
|
# --- 智谱官方:Chat Completions API ---
|
|
93
106
|
# https://docs.bigmodel.cn/cn/guide/models/text/glm-5.3
|
|
@@ -101,7 +114,8 @@ llm:
|
|
|
101
114
|
#
|
|
102
115
|
# 推理强度取决于模型、协议和端点,请按服务商文档维护列表。
|
|
103
116
|
# 模型级省略的字段继承来源配置;声明列表时整表替换;null 或 [] 清除继承的列表。
|
|
104
|
-
#
|
|
117
|
+
# reasoning_efforts 列表不要包含 default;命令行始终提供该选项。
|
|
118
|
+
# 子智能体的 subagents.reasoning_effort 可单独填写 default。
|
|
105
119
|
# Responses 使用 reasoning.effort 参数;Chat Completions 使用 reasoning_effort 参数。
|
|
106
120
|
|
|
107
121
|
|
|
@@ -160,10 +160,43 @@ class UiDisplayLimits:
|
|
|
160
160
|
DEFAULT_UI_DISPLAY_LIMITS = UiDisplayLimits()
|
|
161
161
|
|
|
162
162
|
|
|
163
|
+
@dataclass(frozen=True)
|
|
164
|
+
class SubAgentConfig:
|
|
165
|
+
enabled: bool = True
|
|
166
|
+
max_concurrent: int = 2
|
|
167
|
+
model: str | None = None
|
|
168
|
+
reasoning_effort: str | None = "default"
|
|
169
|
+
permission: str = "allow"
|
|
170
|
+
|
|
171
|
+
@classmethod
|
|
172
|
+
def from_mapping(cls, values: Mapping[str, Any]) -> "SubAgentConfig":
|
|
173
|
+
unknown = set(values) - cls.__dataclass_fields__.keys()
|
|
174
|
+
if unknown:
|
|
175
|
+
raise ValueError(f"Unknown subagents settings: {', '.join(sorted(unknown))}")
|
|
176
|
+
return cls(**values)
|
|
177
|
+
|
|
178
|
+
def __post_init__(self) -> None:
|
|
179
|
+
if not isinstance(self.enabled, bool):
|
|
180
|
+
raise ValueError("subagents.enabled must be a boolean")
|
|
181
|
+
if type(self.max_concurrent) is not int or self.max_concurrent < 1:
|
|
182
|
+
raise ValueError("subagents.max_concurrent must be a positive integer")
|
|
183
|
+
if self.permission != "allow":
|
|
184
|
+
raise ValueError("subagents.permission must be allow")
|
|
185
|
+
for name in ("model", "reasoning_effort"):
|
|
186
|
+
value = getattr(self, name)
|
|
187
|
+
if value is not None and (not isinstance(value, str) or not value.strip()):
|
|
188
|
+
raise ValueError(f"subagents.{name} must be a non-empty string or null")
|
|
189
|
+
if self.reasoning_effort is None:
|
|
190
|
+
object.__setattr__(self, "reasoning_effort", "default")
|
|
191
|
+
if self.reasoning_effort == "auto":
|
|
192
|
+
raise ValueError("subagents.reasoning_effort auto is not supported yet")
|
|
193
|
+
|
|
194
|
+
|
|
163
195
|
@dataclass(frozen=True)
|
|
164
196
|
class Settings:
|
|
165
197
|
llm_profiles: tuple[ModelProfile, ...] = field(default_factory=_default_profiles)
|
|
166
198
|
llm_default: str = "default"
|
|
199
|
+
subagents: SubAgentConfig = field(default_factory=SubAgentConfig)
|
|
167
200
|
sandbox: SandboxConfig = field(default_factory=SandboxConfig)
|
|
168
201
|
state_path: Path | None = None
|
|
169
202
|
config_dir: Path | None = None
|
|
@@ -179,6 +212,14 @@ class Settings:
|
|
|
179
212
|
def __post_init__(self) -> None:
|
|
180
213
|
if not isinstance(self.trust_env, bool):
|
|
181
214
|
raise ValueError("trust_env must be a boolean")
|
|
215
|
+
profile = self.active_profile
|
|
216
|
+
if self.subagents.model is not None:
|
|
217
|
+
profile = next((p for p in self.llm_profiles if p.id == self.subagents.model), None)
|
|
218
|
+
if profile is None:
|
|
219
|
+
raise ValueError(f"Unknown subagents.model: {self.subagents.model}")
|
|
220
|
+
effort = self.subagents.reasoning_effort
|
|
221
|
+
if effort != "default" and effort not in profile.reasoning_efforts:
|
|
222
|
+
raise ValueError(f"Unsupported subagents.reasoning_effort for {profile.id}: {effort}")
|
|
182
223
|
object.__setattr__(self, "sandbox", replace(self.sandbox, trust_env=self.trust_env))
|
|
183
224
|
object.__setattr__(
|
|
184
225
|
self, "request_timeout",
|
|
@@ -299,6 +340,7 @@ class Settings:
|
|
|
299
340
|
result = cls(
|
|
300
341
|
trust_env=trust_env,
|
|
301
342
|
hidden_tools=tuple(dict.fromkeys(name.strip() for name in hidden_tools)),
|
|
343
|
+
subagents=SubAgentConfig.from_mapping(_section(raw, "subagents")),
|
|
302
344
|
llm_profiles=profiles,
|
|
303
345
|
llm_default=default_id,
|
|
304
346
|
sandbox=_sandbox_from_mapping(sandbox_raw, base_dir=root),
|
|
@@ -57,8 +57,19 @@ class RunController:
|
|
|
57
57
|
self._active_tools: dict[str, ToolCancelContext] = {}
|
|
58
58
|
self._defer_steering = False
|
|
59
59
|
self._on_control_event = on_control_event
|
|
60
|
+
self._children: set[RunController] = set()
|
|
60
61
|
self._pending_config_check: Callable[[], bool] = lambda: False
|
|
61
62
|
|
|
63
|
+
def register_child(self, child: RunController) -> None:
|
|
64
|
+
with self._lock:
|
|
65
|
+
self._children.add(child)
|
|
66
|
+
if self.cancel_requested:
|
|
67
|
+
child.cancel()
|
|
68
|
+
|
|
69
|
+
def unregister_child(self, child: RunController) -> None:
|
|
70
|
+
with self._lock:
|
|
71
|
+
self._children.discard(child)
|
|
72
|
+
|
|
62
73
|
def set_pending_config_check(self, check: Callable[[], bool]) -> None:
|
|
63
74
|
with self._lock:
|
|
64
75
|
self._pending_config_check = check
|
|
@@ -242,6 +253,9 @@ class RunController:
|
|
|
242
253
|
control = scope.run_control
|
|
243
254
|
streams = list(scope.model_streams)
|
|
244
255
|
tools = list(self._active_tools.values())
|
|
256
|
+
children = list(self._children)
|
|
257
|
+
for child in children:
|
|
258
|
+
child.cancel()
|
|
245
259
|
for stream in streams:
|
|
246
260
|
stream.cancel()
|
|
247
261
|
if control is not None:
|
|
@@ -278,6 +292,10 @@ class RunController:
|
|
|
278
292
|
deadline = time.monotonic() + timeout
|
|
279
293
|
with self._lock:
|
|
280
294
|
streams = list(self._unclosed_streams)
|
|
295
|
+
children = list(self._children)
|
|
296
|
+
for child in children:
|
|
297
|
+
if not child.wait_model_streams_closed(max(0.0, deadline - time.monotonic())):
|
|
298
|
+
return False
|
|
281
299
|
for stream in streams:
|
|
282
300
|
if not stream.wait_closed(max(0.0, deadline - time.monotonic())):
|
|
283
301
|
return False
|