Skip to content
Written for developers. Just using FluxPlugs? Go to the user guide.

Runtime, sandbox, and RPC

The runtime loads with the injected Fluxer application and reconciles installed plugin records into active sandbox instances. The injector does not need to remain open.

Plugin code is copied into per-user data, checked against its manifest hash, and disabled until the user confirms the exact bundle and capabilities. Importing changed code resets enabled/trust state.

Each enabled plugin gets an opaque-origin frame with scripts allowed but no same-origin privilege. The frame has no parent DOM, Node/Electron access, unrestricted networking, or remote script execution.

The SDK’s definePlugin registers a definition inside this sandbox. Identity and API compatibility are checked before startup.

SDK calls become serializable requests. Both the sandbox client and host check the required capability. Host handlers validate data and context before invoking generic services. Privileged operations repeat appropriate checks at the main-process boundary.

Credentials stay in core. Attachments expose owned opaque handles rather than arbitrary channel/message lookup; external navigation requires a host-held user-interaction authorization.

The adapter only matches the origins in packages/adapters/src/origins.ts, and the main helper accepts IPC only from a main frame on one of them. Older shells load the web client from a Fluxer web origin (web.fluxer.app, web.canary.fluxer.app, fluxer.com, canary.fluxer.com). Since Fluxer’s module system (first on Canary 2026.1009), the shell downloads the client into its user data folder and serves it itself at fluxer-app://app, with its own Content-Security-Policy (the main helper adds fluxplugs-plugin: to frame-src on either kind of origin).

Every bounded Fluxer API call goes through hostSession in host-credentials.ts, which gives the credential and the API base for the current page. On a web origin the token is in localStorage and the API is /api/v1 on the same host. On the shell’s own origin the client keeps the session in the shell’s store instead, so the runtime reads the token and the active account key (<instance key>::<user id>) through the shell’s desktop-storage:get IPC, which Fluxer answers only for its top-level document, and calls the instance’s API where the shell proxies it: fluxer-app://app/api/<instance key, URL-encoded>/v1. The shell adds its own protocol authorization header to those requests because they come from the trusted frame. The fake-fluxer fixture is built the second way, so the integration suites exercise that path; the unit tests cover both.

Bootstrap creates one HostServices per window and hands it to the plugin manager and the Electron host. It holds a RouteWatcher (it polls the path, since Fluxer’s router runs in the page’s own world), a GuildDataService (community info, roles and channels, fetched with the user’s credential, cached for 10 minutes and shared by every plugin and the badge host), an ActivityWatcher (passive capture listeners on Fluxer’s window; it keeps only the time of the last input and hands out focused, visible and idle flags per subscription), a VoiceWatcher (the adapter’s reading of the voice panel, observed only while a plugin listens, keeping the last known state while the panel is hidden), the SettingsPageRegistry of plugins’ settings pages, the ScopedPatcher with its typed hooks (patch-hooks.ts), the message box tracker, the CommandRegistry of plugins’ commands (commands) and, on first use, the DecorationHost. Each plugin instance reaches them through PagePluginServices, which checks inputs, keeps per-plugin limits and registers everything through the instance’s PluginServices, so the 64-registration cap and cleanup apply.

A new page-level primitive usually belongs in PagePluginServices plus a host service, not in PluginServices or the RuntimeHost interface. Transports that run in the main process for one instance, images and network, live in PluginServices instead: it counts that instance’s requests, cancels them when the instance stops and forwards them over IPC.

DecorationHost follows the badge pattern: the adapter asks it what to draw at each place on screen, and it answers from a per-plugin cache, asking providers about visible places in batches and validating every entry on its own. Block rendering (decoration-render.ts) uses fluxer-style.ts classes, sets text as text only, and sends button and link clicks back through the user-action checks.

CommandRegistry (command-registry.ts) holds every plugin’s commands in one window and enforces the name rules, Fluxer’s reserved names from the adapter (FluxerAdapter.reservedCommands), first-come ownership and the 32-per-plugin and 128-in-all limits. While any command is registered, it hooks the adapter’s composer onSubmit: for a send whose text parses as a registered command (parseCommandText in packages/schemas/src/commands.ts), it empties the box, grants the owning instance a 1.5-second user action and emits the invocation to the plugin. If the emit fails, it puts the text back. When an instance stops, its names are held for 15 seconds, so a send during a restart stays in the box instead of reaching the chat. CommandMenu (command-menu.ts) shows the commands while their name is typed. When the adapter finds Fluxer’s command list (commandSuggestions), it appends the matching rows after Fluxer’s own and keeps them last as Fluxer redraws (onSuggestionsChange). Otherwise it draws a list like Fluxer’s above the box. Through onKey it steps the arrow keys from Fluxer’s last or first row into the plugin rows and back, relying on Fluxer’s wrap-around to land on the right row. While a plugin row is highlighted, it dims Fluxer’s highlight with dimSuggestion. Enter, Tab or a click completes the name with replace. Once a name is typed out, it shows the “Enter runs” line, and it also shows the notices from the registry. Everything is styled by the .fp-command-* classes in fluxer-style.ts.

PagePluginServices handles commands.register and message_content.recent. The latter uses up the instance’s user action, then reads /channels/{id}/messages for the open channel through host-api.ts with the user’s credential, in pages of 50 with a numeric query (limit, before) that host-api allowlists. Authors’ names come from the adapter’s readAuthors and are added only for plugins with author_names.

The management UI lists the registry’s pages after FluxPlugs’ own in the settings surface and, when one is selected, draws an empty area filling the content area, like Fluxer’s own scroller. The plugin’s frame can’t move into that area, because moving an iframe reloads it, so PluginServices.embed keeps the frame where it is and positions it as a fixed overlay over the area, re-aligned every animation frame and hidden while another dialog covers settings. The adapter reports when the page is left, which unembeds the frame and sends onHide. While embedded, ui.openView refuses with view_busy, and ui.theme adds --settings-page-width and --settings-page-gutter: the adapter measures Fluxer’s own content column by laying out an empty element with the column’s classes, so the page can match Fluxer’s width at any window size.

For plugins with network, main-helper.cjs handles fluxplugs:network:fetch, fluxplugs:network:cancel (every request of a stopping instance) and fluxplugs:network:abort (one request, by the request id PluginServices gives each fetch, when the plugin aborts its signal). It caps the IPC payload at 600,000 characters, then checks the capability, the code hash, the hosts the user confirmed (PluginRecord.trustedNetworkHosts) and the servers they approved (PluginRecord.approvedServers), and network-resource.ts sends the request. That transport shares its DNS pinning with image loading (public-address.ts): it resolves a listed host or public server to public IPv4 addresses, connects to the checked address and re-checks every redirect. For an approved server on this computer or a private network, resolveLocalAddress checks the literal address, or that localhost resolves only to loopback addresses, with classifyAddress; plain http origins go through node:http, and redirects must stay on the approved origin. The request, host and origin rules (parseServerOrigin) live in packages/schemas/src/network.ts, and injector-core applies the same host rule to manifests.

A plugin with stickers opens FluxPlugs’ Add sticker dialog (sticker-dialog.ts) with stickers.add and the handle of an image or GIF attachment context. The RuntimeHost routes it to the plugin’s FileAttachmentHost, which owns that context: the right-click must be at most 10 seconds old or the call must follow a user action, and each context opens the dialog once. media-source.ts finds the image in the message from Fluxer’s API: an attachment, an embedded image, or a GIF-picker link, which the dialog resolves with Fluxer’s /users/@me/favorite-gifs/resolve. The image is downloaded by main-helper’s fluxplugs:stickers:media (fetchMedia in image-resource.ts, with the same address pinning as image loading, up to 16 MiB), which only that dialog calls. sticker-image.ts fits still images into 320×320 and, only when the user asks, makes a smaller GIF with WebCodecs’ ImageDecoder and gifenc. The communities come from /users/@me/guilds, filtered by the Create expressions and Administrator bits, and the upload is a POST /guilds/:id/stickers through hostApiPostJson, whose allowlist holds only these two dialog requests. The plugin gets back only the community’s id.

A plugin with network.userServers asks for a server with network.requestServer. PluginServices shows FluxPlugs’ own confirmation (confirm-dialog.ts, shared with the management UI), and only an accepted dialog calls fluxplugs:network:approve-server: no plugin RPC reaches that channel. The approval is stored only while the user confirmed userServers (PluginRecord.trustedUserServers). The management UI lists approved servers in the plugin’s row and removes them through fluxplugs:management:revoke-server.

Secret settings and storage.getSecret/setSecret/deleteSecret go through secret-store.ts, bundled into main-helper.cjs, which wraps Electron’s safeStorage. main-helper seals secret settings when they are saved, seals plain values left by older versions or by a session without a keystore at startup when a keystore is available, and opens them for settings.get. Sealed values start with fpenc:v1:. A value stored without encryption that starts with fpenc:v1: or fpraw:v1: gets an fpraw:v1: prefix, so text a plugin wrote is never decrypted later. Stored secrets live in plugin-secrets/<id>.json, apart from ordinary storage, and are deleted with the plugin. They can’t sit in plugin-data/: ids may contain dots, so any extra name there, such as <id>.secrets.json, is also another plugin’s data file. Earlier builds kept them there, so at the first start without plugin-secrets/, main-helper moves each plugin-data/<id>.secrets.json of an installed plugin into it, unless a plugin named <id>.secrets is installed too. storage.secretProtection reports os, basic (Linux’s basic_text backend) or none; storage.setSecret resolves with the same level, and the management UI shows a notice on the Plugins page when it isn’t os.

Developer mode runs the user’s own .js files in Fluxer’s main world. It is deliberately not a capability: no manifest can ask for it, and only FluxPlugs’ Settings page turns it on or allows a file.

  • State. developer-store.ts, bundled into main-helper.cjs, keeps <state root>/developer/settings.json ({ enabled, confirmed }, file names only) and reads <state root>/developer/scripts/. Only regular .js files directly in that folder count, at most 32, 1 MiB each and 4 MiB together; the rest are listed with a reason. fluxplugs:developer:set-enabled turns it on only with confirmed, from FluxPlugs’ warning dialog, and fluxplugs:developer:confirm-script saves a name only while the file still has the hash the dialog showed. Edits to an allowed file run without asking. fluxplugs:developer:sources drops confirmations of files that are gone, so a new file under an old name asks again. Every channel goes through assertSender, and plugins can’t reach any of them: their RPC has no developer methods.
  • Running. bootstrap.ts calls runDeveloperScripts (developer-scripts.ts) once per page load, after the adapter and popout checks and before plugins start. Each allowed file goes through webFrame.executeJavaScript with a sourceURL of fluxplugs-developer/<name>, one after another; a failure is recorded and the next file still runs. That call isn’t subject to the page’s CSP, so it works with Fluxer’s nonce- and hash-based script-src. Nothing from the preload is handed to the page. pnpm test:architecture fails if webFrame or executeJavaScript appears anywhere else in the runtime or adapters, or if contextBridge appears at all.
  • Showing it. While developer mode was on at load, developer-indicator.ts keeps a label at the top of the window, put back if removed; it is separate from the client-info badge, so no patch hook changes it. The Plugins page shows a notice, and the Settings page lists each file with what happened to it on this load.

pnpm test:developer runs the fake-fluxer fixture with seeded scripts: it checks that allowed files ran under the fixture’s CSP and saw no preload globals, that an unallowed file didn’t run, that a throwing file didn’t stop the next, that allowing a file needs a real click, and that nothing runs after turning developer mode off and reloading.

Role badges follow the same split. BadgeHost gives providers a community’s role list (from the shared GuildDataService) and never member data; MemberRoleResolver looks up the roles of people on screen with the user’s credential, one request at a time within per-community budgets, and backs off on 429, 401 and 403. When lookups are off or fail, it falls back to what the page shows.

Reconciliation starts, stops, or restarts plugin instances when trust, enablement, code, or settings change. Custom views show the same plugin frame and instance.

On shutdown, cancel pending work and release dialogs, subscriptions, styles, wrappers, image handles, and other instance-owned resources. Plugin cleanup remains necessary even with core’s safety net.

Use runtime unit tests for grant enforcement, malformed requests, ownership, cleanup, cancellation, and stale asynchronous completions. Use the external-plugin fixture to prove a plugin can run using the public package boundary without private imports.

FluxPlugs is an independent project, not affiliated with or endorsed by Fluxer.