Official

chat

Built-in chat UI (JavaScript UI plugin).

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 convergence/chat@0.2.2

Permissions in 0.2.2

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Send prompts, answer agent questions, and create, change, fork, revert, stop and group chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Run the sidebar's New chat command from the title bar
  • Read chats chats.readMediumReads your transcripts and chat lists.Show workspaces, tasks, chats and transcripts, and follow them as agents work
  • Read files fs.readMediumReads files in the listed places.Suggest workspace files for @ mentionsPlaces: the open workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the chat grid, the title bar, and the Session panel with its rail buttonSlots: centertitlerailright

Files

transcript.ts7.7 KB
// Apply agent snapshots and deltas in place without work beyond the affected transcript.
import type { AgentEventKind, Chat, TranscriptItem, UserSession } from "convergence";
import type { Transcript } from "./state.ts";
import { applyTask, findTask, isLive } from "./subagents.ts";
export type SessionChange = { kind: "handoff" | "session"; from: string; to: string };
/// Where the conversation moved to another agent (a handoff) or to a new
/// native session of the same agent, by the id of the first user message
/// sent there. A session id that is not known yet continues the session.
export function sessionChanges(
  items: readonly TranscriptItem[],
  sessions: Readonly<Record<string, UserSession>>,
): Map<string, SessionChange> {
  const changes = new Map<string, SessionChange>();
  let previous: UserSession | undefined;
  for (const item of items) {
    const current = item.role === "user" ? sessions[item.id] : undefined;
    if (!current) continue;
    if (previous && previous.agentId !== current.agentId)
      changes.set(item.id, { kind: "handoff", from: previous.agentId, to: current.agentId });
    else if (previous?.sessionId && current.sessionId && previous.sessionId !== current.sessionId)
      changes.set(item.id, { kind: "session", from: previous.agentId, to: current.agentId });
    previous = current;
  }
  return changes;
}
/// A user message the host has not archived yet was sent in the chat's
/// current session.
export function noteSession(t: Transcript, item: TranscriptItem, chat: Chat | undefined) {
  if (item.role === "user" && chat && !t.sessions[item.id])
    t.sessions[item.id] = { agentId: chat.agentId, sessionId: chat.sessionId ?? null };
}
/// A send that creates or recovers its session reports its message
/// before the session exists, so it was noted with the session the chat
/// had then. The change that gives the running chat its new session (same
/// agent) carries the session that message went to. Whether it moved.
export function followSession(t: Transcript, before: Chat | undefined, chat: Chat, running: boolean): boolean {
  if (!running || !before || !chat.sessionId || before.agentId !== chat.agentId || before.sessionId === chat.sessionId)
    return false;
  let last: TranscriptItem | undefined;
  for (let i = t.items.length - 1; i >= 0 && !last; i--) if (t.items[i]?.role === "user") last = t.items[i];
  const noted = last && t.sessions[last.id];
  if (!last || !noted || noted.agentId !== chat.agentId || noted.sessionId !== (before.sessionId ?? null)) return false;
  t.sessions[last.id] = { agentId: chat.agentId, sessionId: chat.sessionId };
  return true;
}
/// A notice, unless the one above says the same: an agent that reports its
/// error as a notice and again as the turn's failure says it once (as the
/// host's transcript does).
function pushNotice(t: Transcript, text: string) {
  const last = t.items[t.items.length - 1];
  if (last?.role === "notice" && last.text === text) return;
  t.items.push({ id: `n-${Date.now()}`, role: "notice", text });
}

export function findItem(t: { items: TranscriptItem[] }, id: string | undefined) {
  for (let i = t.items.length - 1; i >= 0; i--) if (t.items[i]?.id === id) return t.items[i] ?? null;
  return null;
}
export function applyText(
  t: { items: TranscriptItem[] },
  kind: Extract<AgentEventKind, { event: "text_delta" | "reasoning_delta" }>,
  role: "assistant" | "reasoning",
) {
  const existing = findItem(t, kind.itemId);
  if (existing && (existing.role === "assistant" || existing.role === "reasoning"))
    existing.text = kind.mode === "replace" ? kind.text : existing.text + kind.text;
  else t.items.push({ id: kind.itemId, role, text: kind.text });
}
export function applyEvent(t: Transcript, kind: AgentEventKind, taskId?: string): boolean {
  if (kind.event === "task") {
    const { event, ...task } = kind;
    const before = task.workflow ? findTask(t.items, task.id)?.task.status : null;
    applyTask(t.items, task);
    // A workflow seen finishing gets its burst, once. One read back from
    // history has no `before` and stays quiet.
    if (before && isLive({ status: before }) && task.status === "completed") (t.finished ??= new Set()).add(task.id);
    return true;
  }
  if (taskId) {
    if (kind.event === "approval" || kind.event === "question") kind.taskId ??= taskId;
    if (kind.event === "plan" || kind.event === "run_started" || kind.event === "run_finished") return false;
  }
  // The list the event's items go into.
  const task = taskId ? findTask(t.items, taskId) : null;
  const scope = task ? { items: (task.items ??= []) } : t;
  switch (kind.event) {
    case "text_delta":
      applyText(scope, kind, "assistant");
      return true;
    case "reasoning_delta":
      applyText(scope, kind, "reasoning");
      return true;
    case "tool_call_started": {
      const { event, ...call } = kind;
      call.content ??= [];
      call.locations ??= [];
      const existing = findItem(scope, call.id);
      if (existing?.role === "tool") existing.call = call;
      else scope.items.push({ id: call.id, role: "tool", call });
      return true;
    }
    case "tool_call_updated": {
      const item = findItem(scope, kind.id);
      if (item?.role !== "tool") return false;
      const call = item.call;
      if (kind.status !== undefined) call.status = kind.status;
      if (kind.title !== undefined) call.title = kind.title;
      if (kind.kind !== undefined) call.kind = kind.kind;
      if (kind.input !== undefined) call.input = kind.input;
      // Some agents (Cline) send a result only here.
      if (kind.output !== undefined) call.output = kind.output;
      if (kind.content !== undefined) call.content = kind.content;
      if (kind.locations !== undefined) call.locations = kind.locations;
      // A code mode program's calls so far, replaced whole.
      if (kind.calls !== undefined) call.calls = kind.calls;
      call.content ??= [];
      call.locations ??= [];
      if (kind.outputDelta) {
        const last = call.content[call.content.length - 1];
        if (last?.type === "text") last.text += kind.outputDelta;
        else if (last?.type === "terminal") last.output += kind.outputDelta;
        else call.content.push({ type: "text", text: kind.outputDelta });
      }
      return true;
    }
    // Kept only to place the kernel's card and to know the chat waits.
    case "approval": {
      const { event, ...req } = kind;
      t.approvals = [...t.approvals.filter((a) => a.id !== req.id), req];
      return true;
    }
    case "question": {
      const { event, ...req } = kind;
      t.questions = [...t.questions.filter((q) => q.id !== req.id), req];
      return true;
    }
    // Answered in another client of the same agent, or withdrawn.
    case "approval_resolved": {
      const before = t.approvals.length;
      t.approvals = t.approvals.filter((a) => a.id !== kind.id);
      return t.approvals.length !== before;
    }
    case "question_resolved": {
      const before = t.questions.length;
      t.questions = t.questions.filter((q) => q.id !== kind.id);
      return t.questions.length !== before;
    }
    case "plan":
      t.plan = { entries: kind.entries };
      return true;
    // The agent went on by itself, for example after a background task.
    case "run_started":
      t.running = true;
      return true;
    case "run_finished":
      t.running = false;
      t.approvals = [];
      t.questions = t.questions.filter((q) => q.responseMode === "message");
      if (kind.outcome.status === "cancelled") pushNotice(t, "Stopped.");
      if (kind.outcome.status === "failed") pushNotice(t, kind.outcome.message);
      return true;
    case "notice":
      if (kind.level === "error") {
        pushNotice(t, kind.message);
        return true;
      }
      return false;
    default:
      return false;
  }
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.5latestNov 21, 2026>=2 <4174.6 KB5 permissionsListed
0.2.4Oct 25, 2026>=2 <4174.2 KB5 permissionsListed
0.2.3Oct 24, 2026>=2 <4165.4 KB5 permissionsListed
0.2.2Oct 23, 2026>=2 <4165 KB5 permissionsListed
0.2.1Oct 6, 2026>=2 <3111.8 KB5 permissionsListed
0.2.0Oct 5, 2026>=2 <3105.1 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.