Sections written: - Getting Started (what-is-openacp, for-users, for-developers, for-contributors) - Platform Setup (Telegram, Discord, Slack) - Using OpenACP (commands, sessions, agents, permissions, voice, files) - Self-Hosting (installation, configuration, daemon, security, logging, updating) - Features (tunnel, context-resume, usage, persistence, handoff, doctor, assistant) - Extending (plugin-system, building-adapters, adapter-reference, contributing) - API Reference (CLI commands, REST API, config schema, env vars) - Troubleshooting (Telegram, Discord, Slack, agent issues, FAQ) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.8 KiB
Plugin System
What Are Plugins?
Plugins are standard npm packages that add channel adapters to OpenACP. A plugin exports an AdapterFactory object, which OpenACP uses to instantiate and register your adapter at startup. Installing a plugin does not require modifying the OpenACP source code or rebuilding anything — the CLI handles discovery, installation, and loading automatically.
Examples of what a plugin might add:
- A Discord adapter (
@openacp/adapter-discord) - A Slack adapter (
@openacp/adapter-slack) - An internal chat platform connector
Plugin Directory
All plugins are installed into a dedicated local directory:
~/.openacp/plugins/
This directory contains its own package.json so npm can manage plugin dependencies independently of your global Node environment. OpenACP creates this directory automatically the first time you install a plugin.
Installing a Plugin
openacp install <package-name>
Example:
openacp install @openacp/adapter-discord
Under the hood, this runs npm install <package-name> --prefix ~/.openacp/plugins/. The plugin is immediately available on the next startup.
Listing Installed Plugins
openacp plugins
This reads the dependencies field from ~/.openacp/plugins/package.json and prints each installed package name and version.
Uninstalling a Plugin
openacp uninstall <package-name>
Example:
openacp uninstall @openacp/adapter-discord
This runs npm uninstall <package-name> --prefix ~/.openacp/plugins/ and removes the entry from the plugins package.json.
How Plugins Are Loaded
At startup, OpenACP reads the dependencies map from ~/.openacp/plugins/package.json. For each listed package, it calls loadAdapterFactory(packageName):
- Resolves the package path using a
requirerooted in the plugins directory. - Dynamically
import()s the resolved module. - Looks for an
adapterFactorynamed export, falling back to thedefaultexport. - Validates that the export has a
createAdapterfunction. - If valid, registers the factory so the adapter can be used by
OpenACPCore.
If a plugin fails to load (missing file, invalid export), OpenACP logs an error and continues — a broken plugin does not prevent other adapters from starting.
Package Requirements
A valid plugin package must:
- Export a named
adapterFactory(or adefaultexport) that conforms to theAdapterFactoryinterface:
import type { AdapterFactory } from '@openacp/cli'
export const adapterFactory: AdapterFactory = {
name: 'my-platform',
createAdapter(core, config) {
return new MyPlatformAdapter(core, config)
},
}
-
The
createAdapterfunction receives:core: OpenACPCore— the running core instanceconfig: ChannelConfig— the adapter's config block from~/.openacp/config.json
-
It must return a
ChannelAdapterinstance (see Building Adapters).
Minimal Plugin package.json
{
"name": "@openacp/adapter-myplatform",
"version": "1.0.0",
"type": "module",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js"
},
"peerDependencies": {
"openacp": ">=0.6.0"
}
}
Example Plugin Structure
@openacp/adapter-myplatform/
src/
index.ts ← exports adapterFactory
adapter.ts ← MyPlatformAdapter class
formatting.ts ← message formatting helpers
dist/ ← compiled output
package.json
tsconfig.json
src/index.ts:
import type { AdapterFactory } from 'openacp'
import { MyPlatformAdapter } from './adapter.js'
export const adapterFactory: AdapterFactory = {
name: 'myplatform',
createAdapter(core, config) {
return new MyPlatformAdapter(core, config)
},
}