Package Exports
- @hashgraphonline/standards-agent-kit
- @hashgraphonline/standards-agent-kit/package.json
Readme
Hashgraph Online Standards Agent Kit
![]() |
A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication. This SDK is built and maintained by Hashgraph Online, a consortium of leading Hedera Organizations within the Hedera ecosystem. 📚 Standards Agent Kit Documentation 📖 HCS Standards Documentation |
|---|
Quick Start
npm install @hashgraphonline/standards-agent-kitInstallation
# Install the core SDK
npm install @hashgraphonline/standards-agent-kit
# Optional: Install the OpenConvAI plugin for additional functionality
npm install @hashgraphonline/standards-agent-pluginDocumentation
For complete documentation, examples, and API references, visit:
Features
- HCS-10 Agent Tools: Complete toolkit for agent registration, discovery, and communication
- Plugin System: Extensible architecture for adding custom capabilities
- LangChain Integration: Seamless integration with LangChain for AI agent development
- Built on Hedera Agent Kit: Leverages the powerful Hedera Agent Kit for blockchain interactions
- OpenConvAI Plugin Support: Pre-built integration with the OpenConvAI standards plugin
- TypeScript Support: Full TypeScript support with comprehensive type definitions
- State Management: Built-in state management for agent operations
Usage
Basic Setup with LangChain
import { HederaAgentKit } from 'hedera-agent-kit';
import {
RegisterAgentTool,
FindRegistrationsTool,
InitiateConnectionTool,
SendMessageToConnectionTool,
HCS10Builder,
OpenConvaiState
} from '@hashgraphonline/standards-agent-kit';
// Initialize HederaAgentKit
const hederaKit = new HederaAgentKit({
accountId: process.env.HEDERA_ACCOUNT_ID,
privateKey: process.env.HEDERA_PRIVATE_KEY,
network: 'testnet'
});
// Create state manager and builder
const stateManager = new OpenConvaiState();
const hcs10Builder = new HCS10Builder(hederaKit, stateManager);
// Create tools
const tools = [
new RegisterAgentTool({ hederaKit, hcs10Builder }),
new FindRegistrationsTool({ hederaKit, hcs10Builder }),
new InitiateConnectionTool({ hederaKit, hcs10Builder }),
new SendMessageToConnectionTool({ hederaKit, hcs10Builder })
];
// Use tools with LangChain
import { ChatOpenAI } from '@langchain/openai';
import { createToolCallingAgent } from 'langchain/agents';
const llm = new ChatOpenAI({
modelName: 'gpt-4',
openAIApiKey: process.env.OPENAI_API_KEY
});
const agent = await createToolCallingAgent({
llm,
tools,
prompt: /* your prompt */
});Using with OpenConvAI Plugin
import { StandardsKit } from '@hashgraphonline/standards-agent-plugin';
// Initialize StandardsKit with OpenConvAI plugin pre-configured
const kit = new StandardsKit({
accountId: process.env.HEDERA_ACCOUNT_ID,
privateKey: process.env.HEDERA_PRIVATE_KEY,
network: 'testnet',
openAIApiKey: process.env.OPENAI_API_KEY
});
await kit.initialize();
// Use the conversational agent
const response = await kit.processMessage('Find all registered AI agents');Running Examples
Clone the repository
git clone https://github.com/hashgraph-online/standards-agent-kit.git cd standards-agent-kit
Install dependencies
pnpm install
Set up environment variables
cp .env.example .envEdit the
.envfile with your Hedera credentials:HEDERA_ACCOUNT_ID=0.0.12345 HEDERA_PRIVATE_KEY=your_private_key_here HEDERA_NETWORK=testnet OPENAI_API_KEY=your_openai_key_here # Required for AI demosRun the examples:
# Interactive CLI demo npm run demo:cli # LangChain integration demo npm run demo:langchain # Plugin system example npm run demo:plugin # OpenConvAI plugin example npm run demo:plugin:openconvai
Available Tools
The SDK provides a comprehensive set of tools for HCS-10 agent operations:
- RegisterAgentTool: Register new agents on the network
- FindRegistrationsTool: Search for registered agents
- RetrieveProfileTool: Get detailed agent profiles
- InitiateConnectionTool: Start connections between agents
- ListConnectionsTool: View active connections
- SendMessageToConnectionTool: Send messages to connected agents
- CheckMessagesTool: Retrieve messages from connections
- ConnectionMonitorTool: Monitor incoming connection requests
- ManageConnectionRequestsTool: Handle pending connections
- AcceptConnectionRequestTool: Accept incoming connections
- ListUnapprovedConnectionRequestsTool: View pending requests
Registry Broker Plugin
The RegistryBrokerPlugin bridges the RegistryBrokerClient inside every Hedera Agent Kit integration. Once registered, agents can call any broker endpoint (search, chat, registration, UAID utilities, ledger auth, credits, encryption) through a single tool. The plugin automatically reuses shared credentials and keeps encrypted chat handles alive via conversation.* operations.
import { PluginRegistry } from 'hedera-agent-kit';
import { RegistryBrokerPlugin } from '@hashgraphonline/standards-agent-kit';
const pluginRegistry = new PluginRegistry();
pluginRegistry.register(
new RegistryBrokerPlugin(),
);Configure credentials via registryBroker plugin config or environment variables:
const plugin = new RegistryBrokerPlugin();
await plugin.initialize({
config: {
hederaKit,
registryBroker: {
client: {
baseUrl: process.env.REGISTRY_BROKER_BASE_URL,
apiKey: process.env.REGISTRY_BROKER_API_KEY,
},
},
},
logger,
});Env Fallbacks
REGISTRY_BROKER_API_KEY/RB_API_KEYREGISTRY_BROKER_BASE_URLREGISTRY_BROKER_LEDGER_ACCOUNT_ID,REGISTRY_BROKER_LEDGER_NETWORK,REGISTRY_BROKER_LEDGER_PRIVATE_KEY(orHEDERA_ACCOUNT_ID/HEDERA_PRIVATE_KEY) – enables automatic ledger authentication if no API key is supplied.
Every operation is invoked through registry_broker_operation:
const [registryTool] = plugin.getTools();
// Discovery
await registryTool._call({
operation: 'search',
payload: { q: 'openrouter', limit: 5 },
});
// Chat with broker-managed UAIDs
const session = await registryTool._call({
operation: 'chat.createSession',
payload: {
uaid: 'uaid:aid:2bnewJwP95isoCUkT5mee5gm212WS76tphHwBQvbWoquRa9kt89UanrBqHXpaSh4AN;uid=anthropic/claude-3.5-sonnet;registry=openrouter;proto=openrouter;nativeId=anthropic/claude-3.5-sonnet',
historyTtlSeconds: 900,
},
});
await registryTool._call({
operation: 'chat.sendMessage',
payload: {
sessionId: JSON.parse(session).result.sessionId,
message: 'Hello from the Hedera Agent Kit plugin!',
},
});For encrypted chat flows, call chat.start, chat.createEncryptedSession, or chat.acceptEncryptedSession. The plugin returns a handleId; subsequent conversation.send, conversation.decryptHistoryEntry, and conversation.release operations reuse that state without exposing the raw ChatConversationHandle.
Plugin Development
Create custom plugins by extending the base plugin interface:
import { BasePlugin } from '@hashgraphonline/standards-agent-kit';
export class MyCustomPlugin extends BasePlugin {
name = 'my-custom-plugin';
async initialize(context) {
// Initialize your plugin
}
getTools() {
// Return your custom tools
}
}Contributing
Please read our Contributing Guide before contributing to this project.
Resources
- Standards Agent Kit Documentation
- HCS Standards Documentation
- Hedera Documentation
- GitHub Repository
License
Apache-2.0
