UNPKG

@hashgraphonline/standards-agent-kit

Version:

A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication. https://hol.org

64 lines (55 loc) 2.06 kB
import { BasePlugin, type GenericPluginContext, type HederaAgentKit, type HederaTool, } from 'hedera-agent-kit'; import { RegistryBrokerClientProvider } from './RegistryBrokerClientProvider'; import type { RegistryBrokerPluginConfiguration } from './RegistryBrokerClientProvider'; import { RegistryBrokerConversationStore } from './RegistryBrokerConversationStore'; import { RegistryBrokerOperationTool } from './RegistryBrokerOperationTool'; export interface RegistryBrokerPluginContext extends GenericPluginContext { config: GenericPluginContext['config'] & { registryBroker?: RegistryBrokerPluginConfiguration; }; } export class RegistryBrokerPlugin extends BasePlugin<RegistryBrokerPluginContext> { id = 'registry-broker'; name = 'Registry Broker Plugin'; description = 'Expose RegistryBrokerClient operations to Hedera Agent Kit tools for discovery, chat, registration, and ledger auth.'; version = '0.1.0'; author = 'Hashgraph Online'; private tools: HederaTool[] = []; private clientProvider?: RegistryBrokerClientProvider; private readonly handleStore = new RegistryBrokerConversationStore(); override async initialize( context: RegistryBrokerPluginContext, ): Promise<void> { await super.initialize(context); const hederaKit = context.config.hederaKit as HederaAgentKit | undefined; if (!hederaKit) { this.context.logger.warn( '[RegistryBrokerPlugin] HederaAgentKit not available; plugin initialization skipped.', ); this.tools = []; return; } const provider = new RegistryBrokerClientProvider( context.config.registryBroker, this.context.logger, ); this.clientProvider = provider; const tool = new RegistryBrokerOperationTool({ hederaKit, logger: this.context.logger, clientProvider: provider, handleStore: this.handleStore, }); this.tools = [tool]; this.context.logger.info?.('[RegistryBrokerPlugin] Initialized.'); } override getTools(): HederaTool[] { return this.tools; } }