API Reference

August 10, 2026 · View on GitHub

All public symbols exported from hivemind_plugin_manager.


hivemind_plugin_manager/__init__.py

HiveMindPluginTypes

class HiveMindPluginTypes(str, enum.Enum):
    DATABASE         = "hivemind.database"           # line 14
    NETWORK_PROTOCOL = "hivemind.network.protocol"   # line 15
    AGENT_PROTOCOL   = "hivemind.agent.protocol"     # line 16
    BINARY_PROTOCOL  = "hivemind.binary.protocol"    # line 17
    POLICY           = "hivemind.policy"             # line 18

Source: hivemind_plugin_manager/__init__.py:13

Each value is the setuptools entry-point group string used for plugin discovery.


find_plugins(plug_type=None) -> dict

Source: hivemind_plugin_manager/__init__.py:136

Discovers all installed plugins matching plug_type.

ArgumentTypeBehaviour
None-iterates every HiveMindPluginTypes group, merges results
HiveMindPluginTypes memberenumiterates that one group
strraw entry-point group nameiterates that group

Returns {plugin_name: class}.

Entry-point load failures are caught, logged once, and skipped. Already-errored entry points are stored in find_plugins._errored (a module-level list) to suppress repeated log noise.


DatabaseFactory

Source: hivemind_plugin_manager/__init__.py:21

DatabaseFactory.get_class(plugin_name: str) -> Type[AbstractDB]

Returns the class registered under plugin_name in hivemind.database. Raises KeyError if not found. Source: __init__.py:23

DatabaseFactory.create(plugin_name, name="clients", subfolder="hivemind-core", password=None, host=None, port=None) -> Union[AbstractDB, AbstractRemoteDB]

Instantiates the plugin. If the class is a subclass of AbstractRemoteDB, host and port are forwarded; otherwise they are dropped. Source: __init__.py:30


AgentProtocolFactory

Source: hivemind_plugin_manager/__init__.py:42

AgentProtocolFactory.get_class(plugin_name: str) -> Type[AgentProtocol]

Raises KeyError if not found. Source: __init__.py:44

AgentProtocolFactory.create(plugin_name, config=None, bus=None, hm_protocol=None) -> AgentProtocol

config defaults to {} when None. Source: __init__.py:51


NetworkProtocolFactory

Source: hivemind_plugin_manager/__init__.py:60

NetworkProtocolFactory.get_class(plugin_name: str) -> Type[NetworkProtocol]

Raises KeyError if not found. Source: __init__.py:62

NetworkProtocolFactory.create(plugin_name, config=None, hm_protocol=None) -> NetworkProtocol

config defaults to {} when None. Source: __init__.py:69


BinaryDataHandlerProtocolFactory

Source: hivemind_plugin_manager/__init__.py:77

BinaryDataHandlerProtocolFactory.get_class(plugin_name: str) -> Type[BinaryDataHandlerProtocol]

Raises KeyError if not found. Source: __init__.py:80

BinaryDataHandlerProtocolFactory.create(plugin_name, config=None, hm_protocol=None, agent_protocol=None) -> BinaryDataHandlerProtocol

config defaults to {} when None. Source: __init__.py:87


PolicyPluginFactory

Source: hivemind_plugin_manager/__init__.py:96

Discovers and instantiates policy plugins registered under hivemind.policy. Consumed by hivemind-core's chain runner when assembling policy.chain at startup.

PolicyPluginFactory.get_class(plugin_name: str) -> Type[PolicyPlugin]

Raises KeyError if not found. Source: __init__.py:103

PolicyPluginFactory.create(plugin_name, config=None, hm_protocol=None) -> PolicyPlugin

config defaults to {} when None. Source: __init__.py:110


hivemind_plugin_manager/database.py

Client

Source: hivemind_plugin_manager/database.py:35

@dataclass
class Client:
    client_id: int           # required; must be int
    api_key: str             # required
    name: str = ""
    description: str = ""
    is_admin: bool = False   # must be bool
    last_seen: float = -1
    allowed_types: List[str] = field(default_factory=list)  # whitelist; empty = deny everything
    crypto_key: Optional[str] = None
    password: Optional[str] = None
    can_broadcast: bool = True
    can_escalate: bool = True
    can_propagate: bool = True
    metadata: Dict[str, Any] = field(default_factory=dict)

__post_init__ (database.py:56) enforces int/bool types. allowed_types is not pre-populated - an empty list means deny-by-default. No automatic message types are appended. See HiveMind-core#85.

Deprecated property shims - skill_blacklist and intent_blacklist are read/write properties (database.py:86, database.py:102) backed by Client.metadata. Setting them emits DeprecationWarning; new code should write to Client.metadata directly. message_blacklist is not part of the data model: no property, no metadata carry-forward. The constructor kwarg is accepted-and-discarded with a DeprecationWarning, and deserialize strips the top-level key silently from on-disk records.

metadata - free-form per-client dict for plugin-specific context. deserialize migrates legacy top-level blacklist keys into metadata automatically (database.py:153) and folds any other unknown top-level keys from older records the same way; an explicit metadata key in the payload wins on collision. A non-dict metadata is coerced to {} in __post_init__ (database.py:70).

MethodSignatureSource
serialize()-> str (JSON)database.py:126
deserialize(data)staticmethod(str | dict) -> Clientdatabase.py:136
__getitem__(key)-> Any; raises KeyErrordatabase.py:189
__setitem__(key, val)raises ValueError on unknown keydatabase.py:206
__eq__(other)compares serialized JSONdatabase.py:222
__repr__()returns serialize()database.py:240

cast2client(ret: ClientTypes) -> Optional[Union[Client, List[Client]]]

Source: hivemind_plugin_manager/database.py:16

Normalises None, Client, JSON string, dict, or list into Client instances. Raises TypeError for unsupported types.


AbstractDB

Source: hivemind_plugin_manager/database.py:300

@dataclass
class AbstractDB(abc.ABC):
    name: str = "clients"
    subfolder: str = "hivemind-core"
    password: Optional[str] = None

    SCHEMA_VERSION: ClassVar[int] = 2  # bumped 2024-05 for legacy-blacklist purge
MethodAbstractSignatureSource
add_itemyes(client: Client) -> booldatabase.py:312
search_by_valueyes(key: str, val) -> List[Client]database.py:364
__len__yes() -> intdatabase.py:377
__iter__yes() -> Iterable[Client]database.py:386
delete_itemno(client) -> bool - tombstone patterndatabase.py:323
update_itemno(client) -> bool - calls add_itemdatabase.py:337
replace_itemno(old, new) -> booldatabase.py:349
syncno() - no-opdatabase.py:394
migrateno(from_version: int) -> None - schema migration hook (default no-op); backends override for their persisted on-disk shapedatabase.py:405
commitno() -> Truedatabase.py:420

See Concepts → Database Schema Migration for the SCHEMA_VERSION + migrate() contract.


AbstractRemoteDB

Source: hivemind_plugin_manager/database.py:431

Extends AbstractDB with:

host: str = "127.0.0.1"
port: Optional[int] = None

Re-declares add_item, search_by_value, __len__, __iter__ as abstract.


hivemind_plugin_manager/protocols.py

Module-level default callbacks

FunctionSignatureBehaviourSource
on_disconnect(client) -> Nonelogs debugprotocols.py:13
on_connect(client) -> Nonelogs debugprotocols.py:16
on_invalid_key(client) -> Nonelogs debugprotocols.py:19
on_invalid_protocol(client) -> Nonelogs debugprotocols.py:22

ClientCallbacks

Source: hivemind_plugin_manager/protocols.py:27

@dataclass
class ClientCallbacks:
    on_connect:          Callable[['HiveMindClientConnection'], None] = on_connect
    on_disconnect:       Callable[['HiveMindClientConnection'], None] = on_disconnect
    on_invalid_key:      Callable[['HiveMindClientConnection'], None] = on_invalid_key
    on_invalid_protocol: Callable[['HiveMindClientConnection'], None] = on_invalid_protocol

Defaults to the module-level no-op functions above.


_SubProtocol

Source: hivemind_plugin_manager/protocols.py:35

Internal base dataclass. All three public protocol classes inherit from it.

Fields: config: dict, hm_protocol: Optional[HiveMindListenerProtocol], callbacks: ClientCallbacks.

Properties:

PropertyReturnsSource
identityhm_protocol.identity or fresh NodeIdentity()protocols.py:41
databasehm_protocol.db or Noneprotocols.py:46
clientshm_protocol.clients or {}protocols.py:52

AgentProtocol

Source: hivemind_plugin_manager/protocols.py:61

Fields: inherits _SubProtocol fields plus bus: Union[FakeBus, MessageBusClient].

Abstract method: natural_language_query(utterance, lang) -> Iterator[Optional[str]], a generator yielding answer chunks then a final None. Concrete overridables: get_bus(client=None) and answer_query(utterance, lang, client=None) — hivemind-core calls answer_query, whose default delegates to natural_language_query.


NetworkProtocol

Source: hivemind_plugin_manager/protocols.py:70

Additional property:

PropertyReturnsSource
agent_protocolhm_protocol.agent_protocol or Noneprotocols.py:77

Abstract method: run(self) - must block while serving. Source: protocols.py:82


BinaryDataHandlerProtocol

Source: hivemind_plugin_manager/protocols.py:88

Additional field: agent_protocol: Optional[AgentProtocol].

__post_init__ (protocols.py:96) auto-populates agent_protocol from hm_protocol if not provided explicitly.

All handler methods are concrete no-ops (log a warning). See Binary Protocol Plugin Guide for the full list with signatures.


hivemind_plugin_manager/tui.py

CLI entry point registered as the hpm console script (pyproject.toml, [project.scripts]).

CommandUsageSource
hpm list <type>print installed plugins as JSONtui.py:84
hpm set <type> <name>write chosen plugin to server.jsontui.py:97
hpm get <type>show currently configured plugintui.py:117
hpm show-configdump full server.jsontui.py:132

<type> accepts: network, agent, binary, database.

Config file: ~/.config/hivemind-core/server.json (XDG). get_server_config() - tui.py:54 - creates the file with defaults on first run.


← Concepts · Home · Advanced →