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.4

Permissions in 0.2.4

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.
  • Run any command process.anyDangerousStarts any program or shell command. This is as strong as your own account.Start the ACP agents, which the registry launches by path or through package runners such as npx and uvx, and run the terminal commands an agent asks for
  • Provide agents agents.provideMediumAdds agents to the app.Provide the agents of the ACP registry, and serve plugin tools to them through the host's loopback MCP server
  • Network access netMediumConnects to the listed hosts.Download the ACP registry and the agents' marks once a dayHosts: cdn.agentclientprotocol.com
  • Read files fs.readMediumReads files in the listed places.Read the files an agent asks for (ACP fs/read_text_file), only inside the chat's workspace, and your own agents from custom.json in this plugin's data folderPlaces: the open workspaceits own data folder
  • Write files fs.writeMediumCreates, changes and deletes files in the listed places.Write the files an agent asks to write (ACP fs/write_text_file), only inside the chat's workspace, and move the custom agents of the old ACP plugin into custom.json oncePlaces: the open workspaceits own data folder
  • Environment variables envMediumReads the listed environment variables.Sign Grok in with your xAI API key when you set one, and tell which Windows build of an agent to runVariables: XAI_API_KEYPROCESSOR_ARCHITECTURE

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

VersionPublishedPlugin APISizePermissionsStatus
0.2.5latestNov 21, 2026>=5 <6134 KB6 permissionsListed
0.2.4Nov 16, 2026>=5 <6132.8 KB6 permissionsListed
0.2.3Nov 11, 2026>=5 <6108.9 KB6 permissionsListed
0.2.2Nov 9, 2026>=5 <6105.6 KB6 permissionsListed
0.2.1Oct 27, 2026>=2 <4105.3 KB6 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.