Official
claude
Claude Code agent provider: runs the Claude Code CLI headless for each account.
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/claude@0.2.7
Permissions in 0.2.7
Files
approvals.ts4.9 KB
// The CLI's permission prompts as the user sees them: a `can_use_tool`
// request becomes an approval card, `AskUserQuestion` a question, and the
// user's choice goes back as the CLI's `control_response` payload.
import * as wire from "./wire.ts";
import type { ApprovalRequest, QuestionRequest } from "./types.ts";
import type { Answer } from "./session.ts";
import { titleOf, toolCall } from "./tools.ts";
/// The answer to a question the user dismissed.
export const DISMISSED = { behavior: "deny", message: "The user dismissed the question." };
/// Maps a `can_use_tool` control request to an approval for the user. The
/// CLI's `display_name` is only the tool's name; what the tool is about to
/// do is more useful on the card, so it comes first.
export function approvalRequest(id: string, request: wire.ControlRequest): ApprovalRequest {
const toolName = typeof request.tool_name === "string" ? request.tool_name : "";
const input = request.input ?? null;
let title = typeof request.title === "string" ? request.title : null;
if (title === null) {
const own = titleOf(toolName, input);
title = own === toolName && typeof request.display_name === "string" ? request.display_name : own;
}
return {
id,
title,
toolCall: toolCall(typeof request.tool_use_id === "string" ? request.tool_use_id : "", toolName, input, "pending"),
options: [
{ id: "allow_once", name: "Allow once", kind: "allow_once" },
...(request.suppress_always_allow_rule === true
? []
: [{ id: "allow_always", name: "Allow always", kind: "allow_always" as const }]),
{ id: "reject", name: "Reject", kind: "reject_once" },
],
};
}
/// The `control_response` payload for one approval option. "Allow always"
/// prefers the rules the CLI suggested and otherwise adds a session rule
/// for the tool.
export function approvalDecision(optionId: string, toolName: string, suggestions: unknown, suppressAlways = false) {
if (optionId === "allow_once") return { behavior: "allow" };
if (optionId === "allow_always" && !suppressAlways) {
const updates = Array.isArray(suggestions)
? suggestions
: [{ type: "addRules", rules: [{ toolName }], behavior: "allow", destination: "session" }];
return { behavior: "allow", updatedPermissions: updates };
}
return { behavior: "deny", message: "The user rejected this tool call." };
}
/// Maps an `AskUserQuestion` input to a question for the user.
export function questionRequest(id: string, raw: unknown): QuestionRequest {
const input = wire.inputOf(raw);
const questions = Array.isArray(input?.questions) ? input.questions : [];
const fields = questions.map((question) => {
const text = typeof question?.question === "string" ? question.question : "";
const options = (Array.isArray(question?.options) ? question.options : []).map((option) => {
const label = typeof option?.label === "string" ? option.label : "";
const out: { value: string; label: string; description?: string } = { value: label, label };
if (typeof option?.description === "string") out.description = option.description;
return out;
});
const field: import("divergence/protocol").QuestionField = {
id: text,
label: typeof question?.header === "string" ? question.header : text,
description: text,
kind: question?.multiSelect === true ? "multi_select" : "select",
allowOther: true,
required: false,
};
if (options.length) field.options = options;
return field;
});
return { responseMode: "tool", id, fields };
}
/// Writes the user's answers back into the `AskUserQuestion` input. The
/// CLI validates `updatedInput` against the tool's schema and reads the
/// answers from an `answers` map keyed by the question text; free text
/// that answers no listed question goes into `response`.
export function answeredInput(raw: unknown, answer: Answer) {
const input = wire.inputOf(raw);
const updated: wire.Input & { answers?: Record<string, unknown>; response?: string } =
input && typeof input === "object" && !Array.isArray(input) ? { ...input } : {};
const values = answer?.values ?? {};
const questions = Array.isArray(input?.questions) ? input.questions : [];
const answers: Record<string, unknown> = {};
for (const question of questions) {
const text = question?.question;
if (typeof text !== "string" || !Object.hasOwn(values, text)) continue;
const value = values[text];
if (typeof value === "string") answers[text] = value;
else if (Array.isArray(value)) answers[text] = value;
else if (typeof value === "boolean") answers[text] = String(value);
}
const free = [];
for (const [key, value] of Object.entries(values)) {
if (!questions.some((question) => question?.question === key) && typeof value === "string") free.push(value);
}
updated.answers = answers;
if (free.length) updated.response = free.join("\n");
return updated;
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.7latest | Nov 21, 2026 | >=5 <6 | 207.5 KB | 4 permissions | Listed |
| 0.2.6 | Nov 16, 2026 | >=5 <6 | 206 KB | 4 permissions | Listed |
| 0.2.5 | Nov 11, 2026 | >=5 <6 | 168.3 KB | 4 permissions | Listed |
| 0.2.4 | Nov 9, 2026 | >=5 <6 | 166.1 KB | 4 permissions | Listed |
| 0.2.3 | Oct 27, 2026 | >=2 <4 | 151.6 KB | 4 permissions | Listed |
No comments yet.