Official
acp
ACP agents from the ACP registry (Gemini, Cursor, Droid, Kilo, pi, ...), Oh My Pi, and your own entries (custom.json in the plugin's data folder). Agents are discovered at runtime.
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/acp@0.2.5
Permissions in 0.2.5
Take care. This plugin asks for permissions that can do anything your account can. The app asks you to hold Enable for two seconds or to type the plugin's name before it turns on.
Files
history.ts6.5 KB
// ACP v1 replay keeps native row identities and session entities in receive order.
import type { TranscriptItem } from "divergence/protocol";
import { compact, newId } from "../sdk/agent.ts";
import {
applyTerminalMeta,
contentText,
userBlock,
toolCall,
toolCallUpdate,
toolContent,
plan,
stripInstructions,
} from "./map.ts";
import type { TerminalView } from "./map.ts";
import { Entities } from "./entities.ts";
import { EmbeddedTools } from "./apps.ts";
import type { Message } from "./wire.ts";
type MutableUserItem = Extract<TranscriptItem, { role: "user" }>;
type MutableTextItem = Extract<TranscriptItem, { role: "assistant" | "reasoning" }>;
const str = (value: unknown) => (typeof value === "string" ? value : null);
/// Turns the `session/update` notifications `session/load` replays into
/// transcript items.
export class Recorder {
readonly apps: EmbeddedTools | null;
constructor(mcpApps = false) {
this.apps = mcpApps ? new EmbeddedTools() : null;
}
readonly entities = new Entities();
private readonly items: TranscriptItem[] = [];
private open: ["user" | "assistant" | "reasoning", number] | null = null;
readonly terminals = new Map<unknown, TerminalView>();
/// Rows named by the agent's own `messageId`, as a live run names them.
readonly identified = new Set<string>();
push(update: Message): void {
if (this.entities.push(update) !== null) {
for (const item of this.entities.items.values()) {
const index = this.items.findIndex((known) => known.id === item.id);
if (index < 0) this.items.push(item);
else this.items[index] = item;
}
return;
}
const messageId = typeof update.messageId === "string" && update.messageId ? update.messageId : null;
if (messageId) this.identified.add(messageId);
switch (update.sessionUpdate) {
case "user_message_chunk": {
const block = userBlock(update.content);
const open = this.openUser();
if (!open || (messageId && open.id !== messageId)) {
this.items.push({ id: messageId ?? newId("acp-item"), role: "user", blocks: [block] });
this.open = ["user", this.items.length - 1];
break;
}
const last = open.blocks[open.blocks.length - 1];
if (last?.type === "text" && block.type === "text") last.text += block.text;
else open.blocks.push(block);
break;
}
case "agent_message_chunk": {
const more = contentText(update.content);
const open = this.openText("assistant", messageId);
if (open) open.text += more;
else this.startText("assistant", more, messageId);
break;
}
case "agent_thought_chunk": {
const more = contentText(update.content);
const open = this.openText("reasoning", messageId);
if (open) open.text += more;
else this.startText("reasoning", more, messageId);
break;
}
case "tool_call": {
if (update.toolCallId === undefined) break;
this.open = null;
applyTerminalMeta(update, this.terminals);
const call = toolCall(update, this.terminals);
if (this.apps) call.content = this.apps.update(update, call.content);
this.items.push({ id: call.id, role: "tool", call });
break;
}
case "tool_call_update":
if (update.toolCallId === undefined) break;
this.open = null;
this.patchTool(update);
break;
case "plan":
this.open = null;
this.items.push({ id: newId("acp-plan"), role: "plan", plan: plan(update) });
break;
default:
break;
}
}
private patchTool(update: Message): void {
const touched = applyTerminalMeta(update, this.terminals);
const patch = toolCallUpdate(update, this.terminals);
if (touched !== null && patch.content === undefined)
patch.content = toolContent([{ type: "terminal", terminalId: touched }], this.terminals);
if (this.apps) patch.content = this.apps.update(update, patch.content);
const existing = [...this.items]
.reverse()
.find(
(item): item is Extract<TranscriptItem, { role: "tool" }> => item.role === "tool" && item.call.id === patch.id,
);
if (!existing) {
this.items.push({
id: patch.id,
role: "tool",
call: compact({
id: patch.id,
name: str(update.name) ?? str(update.kind) ?? "tool",
kind: patch.kind ?? "other",
title: patch.title ?? "",
status: patch.status ?? "pending",
input: patch.input ?? null,
output: patch.output ?? null,
content: patch.content ?? [],
locations: patch.locations ?? [],
}),
});
return;
}
const call = existing.call;
if (patch.name !== undefined) call.name = patch.name;
if (patch.status !== undefined) call.status = patch.status;
if (patch.title !== undefined) call.title = patch.title;
if (patch.kind !== undefined) call.kind = patch.kind;
if (patch.input !== undefined) call.input = patch.input;
if (patch.output !== undefined) call.output = patch.output;
if (patch.content !== undefined) call.content = patch.content;
if (patch.locations !== undefined) call.locations = patch.locations;
}
private startText(role: "assistant" | "reasoning", text: string, messageId: string | null): void {
this.items.push({ id: messageId ?? newId("acp-item"), role, text });
this.open = [role, this.items.length - 1];
}
private openUser(): MutableUserItem | null {
if (!this.open || this.open[0] !== "user") return null;
const item = this.items[this.open[1]];
return item?.role === "user" ? item : null;
}
private openText(role: "assistant" | "reasoning", messageId: string | null): MutableTextItem | null {
if (!this.open || this.open[0] !== role) return null;
const item = this.items[this.open[1]];
if (messageId && item?.id !== messageId) return null;
return item?.role === role ? item : null;
}
/// The transcript. The instructions this plugin sent ahead of a first
/// prompt are the plugin's, not the user's, and are left out.
finish(): TranscriptItem[] {
const out: TranscriptItem[] = [];
for (const item of this.items) {
if (item.role !== "user") {
out.push(item);
continue;
}
const blocks = item.blocks
.map((block) => (block.type === "text" ? { ...block, text: stripInstructions(block.text) } : block))
.filter((block) => block.type !== "text" || block.text !== "");
if (blocks.length) out.push({ ...item, blocks });
}
return out;
}
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.5latest | Nov 21, 2026 | >=5 <6 | 134 KB | 6 permissions | Listed |
| 0.2.4 | Nov 16, 2026 | >=5 <6 | 132.8 KB | 6 permissions | Listed |
| 0.2.3 | Nov 11, 2026 | >=5 <6 | 108.9 KB | 6 permissions | Listed |
| 0.2.2 | Nov 9, 2026 | >=5 <6 | 105.6 KB | 6 permissions | Listed |
| 0.2.1 | Oct 27, 2026 | >=2 <4 | 105.3 KB | 6 permissions | Listed |
No comments yet.