Official

settings

Built-in settings 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/settings@0.2.3

Permissions in 0.2.3

  • Manage plugins plugins.manageOfficial onlyReloads and enables plugins. Only official plugins can have it.List, enable, disable and reload plugins, install updates, and quit to finish an update
  • Change app settings settings.writeHighChanges the app settings.Change the settings and the theme
  • Manage agents agents.manageHighEnables, disables and signs in agents, and changes their settings.Turn agents on and off, sign in to them and update them
  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Import an agent's own sessions as chats
  • Read chats chats.readMediumReads your transcripts and chat lists.List the workspaces an agent's sessions can be imported into, and hold an agent's update until its chats stop running
  • Read app settings settings.readLowReads the app settings.Show the settings, and the tools and rules of every plugin
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw settings and the return-to-onboarding buttonSlots: centertitle

Files

chat-import.ts4.2 KB
// Automatic imports belong to the settings plugin, not the host. Reconcile
// ready agent/project pairs at startup and on changes, never on a timer.
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as z from "zod";
import { Host, Notify, Plugin, Settings, promise } from "divergence/effect";
import type { ViewHandle } from "divergence";

const makeChatImport = Effect.fn("ChatImport.make")(function* () {
  const host = yield* Host;
  const settings = yield* Settings;
  const notify = yield* Notify;
  const plugin = yield* Plugin;
  const state = { enabled: false, running: false, imported: 0, errors: [] as string[] };
  const views: ViewHandle[] = [];
  const redraw = () => {
    for (const view of views) view.update();
  };
  const attempted = new Set<string>();
  let again = false;
  let retry = false;
  const refresh = Effect.fn("ChatImport.refresh")(function* (force = false) {
    retry ||= force;
    if (state.running) {
      again = true;
      return;
    }
    state.running = true;
    redraw();
    yield* Effect.gen(function* () {
      do {
        again = false;
        state.enabled = (yield* settings.get("autoImportChats", z.boolean().nullable())) === true;
        if (retry || !state.enabled) {
          attempted.clear();
          state.errors = [];
          retry = false;
        }
        redraw();
        if (!state.enabled) continue;
        const [agents, workspaces] = yield* Effect.all(
          [host.call("host/agents.all", {}), host.call("host/workspaces.list", {})],
          { concurrency: "unbounded" },
        );
        const pairs = workspaces.workspaces
          .filter((w) => w.mark !== "puzzle")
          .flatMap((workspace) =>
            agents.agents
              .filter((a) => a.enabled && a.status?.state === "ready" && a.capabilities?.sessionList)
              .map((agent) => ({ workspace, agent, key: JSON.stringify([workspace.id, workspace.path, agent.id]) })),
          );
        const eligible = new Set(pairs.map((p) => p.key));
        for (const key of attempted) if (!eligible.has(key)) attempted.delete(key);
        for (const { workspace, agent, key } of pairs) {
          // A toggle or agent/workspace change during a slow import must
          // be reconciled before admitting another pair from this snapshot.
          if (again || !state.enabled) break;
          if (attempted.has(key)) continue;
          attempted.add(key);
          yield* host.call("host/chats.import", { workspaceId: workspace.id, agentId: agent.id }).pipe(
            Effect.tap((result) =>
              Effect.sync(() => {
                state.imported += result.imported;
              }),
            ),
            Effect.catch((error) =>
              Effect.gen(function* () {
                const message = `Could not import ${agent.name} chats into ${workspace.name}: ${error.message}`;
                state.errors.push(message);
                yield* notify.error(message);
              }),
            ),
          );
          redraw();
        }
      } while (again);
    }).pipe(
      Effect.catch((error) =>
        Effect.gen(function* () {
          state.errors = [error.message];
          yield* notify.error(`Could not refresh automatic chat imports: ${error.message}`);
        }),
      ),
      Effect.ensuring(
        Effect.sync(() => {
          state.running = false;
          redraw();
        }),
      ),
    );
  });
  const setEnabled = Effect.fn("ChatImport.setEnabled")(function* (enabled: boolean) {
    yield* promise("settings.set", () => plugin.api.settings.set("autoImportChats", enabled)).pipe(
      Effect.tap(() =>
        Effect.sync(() => {
          state.enabled = enabled;
          redraw();
        }),
      ),
      Effect.andThen(refresh()),
      Effect.catch((error) => notify.error(`Could not change automatic chat import: ${error.message}`)),
    );
  });
  return { state, views, refresh, setEnabled, retry: () => refresh(true) };
});

export class ChatImport extends Context.Service<ChatImport, Effect.Success<ReturnType<typeof makeChatImport>>>()(
  "settings/ChatImport",
) {
  static readonly layer = Layer.effect(ChatImport, makeChatImport());
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.8latestNov 21, 2026>=5 <668.5 KB7 permissionsListed
0.2.7Nov 18, 2026>=5 <668 KB7 permissionsListed
0.2.6Nov 16, 2026>=5 <666.3 KB7 permissionsListed
0.2.5Nov 11, 2026>=5 <663.6 KB7 permissionsListed
0.2.4Nov 9, 2026>=5 <661.6 KB7 permissionsListed
0.2.3Oct 27, 2026>=2 <446.8 KB7 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.