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.2
Permissions in 0.1.2
Files
reads.ts4.7 KB
// The listing page's reads beyond the listing itself: its pictures, kept by
// the host and drawn from its cache, and its overview, read from the
// release. Each is asked for once; the views run the effects these return
// with `ctx.run`, as `settingsOf` in the controller does.
import * as Effect from "effect/Effect";
import { Host, Plugin, parse, promise } from "divergence/effect";
import type { PluginServices } from "divergence/effect";
import { MarketState } from "./state.ts";
import { additions, messageOf } from "./logic.ts";
import { manifestAddsSchema, mediaPathSchema, releaseFileSchema, releaseSchema } from "./remote.ts";
import type { Listing, ListingMedia } from "./remote.ts";
export const listingReads = Effect.fn("Market.listingReads")(function* (redraw: () => void) {
const state = yield* MarketState;
const host = yield* Host;
const plugin = yield* Plugin;
// A listing picture as a file the kernel draws, once `host/market.media`
// kept it; each picture is asked for once per activation.
const mediaOf = (
media: ListingMedia,
id: string,
): { path: string | null; error: string | null; fetch: Effect.Effect<void, unknown, PluginServices> | null } => {
const known = state.media[media.sha256];
if (known === "loading") return { path: null, error: null, fetch: null };
if (known) return "path" in known ? { path: known.path, error: null, fetch: null } : { path: null, error: known.error, fetch: null };
state.media = { ...state.media, [media.sha256]: "loading" };
const fetch = host
.call("host/market.media", { id, version: media.version, path: media.path, sha256: media.sha256 })
.pipe(
Effect.flatMap((raw) => parse("picture", mediaPathSchema, raw)),
Effect.map(({ path }): { path: string } | { error: string } => ({ path })),
Effect.catch((error) => Effect.succeed({ error: messageOf(error) })),
Effect.tap((answer) =>
Effect.sync(() => {
state.media = { ...state.media, [media.sha256]: answer };
redraw();
}),
),
Effect.asVoid,
);
return { path: null, error: null, fetch };
};
// The listing's overview: its README and what its plugin.json adds, read
// from the chosen version's verified package (the host keeps the package,
// so the Files tab reads it again at once). Read once per id and version.
const overviewOf = (listing: Listing, permissions: unknown): Effect.Effect<void, unknown, PluginServices> | null => {
const { listingId: id, version } = state;
if (!id || !version) return null;
const key = `${id}@${version}`;
if (state.overview?.key === key) return null;
state.overview = { key, kind: "loading" };
return Effect.gen(function* () {
const read = (path?: string) => host.call("host/market.read", { id, version, ...(path ? { path } : {}) });
const release = yield* read().pipe(Effect.flatMap((raw) => parse("release", releaseSchema, raw)));
const files = release.files ?? [];
const readmePath = listing.listing?.readme ?? files.find((file) => /^readme\.md$/i.test(file.path))?.path ?? null;
const [readme, manifest] = yield* Effect.all(
[
readmePath
? read(readmePath).pipe(Effect.flatMap((raw) => parse("README", releaseFileSchema, raw)))
: Effect.succeed(null),
read("plugin.json").pipe(
Effect.flatMap((raw) => parse("plugin.json", releaseFileSchema, raw)),
Effect.flatMap((file) => Effect.try({ try: () => JSON.parse(file.text ?? "{}") as unknown, catch: (error) => error })),
Effect.map((json) => {
const parsed = manifestAddsSchema.safeParse(json);
return parsed.success ? parsed.data : null;
}),
),
],
{ concurrency: 2 },
);
return {
kind: "ready" as const,
readme: readme && !readme.binary ? (readme.text ?? "") : null,
readmeTruncated: readme?.truncated ?? false,
adds: additions(manifest, permissions),
files: files.length,
bytes: files.reduce((sum, file) => sum + (file.size ?? 0), 0),
};
}).pipe(
Effect.catch((error) => Effect.succeed({ kind: "failed" as const, error: messageOf(error) })),
Effect.tap((overview) =>
Effect.sync(() => {
if (state.overview?.key !== key) return;
state.overview = { key, ...overview };
redraw();
}),
),
Effect.asVoid,
);
};
const chooseShot = (shot: number): void => {
state.shot = shot;
redraw();
};
const openLink = Effect.fn("Market.openLink")(function* (url: string) {
yield* promise("openUrl", () => plugin.api.openUrl(url));
});
return { mediaOf, overviewOf, chooseShot, openLink };
});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.