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.
Files
audit.test.ts21.2 KB
import { test } from "node:test";
import assert from "node:assert/strict";
import { harness, acpPeer, present, SESSION, next, replyTo, responseError, update } from "./testing.ts";
import { settle } from "../sdk/testing.ts";
import { Recorder } from "./history.ts";
import { Replay } from "./replay.ts";
import { ToolStream } from "./throttle.ts";
import * as map from "./map.ts";
import type { PeerHandler } from "./testing.ts";
const mode = {
id: "mode",
name: "Mode",
category: "mode",
type: "select",
currentValue: "ask",
options: [
{ value: "ask", name: "Ask" },
{ value: "code", name: "Code" },
],
};
function provider(capabilities: Record<string, unknown> = {}, handlers: Record<string, PeerHandler> = {}) {
return acpPeer({
init: { agentCapabilities: capabilities },
handlers: {
"session/new": () => ({ sessionId: "native", configOptions: [mode] }),
"session/close": () => ({}),
...handlers,
},
});
}
test("native config mode options use their config setter while legacy modes keep set_mode", async () => {
const { agent, api } = harness("test", {
peer: provider(
{},
{
"session/set_config_option": () => ({ configOptions: [{ ...mode, currentValue: "code" }] }),
"session/set_mode": () => ({}),
},
),
});
const { sessionId } = await agent.createSession({ workspace: "/w" });
await agent.setOption({ sessionId, optionId: "mode", value: "code" });
const peer = present(api.peers[0]);
assert.equal(peer.received.filter((message) => message.method === "session/set_mode").length, 0);
assert.equal(
peer.received.find((message) => message.method === "session/set_config_option")?.params.configId,
"mode",
);
present(agent.sessions.get(sessionId)).config = [];
present(agent.sessions.get(sessionId)).modes = {
currentModeId: "ask",
availableModes: [{ id: "ask" }, { id: "code" }],
};
await agent.setOption({ sessionId, optionId: "mode", value: "ask" });
assert.ok(peer.received.some((message) => message.method === "session/set_mode"));
});
test("logout is sent only when the native logout capability is non-null", async () => {
for (const logout of [undefined, null, {}]) {
const { agent, api } = harness("test", { peer: provider({ auth: { logout } }, { logout: () => ({}) }) });
if (logout == null) await assert.rejects(agent.logout(), /does not support signing out/);
else await agent.logout();
assert.equal(
present(api.peers[0]).received.filter((message) => message.method === "logout").length,
logout == null ? 0 : 1,
);
}
});
test("tool renames survive live updates, coalescing, and replay", () => {
const { agent, events } = harness();
update(agent, { sessionUpdate: "tool_call", toolCallId: "t", title: "Working" });
update(agent, { sessionUpdate: "tool_call_update", toolCallId: "t", name: "read_file" });
assert.equal((events.at(-1) as { name?: string }).name, "read_file");
const stream = new ToolStream();
stream.push({ id: "t", title: "Working" });
assert.equal(stream.push({ id: "t", name: "read_file" })?.name, "read_file");
const replay = new Recorder();
replay.push({ sessionUpdate: "tool_call", toolCallId: "t", name: "generic" });
replay.push({ sessionUpdate: "tool_call_update", toolCallId: "t", name: "read_file" });
const item = replay.finish()[0];
assert.equal(item?.role === "tool" ? item.call.name : null, "read_file");
});
test("v1 advertises boolean options and notices without overclaiming incomplete host contracts", () => {
const caps = harness().agent.initializeParams().clientCapabilities;
assert.deepEqual(caps.session.configOptions.boolean, {});
assert.deepEqual(caps.session.notices, {});
assert.equal("subagents" in caps, false);
assert.equal("compaction" in caps.session, false);
});
test("advertised system prompts carry trusted instructions on new, load, resume, and fork", async () => {
for (const operation of ["new", "load", "resume", "fork"] as const) {
const { agent, api, events } = harness("test", {
peer: provider(
{ loadSession: operation === "load", sessionCapabilities: { systemPrompt: {}, resume: {}, fork: {} } },
{
"session/load": () => ({}),
"session/resume": () => ({}),
"session/fork": () => ({ sessionId: "copy" }),
"session/prompt": () => ({ stopReason: "end_turn" }),
},
),
});
agent.sessions.clear();
if (operation === "new") await agent.createSession({ workspace: "/w", instructions: "Follow these rules." });
else if (operation === "fork")
await agent.forkSession({ sessionId: "saved", workspace: "/w", instructions: "Follow these rules." });
else await agent.resumeSession({ sessionId: "saved", workspace: "/w", instructions: "Follow these rules." });
const peer = present(api.peers[0]);
const request = present(peer.received.find((message) => message.method === `session/${operation}`));
assert.deepEqual(request.params.systemPrompt, {
mode: "append",
content: [{ type: "text", text: "Follow these rules." }],
});
const sessionId = operation === "new" ? "native" : operation === "fork" ? "copy" : "saved";
await agent.prompt({ sessionId, input: { blocks: [{ type: "text", text: "Go." }] } });
await next(events, "run_finished");
const prompt = present(peer.received.find((message) => message.method === "session/prompt"));
assert.deepEqual(prompt.params.prompt, [{ type: "text", text: "Go." }]);
}
});
test("native notices preserve presentation hints without changing the run", () => {
const { agent, events } = harness();
for (const severity of ["info", "warning", "error", "future"])
update(agent, {
sessionUpdate: "notice",
severity,
title: "MCP server unavailable",
description: "Continuing without it.",
});
assert.deepEqual(
events.map((event) => (event.event === "notice" ? [event.level, event.message] : null)),
["info", "warning", "error", "info"].map((level) => [level, "MCP server unavailable\n\nContinuing without it."]),
);
assert.equal(agent.sessions.get(SESSION)?.run, "run-1");
});
test("compaction summaries apply append, replacement, clear, and failure semantics in replay", () => {
const replay = new Recorder();
const { agent, events } = harness();
const updates = [
{ sessionUpdate: "compaction_summary_chunk", compactionId: "c", content: { type: "text", text: "partial" } },
{
sessionUpdate: "compaction_update",
compactionId: "c",
status: "in_progress",
summary: [{ type: "text", text: "retained" }],
},
{ sessionUpdate: "compaction_summary_chunk", compactionId: "c", content: { type: "text", text: " context" } },
{ sessionUpdate: "compaction_update", compactionId: "c", status: "completed" },
{ sessionUpdate: "compaction_update", compactionId: "failed", status: "in_progress" },
{
sessionUpdate: "compaction_update",
compactionId: "failed",
status: "failed",
summary: null,
error: "The model failed.",
},
];
for (const value of updates) {
replay.push(value);
update(agent, value);
}
assert.equal(events.filter((event) => event.event === "compacting").length, 2);
assert.deepEqual(
events.filter((event) => event.event === "compacted").map((event) => event.summary),
["retained context", undefined],
);
assert.deepEqual(replay.finish(), [
{ id: "compaction:c", role: "compaction", summary: "retained context", running: false },
{ id: "compaction:failed", role: "notice", text: "The model failed." },
]);
});
test("session/options avoids throwaway sessions and sends initial config choices during setup", async () => {
const { agent, api } = harness("test", {
peer: provider(
{ sessionCapabilities: { options: {} } },
{
"session/options": () => ({
configOptions: [mode, { id: "enabled", name: "Enabled", type: "boolean", currentValue: false }],
}),
"session/new": (params) => ({
sessionId: "native",
configOptions: [
{ ...mode, currentValue: "code" },
{ id: "enabled", name: "Enabled", type: "boolean", currentValue: true },
],
}),
},
),
});
const listed = await agent.listOptions({ workspace: "/w" });
assert.equal(listed.options.find((option) => option.id === "enabled")?.kind, "toggle");
const peer = present(api.peers[0]);
assert.equal(
peer.received.some((message) => message.method === "session/new"),
false,
);
await agent.createSession({ workspace: "/w", options: { mode: "code", enabled: true, permission_mode: "full" } });
assert.deepEqual(peer.received.find((message) => message.method === "session/new")?.params.configOptions, [
{ configId: "mode", value: "code" },
{ configId: "enabled", type: "boolean", value: true },
]);
assert.equal(
peer.received.some(
(message) => message.method === "session/set_config_option" || message.method === "session/set_mode",
),
false,
);
});
test("auth status queries and notifications refresh readiness without exposing accounts", async () => {
const calls: string[] = [];
const { agent, api } = harness("test", {
onHost: (method) => {
calls.push(method);
return {};
},
peer: provider(
{ auth: { status: {} } },
{
"auth/status": () => ({ state: "unauthenticated", accounts: [{ name: "Private account" }] }),
},
),
});
assert.equal((await agent.initialize()).status?.state, "auth_required");
assert.ok(present(api.peers[0]).received.some((message) => message.method === "auth/status"));
agent.onNotification("auth/status_update", { state: "authenticated", accounts: [{ name: "Private account" }] });
await settle();
assert.equal((await agent.initialize()).status?.state, "ready");
const count = calls.filter((method) => method === "host/agents.changed").length;
agent.onNotification("auth/status_update", { state: "future" });
await settle();
assert.equal(calls.filter((method) => method === "host/agents.changed").length, count);
assert.equal(JSON.stringify(await agent.initialize()).includes("Private account"), false);
});
test("child sessions preserve ownership, restrictions, task-tagged events, and reusable state", async () => {
const { agent, events, api } = harness();
await agent.client();
update(agent, {
sessionUpdate: "subagent_update",
sessionId: "child",
title: "Worker",
capabilities: { cancel: {} },
state: { state: "running" },
});
update(agent, { sessionUpdate: "subagent_update", sessionId: "grandchild", title: "Nested" }, "child");
update(agent, { sessionUpdate: "agent_message_chunk", content: { type: "text", text: "Evidence" } }, "grandchild");
const text = events.find((event) => event.event === "text_delta");
assert.equal(text?.sessionId, SESSION);
assert.equal(text?.taskId, "grandchild");
assert.equal(events.find((event) => event.event === "task" && event.id === "grandchild")?.event === "task", true);
update(agent, { sessionUpdate: "subagent_update", sessionId: "child", state: { state: "idle" } });
assert.equal(agent.subagents.task("child").status, "idle");
update(agent, { sessionUpdate: "subagent_update", sessionId: "child", state: null, capabilities: {} });
assert.equal(agent.subagents.task("child").status, undefined);
await assert.rejects(
agent.prompt({ sessionId: "child", input: { blocks: [{ type: "text", text: "No." }] } }),
/does not permit/,
);
await assert.rejects(agent.setOption({ sessionId: "child", optionId: "mode", value: "code" }), /does not permit/);
await assert.rejects(agent.cancelTask({ sessionId: SESSION, taskId: "child" }), /does not support/);
update(agent, { sessionUpdate: "subagent_update", sessionId: "child", capabilities: { cancel: {} } });
await agent.cancelTask({ sessionId: SESSION, taskId: "child" });
assert.ok(
present(api.peers[0]).received.some(
(message) => message.method === "session/cancel" && message.params.sessionId === "child",
),
);
});
test("replay nests children at their announcement and preserves patched session messages", () => {
const replay = new Replay(SESSION, 1);
replay.push({ sessionUpdate: "subagent_update", sessionId: "child", title: "Worker", state: { state: "running" } });
replay.push(
{
sessionUpdate: "session_message",
messageId: "task",
senderSessionId: SESSION,
content: [{ type: "text", text: "old" }],
},
"child",
);
replay.push({ sessionUpdate: "session_message", messageId: "task", content: null }, "child");
replay.push(
{ sessionUpdate: "session_message_chunk", messageId: "task", content: { type: "text", text: "actual task" } },
"child",
);
replay.push({ sessionUpdate: "agent_message_chunk", content: { type: "text", text: "Parent answer" } });
const items = replay.finish();
assert.equal(items[0]?.role, "task");
assert.equal(items[1]?.role, "assistant");
const child = items[0];
assert.equal(
child?.role === "task" && child.items?.[0]?.role === "assistant" ? child.items[0].text : null,
`From ${SESSION}\n\nactual task`,
);
});
test("URL consent can decline or cancel and completion cannot grant consent", async () => {
for (const action of ["decline", "cancel"] as const) {
const { agent, api, events } = harness();
await agent.client();
const peer = present(api.peers[0]);
peer.send({
jsonrpc: "2.0",
id: 90,
method: "elicitation/create",
params: { sessionId: SESSION, mode: "url", url: "https://example.com", message: "Continue?", elicitationId: "e" },
});
const question = await next(events, "question");
peer.send({ jsonrpc: "2.0", method: "elicitation/complete", params: { elicitationId: "e" } });
await settle();
assert.equal(peer.received.some(replyTo(90)), false);
await agent.respondToQuestion({
questionId: question.id,
answer: { values: { action }, cancelled: action === "cancel" },
});
assert.deepEqual((await peer.waitFor(replyTo(90))).result, { action });
}
});
test("out-of-session URL requests decline without inventing consent during sign-in", async () => {
const { agent, api } = harness("test", {
peer: provider(
{},
{
authenticate: (_params, message, peer) => {
peer.send({
jsonrpc: "2.0",
id: "url",
method: "elicitation/create",
params: {
requestId: message.id,
mode: "url",
message: "Sign in",
url: "https://example.com/login",
elicitationId: "login",
},
});
},
},
),
});
const signIn = agent.authenticate({ method: "login" });
await settle();
const peer = present(api.peers[0]);
assert.deepEqual((await peer.waitFor(replyTo("url"))).result, { action: "decline" });
assert.deepEqual(api.opened, []);
peer.reply(present(peer.received.find((message) => message.method === "authenticate")), {});
await signIn;
peer.send({
jsonrpc: "2.0",
id: "unasked",
method: "elicitation/create",
params: { requestId: 33, mode: "url", message: "Open", url: "https://example.com/other", elicitationId: "other" },
});
assert.deepEqual((await peer.waitFor(replyTo("unasked"))).result, { action: "decline" });
});
test("v1 native titles received while loading still publish session_info", async () => {
const { agent, events } = harness("test", {
peer: provider(
{ loadSession: true },
{
"session/load": (params, _message, peer) => {
peer.send({
jsonrpc: "2.0",
method: "session/update",
params: {
sessionId: params.sessionId,
update: { sessionUpdate: "session_info_update", title: "Loaded native title" },
},
});
return {};
},
},
),
});
await agent.readSession({ sessionId: SESSION, workspace: "/w" });
assert.equal((await next(events, "session_info")).title, "Loaded native title");
});
test("child config and permissions stay inside the child task and session references attach its tool", async () => {
const { agent, events, api } = harness();
await agent.client();
update(agent, { sessionUpdate: "subagent_update", sessionId: "child", title: "Worker" });
update(
agent,
{
sessionUpdate: "config_option_update",
configOptions: [{ id: "m", type: "select", category: "model", currentValue: "native-model", options: [] }],
},
"child",
);
update(agent, {
sessionUpdate: "tool_call",
toolCallId: "spawn",
content: [{ type: "session", sessionId: "child" }],
});
assert.equal(agent.subagents.task("child").toolCallId, "spawn");
assert.equal(agent.subagents.task("child").model, "native-model");
const peer = present(api.peers[0]);
peer.send({
jsonrpc: "2.0",
id: "child-permission",
method: "session/request_permission",
params: {
sessionId: "child",
toolCall: { toolCallId: "read", title: "Read" },
options: [{ optionId: "yes", kind: "allow_once", name: "Allow" }],
},
});
const approval = await next(events, "approval");
assert.equal(approval.sessionId, SESSION);
assert.equal(approval.taskId, "child");
await agent.respondToApproval({ approvalId: approval.id, optionId: "yes" });
assert.deepEqual((await peer.waitFor(replyTo("child-permission"))).result, {
outcome: { outcome: "selected", optionId: "yes" },
});
});
test("permission-mode aliases route native mode config through its config setter", async () => {
const { agent, api } = harness("antigravity-acp", {
peer: provider(
{},
{
"session/set_config_option": (params) => ({ configOptions: [{ ...mode, currentValue: params.value }] }),
},
),
});
await agent.createSession({ workspace: "/w", options: { permission_mode: "full" } });
const peer = present(api.peers[0]);
assert.ok(
peer.received.some(
(message) => message.method === "session/set_config_option" && message.params.configId === "mode",
),
);
assert.equal(
peer.received.some((message) => message.method === "session/set_mode"),
false,
);
});
test("v1 startup titles and notices wait until the host session is addressable", async () => {
const { agent, events } = harness("test", {
peer: provider(
{},
{
"session/new": (_params, _message, peer) => {
for (const update of [
{ sessionUpdate: "session_info_update", title: "Startup title" },
{ sessionUpdate: "notice", severity: "warning", title: "Startup notice" },
])
peer.send({ jsonrpc: "2.0", method: "session/update", params: { sessionId: "native", update } });
return { sessionId: "native" };
},
},
),
});
await agent.createSession({ workspace: "/w" });
assert.equal((await next(events, "session_info")).title, "Startup title");
assert.equal((await next(events, "notice")).message, "Startup notice");
});
test("an advertised auth-status failure is visible and retires the unusable connection", async () => {
const { agent, api } = harness("test", {
peer: provider(
{ auth: { status: {} } },
{
"auth/status": (_params, message, peer) => {
peer.send({ jsonrpc: "2.0", id: message.id, error: { code: -32603, message: "Status failed." } });
},
},
),
});
assert.equal((await agent.initialize()).status?.state, "unavailable");
assert.equal(agent.proc, null);
assert.ok(present(api.peers[0]).stdinClosed);
});
test("client file writes report parent-creation failures without attempting the write", async () => {
const { agent, api } = harness();
let writes = 0;
api.fs.mkdir = async () => {
throw new Error("Parent creation failed.");
};
api.fs.write = async () => {
writes++;
};
await agent.client();
const peer = present(api.peers[0]);
peer.send({
jsonrpc: "2.0",
id: "write",
method: "fs/write_text_file",
params: { sessionId: SESSION, path: "/w/new/file", content: "x" },
});
assert.match(responseError(await peer.waitFor(replyTo("write"))).message, /Parent creation failed/);
assert.equal(writes, 0);
});
test("reattaching a live native-system session keeps instructions out of user prompts and updates them through resume", async () => {
const { agent, api, events } = harness("test", {
peer: provider(
{ sessionCapabilities: { systemPrompt: {}, resume: {} } },
{
"session/resume": () => ({}),
"session/prompt": () => ({ stopReason: "end_turn" }),
},
),
});
const { sessionId } = await agent.createSession({ workspace: "/w", instructions: "Original rules." });
await agent.resumeSession({ sessionId, workspace: "/w", instructions: "Original rules." });
await agent.resumeSession({ sessionId, workspace: "/w", instructions: "Updated rules." });
await agent.prompt({ sessionId, input: { blocks: [{ type: "text", text: "Go." }] } });
await next(events, "run_finished");
const peer = present(api.peers[0]);
assert.equal(peer.received.filter((message) => message.method === "session/resume").length, 1);
assert.deepEqual(peer.received.find((message) => message.method === "session/resume")?.params.systemPrompt, {
mode: "append",
content: [{ type: "text", text: "Updated rules." }],
});
assert.deepEqual(peer.received.find((message) => message.method === "session/prompt")?.params.prompt, [
{ type: "text", text: "Go." },
]);
});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.