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
v1.ts5.9 KB
// ACP v1 keeps chunk streaming and prompt-response completion semantics.
import type { AcpAgent } from "./agent.ts";
import * as map from "./map.ts";
import * as wire from "./wire.ts";
import { ToolStream, bound } from "./throttle.ts";
import { Entities, notice } from "./entities.ts";
import { EmbeddedTools } from "./apps.ts";
export function applyUpdate(this: AcpAgent, session: string, live: string, update: wire.Message) {
let entities = this.entities.get(live);
if (!entities) this.entities.set(live, (entities = new Entities()));
const events = entities.push(update);
if (events !== null) {
for (const event of events) this.emitFor(session, event);
return;
}
if (update.sessionUpdate === "notice") return this.emitFor(session, notice(update));
// One prompt per session makes live model output unambiguous. Metadata,
// replay and user echoes do not establish pickup of the current input.
if (["agent_message_chunk", "agent_thought_chunk", "tool_call"].includes(update.sessionUpdate ?? ""))
this.consumeInput(session);
switch (update.sessionUpdate) {
// The user message is already in the host's transcript.
case "user_message_chunk":
return;
case "agent_message_chunk": {
const itemId = this.chunkItem(session, false, update.messageId);
return this.emitFor(session, {
event: "text_delta",
itemId,
text: map.contentText(update.content),
mode: "append",
});
}
case "agent_thought_chunk": {
const itemId = this.chunkItem(session, true, update.messageId);
return this.emitFor(session, {
event: "reasoning_delta",
itemId,
text: map.contentText(update.content),
mode: "append",
});
}
case "tool_call":
return startTool.call(this, session, live, update);
case "tool_call_update":
return updateTool.call(this, session, live, update);
case "plan":
this.breakChunks(session);
return this.emitFor(session, { event: "plan", ...map.plan(update) });
case "available_commands_update": {
const commands = map.commands(update);
const state = this.sessions.get(session);
if (state) state.commands = commands;
return this.emitFor(session, { event: "commands", commands });
}
case "current_mode_update": {
const state = this.stateOf(session);
if (state.modes && typeof update.currentModeId === "string")
state.modes = { ...state.modes, currentModeId: update.currentModeId };
return this.publishOptions(session);
}
case "config_option_update": {
this.stateOf(session).config = Array.isArray(update.configOptions) ? update.configOptions : [];
return this.publishOptions(session);
}
case "session_info_update":
if (typeof update.title === "string") this.emitFor(session, { event: "session_info", title: update.title });
return;
case "usage_update": {
const usage = map.contextUsage(update);
this.stateOf(session).context = usage;
return this.emitFor(session, { event: "usage", ...usage });
}
// Compaction, `plan_update` and `plan_removed` have no place yet.
default:
return;
}
}
export function permission(request: wire.Message) {
return { request, subject: {}, title: null as string | null, warning: null as string | null };
}
function startTool(this: AcpAgent, session: string, live: string, update: wire.Message) {
if (update.toolCallId === undefined) return;
this.breakChunks(session);
map.applyTerminalMeta(update, this.reportedTerminals(live));
const views = this.terminalViews(live);
this.rememberTerminals(session, live, update.toolCallId, update.content);
const started = map.toolCall(update, views);
if (this.hostFeatures.includes("mcpApps")) {
let tools = this.embeddedTools.get(live);
if (!tools) this.embeddedTools.set(live, (tools = new EmbeddedTools()));
started.content = tools.update(update, started.content);
}
bound(started.content);
this.note(session, { kind: "tool", id: started.id });
// A subagent is announced as a tool call and has nothing else to
// declare it, so the task is derived from the call and the call
// itself still renders as the row it nests under.
const task = this.quirks.subagent(update);
if (task) {
started.kind = "task";
this.tasks.set(task.id, task.title);
this.emitFor(session, { event: "task", ...task });
}
return this.emitFor(session, { event: "tool_call_started", ...started });
}
function updateTool(this: AcpAgent, session: string, live: string, update: wire.Message) {
if (update.toolCallId === undefined) return;
this.breakChunks(session);
const touched = map.applyTerminalMeta(update, this.reportedTerminals(live));
const views = this.terminalViews(live);
if (Array.isArray(update.content)) this.rememberTerminals(session, live, update.toolCallId, update.content);
const task = this.finishedTask(update);
if (task) this.emitFor(session, { event: "task", ...task });
const patch = map.toolCallUpdate(update, views);
// Output reported in `_meta` changes the row's terminal.
if (touched !== null && patch.content === undefined)
patch.content = map.toolContent([{ type: "terminal", terminalId: touched }], views);
if (this.hostFeatures.includes("mcpApps")) {
let tools = this.embeddedTools.get(live);
if (!tools) this.embeddedTools.set(live, (tools = new EmbeddedTools()));
patch.content = tools.update(update, patch.content);
}
bound(patch.content);
// Agents that resend the whole output on every tick would otherwise
// send one event per tick.
let streams = this.toolStreams.get(session);
if (!streams) {
streams = new Map();
this.toolStreams.set(session, streams);
}
let stream = streams.get(patch.id);
if (!stream) {
stream = new ToolStream();
streams.set(patch.id, stream);
}
const send = stream.push(patch);
if (send) this.emitFor(session, { event: "tool_call_updated", ...send });
return;
}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.