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
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
| 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.