The adapter module handles translation between ACP message formats and LangChain/LangGraph message formats. It also provides utilities for tool call metadata, plan entries, and file URI handling.
Learn more: For the ACP content block specification, see agentclientprotocol.com.
Convert incoming ACP ContentBlock arrays into LangChain HumanMessage instances:
import { acpPromptToHumanMessage } from "deepagents-acp";
const humanMessage = acpPromptToHumanMessage(acpContentBlocks);
Supports text, image (base64 and URL), and resource content blocks.
Convert outgoing LangChain messages back to ACP ContentBlock arrays:
import { langChainMessageToACP, langChainContentToACP } from "deepagents-acp";
const contentBlocks = langChainMessageToACP(aiMessage);
const blocks = langChainContentToACP("Hello, world!");
Extract structured tool call info from LangChain AIMessage instances:
import { extractToolCalls } from "deepagents-acp";
const toolCalls = extractToolCalls(aiMessage);
// [{ id, name, args, status: "pending" }]
Categorize tool calls using ACP-standard kinds for proper icon display in IDEs:
import { getToolCallKind } from "deepagents-acp";
getToolCallKind("read_file"); // "read"
getToolCallKind("edit_file"); // "edit"
getToolCallKind("grep"); // "search"
getToolCallKind("execute"); // "execute"
getToolCallKind("write_todos"); // "think"
| Kind | Tools |
|---|---|
read |
read_file, ls |
search |
grep, glob |
edit |
write_file, edit_file |
execute |
execute, shell |
think |
write_todos |
other |
All other tools |
Generate human-readable titles for tool call display:
import { formatToolCallTitle } from "deepagents-acp";
formatToolCallTitle("read_file", { path: "src/index.ts" });
// "Reading src/index.ts"
Extract file locations from tool call arguments for IDE follow-along:
import { extractToolCallLocations } from "deepagents-acp";
const locations = extractToolCallLocations(
"edit_file",
{ path: "src/app.ts", line: 42 },
"/workspace",
);
// [{ path: "/workspace/src/app.ts", line: 42 }]
Convert DeepAgents todo list state to ACP plan entries:
import { todosToPlanEntries } from "deepagents-acp";
const planEntries = todosToPlanEntries([
{ id: "1", content: "Implement feature", status: "in_progress" },
{ id: "2", content: "Write tests", status: "pending" },
]);
Convert between file URIs and absolute paths:
import { fileUriToPath, pathToFileUri } from "deepagents-acp";
fileUriToPath("file:///workspace/src/index.ts"); // "/workspace/src/index.ts"
pathToFileUri("/workspace/src/index.ts"); // "file:///workspace/src/index.ts"
Generate unique session and tool call IDs:
import { generateSessionId, generateToolCallId } from "deepagents-acp";
generateSessionId(); // "sess_a1b2c3d4e5f6g7h8"
generateToolCallId(); // "call_a1b2c3d4e5f6"
Convert ACP prompt content blocks to a LangChain HumanMessage
Convert ACP content blocks to LangChain message content
Convert LangChain BaseMessage to ACP content blocks
Convert LangChain message content to ACP content blocks
Extract tool calls from LangChain AIMessage
Convert todo list state to ACP plan entries
Determine the kind of tool call for ACP display
Format tool call title for ACP display
Extract file locations from tool call arguments for ACP follow-along
Generate a unique session ID
Generate a unique tool call ID
Parse file URI to absolute path
Convert absolute path to file URI