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.6
Permissions in 0.2.6
Files
control.ts5.9 KB
// Claude's acknowledged control operations and session metadata updates.
import * as Effect from "effect/Effect";
import type { Session } from "./session.ts";
import {
DEFAULT,
EFFORT,
FAST_MODE,
MODEL,
PERMISSION_MODE,
ULTRACODE,
effortSettings,
permissionFlag,
} from "./options.ts";
import { outcome, permissionMode } from "../sdk/agent.ts";
import * as wire from "./wire.ts";
import { sessionFile } from "./history.ts";
import { capabilitiesFor, refreshAppsLater, supportsApps } from "./mcp.ts";
/// How long a run may take to report a result after an interrupt.
export const CANCEL_TIMEOUT = 10_000;
export const setOption = Effect.fn("Claude.setOption")(function* (this: Session, optionId: string, value: unknown) {
if (this.proc?.alive) {
switch (optionId) {
case MODEL:
yield* this.controlRequest({
subtype: "set_model",
...(typeof value === "string" && value !== DEFAULT ? { model: value } : {}),
});
break;
case EFFORT:
yield* this.controlRequest({
subtype: "apply_flag_settings",
settings: { ...effortSettings(typeof value === "string" ? value : DEFAULT), ultracode: this.ultracode() },
});
break;
case ULTRACODE:
yield* this.controlRequest({ subtype: "apply_flag_settings", settings: { ultracode: value === true } });
break;
case PERMISSION_MODE:
yield* this.controlRequest({
subtype: "set_permission_mode",
mode: permissionFlag(typeof value === "string" ? value : permissionMode.SUPERVISED),
});
break;
case FAST_MODE:
yield* this.controlRequest({ subtype: "apply_flag_settings", settings: { fastMode: value === true } });
break;
}
}
this.values[optionId] = value;
if (this.proc?.alive) {
if (optionId === MODEL) yield* this.readContext().pipe(Effect.forkIn(this.ctx.scope));
if ((optionId === MODEL || optionId === ULTRACODE) && this.ultracode()) yield* this.checkUltracode();
}
return this.options();
});
export const cancel = Effect.fn("Claude.cancel")(function* (this: Session) {
if (!this.run) {
this.stopBeforeRun = true;
return;
}
const runId = this.run;
this.cancelled = true;
for (const id of [...this.pending.keys()])
this.withdraw(id, { behavior: "deny", message: "The user stopped the run." });
// The watchdog starts before the receipt wait so an unresponsive CLI
// cannot keep the run open for the control-request timeout.
yield* Effect.sleep(CANCEL_TIMEOUT).pipe(
Effect.andThen(
Effect.sync(() => {
if (this.cancelled && this.run === runId) {
this.cancelled = false;
this.finishRun(outcome.cancelled());
}
}),
),
Effect.forkIn(this.ctx.scope),
);
const receipt = wire.objectOf(
yield* this.controlRequest({
subtype: "interrupt",
...(this.capabilities === null || this.capabilities.has("interrupt_cancel_queued_v1")
? { cancel_queued: true }
: {}),
}),
);
const cancelled = Array.isArray(receipt.cancelled) ? receipt.cancelled : [];
const survivors = Array.isArray(receipt.still_queued) ? receipt.still_queued : [];
for (const uuid of survivors) {
if (typeof uuid !== "string" || !this.inputs.has(uuid)) continue;
const response = wire.objectOf(yield* this.controlRequest({ subtype: "cancel_async_message", message_uuid: uuid }));
if (response.cancelled === true) cancelled.push(uuid);
else
this.emitEvent({
event: "notice",
level: "warning",
message: "Claude could not withdraw a submitted message after Stop; it may still run.",
});
}
for (const uuid of cancelled) {
const input = typeof uuid === "string" ? this.inputs.get(uuid) : undefined;
if (input) input.answered = true;
}
});
/// Handles native session metadata before transcript mapping or run attribution.
export const sessionUpdate = Effect.fn("Claude.sessionUpdate")(function* (session: Session, message: wire.Record) {
if (message.type === "conversation_reset" && message.new_conversation_id) {
session.cli = message.new_conversation_id;
session.sent = {};
session.rewound = null;
session.startMode = { kind: "resume" };
const path = sessionFile(session.configDir, session.workspace, session.cli);
session.read = path ? { path, offset: 0 } : null;
session.inbox = { offset: 0, heard: new Map(), other: new Set() };
session.replies.clear();
yield* session.ctx.store.save(session.id, { cli: session.cli, sent: {}, rewound: null });
yield* session.ctx.store.keepAlias(session.cli, session.id);
return true;
}
if (message.type !== "system") return false;
switch (message.subtype) {
case "init":
session.capabilities = new Set(message.capabilities ?? []);
if (session.ctx.hostFeatures?.has("mcpApps")) {
yield* capabilitiesFor(session, message.claude_code_version, false);
session.mapper.mcp.enabled = supportsApps(session.capabilities);
yield* refreshAppsLater(session);
}
return false;
case "commands_changed":
if (!message.commands) return true;
session.catalog.commands = message.commands;
session.emitEvent({ event: "commands", commands: session.commands() });
yield* session.refreshSkills();
return true;
case "elicitation_complete":
for (const [id, pending] of session.pending) {
const request = pending.kind === "elicitation" ? pending.request : null;
if (
request?.mode === "url" &&
request.elicitation_id === message.elicitation_id &&
request.mcp_server_name === message.mcp_server_name
) {
session.respondToQuestion(id, {});
session.emitEvent({ event: "question_resolved", id });
}
}
session.emitEvent({
event: "notice",
level: "info",
message: `The browser request from ${message.mcp_server_name} completed.`,
});
return true;
default:
return false;
}
});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.