Overview
Plugins extend agent functionality by hooking into the tick lifecycle, exposing actions, and managing state. They’re the primary way to add capabilities like social posting, trading, or custom integrations. Reference:src/plugins/types.ts
Plugin Interface
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier |
version | string | Yes | Semver version |
description | string | No | Human-readable description |
dependencies | string[] | No | Plugins that must load first |
init | function | No | Called once on registration |
cleanup | function | No | Called when agent stops |
onTick | function | No | Called after every tick |
actions | object | No | Callable methods |
Lifecycle Hooks
| Hook | When Called | Use For |
|---|---|---|
init(agent) | Plugin registration | Setup, connections, validation |
onTick(context) | After each tick | React to state, execute actions |
cleanup(agent) | Agent stops | Close connections, flush buffers |
TickContext
The context passed toonTick:
| Field | Type | Description |
|---|---|---|
state | AgentState | Current mood, health, routine |
memories | Memory[] | Retrieved memories for tick |
knowledge | Knowledge[] | Retrieved knowledge items |
recentLogs | Log[] | Recent activity logs |
TickContext interface in src/core/types.ts
Creating Plugins
Static Plugin
Factory Pattern (Recommended)
Use factories when plugins need configuration or internal state:src/plugins directory
Plugin Actions
Actions are methods exposed by plugins, callable via the agent:Registration
agent.use() in src/core/agent.ts
Dependencies
Plugins can declare dependencies that must load first:loadPlugins() in src/plugins/loader.ts
Configuration Patterns
| Pattern | When to Use |
|---|---|
| Environment variables | API keys, feature flags |
| Factory parameters | Cooldowns, limits, options |
| Runtime actions | Dynamic reconfiguration |
Error Handling
Plugins should catch errors to avoid crashing the agent:Testing
tests/plugins/