deep-agent-cli 0.2.2__tar.gz → 0.3.0__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.2 → deep_agent_cli-0.3.0}/PKG-INFO +34 -23
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/README.md +30 -22
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/bootstrap/config.py +29 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/bootstrap/factory.py +63 -5
- deep_agent_cli-0.3.0/agent/bootstrap/setup.py +75 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/access_selection.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/app.py +272 -126
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/attachments_controller.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/commands.py +24 -7
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/display.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/formatting.py +15 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/gitinfo.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/input_actions.py +6 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/interactions.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/key_bindings.py +34 -16
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/mcp_ui.py +36 -8
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/previews.py +48 -43
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/rendering.py +87 -29
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/run_dispatch.py +13 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/run_events_controller.py +8 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/session_controller.py +1 -4
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/session_summaries.py +21 -11
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/state.py +33 -6
- deep_agent_cli-0.3.0/agent/cli/text_selection.py +92 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/transcript_navigation.py +44 -85
- deep_agent_cli-0.3.0/agent/cli/widgets.py +365 -0
- deep_agent_cli-0.3.0/agent/companion/__init__.py +3 -0
- deep_agent_cli-0.3.0/agent/companion/animation.py +47 -0
- deep_agent_cli-0.3.0/agent/companion/ascii_art.py +120 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_concerned.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_curious.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_focused.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_idle.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_observing.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/lain_relieved.gif +0 -0
- deep_agent_cli-0.3.0/agent/companion/assets/manifest.json +109 -0
- deep_agent_cli-0.3.0/agent/companion/chart.py +98 -0
- deep_agent_cli-0.3.0/agent/companion/chat.md +7 -0
- deep_agent_cli-0.3.0/agent/companion/config.py +48 -0
- deep_agent_cli-0.3.0/agent/companion/controller.py +1160 -0
- deep_agent_cli-0.3.0/agent/companion/diagnosis.py +105 -0
- deep_agent_cli-0.3.0/agent/companion/diagnostic_io.py +36 -0
- deep_agent_cli-0.3.0/agent/companion/evidence.py +36 -0
- deep_agent_cli-0.3.0/agent/companion/monitor.py +122 -0
- deep_agent_cli-0.3.0/agent/companion/observation.md +13 -0
- deep_agent_cli-0.3.0/agent/companion/panel.py +294 -0
- deep_agent_cli-0.3.0/agent/companion/persona.md +13 -0
- deep_agent_cli-0.3.0/agent/companion/redaction.py +123 -0
- deep_agent_cli-0.3.0/agent/companion/repository.py +246 -0
- deep_agent_cli-0.3.0/agent/companion/session_inspector.py +491 -0
- deep_agent_cli-0.3.0/agent/companion/theme.py +8 -0
- deep_agent_cli-0.3.0/agent/companion/timeline.py +478 -0
- deep_agent_cli-0.3.0/agent/companion/worker.py +334 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/config.example.yaml +21 -4
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/environment.py +18 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/pool.py +8 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/process.py +8 -5
- deep_agent_cli-0.3.0/agent/execution/service_observation.py +25 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/worker.py +3 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/adapter.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/steering.py +9 -3
- deep_agent_cli-0.3.0/agent/middleware/workspace_filesystem.py +119 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/write_operation.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/messages.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/session_summary.py +1 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/contracts.py +8 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/control.py +27 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/events.py +12 -7
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/metrics.py +4 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/permissions.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/runner.py +147 -61
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/contracts.py +1 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/lifecycle.py +15 -5
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/reader.py +23 -14
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/summary.py +21 -25
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/transcript.py +89 -38
- deep_agent_cli-0.3.0/agent/subagents/__init__.py +1 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/subagents/configuration.py +4 -0
- deep_agent_cli-0.3.0/agent/subagents/manager.py +142 -0
- deep_agent_cli-0.3.0/agent/subagents/notifications.py +39 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/subagents/runtime.py +60 -10
- deep_agent_cli-0.3.0/agent/tools/background_tasks.py +89 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/execute.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/grep.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/subagent_logs.py +2 -2
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/web_search.py +1 -1
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/pyproject.toml +5 -2
- deep_agent_cli-0.2.2/agent/bootstrap/setup.py +0 -45
- deep_agent_cli-0.2.2/agent/cli/widgets.py +0 -180
- deep_agent_cli-0.2.2/agent/middleware/workspace_filesystem.py +0 -64
- deep_agent_cli-0.2.2/agent/subagents/__init__.py +0 -1
- deep_agent_cli-0.2.2/agent/subagents/manager.py +0 -51
- deep_agent_cli-0.2.2//347/273/210/347/253/257.png +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/.gitignore +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/LICENSE +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/bootstrap/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/clipboard.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/completion.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/context_compaction.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/input.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/interaction_flow.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/lifecycle.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/main.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/mcp_controller.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/model_selection.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/pasted_content.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/skill_selection.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/skills.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/view_state.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/working_messages.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/cli/working_messages.yaml +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/backend.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/filesystem.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/layout.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/mounts.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/mutations.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/network.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/policy.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/ports.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/execution/types.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/bridge.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/config.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/content.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/contracts.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/logging.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/manager.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/middleware.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/names.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/oauth.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/oauth_storage.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/mcp/tools.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/attachments.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/cancel_tools.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/current_time.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/pause.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/payload_recovery.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/recovery.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/runtime_config.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/tool_arg_hints.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/middleware/usage.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/catalog.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/client.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/http.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/profile.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/models/stream_lifecycle.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/cancellation.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/configuration.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/runtime/graph_execution.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/attachments.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/images.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/locks.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/ports.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/recovery.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/snapshots.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/sessions/store.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/subagents/log_store.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/__init__.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/_grep_worker.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/examples.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/human_input.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/tools/human_interaction.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/agent/version.py +0 -0
- {deep_agent_cli-0.2.2 → deep_agent_cli-0.3.0}/assets/readme/runtime-map.svg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deep-agent-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A sandboxed coding agent CLI for Linux and WSL2
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -17,7 +17,10 @@ Requires-Dist: langchain-core<2.0,>=1.7.7
|
|
|
17
17
|
Requires-Dist: langchain-openai<1.8.0,>=1.7.4
|
|
18
18
|
Requires-Dist: langchain[mcp]<2.0,>=1.4.9
|
|
19
19
|
Requires-Dist: langgraph-checkpoint-sqlite<4,>=3.1.3
|
|
20
|
+
Requires-Dist: langgraph-prebuilt<2,>=1.1.1
|
|
20
21
|
Requires-Dist: langgraph<2.0,>=1.2.20
|
|
22
|
+
Requires-Dist: numpy<3,>=2
|
|
23
|
+
Requires-Dist: pillow<14,>=11
|
|
21
24
|
Requires-Dist: prompt-toolkit<4.0,>=3.0.48
|
|
22
25
|
Requires-Dist: py-key-value-aio[filetree]<0.5,>=0.4.4
|
|
23
26
|
Requires-Dist: pyyaml<7.0,>=6.0
|
|
@@ -38,27 +41,28 @@ Description-Content-Type: text/markdown
|
|
|
38
41
|
Linux / WSL2 · Python 3.12+<br>
|
|
39
42
|
OpenAI 兼容接口 · Bubblewrap
|
|
40
43
|
|
|
41
|
-
[快速开始](#快速开始) · [常用操作](#常用操作) · [架构与安全](#架构与安全) · [文档](#文档)
|
|
44
|
+
[快速开始](#快速开始) · [常用操作](#常用操作) · [Lain Companion](#lain-companion) · [架构与安全](#架构与安全) · [文档](#文档)
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
<br>
|
|
47
|
+
|
|
48
|
+

|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
<img src="终端.png" width="760" alt="deep-agent 真实终端空闲界面,底栏显示工作区、模型来源、SANDBOXED 和 perm:ask。">
|
|
47
|
-
</p>
|
|
50
|
+
</div>
|
|
48
51
|
|
|
49
52
|
`deep-agent` 是基于 [Deep Agents](https://github.com/langchain-ai/deepagents) 和 LangGraph 的终端 Coding Agent。它在当前项目中工作,主 Agent 默认在文件变更、命令执行和网页搜索前请求批准,通过 [Bubblewrap](https://github.com/containers/bubblewrap) 隔离命令执行。
|
|
50
53
|
|
|
51
54
|
在项目目录运行 `deep-agent` 进入交互式终端,用 `deep-agent resume` 恢复已有会话。要在其他 Python 程序里复用同一套运行核心,使用 [Python API](docs/library.md)。
|
|
52
55
|
|
|
53
|
-
> 当前版本 **
|
|
56
|
+
> 当前版本 **v0.3.0**,处于早期开发阶段。稳定版前,配置、会话存储格式和 Python API 可能出现不兼容变更。
|
|
54
57
|
|
|
55
58
|
## 能做什么
|
|
56
59
|
|
|
57
60
|
- **查代码、改文件** — 浏览、读取、正则搜索、编辑和删除;`Ctrl+R` 审阅完整改动,`F2` 处理审批。
|
|
58
61
|
- **运行项目命令** — 实时查看输出,会话内复用持久沙箱;默认审批、隔离直接 IP 网络。
|
|
59
62
|
- **随时介入任务** — 追加指令、排队后续任务、暂停、取消,以及结构化人工输入。
|
|
60
|
-
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2
|
|
63
|
+
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2 个;主 Agent 可同步等待最终结果,也可把耗时子任务放到后台继续工作,完成后自动收到结果。TUI 为每个子任务显示独立卡片、状态及可展开的完整返回结果,内部思考和工具输出保持隔离。
|
|
61
64
|
- **保留工作上下文** — SQLite 会话恢复、模型与推理强度切换、上下文压缩;支持图片输入的模型可接收附件。
|
|
65
|
+
- **观察当前会话** — Lain 侧栏显示工具活动热力图、资源占用、Git 状态和正在运行的服务,也可以通过流式对话查询异常。
|
|
62
66
|
|
|
63
67
|
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。SubAgent 配置、独立思考强度及日志查询见 [SubAgent 委派](docs/configuration.md#subagent-委派)。
|
|
64
68
|
|
|
@@ -84,7 +88,7 @@ deep-agent --version
|
|
|
84
88
|
|
|
85
89
|
### 2. 初始化与配置
|
|
86
90
|
|
|
87
|
-
从项目目录启动,首次运行会创建 `~/.deep-agent/config.yaml
|
|
91
|
+
从项目目录启动,首次运行会创建 `~/.deep-agent/config.yaml`、Skills 目录,以及 Lain 的提示词和 GIF,然后退出。已有配置会保留。设置了 `DEEP_AGENT_CONFIG` 时使用指定配置。
|
|
88
92
|
|
|
89
93
|
```bash
|
|
90
94
|
cd ~/projects/my-app # 替换为你的项目目录
|
|
@@ -95,11 +99,11 @@ deep-agent
|
|
|
95
99
|
|
|
96
100
|
默认模板是 `mode: restricted`,不预置工具挂载;需要 Node、Cargo / Rustup、Chrome、X11 或浏览器缓存时,按 [默认工具挂载](docs/configuration.md#默认工具挂载) 中的示例手动添加,可选源不存在时跳过。NVM 挂载整个版本目录后,使用哪个版本由用户在沙箱 `PATH` 中指定;程序不自动发现工具安装位置或选择版本。已有配置需手动对照模板合并,升级不会覆盖用户配置。
|
|
97
101
|
|
|
98
|
-
默认模板使用 `
|
|
102
|
+
默认模板使用 `deepseek/deepseek-flash`。在启动 Agent 的同一个 Bash 终端中输入 DeepSeek 密钥。
|
|
99
103
|
|
|
100
104
|
```bash
|
|
101
|
-
read -rsp '
|
|
102
|
-
export
|
|
105
|
+
read -rsp 'DeepSeek API key: ' DEEPSEEK_API_KEY
|
|
106
|
+
export DEEPSEEK_API_KEY
|
|
103
107
|
printf '\n'
|
|
104
108
|
```
|
|
105
109
|
|
|
@@ -112,20 +116,16 @@ printf '\n'
|
|
|
112
116
|
|
|
113
117
|
```yaml
|
|
114
118
|
llm:
|
|
115
|
-
default:
|
|
119
|
+
default: deepseek/deepseek-flash
|
|
116
120
|
timeout: 60
|
|
117
121
|
models:
|
|
118
|
-
|
|
119
|
-
base_url: https://
|
|
120
|
-
api_key: ${
|
|
122
|
+
deepseek:
|
|
123
|
+
base_url: https://api.deepseek.com/v1
|
|
124
|
+
api_key: ${DEEPSEEK_API_KEY}
|
|
121
125
|
api: chat_completions
|
|
122
|
-
|
|
123
|
-
stream_chunk_timeout: 120
|
|
124
|
-
reasoning_efforts: [none, low, medium, xhigh]
|
|
126
|
+
reasoning_efforts: [none, low, high, max]
|
|
125
127
|
models:
|
|
126
|
-
|
|
127
|
-
input: [text, image]
|
|
128
|
-
context_window: 1m
|
|
128
|
+
deepseek-flash: {}
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
端点、上下文窗口、输入模态和推理强度取决于所选服务,完整说明见 [配置参考](docs/configuration.md)。
|
|
@@ -152,7 +152,7 @@ deep-agent resume 01a08aae # 换成已有会话的 ID 或前缀
|
|
|
152
152
|
pipx upgrade deep-agent-cli
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
会话按工作区保存,请从原项目目录运行 `resume`。新会话收到第一条提问后会在后台生成中文标题,恢复命令仍使用会话 ID。底栏显示当前模型最近一次有效的上下文用量。恢复只加载状态,不自动继续未完成任务;旧数据库格式不自动迁移。取消不回滚已发生的文件修改或外部副作用。
|
|
156
156
|
|
|
157
157
|
不使用 pipx 时,也可安装到虚拟环境:
|
|
158
158
|
|
|
@@ -173,12 +173,23 @@ python3.12 -m venv ~/.venvs/deep-agent
|
|
|
173
173
|
| `Enter` / `Alt+Enter` | 提交或运行中追加指令 / 排队后续任务 |
|
|
174
174
|
| `Esc` | 请求取消当前任务 |
|
|
175
175
|
| `Ctrl+O` / `Ctrl+T` | 展开工具输出 / 思考内容 |
|
|
176
|
+
| `Ctrl+C` | 清空当前输入框,1 秒内再按一次退出 |
|
|
176
177
|
| `/resume` / `/new` | 恢复或新建会话 |
|
|
177
178
|
| `/mcp` | 查看、开关和配置宿主 MCP 服务 |
|
|
178
179
|
| `/help` / `/status` | 查看完整操作与当前状态 |
|
|
179
180
|
|
|
180
181
|
更多按键、图片附件、队列、Skills 和显示设置见 [终端界面](docs/tui.md)。
|
|
181
182
|
|
|
183
|
+
## Lain Companion
|
|
184
|
+
|
|
185
|
+
终端至少为 **120 列 × 32 行**时,Lain 会显示在右侧。侧栏显示当前时间与运行环境、CPU / GPU / RAM / 磁盘使用率、Git 分支和工作区服务。
|
|
186
|
+
|
|
187
|
+
- **Tool Health** 按完成顺序显示最近 60 次有明确结果的工具调用,每 3 次一列。颜色表示调用次数,出现失败时显示 `×`。
|
|
188
|
+
- **Talk To Lain** 用 `Ctrl+→` 进入,`Enter` 发送,`Ctrl+←` 返回主输入框。回复流式显示并以 Markdown 渲染;聊天历史可用鼠标滚轮翻看。可只读检查当前会话的工具明细与近期消息。
|
|
189
|
+
- **主动观察** 由本地工具统计触发。Lain 可根据当前会话的证据说明异常,也可应用户要求复盘。
|
|
190
|
+
|
|
191
|
+
Lain 的模型凭据优先读取 `COMPANION_DEEPSEEK_API_KEY`,也可保存在 `~/.deep-agent/companion.key`。本地监控和动画无需模型凭据。人设、观察提示词、聊天提示词和各状态 GIF 可在 `config.yaml` 的 `companion` 段配置。详见 [Lain 侧栏配置](docs/configuration.md#lain-侧栏companion) 和 [统计口径](docs/companion-phase2.md)。
|
|
192
|
+
|
|
182
193
|
## 架构与安全
|
|
183
194
|
|
|
184
195
|
**审批决定是否执行,隔离决定命令能访问哪些资源。** 文件工具和命令走不同通路:
|
|
@@ -7,27 +7,28 @@
|
|
|
7
7
|
Linux / WSL2 · Python 3.12+<br>
|
|
8
8
|
OpenAI 兼容接口 · Bubblewrap
|
|
9
9
|
|
|
10
|
-
[快速开始](#快速开始) · [常用操作](#常用操作) · [架构与安全](#架构与安全) · [文档](#文档)
|
|
10
|
+
[快速开始](#快速开始) · [常用操作](#常用操作) · [Lain Companion](#lain-companion) · [架构与安全](#架构与安全) · [文档](#文档)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
<br>
|
|
13
|
+
|
|
14
|
+

|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
<img src="终端.png" width="760" alt="deep-agent 真实终端空闲界面,底栏显示工作区、模型来源、SANDBOXED 和 perm:ask。">
|
|
16
|
-
</p>
|
|
16
|
+
</div>
|
|
17
17
|
|
|
18
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
|
-
> 当前版本 **
|
|
22
|
+
> 当前版本 **v0.3.0**,处于早期开发阶段。稳定版前,配置、会话存储格式和 Python API 可能出现不兼容变更。
|
|
23
23
|
|
|
24
24
|
## 能做什么
|
|
25
25
|
|
|
26
26
|
- **查代码、改文件** — 浏览、读取、正则搜索、编辑和删除;`Ctrl+R` 审阅完整改动,`F2` 处理审批。
|
|
27
27
|
- **运行项目命令** — 实时查看输出,会话内复用持久沙箱;默认审批、隔离直接 IP 网络。
|
|
28
28
|
- **随时介入任务** — 追加指令、排队后续任务、暂停、取消,以及结构化人工输入。
|
|
29
|
-
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2
|
|
29
|
+
- **拆分独立任务** — 仅当问题能分解为多个独立、互不干扰的子问题时派生 SubAgent;默认最多并行 2 个;主 Agent 可同步等待最终结果,也可把耗时子任务放到后台继续工作,完成后自动收到结果。TUI 为每个子任务显示独立卡片、状态及可展开的完整返回结果,内部思考和工具输出保持隔离。
|
|
30
30
|
- **保留工作上下文** — SQLite 会话恢复、模型与推理强度切换、上下文压缩;支持图片输入的模型可接收附件。
|
|
31
|
+
- **观察当前会话** — Lain 侧栏显示工具活动热力图、资源占用、Git 状态和正在运行的服务,也可以通过流式对话查询异常。
|
|
31
32
|
|
|
32
33
|
支持通过 Skills 和 `AGENTS.md` 扩展项目指令。SubAgent 配置、独立思考强度及日志查询见 [SubAgent 委派](docs/configuration.md#subagent-委派)。
|
|
33
34
|
|
|
@@ -53,7 +54,7 @@ deep-agent --version
|
|
|
53
54
|
|
|
54
55
|
### 2. 初始化与配置
|
|
55
56
|
|
|
56
|
-
从项目目录启动,首次运行会创建 `~/.deep-agent/config.yaml
|
|
57
|
+
从项目目录启动,首次运行会创建 `~/.deep-agent/config.yaml`、Skills 目录,以及 Lain 的提示词和 GIF,然后退出。已有配置会保留。设置了 `DEEP_AGENT_CONFIG` 时使用指定配置。
|
|
57
58
|
|
|
58
59
|
```bash
|
|
59
60
|
cd ~/projects/my-app # 替换为你的项目目录
|
|
@@ -64,11 +65,11 @@ deep-agent
|
|
|
64
65
|
|
|
65
66
|
默认模板是 `mode: restricted`,不预置工具挂载;需要 Node、Cargo / Rustup、Chrome、X11 或浏览器缓存时,按 [默认工具挂载](docs/configuration.md#默认工具挂载) 中的示例手动添加,可选源不存在时跳过。NVM 挂载整个版本目录后,使用哪个版本由用户在沙箱 `PATH` 中指定;程序不自动发现工具安装位置或选择版本。已有配置需手动对照模板合并,升级不会覆盖用户配置。
|
|
66
67
|
|
|
67
|
-
默认模板使用 `
|
|
68
|
+
默认模板使用 `deepseek/deepseek-flash`。在启动 Agent 的同一个 Bash 终端中输入 DeepSeek 密钥。
|
|
68
69
|
|
|
69
70
|
```bash
|
|
70
|
-
read -rsp '
|
|
71
|
-
export
|
|
71
|
+
read -rsp 'DeepSeek API key: ' DEEPSEEK_API_KEY
|
|
72
|
+
export DEEPSEEK_API_KEY
|
|
72
73
|
printf '\n'
|
|
73
74
|
```
|
|
74
75
|
|
|
@@ -81,20 +82,16 @@ printf '\n'
|
|
|
81
82
|
|
|
82
83
|
```yaml
|
|
83
84
|
llm:
|
|
84
|
-
default:
|
|
85
|
+
default: deepseek/deepseek-flash
|
|
85
86
|
timeout: 60
|
|
86
87
|
models:
|
|
87
|
-
|
|
88
|
-
base_url: https://
|
|
89
|
-
api_key: ${
|
|
88
|
+
deepseek:
|
|
89
|
+
base_url: https://api.deepseek.com/v1
|
|
90
|
+
api_key: ${DEEPSEEK_API_KEY}
|
|
90
91
|
api: chat_completions
|
|
91
|
-
|
|
92
|
-
stream_chunk_timeout: 120
|
|
93
|
-
reasoning_efforts: [none, low, medium, xhigh]
|
|
92
|
+
reasoning_efforts: [none, low, high, max]
|
|
94
93
|
models:
|
|
95
|
-
|
|
96
|
-
input: [text, image]
|
|
97
|
-
context_window: 1m
|
|
94
|
+
deepseek-flash: {}
|
|
98
95
|
```
|
|
99
96
|
|
|
100
97
|
端点、上下文窗口、输入模态和推理强度取决于所选服务,完整说明见 [配置参考](docs/configuration.md)。
|
|
@@ -121,7 +118,7 @@ deep-agent resume 01a08aae # 换成已有会话的 ID 或前缀
|
|
|
121
118
|
pipx upgrade deep-agent-cli
|
|
122
119
|
```
|
|
123
120
|
|
|
124
|
-
|
|
121
|
+
会话按工作区保存,请从原项目目录运行 `resume`。新会话收到第一条提问后会在后台生成中文标题,恢复命令仍使用会话 ID。底栏显示当前模型最近一次有效的上下文用量。恢复只加载状态,不自动继续未完成任务;旧数据库格式不自动迁移。取消不回滚已发生的文件修改或外部副作用。
|
|
125
122
|
|
|
126
123
|
不使用 pipx 时,也可安装到虚拟环境:
|
|
127
124
|
|
|
@@ -142,12 +139,23 @@ python3.12 -m venv ~/.venvs/deep-agent
|
|
|
142
139
|
| `Enter` / `Alt+Enter` | 提交或运行中追加指令 / 排队后续任务 |
|
|
143
140
|
| `Esc` | 请求取消当前任务 |
|
|
144
141
|
| `Ctrl+O` / `Ctrl+T` | 展开工具输出 / 思考内容 |
|
|
142
|
+
| `Ctrl+C` | 清空当前输入框,1 秒内再按一次退出 |
|
|
145
143
|
| `/resume` / `/new` | 恢复或新建会话 |
|
|
146
144
|
| `/mcp` | 查看、开关和配置宿主 MCP 服务 |
|
|
147
145
|
| `/help` / `/status` | 查看完整操作与当前状态 |
|
|
148
146
|
|
|
149
147
|
更多按键、图片附件、队列、Skills 和显示设置见 [终端界面](docs/tui.md)。
|
|
150
148
|
|
|
149
|
+
## Lain Companion
|
|
150
|
+
|
|
151
|
+
终端至少为 **120 列 × 32 行**时,Lain 会显示在右侧。侧栏显示当前时间与运行环境、CPU / GPU / RAM / 磁盘使用率、Git 分支和工作区服务。
|
|
152
|
+
|
|
153
|
+
- **Tool Health** 按完成顺序显示最近 60 次有明确结果的工具调用,每 3 次一列。颜色表示调用次数,出现失败时显示 `×`。
|
|
154
|
+
- **Talk To Lain** 用 `Ctrl+→` 进入,`Enter` 发送,`Ctrl+←` 返回主输入框。回复流式显示并以 Markdown 渲染;聊天历史可用鼠标滚轮翻看。可只读检查当前会话的工具明细与近期消息。
|
|
155
|
+
- **主动观察** 由本地工具统计触发。Lain 可根据当前会话的证据说明异常,也可应用户要求复盘。
|
|
156
|
+
|
|
157
|
+
Lain 的模型凭据优先读取 `COMPANION_DEEPSEEK_API_KEY`,也可保存在 `~/.deep-agent/companion.key`。本地监控和动画无需模型凭据。人设、观察提示词、聊天提示词和各状态 GIF 可在 `config.yaml` 的 `companion` 段配置。详见 [Lain 侧栏配置](docs/configuration.md#lain-侧栏companion) 和 [统计口径](docs/companion-phase2.md)。
|
|
158
|
+
|
|
151
159
|
## 架构与安全
|
|
152
160
|
|
|
153
161
|
**审批决定是否执行,隔离决定命令能访问哪些资源。** 文件工具和命令走不同通路:
|
|
@@ -8,6 +8,8 @@ from typing import Any, Mapping
|
|
|
8
8
|
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
|
9
9
|
import yaml
|
|
10
10
|
|
|
11
|
+
from agent.companion import STATES
|
|
12
|
+
from agent.companion.config import CompanionConfig
|
|
11
13
|
from agent.execution.policy import BindMount, SandboxMode, parse_sandbox_mode, SandboxConfig
|
|
12
14
|
from agent.subagents.configuration import SubAgentConfig
|
|
13
15
|
from agent.cli.display import UiDisplayLimits, DEFAULT_UI_TIMEZONE
|
|
@@ -60,6 +62,7 @@ class Settings:
|
|
|
60
62
|
trust_env: bool = False
|
|
61
63
|
request_timeout: float = DEFAULT_REQUEST_TIMEOUT
|
|
62
64
|
compaction_threshold: float = 0.85
|
|
65
|
+
companion: CompanionConfig = field(default_factory=CompanionConfig)
|
|
63
66
|
|
|
64
67
|
def __post_init__(self) -> None:
|
|
65
68
|
if (isinstance(self.compaction_threshold, bool)
|
|
@@ -199,6 +202,7 @@ class Settings:
|
|
|
199
202
|
compaction_threshold=agent.get("compaction_threshold", 0.85),
|
|
200
203
|
ui_timezone=timezone_name,
|
|
201
204
|
ui_display_limits=display_limits,
|
|
205
|
+
companion=_companion_from_mapping(_section(raw, "companion"), base_dir=root),
|
|
202
206
|
tavily_api_key=os.environ.get("TAVILY_API_KEY") or _optional_secret(
|
|
203
207
|
web_search.get("tavily_api_key"), field_name="web_search.tavily_api_key"
|
|
204
208
|
),
|
|
@@ -283,6 +287,31 @@ def _optional_path(value: Any, *, base_dir: Path) -> Path | None:
|
|
|
283
287
|
return path.resolve()
|
|
284
288
|
|
|
285
289
|
|
|
290
|
+
def _companion_from_mapping(data: Mapping[str, Any], *, base_dir: Path) -> CompanionConfig:
|
|
291
|
+
def path(value: Any, name: str) -> Path | None:
|
|
292
|
+
if value is not None and (not isinstance(value, str) or not value.strip()):
|
|
293
|
+
raise ValueError(f"companion.{name} must be a non-empty path or null")
|
|
294
|
+
return _optional_path(value, base_dir=base_dir)
|
|
295
|
+
|
|
296
|
+
gifs = {}
|
|
297
|
+
for state, value in _section(data, "gifs").items():
|
|
298
|
+
if state not in STATES:
|
|
299
|
+
raise ValueError(f"unknown companion.gifs state: {state}")
|
|
300
|
+
configured = path(value, f"gifs.{state}")
|
|
301
|
+
if configured is not None:
|
|
302
|
+
gifs[state] = configured
|
|
303
|
+
defaults = CompanionConfig()
|
|
304
|
+
return CompanionConfig(
|
|
305
|
+
persona_prompt=path(data.get("persona_prompt"), "persona_prompt") or defaults.persona_prompt,
|
|
306
|
+
observation_prompt=path(data.get("observation_prompt"), "observation_prompt") or defaults.observation_prompt,
|
|
307
|
+
chat_prompt=path(data.get("chat_prompt"), "chat_prompt") or defaults.chat_prompt,
|
|
308
|
+
gifs=gifs,
|
|
309
|
+
rpc_timeout_seconds=data.get("rpc_timeout_seconds", defaults.rpc_timeout_seconds),
|
|
310
|
+
question_timeout_seconds=data.get("question_timeout_seconds", defaults.question_timeout_seconds),
|
|
311
|
+
source_read_lines=data.get("source_read_lines", defaults.source_read_lines),
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
|
|
286
315
|
def _required_path(value: Any, *, base_dir: Path, default: Path) -> Path:
|
|
287
316
|
if value is None or value == "":
|
|
288
317
|
return default.expanduser().resolve()
|
|
@@ -10,7 +10,8 @@ from deepagents import (
|
|
|
10
10
|
register_harness_profile,
|
|
11
11
|
)
|
|
12
12
|
from deepagents.backends.protocol import BackendProtocol, SandboxBackendProtocol
|
|
13
|
-
from deepagents.middleware.subagents import CompiledSubAgent
|
|
13
|
+
from deepagents.middleware.subagents import CompiledSubAgent, SubAgentMiddleware
|
|
14
|
+
from deepagents.middleware.skills import SKILLS_SYSTEM_PROMPT, SkillsMiddleware
|
|
14
15
|
from deepagents.middleware.summarization import (
|
|
15
16
|
SummarizationMiddleware,
|
|
16
17
|
SummarizationToolMiddleware,
|
|
@@ -19,6 +20,7 @@ from deepagents.middleware.summarization import (
|
|
|
19
20
|
from deepagents._models import get_model_identifier, get_model_provider
|
|
20
21
|
from langchain.agents.middleware import AgentMiddleware
|
|
21
22
|
from langchain_core.language_models import BaseChatModel
|
|
23
|
+
from langchain_core.messages import AIMessage, AnyMessage
|
|
22
24
|
from langchain_core.tools import BaseTool
|
|
23
25
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
24
26
|
|
|
@@ -57,7 +59,7 @@ from agent.tools.web_search import build_web_search_tool
|
|
|
57
59
|
# Middleware augments the Deep Agents defaults; create_deep_agent remains the only assembly entry.
|
|
58
60
|
|
|
59
61
|
|
|
60
|
-
DEFAULT_FS_TOOLS = ["ls", "
|
|
62
|
+
DEFAULT_FS_TOOLS = ["ls", "read", "write", "edit", "delete"]
|
|
61
63
|
|
|
62
64
|
DEFAULT_SYSTEM_PROMPT = (
|
|
63
65
|
"你是运行在 Deep Agent CLI 中、使用 {model_name} 的编程智能体。"
|
|
@@ -92,6 +94,47 @@ DEFAULT_SYSTEM_PROMPT = (
|
|
|
92
94
|
)
|
|
93
95
|
|
|
94
96
|
|
|
97
|
+
class StartTaskMiddleware(SubAgentMiddleware):
|
|
98
|
+
@property
|
|
99
|
+
def name(self) -> str:
|
|
100
|
+
return "SubAgentMiddleware"
|
|
101
|
+
|
|
102
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
103
|
+
super().__init__(**kwargs)
|
|
104
|
+
self.tools[0].name = "start_task"
|
|
105
|
+
|
|
106
|
+
@SubAgentMiddleware.private_state_keys.setter
|
|
107
|
+
def private_state_keys(self, value: frozenset[str]) -> None:
|
|
108
|
+
# create_deep_agent rebuilds the native tool after collecting state keys.
|
|
109
|
+
SubAgentMiddleware.private_state_keys.fset(self, value)
|
|
110
|
+
self.tools[0].name = "start_task"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class WorkspaceSummarizationMiddleware(SummarizationMiddleware):
|
|
114
|
+
def _truncate_args(
|
|
115
|
+
self, messages: list[AnyMessage], total_tokens: int,
|
|
116
|
+
) -> tuple[list[AnyMessage], bool]:
|
|
117
|
+
"""Keep upstream argument truncation for the renamed write and edit tools."""
|
|
118
|
+
if not self._should_truncate_args(messages, total_tokens):
|
|
119
|
+
return messages, False
|
|
120
|
+
cutoff = self._determine_truncate_cutoff_index(messages)
|
|
121
|
+
if cutoff >= len(messages):
|
|
122
|
+
return messages, False
|
|
123
|
+
updated = list(messages)
|
|
124
|
+
modified = False
|
|
125
|
+
for index, message in enumerate(messages[:cutoff]):
|
|
126
|
+
if not isinstance(message, AIMessage):
|
|
127
|
+
continue
|
|
128
|
+
calls = [
|
|
129
|
+
self._truncate_tool_call(call) if call["name"] in {"write", "edit"} else call
|
|
130
|
+
for call in message.tool_calls
|
|
131
|
+
]
|
|
132
|
+
if calls != message.tool_calls:
|
|
133
|
+
updated[index] = message.model_copy(update={"tool_calls": calls})
|
|
134
|
+
modified = True
|
|
135
|
+
return (updated, True) if modified else (messages, False)
|
|
136
|
+
|
|
137
|
+
|
|
95
138
|
class HiddenToolsMiddleware(AgentMiddleware):
|
|
96
139
|
"""Filter middleware-provided tools too, without changing approval rules."""
|
|
97
140
|
|
|
@@ -215,7 +258,7 @@ def build_agent(
|
|
|
215
258
|
trigger = ("fraction", min(trigger[1], cfg.compaction_threshold))
|
|
216
259
|
if keep[0] == "fraction" and keep[1] >= trigger[1]:
|
|
217
260
|
keep = ("fraction", trigger[1] / 2)
|
|
218
|
-
summarization =
|
|
261
|
+
summarization = WorkspaceSummarizationMiddleware(
|
|
219
262
|
model=model, backend=fs_backend, trigger=trigger,
|
|
220
263
|
keep=keep, trim_tokens_to_summarize=None,
|
|
221
264
|
truncate_args_settings=summary_defaults["truncate_args_settings"],
|
|
@@ -240,6 +283,8 @@ def build_agent(
|
|
|
240
283
|
from agent.subagents.manager import SubAgentManager
|
|
241
284
|
from agent.subagents.log_store import SubAgentLogStore
|
|
242
285
|
from agent.subagents.runtime import SubAgentRuntime
|
|
286
|
+
from agent.subagents.notifications import BACKGROUND_TOOLS
|
|
287
|
+
from agent.tools.background_tasks import build_background_task_tools
|
|
243
288
|
from agent.tools.subagent_logs import build_subagent_log_tool
|
|
244
289
|
# Rebuilds occur at a safe boundary; keep lifetime accounting on the
|
|
245
290
|
# parent controller, which survives model changes and session switches.
|
|
@@ -275,7 +320,8 @@ def build_agent(
|
|
|
275
320
|
child_spec = replace(
|
|
276
321
|
spec, role="subagent", tools=(), backend=fs_backend,
|
|
277
322
|
skills=tuple(skill_sources or ()),
|
|
278
|
-
hidden_tools=tuple(set(spec.hidden_tools) |
|
|
323
|
+
hidden_tools=tuple(set(spec.hidden_tools) | BACKGROUND_TOOLS
|
|
324
|
+
| {"start_task", "request_human_input", "read_task_log"}),
|
|
279
325
|
)
|
|
280
326
|
try:
|
|
281
327
|
child = build_agent(child_spec, child_model, PermissionMode.ALLOW, None,
|
|
@@ -289,7 +335,14 @@ def build_agent(
|
|
|
289
335
|
return child
|
|
290
336
|
|
|
291
337
|
runtime = SubAgentRuntime(manager, store, prepare_child,
|
|
292
|
-
cfg.subagents.model or str(get_model_identifier(model) or type(model).__name__)
|
|
338
|
+
cfg.subagents.model or str(get_model_identifier(model) or type(model).__name__),
|
|
339
|
+
cfg.subagents.reasoning_effort or "default")
|
|
340
|
+
if cfg.subagents.background:
|
|
341
|
+
tools.extend(build_background_task_tools(
|
|
342
|
+
runtime, manager,
|
|
343
|
+
unavailable="" if execution_mode is ExecutionMode.SANDBOXED
|
|
344
|
+
else "Subagents require a verified SANDBOXED backend for allow permission",
|
|
345
|
+
))
|
|
293
346
|
subagents.append({
|
|
294
347
|
"name": "general-purpose",
|
|
295
348
|
"description": (
|
|
@@ -324,6 +377,11 @@ def build_agent(
|
|
|
324
377
|
AttachmentMaterializationMiddleware(),
|
|
325
378
|
PayloadRecoveryMiddleware(),
|
|
326
379
|
WorkspaceFilesystemMiddleware(backend=fs_backend, tools=filesystem_tools),
|
|
380
|
+
*([StartTaskMiddleware(backend=fs_backend, subagents=subagents)] if subagents else []),
|
|
381
|
+
*([SkillsMiddleware(
|
|
382
|
+
backend=fs_backend, sources=skill_sources,
|
|
383
|
+
system_prompt=SKILLS_SYSTEM_PROMPT.replace("read_file", "read"),
|
|
384
|
+
)] if skill_sources else []),
|
|
327
385
|
summarization,
|
|
328
386
|
compact_middleware,
|
|
329
387
|
*([MCPMiddleware(mcp, mcp_tools)] if include_mcp else []),
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Initialize the CLI's user-owned configuration on first launch."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from importlib.resources import abc, files
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import tempfile
|
|
9
|
+
|
|
10
|
+
from agent.bootstrap.config import default_skills_dir, require_outside_workspace
|
|
11
|
+
from agent.companion import STATES
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def initialize_user_files(*, workspace: Path | None = None) -> Path | None:
|
|
15
|
+
"""Create missing default files; return config path only when newly created."""
|
|
16
|
+
work = (workspace or Path.cwd()).resolve()
|
|
17
|
+
skills = default_skills_dir()
|
|
18
|
+
root = skills.parent
|
|
19
|
+
config = root / "config.yaml"
|
|
20
|
+
require_outside_workspace(root, work, label="configuration directory")
|
|
21
|
+
require_outside_workspace(skills, work, label="skills directory")
|
|
22
|
+
if root.is_symlink() or skills.is_symlink():
|
|
23
|
+
raise ValueError("configuration and skills directories must not be symlinks")
|
|
24
|
+
root.mkdir(mode=0o700, exist_ok=True)
|
|
25
|
+
skills.mkdir(mode=0o700, exist_ok=True)
|
|
26
|
+
if os.environ.get("DEEP_AGENT_CONFIG"):
|
|
27
|
+
return None
|
|
28
|
+
# Creating config.yaml and filling missing companion prompts/GIFs are
|
|
29
|
+
# independent: an older config must still receive newly required assets.
|
|
30
|
+
initialize_companion_files(root)
|
|
31
|
+
if config.exists() or config.is_symlink():
|
|
32
|
+
if not config.is_file():
|
|
33
|
+
raise ValueError(f"configuration path must be a file: {config}")
|
|
34
|
+
return None
|
|
35
|
+
template = files("agent").joinpath("config.example.yaml")
|
|
36
|
+
return config if _write_default(config, template) else None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def initialize_companion_files(config_dir: Path) -> None:
|
|
40
|
+
source = files("agent.companion")
|
|
41
|
+
companion_dir = config_dir / "companion"
|
|
42
|
+
prompts = companion_dir / "prompts"
|
|
43
|
+
gifs = companion_dir / "gifs"
|
|
44
|
+
for directory in (companion_dir, prompts, gifs):
|
|
45
|
+
if directory.is_symlink():
|
|
46
|
+
raise ValueError(f"Companion directory must not be a symlink: {directory}")
|
|
47
|
+
directory.mkdir(mode=0o700, exist_ok=True)
|
|
48
|
+
for name in ("persona.md", "observation.md", "chat.md"):
|
|
49
|
+
_write_default(prompts / name, source.joinpath(name))
|
|
50
|
+
for state in STATES:
|
|
51
|
+
name = f"lain_{state}.gif"
|
|
52
|
+
_write_default(gifs / name, source.joinpath("assets", name))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _write_default(destination: Path, source: abc.Traversable) -> bool:
|
|
56
|
+
if destination.exists() or destination.is_symlink():
|
|
57
|
+
if not destination.is_file():
|
|
58
|
+
raise ValueError(f"configuration asset must be a file: {destination}")
|
|
59
|
+
return False
|
|
60
|
+
with tempfile.NamedTemporaryFile(mode="wb", dir=destination.parent, prefix=".config-", delete=False) as temporary:
|
|
61
|
+
temp_path = Path(temporary.name)
|
|
62
|
+
try:
|
|
63
|
+
os.chmod(temp_path, 0o600)
|
|
64
|
+
temporary.write(source.read_bytes())
|
|
65
|
+
temporary.flush()
|
|
66
|
+
os.fsync(temporary.fileno())
|
|
67
|
+
try:
|
|
68
|
+
os.link(temp_path, destination)
|
|
69
|
+
except FileExistsError:
|
|
70
|
+
if not destination.is_file():
|
|
71
|
+
raise ValueError(f"configuration asset must be a file: {destination}") from None
|
|
72
|
+
return False
|
|
73
|
+
finally:
|
|
74
|
+
temp_path.unlink(missing_ok=True)
|
|
75
|
+
return True
|
|
@@ -158,7 +158,7 @@ class AccessSelection:
|
|
|
158
158
|
self.state.add_system("Sandbox mount policy is not available for this backend.", error=True)
|
|
159
159
|
return
|
|
160
160
|
skills = getattr(backend, "skills_dir", None)
|
|
161
|
-
self.state.
|
|
161
|
+
self.state.add_command_panel("/sandbox mounts", render_launch_manifest(
|
|
162
162
|
config, skills_dir=skills, pending_mode=self.runner.pending_sandbox_mode(),
|
|
163
163
|
))
|
|
164
164
|
self.invalidate()
|