跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.devinenterprise.com/llms.txt

Use this file to discover all available pages before exploring further.

本页介绍构建可在 Devin Desktop 中运行的自定义 ACP Agent 需要实现的内容。 如需查看完整的协议规范,请参见 agentclientprotocol.com。官方客户端库提供了 RustTypeScriptPythonKotlinJava 版本。

基础

ACP Agent 会作为本地子进程运行,由 Devin Desktop 按需启动。所有通信都通过 stdio 上的 JSON-RPC 进行。

你必须实现的方法

你的 Agent 至少需要处理 Devin Desktop 的以下方法:
  • initialize — 协商协议版本,声明 Agent 的能力,并返回 Agent 信息 (名称、版本) 。
  • session/new — 为工作目录创建一个新会话,并返回会话 ID。Devin Desktop 会传入 cwd 以及所有已配置的 MCP 服务器。
  • session/prompt — 接收用户消息,推进提示轮次,并在完成时返回 stopReason
  • session/cancel — 当用户取消时,中止该会话中所有正在进行的工作。

提示轮次生命周期

session/prompt 轮次期间,你的 Agent 会以 JSON-RPC 通知的形式,将更新流式发送回 Devin Desktop:
  • 带有 agent_message_chunksession/update,用于流式传输助手文本。
  • 带有 tool_calltool_call_updatesession/update,用于在 Devin Desktop UI 中显示工具调用及其状态。
  • session/request_permission,用于在运行敏感工具调用前征求用户许可。
  • 如果你的 Agent 维护了agent plan,则会发送带有 plansession/update
当你的 Agent 返回带有 stopReason (例如 end_turncancelledmax_tokens) 的 session/prompt 响应时,该轮次结束。

测试

要在 Devin Desktop 中测试你的 Agent:
  1. 在你的本地 registry 配置中为你的 Agent 添加一个条目,将 cmd 指向本地 Agent 二进制文件 (或封装脚本) 的路径。
  2. 修改你的 Agent,并按需重建。
  3. 在 Command Palette 中运行 Reload ACP Connections 以加载最新版本——每次迭代之间都无需重启 Devin Desktop。

局限性

Devin Desktop 目前尚未支持 ACP 规范的所有内容。在构建面向 Devin Desktop 的 Agent 时,以下是需要注意的主要差异:
  • 不支持会话模式。 会话模式 不会在 Devin Desktop UI 中显示。如果你的 Agent 需要让用户在不同模式之间进行选择 (例如 plan / build / review) ,请改为将这些模式作为 会话配置选项 提供,并使用 "mode" 类别。
  • 不提供终端能力。 Devin Desktop 不会声明 终端能力,因此 Agent 无法在 Devin Desktop UI 中创建终端。Agent 应在自己的子进程中运行命令,并通过 tool_call 更新流式传回输出。