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
wire.ts11.4 KB
// The CLI fields used by streams, stored records and workflow snapshots.
// Loose objects preserve fields passed back to Claude without interpreting them.
import * as z from "zod";
const text = z.string().nullish();
const number = z.number().nullish();
const boolean = z.boolean().nullish();
export const object = z.record(z.string(), z.unknown());
export const toolInput = z.looseObject({
to: text,
subagent_type: text,
prompt: text,
description: text,
run_in_background: boolean,
offset: number,
edits: z.array(object).nullish(),
todos: z.array(z.looseObject({ content: text, activeForm: text, status: text })).nullish(),
questions: z
.array(
z.looseObject({
question: text,
header: text,
multiSelect: boolean,
options: z.array(z.looseObject({ label: text, description: text })).nullish(),
}),
)
.nullish(),
});
export const block = z.looseObject({
type: text,
id: text,
name: text,
text: text,
thinking: text,
input: toolInput.nullish(),
tool_use_id: text,
is_error: boolean,
content: z.unknown().optional(),
});
const content = z.union([z.string(), z.array(block)]).nullish();
export const usage = z.looseObject({
total_tokens: number,
input_tokens: number,
cache_read_input_tokens: number,
cache_creation_input_tokens: number,
output_tokens: number,
tool_uses: number,
output_tokens_details: z.object({ thinking_tokens: number }).nullish(),
});
export const progress = z.looseObject({
type: text,
index: number,
title: text,
label: text,
agentId: text,
model: text,
state: text,
startedAt: number,
lastProgressAt: number,
durationMs: number,
lastToolName: text,
lastToolSummary: text,
error: text,
resultPreview: text,
agentType: text,
promptPreview: text,
tokens: number,
toolCalls: number,
phaseTitle: text,
});
/// What a subagent handed back through the CLI's `SubagentHandback` tool:
/// its whole report, and the warning auto mode put above it when it
/// flagged the report.
export const handbackReport = z.looseObject({ text: text, warning: text });
export const structured = z.looseObject({
taskType: text,
taskId: text,
runId: text,
workflowName: text,
summary: text,
transcriptDir: text,
agentId: text,
isAsync: boolean,
status: text,
content: z.unknown().optional(),
totalTokens: number,
totalToolCalls: number,
totalToolUseCount: number,
handbackReport: handbackReport.nullish(),
});
const nativeResult = z.union([structured, z.array(z.unknown()), z.string()]).nullish();
/// Who a message the CLI took in came from. A message from another
/// session (`peer`) names it and carries the message as it was sent; a
/// subagent's hand-back is a `peer` message too, with `senderTaskId`, and
/// its report alone in `handbackReportText`.
export const origin = z.looseObject({
kind: text,
from: text,
name: text,
body: text,
senderTaskId: text,
runId: text,
handbackReportText: text,
});
export const command = z.looseObject({ name: text, description: text, argumentHint: text });
export const record = z.looseObject({
type: text,
subtype: text,
uuid: text,
command_uuid: text,
new_conversation_id: text,
claude_code_version: text,
capabilities: z.array(z.string()).nullish(),
supersedes: z.array(z.string()).nullish(),
supersedesUuids: z.array(z.string()).nullish(),
retracted_message_uuids: z.array(z.string()).nullish(),
retractedWireUuids: z.array(z.string()).nullish(),
retractedMessageUuids: z.array(z.string()).nullish(),
commands: z.array(command).nullish(),
mcp_server_name: text,
elicitation_id: text,
error_code: text,
lost: z.array(z.string()).nullish(),
transcript_session_ids: z.array(z.string()).nullish(),
run_id: text,
user_message_uuid: text,
user_message_uuids: z.array(z.string()).nullish(),
num_turns: number,
request_sent_wall_ms: number,
/// The local command (`compact`) a `result` ended, which takes no turn.
local_command: text,
error: text,
parentUuid: text,
/// The record a compaction followed; its own `parentUuid` is null.
logicalParentUuid: text,
/// Set on the records of an agent team's member, which a resume skips.
teamName: text,
timestamp: text,
customTitle: text,
aiTitle: text,
isSidechain: boolean,
parent_tool_use_id: text,
task_id: text,
tool_use_id: text,
task_type: text,
description: text,
subagent_type: text,
prompt: text,
is_backgrounded: boolean,
workflow_name: text,
summary: text,
last_tool_name: text,
status: text,
output_file: text,
handback_report: handbackReport.nullish(),
agent_id: text,
tool_name: text,
state: text,
usage: usage.nullish(),
modelUsage: z.record(z.string(), z.looseObject({ contextWindow: number, thinkingTokens: number })).nullish(),
total_cost_usd: number,
is_error: boolean,
errors: z.array(z.unknown()).nullish(),
result: z.unknown().optional(),
message: z.looseObject({ id: text, model: text, role: text, content, usage: usage.nullish() }).nullish(),
// MCP results retain their content arrays and native metadata.
tool_use_result: nativeResult,
toolUseResult: nativeResult,
mcpMeta: object.nullish(),
origin: origin.nullish(),
// A queued command's prompt is its text or, with images, its blocks.
attachment: z
.looseObject({ type: text, commandMode: text, prompt: z.unknown().optional(), source_uuid: text })
.nullish(),
isMeta: boolean,
operation: text,
content: z.unknown().optional(),
workflow_progress: z.array(progress).nullish(),
patch: z.looseObject({ status: text, is_backgrounded: boolean, error: text }).nullish(),
compact_result: text,
compact_error: text,
isCompactSummary: boolean,
level: text,
compact_metadata: z.unknown().optional(),
event: z
.looseObject({
type: text,
index: number,
message: z.object({ id: text, model: text }).nullish(),
content_block: block.nullish(),
delta: z.object({ type: text, text: text, thinking: text, partial_json: text }).nullish(),
})
.nullish(),
request_id: text,
request: z
.looseObject({
subtype: text,
server_name: text,
message: z.unknown().optional(),
tool_name: text,
tool_use_id: text,
input: toolInput.nullish(),
title: text,
display_name: text,
agent_id: text,
permission_suggestions: z.unknown().optional(),
suppress_always_allow_rule: boolean,
mcp_server_name: text,
mode: text,
url: text,
elicitation_id: text,
requested_schema: object.nullish(),
property_order: z.array(z.string()).nullish(),
})
.nullish(),
response: z.looseObject({ subtype: text, request_id: text, error: text, response: z.unknown().optional() }).nullish(),
rate_limit_info: z.unknown().optional(),
});
export const workflowOutput = z.looseObject({
result: z.unknown().optional(),
logs: z.array(z.unknown()).nullish(),
phases: z.array(z.object({ title: text })).nullish(),
workflowProgress: z.array(progress).nullish(),
totalTokens: number,
totalToolCalls: number,
startTime: number,
durationMs: number,
status: text,
summary: text,
workflowName: text,
script: text,
error: text,
});
export const metadata = z.looseObject({
toolUseId: text,
model: text,
description: text,
requestShape: text,
agentType: text,
parentAgentId: text,
workflowPhase: text,
});
export const model = z.looseObject({
value: text,
resolvedModel: text,
displayName: text,
supportedEffortLevels: z.array(z.string()).nullish(),
supportsAdaptiveThinking: boolean,
supportsFastMode: boolean,
});
export const catalog = z.looseObject({
capabilities: z.array(z.string()).nullish(),
models: z.array(model).nullish(),
commands: z.array(command).nullish(),
fast_mode_state: text,
fast_mode_disabled_reason: text,
});
export type CatalogResponse = z.infer<typeof catalog>;
export type Record = z.infer<typeof record>;
export type Input = z.infer<typeof toolInput>;
export type Progress = z.infer<typeof progress>;
export type Structured = z.infer<typeof structured>;
export type HandbackReport = z.infer<typeof handbackReport>;
export type Output = z.infer<typeof workflowOutput>;
export type Metadata = z.infer<typeof metadata>;
export type Command = z.infer<typeof command>;
export type Model = z.infer<typeof model>;
export type Origin = z.infer<typeof origin>;
export type ControlRequest = NonNullable<Record["request"]>;
export type StreamEvent = NonNullable<Record["event"]>;
/// Reads one CLI line or stored record. A field in a shape the plugin does
/// not expect is left out, not the whole line: the tool result or the end
/// of a task in the same line still counts. `dropped` names what was left
/// out; `null` is a line that is not an object.
export function readRecord(value: unknown): { record: Record; dropped: string[] } | null {
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
let candidate = value;
const dropped: string[] = [];
// Each round leaves out at least one field, so this ends.
for (;;) {
const parsed = record.safeParse(candidate);
if (parsed.success) return { record: parsed.data, dropped };
if (candidate === value) candidate = structuredClone(value);
const before = dropped.length;
for (const path of issuePaths(parsed.error.issues, [])) {
const left = leaveOut(candidate, path);
if (left !== null) dropped.push(left);
}
if (dropped.length === before) return null;
}
}
/// Where each issue is. For a union, the option that got furthest into the
/// value is the one the value is meant as: a bad block in a content array
/// is that block's field, not the whole content.
function issuePaths(issues: readonly z.core.$ZodIssue[], prefix: PropertyKey[]): PropertyKey[][] {
const paths: PropertyKey[][] = [];
for (const issue of issues) {
const path = [...prefix, ...issue.path];
if (issue.code !== "invalid_union" || issue.errors.length === 0) {
paths.push(path);
continue;
}
const depth = (option: PropertyKey[][]) => Math.max(...option.map((found) => found.length));
const best = issue.errors
.map((option) => issuePaths(option, path))
.reduce((best, option) => (depth(option) > depth(best) ? option : best));
paths.push(...(depth(best) > path.length ? best : [path]));
}
return paths;
}
/// Deletes the deepest object field on `path`; its dotted path, or `null`
/// when there is none left to delete.
function leaveOut(root: object, path: PropertyKey[]) {
let target: { parent: { [key: string]: unknown }; key: string; at: number } | null = null;
let node: unknown = root;
for (let at = 0; at < path.length; at++) {
if (node === null || typeof node !== "object") break;
const key = path[at]!;
if (typeof key === "string" && !Array.isArray(node) && Object.hasOwn(node, key))
target = { parent: node as { [key: string]: unknown }, key, at };
node = (node as { [key: PropertyKey]: unknown })[key];
}
if (target === null) return null;
delete target.parent[target.key];
return path.slice(0, target.at + 1).join(".");
}
export function objectOf(value: unknown) {
const parsed = object.safeParse(value);
return parsed.success ? parsed.data : {};
}
export function inputOf(value: unknown) {
const parsed = toolInput.safeParse(value);
return parsed.success ? parsed.data : {};
}
export function structuredOf(value: unknown): Structured | null {
const parsed = structured.safeParse(value);
return parsed.success ? parsed.data : null;
}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.