Official

market

The plugin marketplace: browse, install through an agent's scan, update and publish plugins, and the marketplace tools of agents in the Plugins workspace.

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/market@0.1.3

Permissions in 0.1.3

  • Marketplace marketOfficial onlyUses the marketplace APIs. Only official plugins can have it.Search, read, install, update and publish marketplace plugins, and sign in to the marketplace
  • Manage plugins plugins.manageOfficial onlyReloads and enables plugins. Only official plugins can have it.Ask for the enable card of a plugin an agent installed
  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Open the chat in the Plugins workspace where an agent scans, installs or updates a plugin
  • Provide agent tools tools.provideMediumGives tools to agents.Give agents in the Plugins workspace the marketplace tools
  • Read chats chats.readMediumReads your transcripts and chat lists.Find the agent, model and effort last used in the Plugins workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Show the marketplace pageSlots: center

Files

account.ts4 KB
// The marketplace account in the page's header: reading it, the device
// sign-in with its code, cancelling it, and signing out.
import * as Effect from "effect/Effect";
import { Host, Notify, Plugin, parse, promise } from "divergence/effect";
import type { HostError, PluginServices } from "divergence/effect";
import { MarketState } from "./state.ts";
import { messageOf } from "./logic.ts";
import { accountSchema, loginSchema } from "./remote.ts";

// A host that does not know a method answers with JSON-RPC's
// method-not-found code, or, before it had one for host methods, with an
// error that names the method as unknown.
const unknownMethod = (error: HostError): boolean =>
  error._tag === "HostCallFailed" && (error.code === -32601 || error.message.startsWith("unknown host method"));

export const accountActions = Effect.fn("Market.accountActions")(function* (
  redraw: () => void,
  fail: (what: string, error: unknown) => Effect.Effect<void>,
  busy: (
    key: string,
    work: Effect.Effect<unknown, unknown, PluginServices>,
  ) => Effect.Effect<void, unknown, PluginServices>,
) {
  const state = yield* MarketState;
  const host = yield* Host;
  const notify = yield* Notify;
  const plugin = yield* Plugin;

  const loadAccount = Effect.fn("Market.loadAccount")(function* () {
    yield* host.call("host/market.whoami", {}).pipe(
      Effect.flatMap((raw) => parse("account", accountSchema, raw)),
      Effect.tap((account) =>
        Effect.sync(() => {
          state.account = account;
        }),
      ),
      Effect.catch((error) =>
        Effect.sync(() => {
          state.account = { signedIn: false as const, error: messageOf(error) };
        }),
      ),
    );
    redraw();
    return state.account;
  });

  const registry = Effect.fn("Market.registry")(function* () {
    return (state.account ?? (yield* loadAccount()))?.registry;
  });

  const signIn = Effect.fn("Market.signIn")(function* () {
    yield* busy(
      "sign-in",
      host.call("host/market.login", {}).pipe(
        Effect.flatMap((raw) => parse("sign-in", loginSchema, raw)),
        Effect.tap((code) =>
          Effect.sync(() => {
            state.signIn = { code: code.userCode, url: code.verificationUriComplete ?? code.verificationUri };
          }),
        ),
        Effect.catch((error) => fail("Could not start the sign-in", error)),
      ),
    );
  });

  // The code row's X: the host stops waiting for the code, so a page
  // still open in the browser can no longer sign the app in. An older host
  // has no such call (method not found); its wait ends when the code expires.
  const cancelSignIn = Effect.fn("Market.cancelSignIn")(function* () {
    state.signIn = null;
    redraw();
    yield* host
      .call("host/market.login_cancel", {})
      .pipe(
        Effect.catch((error) => (unknownMethod(error) ? Effect.void : fail("Could not cancel the sign-in", error))),
      );
  });

  const signOut = Effect.fn("Market.signOut")(function* () {
    yield* busy(
      "sign-out",
      Effect.gen(function* () {
        yield* host.call("host/market.logout", {}).pipe(Effect.catch((error) => fail("Could not sign out", error)));
        yield* loadAccount();
      }),
    );
  });

  const openSignInPage = Effect.fn("Market.openSignInPage")(function* () {
    const signInState = state.signIn;
    if (!signInState) return;
    const result = yield* promise("openUrl", () => plugin.api.openUrl(signInState.url));
    if (!result.opened)
      yield* notify.warning(
        `Open ${signInState.url} and enter ${signInState.code}${result.reason ? ` (${result.reason})` : ""}.`,
      );
  });

  const onMarketAccount = Effect.fn("Market.onMarketAccount")(function* (event: {
    readonly signedIn: boolean;
    readonly error?: string;
  }) {
    state.signIn = null;
    if (event.error) yield* notify.error(`Marketplace sign-in: ${event.error}`);
    else if (event.signedIn) yield* notify.info("Signed in to the marketplace.");
    yield* loadAccount();
  });

  return { loadAccount, registry, signIn, cancelSignIn, signOut, openSignInPage, onMarketAccount };
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.1.6latestNov 21, 2026>=5 <671.9 KB6 permissionsListed
0.1.5Nov 18, 2026>=5 <671.4 KB6 permissionsListed
0.1.4Nov 16, 2026>=5 <670.5 KB6 permissionsListed
0.1.3Nov 11, 2026>=5 <662.7 KB6 permissionsListed
0.1.2Nov 9, 2026>=5 <657.5 KB6 permissionsListed
0.1.1Oct 27, 2026>=2 <446.2 KB6 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.