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 convergence/claude@0.2.2
Permissions in 0.2.2
Files
options.test.ts8.4 KB
// Ported from the Rust plugin's options.rs and models.rs tests.
import assert from "node:assert/strict";
import type { ConfigOption } from "./types.ts";
import { required, test } from "./testing.ts";
import {
Catalog,
DEFAULT,
EFFORT,
FAST_MODE,
MODEL,
PERMISSION_MODE,
THINKING,
ULTRACODE,
choiceFor,
effortSettings,
fastModeNote,
permissionFlag,
selected,
} from "./options.ts";
import { permissionMode } from "../sdk/agent.ts";
function catalog() {
return Catalog.fromResponse({
models: [
{
value: "default",
resolvedModel: "claude-opus-5[1m]",
displayName: "Default (recommended)",
description: "Opus 5",
supportsEffort: true,
supportedEffortLevels: ["low", "medium", "high"],
supportsAdaptiveThinking: true,
supportsFastMode: true,
},
{ value: "haiku", resolvedModel: "claude-haiku-4-5", displayName: "Haiku", description: "Fast" },
],
commands: [{ name: "review", description: "Review code", argumentHint: "<path>" }],
current_permission_mode: "auto",
fast_mode_state: "off",
fast_mode_disabled_reason: "sdk_opt_in_required",
});
}
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
/// The CLI's catalog as 2.1.296 answers it: the current model of each
/// family under an alias, then the older models under their own ids.
function cliCatalog() {
return Catalog.fromResponse({
models: [
{ value: "default", resolvedModel: "claude-opus-5-5", displayName: "Default (recommended)", supportedEffortLevels: EFFORTS },
{ value: "opus", resolvedModel: "claude-opus-5-5", displayName: "Opus 5.5", supportedEffortLevels: EFFORTS },
{ value: "fable", resolvedModel: "claude-fable-5-1", displayName: "Fable 5.1", supportedEffortLevels: EFFORTS },
{ value: "sonnet", resolvedModel: "claude-sonnet-5-5", displayName: "Sonnet 5.5", supportedEffortLevels: EFFORTS },
{ value: "haiku", resolvedModel: "claude-haiku-5-5", displayName: "Haiku 5.5", supportedEffortLevels: ["low", "medium", "high"] },
{ value: "claude-haiku-4-5-20251001", resolvedModel: "claude-haiku-4-5-20251001", displayName: "Haiku 4.5" },
{ value: "claude-sonnet-5", resolvedModel: "claude-sonnet-5", displayName: "Sonnet 5", supportedEffortLevels: EFFORTS },
{ value: "claude-opus-4-6", resolvedModel: "claude-opus-4-6", displayName: "Opus 4.6", supportedEffortLevels: ["low", "medium", "high", "max"] },
],
});
}
const option = (options: ConfigOption[], id: string) =>
options.find((option) => option.id === id) ?? assert.fail(`no ${id} option`);
/// The host's `model_reasoning`: a per-model catalog, or null.
function reasoningOf(option: ConfigOption, model: string) {
if (!required(option.choices).some((choice) => (choice.reasoningLevels ?? []).length)) return null;
return required(option.choices).find((choice) => choice.value === model)?.reasoningLevels ?? [];
}
test("the picker offers the current model of each family, by version", () => {
const model = option(cliCatalog().options({}), MODEL);
assert.equal(model.category, "model");
assert.equal(model.value, "claude-opus-5-5", "a new chat starts on the CLI's default");
assert.deepEqual(
required(model.choices).map((choice) => [choice.value, choice.name]),
[
["claude-opus-5-5", "Opus 5.5"],
["claude-fable-5-1", "Fable 5.1"],
["claude-sonnet-5-5", "Sonnet 5.5"],
["claude-haiku-5-5", "Haiku 5.5"],
],
);
});
test("models carry their own effort levels", () => {
const model = option(cliCatalog().options({}), MODEL);
assert.deepEqual(
required(reasoningOf(model, "claude-haiku-5-5")).map((choice) => choice.value),
["low", "medium", "high"],
);
});
test("ultracode is offered where the model has xhigh", () => {
const levels = (catalog: Catalog, model: string) =>
required(reasoningOf(option(catalog.options({}), MODEL), model)).map((choice) => choice.value);
const cli = cliCatalog();
assert.deepEqual(levels(cli, "claude-opus-5-5"), [...EFFORTS, ULTRACODE]);
assert.ok(!levels(cli, "claude-haiku-5-5").includes(ULTRACODE), "no xhigh");
const options = cli.options({});
const ultracode = required(reasoningOf(option(options, MODEL), "claude-opus-5-5")).at(-1);
assert.equal(required(ultracode).name, "Ultracode");
assert.ok(required(ultracode).icon, "the pill shows its mark");
assert.equal(required(ultracode).transient, true, "a new chat must not inherit it");
assert.ok(required(option(options, EFFORT).choices).some((choice) => choice.value === ULTRACODE));
const off = cliCatalog();
off.workflowsOff = true;
assert.ok(!levels(off, "claude-opus-5-5").includes(ULTRACODE), "workflows are off");
});
test("effort choices become flag settings", () => {
assert.deepEqual(effortSettings(ULTRACODE), { effortLevel: "xhigh", ultracode: true });
assert.deepEqual(effortSettings("high"), { effortLevel: "high", ultracode: false });
assert.deepEqual(effortSettings(DEFAULT), { effortLevel: null, ultracode: false });
});
test("stored CLI values and 1M ids select the model they resolve to", () => {
const model = option(cliCatalog().options({}), MODEL);
const chosen = (value: string) => choiceFor(model, value)?.name;
for (const value of ["opus", "default", "claude-opus-5-5", "claude-opus-5-5[1m]"])
assert.equal(chosen(value), "Opus 5.5", value);
assert.equal(chosen("sonnet"), "Sonnet 5.5");
assert.equal(chosen("claude-fable-5-1[1m]"), "Fable 5.1");
});
test("an older CLI's opus[1m] row is the same model, not a second entry", () => {
const catalog = Catalog.fromResponse({
models: [
{ value: "default", resolvedModel: "claude-opus-5-5[1m]", displayName: "Default (recommended)" },
{ value: "opus[1m]", resolvedModel: "claude-opus-5-5[1m]", displayName: "Opus 5.5 (1M context)" },
{ value: "opus", resolvedModel: "claude-opus-5-5", displayName: "Opus 5.5" },
],
});
const model = option(catalog.options({}), MODEL);
assert.deepEqual(required(model.choices).map((choice) => choice.value), ["claude-opus-5-5"]);
assert.equal(choiceFor(model, "opus[1m]")?.value, "claude-opus-5-5");
});
test("chosen values win over catalog defaults", () => {
const values = { [MODEL]: "claude-haiku-4-5", [EFFORT]: "high" };
const options = catalog().options(values);
assert.equal(option(options, MODEL).value, "claude-haiku-4-5");
assert.equal(option(options, EFFORT).value, "high");
assert.equal(selected(values, EFFORT), "high");
assert.equal(selected({ [EFFORT]: "default" }, EFFORT), null);
});
test("slash commands come from the CLI", () => {
assert.deepEqual(catalog().slashCommands(), [
{ name: "review", description: "Review code", source: "agent", inputHint: "<path>" },
]);
});
test("approvals use the shared four modes", () => {
const approvals = option(catalog().options({}), PERMISSION_MODE);
assert.equal(approvals.category, "approval");
assert.deepEqual(
required(approvals.choices).map((choice) => choice.value),
permissionMode.ALL,
"Claude has its own reviewer, so Auto is offered",
);
// The CLI is configured for `auto` here, and a chat still starts
// Supervised.
assert.equal(approvals.value, permissionMode.SUPERVISED);
assert.equal(
option(catalog().options({ [PERMISSION_MODE]: permissionMode.FULL }), PERMISSION_MODE).value,
permissionMode.FULL,
);
assert.equal(permissionFlag(permissionMode.SUPERVISED), "default");
assert.equal(permissionFlag(permissionMode.AUTO_EDITS), "acceptEdits");
assert.equal(permissionFlag(permissionMode.AUTO), "auto");
assert.equal(permissionFlag(permissionMode.FULL), "bypassPermissions");
});
test("toggles appear only when a model supports them", () => {
const options = catalog().options({ [FAST_MODE]: true });
assert.equal(option(options, THINKING).kind, "toggle");
assert.equal(option(options, THINKING).value, true);
assert.equal(option(options, FAST_MODE).value, true);
// The CLI says fast mode waits for a client to opt in, and this toggle
// is that opt in, so nothing is reported as unavailable.
assert.equal(option(options, FAST_MODE).description, undefined);
assert.equal(option(options, FAST_MODE).category, "speed");
assert.equal(fastModeNote("not_first_party"), "Only an Anthropic account can use fast mode.");
const plain = Catalog.fromResponse({ models: [{ value: "haiku", displayName: "Haiku", description: "" }] }).options(
{},
);
assert.ok(!plain.some((option) => option.id === THINKING));
assert.ok(!plain.some((option) => option.id === FAST_MODE));
});
No comments yet.