Plugins
Stable in docs/STATUS.md. Mnemosyne is alpha, on the 3.6.x line, and the
API can still change within 3.x.
A plugin extends the server without a fork. It is an npm package whose default
export implements the MnemoPlugin interface. The loader and ten built-in
plugins are in packages/plugins, an internal package that runs inside the
server and is not published to npm.
Plugins are not sandboxed. A plugin runs in the same Node.js process as
the server, with access to memory, the filesystem, the network and the
environment. Audit a plugin as you would audit server code. On the server,
MNEMO_PLUGINS is the opt-in: with it unset, no plugin code runs.
Loading plugins
export MNEMO_PLUGINS="builtin:webhook-notify,@acme/mnemo-plugin-audit-log"
export MNEMO_PLUGIN_WEBHOOK_NOTIFY__URL="https://hooks.acme.example/mnemosyne"The server reads only the environment. MNEMO_PLUGINS lists npm packages and
built-ins (builtin:<id>), and MNEMO_PLUGIN_<ID>__<KEY> gives each plugin
its own config (see Operations: plugins). A host that
builds its own loader can read the same list from mnemo.config.yaml with
parsePluginConfig, which refuses to load anything unless
allowUnsandboxedPlugins is true:
plugins:
allowUnsandboxedPlugins: true
load:
- package: "@acme/mnemo-plugin-audit-log"
config:
webhookUrl: "https://hooks.acme.example/mnemosyne"The interface
From packages/plugins/src/index.ts. Every hook is optional.
interface MnemoPlugin {
readonly id: string;
readonly name: string;
readonly version: string;
readonly description?: string;
// Lifecycle
onInit?(ctx: PluginContext): Promise<void> | void;
onShutdown?(ctx?: PluginContext): Promise<void> | void;
onHealthCheck?(): Promise<PluginHealth> | PluginHealth;
// Write path: can change the write; null rejects it
onBeforeWrite?(unit: PluginKnowledgeUnit, ctx: PluginContext):
PluginKnowledgeUnit | null | Promise<PluginKnowledgeUnit | null>;
onAfterWrite?(unit: PluginKnowledgeUnit, ctx: PluginContext): void | Promise<void>;
// Read path: can change the query and the hits
onBeforeRecall?(input: PluginRecallInput, ctx: PluginContext):
PluginRecallInput | Promise<PluginRecallInput>;
onAfterRecall?(hits: PluginRecallHit[], ctx: PluginContext):
PluginRecallHit[] | Promise<PluginRecallHit[]>;
// Event hooks: asynchronous, they do not block the request
onFactCreated?(fact: PluginFact, ctx: PluginContext): Promise<void>;
onTaskCompleted?(task: PluginTask, ctx: PluginContext): Promise<void>;
onSessionCollapsed?(summary: SessionCollapseSummary, ctx: PluginContext): Promise<void>;
onConflictDetected?(conflict: FactConflict, ctx: PluginContext): Promise<void>;
onWorthChanged?(memoryId: string, newWorth: number, ctx: PluginContext): Promise<void>;
// Polling
syncInterval?: number;
sync?(ctx: PluginContext): Promise<SyncResult>;
// Verification
verify?(facts: PluginFact[], ctx: PluginContext): Promise<VerificationResult[]>;
}There is also an onEventRecorded hook, fired when an event is recorded.
What a plugin receives
The context limits what a plugin does through the server’s own API. It is a convention, not a sandbox.
interface PluginContext {
readonly workspaceId: string;
readonly config: Record<string, string | undefined>;
readonly maxSensitivity: Sensitivity;
// Read, scoped to the workspace
recall(query: string): Promise<PluginRecallHit[]>;
getFact(id: string): Promise<PluginFact | null>;
// Write: rate-limited, audited, recorded as "plugin:<id>"
createFact(input: PluginCreateFactInput): Promise<PluginFact>;
createEvent(input: PluginCreateEventInput): Promise<PluginEvent>;
createTask(input: PluginCreateTaskInput): Promise<PluginTask>;
createEpisode(input: PluginCreateEpisodeInput): Promise<PluginEpisode>;
// Private state and logging
readonly state: PluginStateStore;
readonly log: PluginLogger;
}- Writes are limited to 10 per minute per plugin.
- A plugin cannot write above
maxSensitivity, which isinternalunlessMNEMO_PLUGIN_<ID>__MAX_SENSITIVITYsets another tier. stateis private to the plugin and persisted inmnemo_plugin_state.
Failure handling
A hook that takes longer than 2 seconds, or fails three times in a row, is
disabled until the server restarts. The log line carries the code MNEMO_010.
Built-in plugins
Ten factories ship in packages/plugins/src/builtins:
| Plugin | What it does |
|---|---|
webhook-notify | Posts to a webhook URL when a fact is created, a task completes or worth changes |
feedback-loop | Keeps a short history of worth changes in its state |
git-verifier | Checks a fact’s metadata.commitSha against a repository |
calendar-sync | Reads an ICS feed and records one event per calendar entry |
slack-events | Records Slack messages as events |
github-events | Records pull requests as events; an opened issue also creates a fact |
outline-sync | Syncs Outline documents into facts |
obsidian-export | Writes facts as Markdown files in a vault folder |
claude-import | Imports a Claude memory JSON array as facts |
event-reactions | Fires configured rules when a recorded event matches a trigger |