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.6
Permissions in 0.1.6
Files
main.ts5 KB
// The marketplace (divergence/market, MARKETPLACE.md §10.3): browse and
// search, a listing page with its files, permissions and comments, Install
// through a scan chat in the Plugins workspace, update notices, sign-in, and
// the tools agents in the Plugins workspace use.
//
// Nothing here enables, publishes or reports by itself. Those are native
// cards the app draws (the enable card, the publish row, the report card,
// the bug report's send card and the attach card); this plugin only asks
// for them.
import * as Effect from "effect/Effect";
import * as Stream from "effect/Stream";
import { App, Commands, Events, Services, Views, runPlugin } from "divergence/effect";
import type { PluginServices } from "divergence/effect";
import { MarketState, PICTURE_ITEM, ROUTE } from "./state.ts";
import { controller } from "./controller.ts";
import { registerMarketTools } from "./tools.ts";
import { Market } from "./contract.ts";
import { messageOf, offeredUpdates } from "./logic.ts";
import { ACCOUNT_ITEM, LEGACY_FOOTER_ITEM, SIDEBAR_ITEM, renderAccountItem, renderCenter, renderPicture, renderSidebarItem } from "./views.tsx";
export { ROUTE };
const follow = <E>(stream: Stream.Stream<E>, handle: (event: E) => Effect.Effect<void, unknown, PluginServices>) =>
stream.pipe(Stream.mapEffect(handle, { concurrency: "unbounded" }), Stream.runDrain, Effect.forkScoped);
const program = Effect.gen(function* () {
const market = yield* controller();
const views = yield* Views;
market.state.views.push(yield* views.add("center", { slot: "center", render: (ctx) => renderCenter(ctx, market), on: ["app_state"] }));
// The Marketplace row above Settings in the sidebar: a view of our own,
// which the sidebar draws by the id published under SIDEBAR_ITEM.
const item = yield* views.add("sidebar-item", { slot: "sidebar-item", render: (ctx) => renderSidebarItem(ctx, market), on: ["app_state"] });
market.state.views.push(item);
// The account row at the top of that menu, and the picture in the circle
// that opens it, which the account publishes while it has one.
const account = yield* views.add("sidebar-account", { slot: "sidebar-item", render: (ctx) => renderAccountItem(ctx, market) });
const picture = yield* views.add("sidebar-picture", { slot: "sidebar-item", render: () => renderPicture(market) });
market.state.views.push(account, picture);
market.state.pictureView = picture.id;
const app = yield* App;
yield* Effect.acquireRelease(app.update({ shared: { [SIDEBAR_ITEM]: item.id, [ACCOUNT_ITEM]: account.id, [LEGACY_FOOTER_ITEM]: null } }), () =>
app.update({ shared: { [SIDEBAR_ITEM]: null, [ACCOUNT_ITEM]: null, [PICTURE_ITEM]: null } }),
);
const commands = yield* Commands;
yield* commands.register("market.open", app.route(ROUTE));
// "Report a bug" (§14.1): the palette lists it; Settings and the Help
// menu reach the same form through `host/market.open_bug_form`.
yield* commands.register("market.reportBug", market.openBugForm());
yield* registerMarketTools();
const events = yield* Events;
yield* follow(events.stream("market_bug_form"), market.onBugForm);
yield* follow(events.stream("market_bug_report"), market.onBugReport);
yield* follow(events.stream("security_resolved"), (event) =>
Effect.sync(() => market.onSecurityResolved(event.id, event.outcome)),
);
yield* follow(events.stream("market_changed"), (event) => Effect.sync(() => market.onMarketChanged(event.updates)));
yield* follow(events.stream("market_account"), market.onMarketAccount);
// A listing installed, enabled or removed: its Install row changes.
yield* follow(events.stream("plugins_changed"), () => market.refreshListing());
yield* follow(events.stream("access_changed"), () => market.refreshListing());
// An agent turned on, off or signed in: the agent menus change.
yield* follow(events.stream("agents_changed"), () => market.refreshMenus());
yield* follow(app.changes, market.followApp);
yield* Effect.forkScoped(market.loadUpdates(), { startImmediately: true });
yield* Effect.forkScoped(market.loadAccount(), { startImmediately: true });
yield* market.followApp(yield* app.state);
// The update button at the foot of the sidebar lists these updates and
// runs Update for them. Providing goes last: it waits for the host.
const services = yield* Services;
const handle = yield* services.provide(Market, {
updates: () => Effect.succeed(offeredUpdates(market.state.updates)),
check: () =>
market.readUpdates(true).pipe(
Effect.map(offeredUpdates),
Effect.mapError((error) => ({ _tag: "CheckFailed" as const, message: messageOf(error) })),
),
update: ({ folder }) =>
market.updateNow({ folder, id: market.state.updates.find((update) => update.folder === folder)?.id ?? folder }).pipe(
Effect.as({}),
Effect.mapError((error) => ({ _tag: "UpdateFailed" as const, message: messageOf(error) })),
),
});
market.updateWatchers.push((updates) => handle.emit("updatesChanged", offeredUpdates(updates)));
});
export default runPlugin(MarketState.layer, program);Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.1.6latest | Nov 21, 2026 | >=5 <6 | 71.9 KB | 6 permissions | Listed |
| 0.1.5 | Nov 18, 2026 | >=5 <6 | 71.4 KB | 6 permissions | Listed |
| 0.1.4 | Nov 16, 2026 | >=5 <6 | 70.5 KB | 6 permissions | Listed |
| 0.1.3 | Nov 11, 2026 | >=5 <6 | 62.7 KB | 6 permissions | Listed |
| 0.1.2 | Nov 9, 2026 | >=5 <6 | 57.5 KB | 6 permissions | Listed |
| 0.1.1 | Oct 27, 2026 | >=2 <4 | 46.2 KB | 6 permissions | Listed |
No comments yet.