Official
chat
Built-in chat UI (JavaScript UI plugin).
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/chat@0.2.5
Permissions in 0.2.5
Files
composition.ts3.5 KB
// Capture a complete structured composition before acknowledging or clearing it.
// Reading one attachment fails the submission, never silently sends a subset.
import * as Effect from "effect/Effect";
import type { Chat, ContentBlock, InputComposition } from "divergence";
import type { Controller } from "./controller.ts";
import type { Prompt } from "./state.ts";
import { mentionInstructions, tagTokens } from "./mentions.ts";
let sequence = 0;
export const inputId = () => `chat:${Date.now()}:${++sequence}:${Math.random().toString(36).slice(2)}`;
export function steeringReason(c: Controller, chat: Chat): string | undefined {
if (!c.isRunning(chat)) return;
if (c.scheduler.available === false) return "Active steering needs an updated app; Queue retains the prompt";
const capabilities = c.state.agents[chat.agentId]?.capabilities;
if (!capabilities?.steer && !capabilities?.simulatedSteer)
return "This agent does not support active steering; use Queue or Stop";
}
// Legacy drafts use only the established first-text editable convention. No
// later block is classified by its contents; explicit provenance is the owner.
export function editableComposition(value: { blocks: readonly ContentBlock[]; composition?: InputComposition }) {
if (value.composition) {
const generated = new Set(value.composition.generated);
return { text: value.composition.text, carriedBlocks: value.blocks.filter((_, index) => !generated.has(index)) };
}
const first = value.blocks[0];
return {
text: first?.type === "text" ? first.text : "",
carriedBlocks: first?.type === "text" ? value.blocks.slice(1) : value.blocks,
};
}
export const compositionFor = Effect.fn("Chat.compositionFor")(function* (
c: Controller,
chatId: string,
editableText: string,
attachments: Prompt["attachments"],
carried: readonly ContentBlock[] = c.composer(chatId).carriedBlocks ?? [],
expand = true,
) {
const composer = c.composer(chatId);
const blocks: ContentBlock[] = [];
const text = expand ? editableText.trim() : editableText;
const [name = "", ...rest] = text.slice(1).split(/\s+/);
if (expand && text.startsWith("$") && composer.skills.some((skill) => skill.name === name))
blocks.push({ type: "skill", name, input: rest.join(" ") });
else if (text) blocks.push({ type: "text", text });
const mentions = c.api.mentions.list(),
tags = tagTokens(text, mentions);
for (const token of text.split(/\s+/)) {
if (tags.has(token)) continue;
if (token.startsWith("@") && token.length > 1 && /[./]/.test(token))
blocks.push({ type: "file_ref", path: token.slice(1).replace(/[,.;:]+$/, "") });
}
const instructions = expand ? mentionInstructions(text, mentions) : undefined;
if (instructions) blocks.push({ type: "text", text: instructions });
const composition: InputComposition = { text: editableText, generated: blocks.map((_, index) => index) };
for (const image of attachments) {
const { mimeType, data } = yield* c.kernel.call("image_data", { id: image.id });
blocks.push({ type: "image", mimeType, data });
}
blocks.push(...carried);
return { blocks, composition };
});
export const blocksFor = Effect.fn("Chat.blocksFor")((...args: Parameters<typeof compositionFor>) =>
compositionFor(...args).pipe(Effect.map((value) => value.blocks)),
);
export function amendedInput(snapshot: import("divergence").InputSnapshot, id: string) {
return (
snapshot.inputs.find((input) => input.id === id) ??
snapshot.inputs.filter((input) => input.intent === "steer" && input.state === "held").at(-1)
);
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.