Skip to main content
The ink SDK provides two extension mechanisms: Plugins for tick lifecycle hooks and Services for background data fetching.

Plugins vs Services

AspectPluginsServices
PurposeReact to ticks, expose actionsFetch and cache data
LifecycleTied to tick cycleIndependent background
InterfaceonTick, actionsgetData, refresh
Referencesrc/plugins/types.tssrc/services/types.ts

Plugin Interface

Plugins hook into the agent tick lifecycle:
FieldTypeDescription
namestringUnique identifier
versionstringSemver version
initfunctionCalled on registration
cleanupfunctionCalled on agent stop
onTickfunctionCalled after each tick
actionsobjectCallable methods
Reference: Plugin interface in src/plugins/types.ts

Service Interface

Services run independently, caching data:
MethodDescription
initialize(runtime)Setup with runtime context
start()Begin fetching
stop()Cleanup
getData<T>()Get cached data
refresh()Force refresh
getHealth()Status and stats
Reference: Service interface in src/services/types.ts

Built-in Services

ServiceDescriptionReference
ChanService4chan SFW board threadssrc/services/chan.ts
NewsServiceRSS/API news aggregationsrc/services/news.ts
MarketServiceCrypto price datasrc/services/market.ts
import { createChanService, createNewsService, createMarketService } from './src/services';

const chan = createChanService({ options: { boards: ['g', 'sci'] } });
const news = createNewsService();
const market = createMarketService();

Creating a Plugin

import { definePlugin } from './src/plugins';

export const myPlugin = definePlugin({
  name: "my-plugin",
  version: "1.0.0",
  onTick(context) {
    console.log(`Mood: ${context.state.mood}`);
  }
});
Reference: definePlugin() in src/plugins/loader.ts

Plugin Utilities

FunctionDescription
definePlugin(def)Create and validate plugin
validatePlugin(obj)Check plugin structure
loadPlugin(path)Dynamic import
sortPluginsByDependencies(plugins)Resolve load order
Reference: src/plugins/loader.ts

Service Types

TypeDescription
newsNews feeds
marketPrice data
socialSocial mentions
calendarScheduling
walletBlockchain data
storageFile storage
customUser-defined
Reference: ServiceType enum in src/services/types.ts

Next Steps