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
connection.ts5.3 KB
// Version negotiation selects one wire handler for the lifetime of the connection.
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
import * as z from "zod";
import { ProviderError } from "../sdk/errors.ts";
import type { RequestOptions, JsonRpcConnection } from "../sdk/jsonrpc.ts";
import { request } from "../sdk/effect.ts";
import type { TransportError } from "../sdk/effect.ts";
import * as wire from "./wire.ts";
import * as v1 from "./v1.ts";
import type { Quirks } from "./quirks.ts";
import * as v2 from "./v2.ts";
import { defaultsOf } from "./state.ts";
import type { AcpAgentInfo, AcpAuthMethod, AcpDefaults, Capabilities } from "./types.ts";
export type Version = 1 | 2;
export class Connection {
readonly version: Version;
sessionEnabled = true;
authEnabled = true;
readonly subagentsVisible: boolean;
readonly applyUpdate: typeof v1.applyUpdate;
readonly permission: typeof v2.permission;
constructor(version: Version) {
this.version = version;
this.subagentsVisible = version === 2;
this.applyUpdate = version === 1 ? v1.applyUpdate : v2.applyUpdate;
this.permission = version === 1 ? v1.permission : v2.permission;
}
initialize(value: unknown): {
defaults: AcpDefaults;
capabilities: Capabilities;
authMethods: AcpAuthMethod[];
agentInfo: AcpAgentInfo | null;
} {
if (this.version === 2) {
const response = v2.initialize.parse(value);
this.sessionEnabled = response.capabilities?.session != null;
this.authEnabled = !!response.authMethods?.length;
return {
defaults: defaultsOf(null),
capabilities: v2.capabilities(response.capabilities, this.authEnabled),
authMethods: (response.authMethods ?? [])
.filter((method) => method.type === "agent")
.map((method) => ({ ...method, id: method.methodId })),
agentInfo: response.info,
};
}
const response = wire.responses.initialize.parse(value);
const caps = response.agentCapabilities;
return {
defaults: defaultsOf(response._meta),
capabilities: {
...caps,
auth: caps?.auth ?? undefined,
promptCapabilities: caps?.promptCapabilities ?? undefined,
mcpCapabilities: caps?.mcpCapabilities ?? undefined,
sessionCapabilities: caps?.sessionCapabilities ?? undefined,
},
authMethods: response.authMethods ?? [],
agentInfo: response.agentInfo ?? null,
};
}
clientMethod(method: string) {
return this.version === 1 || (!method.startsWith("fs/") && !method.startsWith("terminal/"));
}
startupMetadata(update: wire.Message) {
return this.version === 2 || wire.startupMetadata(update);
}
prepareUpdate(quirks: Quirks, update: wire.Message) {
if (this.version === 2) return v2.readUpdate(update);
quirks.sessionUpdate(update);
return update;
}
clientSchema(method: string) {
return this.version === 2 ? v2.clientSchema(method) : wire.message;
}
initialLists(state: import("./types.ts").SessionState, response: wire.Response<"session/new">) {
if (this.version !== 2) return;
state.config = response.configOptions ?? [];
state.commands = v2.commands(response.availableCommands);
}
mcpServers(values: unknown[], caps: import("./types.ts").Capabilities) {
return this.version === 2 ? v2.mcpServers(values, caps) : [...values];
}
configs(value: unknown) {
return this.version === 2 ? v2.configs(value) : Array.isArray(value) ? value : [];
}
commands(value: unknown) {
return this.version === 2 ? v2.commands(value) : [];
}
configValue(value: unknown) {
return this.version === 2 && typeof value !== "boolean" ? { type: "id", value } : {};
}
load<A, E, R>(answered: Effect.Effect<A, E, R>, quiet: Effect.Effect<A>, late: Effect.Effect<never, E>) {
return Effect.raceFirst(this.version === 1 ? Effect.raceFirst(answered, quiet) : answered, late);
}
request<M extends keyof typeof wire.responses>(
connection: JsonRpcConnection,
method: M,
params?: unknown,
options?: Omit<RequestOptions, "signal">,
): Effect.Effect<wire.Response<M>, TransportError | ProviderError> {
if (!this.sessionEnabled && method.startsWith("session/"))
return Effect.fail(new ProviderError({ message: "This agent does not advertise session support." }));
if (!this.authEnabled && (method === "authenticate" || method === "logout"))
return Effect.fail(new ProviderError({ message: "This agent does not advertise authentication methods." }));
const shape = this.version === 2 ? v2.requestShape(method, params) : { method, params };
const schema = this.version === 2 ? v2.responseSchema(method) : wire.responses[method];
return request<wire.Response<M>>(connection, shape.method, schema, shape.params, options);
}
turn<E, R>(
requested: Effect.Effect<wire.Response<"session/prompt">, E, R>,
completed: Fiber.Fiber<wire.Response<"session/prompt">, never>,
accepted: (messageId: string) => void,
) {
if (this.version === 1) return Effect.raceFirst(requested, Fiber.join(completed));
return Effect.gen(function* () {
const response = yield* requested;
accepted(response.messageId!);
return yield* Fiber.join(completed);
});
}
}
export const negotiation = z.looseObject({ protocolVersion: z.union([z.literal(1), z.literal(2)]) });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.