@hashgraphonline/standards-agent-kit 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +137 -170
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,22 @@
1
- # Hashgraph Online Standards AI Agent Kit
1
+ # Hashgraph Online Standards Agent Kit
2
2
 
3
- [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
3
+ | ![](https://hashgraphonline.com/img/logo.png) | A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.<br><br>This SDK is built and maintained by [Hashgraph Online](https://hashgraphonline.com), a consortium of leading Hedera Organizations within the Hedera ecosystem.<br><br>[📚 Standards Agent Kit Documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/)<br>[📖 HCS Standards Documentation](https://hcs-improvement-proposals.pages.dev/docs/standards) |
4
+ | :-------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4
5
 
5
- # **_This SDK is currently in alpha, use at your own risk._**
6
+ ## Quick Start
6
7
 
7
- A toolkit built with TypeScript and LangChain for creating AI agents that communicate trustlessly on the Hedera network using the [HCS-10 AI Agent Communication Standard](https://hashgraphonline.com/docs/standards/hcs-10/).
8
+ ```bash
9
+ npm install @hashgraphonline/standards-agent-kit
10
+ ```
8
11
 
9
- ## Quick Start
12
+ ## Installation
10
13
 
11
14
  ```bash
15
+ # Install the core SDK
12
16
  npm install @hashgraphonline/standards-agent-kit
17
+
18
+ # Optional: Install the OpenConvAI plugin for additional functionality
19
+ npm install @hashgraphonline/standards-agent-plugin
13
20
  ```
14
21
 
15
22
  ## Documentation
@@ -17,216 +24,176 @@ npm install @hashgraphonline/standards-agent-kit
17
24
  For complete documentation, examples, and API references, visit:
18
25
 
19
26
  - [Standards Agent Kit Documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/)
27
+ - [HCS-10 Standard Documentation](https://hcs-improvement-proposals.pages.dev/docs/standards/hcs-10)
20
28
 
21
29
  ## Features
22
30
 
23
- - **HCS-10 Compliance:** Built on top of the official `@hashgraphonline/standards-sdk` for standard compliance.
24
- - **Agent Lifecycle Management:** Create, register, and manage HCS-10 agents on Hedera.
25
- - **Trustless Communication:** Facilitates secure peer-to-peer communication setup between agents via Hedera Consensus Service (HCS).
26
- - **LangChain Integration:** Provides ready-to-use LangChain `StructuredTool`s for common agent actions.
27
- - **Message Handling:** Send and receive messages over HCS, including support for large messages via HCS-3 inscriptions.
28
- - **Connection Monitoring:** Automatically monitor inbound topics for connection requests and handle them.
29
- - **Configurable:** Set Hedera network, credentials, and registry via environment variables.
30
-
31
- ## Supported Tools
32
-
33
- - **RegisterAgentTool**: Create and register a new HCS-10 agent
34
- - **SendMessageTool**: Send messages to a topic with optional response monitoring
35
- - **ConnectionTool**: Monitor inbound topics for connection requests
36
- - **FindRegistrationsTool**: Search for agent registrations by criteria
37
- - **InitiateConnectionTool**: Start a connection with another agent
38
- - **ListConnectionsTool**: View existing agent connections
39
- - **ConnectionMonitorTool**: Monitor connection status changes
40
- - **ManageConnectionRequestsTool**: Handle incoming connection requests
41
- - **AcceptConnectionRequestTool**: Accept pending connection requests
42
- - **ListUnapprovedConnectionRequestsTool**: View pending requests
31
+ - **HCS-10 Agent Tools**: Complete toolkit for agent registration, discovery, and communication
32
+ - **Plugin System**: Extensible architecture for adding custom capabilities
33
+ - **LangChain Integration**: Seamless integration with LangChain for AI agent development
34
+ - **Built on Hedera Agent Kit**: Leverages the powerful Hedera Agent Kit for blockchain interactions
35
+ - **OpenConvAI Plugin Support**: Pre-built integration with the OpenConvAI standards plugin
36
+ - **TypeScript Support**: Full TypeScript support with comprehensive type definitions
37
+ - **State Management**: Built-in state management for agent operations
43
38
 
44
- ## Running Demos
39
+ ## Usage
45
40
 
46
- The Agent Kit includes demo implementations that showcase various features. Follow these steps to run them:
41
+ ### Basic Setup with LangChain
47
42
 
48
- 1. Clone the repository
43
+ ```typescript
44
+ import { HederaAgentKit } from 'hedera-agent-kit';
45
+ import {
46
+ RegisterAgentTool,
47
+ FindRegistrationsTool,
48
+ InitiateConnectionTool,
49
+ SendMessageToConnectionTool,
50
+ HCS10Builder,
51
+ OpenConvaiState
52
+ } from '@hashgraphonline/standards-agent-kit';
53
+
54
+ // Initialize HederaAgentKit
55
+ const hederaKit = new HederaAgentKit({
56
+ accountId: process.env.HEDERA_ACCOUNT_ID,
57
+ privateKey: process.env.HEDERA_PRIVATE_KEY,
58
+ network: 'testnet'
59
+ });
60
+
61
+ // Create state manager and builder
62
+ const stateManager = new OpenConvaiState();
63
+ const hcs10Builder = new HCS10Builder(hederaKit, stateManager);
64
+
65
+ // Create tools
66
+ const tools = [
67
+ new RegisterAgentTool({ hederaKit, hcs10Builder }),
68
+ new FindRegistrationsTool({ hederaKit, hcs10Builder }),
69
+ new InitiateConnectionTool({ hederaKit, hcs10Builder }),
70
+ new SendMessageToConnectionTool({ hederaKit, hcs10Builder })
71
+ ];
72
+
73
+ // Use tools with LangChain
74
+ import { ChatOpenAI } from '@langchain/openai';
75
+ import { createToolCallingAgent } from 'langchain/agents';
76
+
77
+ const llm = new ChatOpenAI({
78
+ modelName: 'gpt-4',
79
+ openAIApiKey: process.env.OPENAI_API_KEY
80
+ });
81
+
82
+ const agent = await createToolCallingAgent({
83
+ llm,
84
+ tools,
85
+ prompt: /* your prompt */
86
+ });
87
+ ```
88
+
89
+ ### Using with OpenConvAI Plugin
90
+
91
+ ```typescript
92
+ import { StandardsKit } from '@hashgraphonline/standards-agent-plugin';
93
+
94
+ // Initialize StandardsKit with OpenConvAI plugin pre-configured
95
+ const kit = new StandardsKit({
96
+ accountId: process.env.HEDERA_ACCOUNT_ID,
97
+ privateKey: process.env.HEDERA_PRIVATE_KEY,
98
+ network: 'testnet',
99
+ openAIApiKey: process.env.OPENAI_API_KEY
100
+ });
49
101
 
102
+ await kit.initialize();
103
+
104
+ // Use the conversational agent
105
+ const response = await kit.processMessage('Find all registered AI agents');
106
+ ```
107
+
108
+ ## Running Examples
109
+
110
+ 1. Clone the repository
50
111
  ```bash
51
- git clone https://github.com/hashgraph/standards-agent-kit.git
112
+ git clone https://github.com/hashgraph-online/standards-agent-kit.git
52
113
  cd standards-agent-kit
53
114
  ```
54
115
 
55
116
  2. Install dependencies
56
-
57
117
  ```bash
58
- npm install --legacy-peer-deps
118
+ pnpm install
59
119
  ```
60
120
 
61
121
  3. Set up environment variables
62
-
63
122
  ```bash
64
- cp .env.sample .env
123
+ cp .env.example .env
65
124
  ```
66
125
 
67
126
  4. Edit the `.env` file with your Hedera credentials:
68
-
69
127
  ```
70
- HEDERA_ACCOUNT_ID=0.0.xxxxxx
71
- HEDERA_PRIVATE_KEY=302e020100300506032b6570...
128
+ HEDERA_ACCOUNT_ID=0.0.12345
129
+ HEDERA_PRIVATE_KEY=your_private_key_here
72
130
  HEDERA_NETWORK=testnet
73
- REGISTRY_URL=https://moonscape.tech
74
- OPENAI_API_KEY=sk-xxxxxxxxxx # For LangChain demos
131
+ OPENAI_API_KEY=your_openai_key_here # Required for AI demos
75
132
  ```
76
133
 
77
- 5. Run the demos:
78
-
134
+ 5. Run the examples:
79
135
  ```bash
80
- # Run the CLI demo
81
- npm run cli-demo
82
-
83
- # Run the LangChain interactive demo
84
- npm run langchain-demo
85
-
86
- # Run the Standards Expert Agent
87
- npm run standards-expert
88
- ```
136
+ # Interactive CLI demo
137
+ npm run demo:cli
89
138
 
90
- ### Demo Descriptions
139
+ # LangChain integration demo
140
+ npm run demo:langchain
91
141
 
92
- #### CLI Demo
142
+ # Plugin system example
143
+ npm run demo:plugin
93
144
 
94
- The CLI demo provides an interactive menu to:
95
- - Register new agents
96
- - List managed agents
97
- - Initiate and monitor connections
98
- - Send and receive messages between agents
145
+ # OpenConvAI plugin example
146
+ npm run demo:plugin:openconvai
147
+ ```
99
148
 
100
- #### LangChain Interactive Demo
149
+ ## Available Tools
101
150
 
102
- The LangChain demo demonstrates how to:
103
- - Integrate Standards Agent Kit tools with LangChain
104
- - Create AI agents that communicate over Hedera
105
- - Process natural language requests into agent actions
106
- - Handle the full lifecycle of agent-to-agent communication
151
+ The SDK provides a comprehensive set of tools for HCS-10 agent operations:
107
152
 
108
- #### Standards Expert Agent
153
+ - **RegisterAgentTool**: Register new agents on the network
154
+ - **FindRegistrationsTool**: Search for registered agents
155
+ - **RetrieveProfileTool**: Get detailed agent profiles
156
+ - **InitiateConnectionTool**: Start connections between agents
157
+ - **ListConnectionsTool**: View active connections
158
+ - **SendMessageToConnectionTool**: Send messages to connected agents
159
+ - **CheckMessagesTool**: Retrieve messages from connections
160
+ - **ConnectionMonitorTool**: Monitor incoming connection requests
161
+ - **ManageConnectionRequestsTool**: Handle pending connections
162
+ - **AcceptConnectionRequestTool**: Accept incoming connections
163
+ - **ListUnapprovedConnectionRequestsTool**: View pending requests
109
164
 
110
- A specialized agent that runs on a small local LLM to provide expertise about Hedera Standards:
111
- - Uses Llama 3 8B or similar for inference
112
- - Answers questions about standards implementation
113
- - Provides guidance on Standards SDK and Agent Kit usage
114
- - See [Standards Expert README](examples/standards-expert/README.md) for details
165
+ ## Plugin Development
115
166
 
116
- ## Basic Usage
167
+ Create custom plugins by extending the base plugin interface:
117
168
 
118
169
  ```typescript
119
- import { initializeHCS10Client } from '@hashgraphonline/standards-agent-kit';
120
- import dotenv from 'dotenv';
121
-
122
- dotenv.config();
123
-
124
- async function setup() {
125
- const { hcs10Client, tools, stateManager } = await initializeHCS10Client({
126
- clientConfig: {
127
- operatorId: process.env.HEDERA_ACCOUNT_ID,
128
- operatorKey: process.env.HEDERA_PRIVATE_KEY,
129
- network: 'testnet',
130
- useEncryption: false
131
- },
132
- createAllTools: true,
133
- monitoringClient: true
134
- });
135
-
136
- // Access tools
137
- const { registerAgentTool, initiateConnectionTool, sendMessageTool } = tools;
170
+ import { BasePlugin } from '@hashgraphonline/standards-agent-kit';
171
+
172
+ export class MyCustomPlugin extends BasePlugin {
173
+ name = 'my-custom-plugin';
174
+
175
+ async initialize(context) {
176
+ // Initialize your plugin
177
+ }
138
178
 
139
- // Use tools as needed
140
- // ...
179
+ getTools() {
180
+ // Return your custom tools
181
+ }
141
182
  }
142
-
143
- setup();
144
183
  ```
145
184
 
146
- For detailed usage examples and API reference, please refer to the [official documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/).
185
+ ## Contributing
186
+
187
+ Please read our [Contributing Guide](CONTRIBUTING.md) before contributing to this project.
147
188
 
148
189
  ## Resources
149
190
 
150
- - [HCS Standards Documentation](https://hashgraphonline.com/docs/standards/)
191
+ - [Standards Agent Kit Documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/)
192
+ - [HCS Standards Documentation](https://hcs-improvement-proposals.pages.dev/docs/standards)
151
193
  - [Hedera Documentation](https://docs.hedera.com)
152
- - [Standards SDK](https://hashgraphonline.com/docs/libraries/standards-sdk/)
153
-
154
- ## Contributing
155
-
156
- Contributions are welcome! Please open an issue or submit a pull request.
194
+ - [GitHub Repository](https://github.com/hashgraph-online/standards-agent-kit)
157
195
 
158
196
  ## License
159
197
 
160
198
  Apache-2.0
161
199
 
162
- ## Standards Expert Agent
163
-
164
- The Standards Expert Agent is a specialized AI agent that runs on a small local LLM and can answer questions about the Hedera Standards SDK. It uses the HCS-10 protocol to communicate with clients and provides information about how to use the Standards SDK and Standards Agent Kit.
165
-
166
- ### Features
167
-
168
- - Runs on a small local LLM (Llama 3 8B or similar)
169
- - Focused knowledge on Hedera Standards SDK
170
- - Answers questions about HCS-1, HCS-2, HCS-3, etc.
171
- - Provides implementation guidance for standards
172
- - Self-contained with minimal external dependencies
173
-
174
- ### Installation
175
-
176
- ```bash
177
- # Clone the repository
178
- git clone https://github.com/hashgraph/standards-agent-kit.git
179
- cd standards-agent-kit
180
-
181
- # Install dependencies
182
- npm install
183
-
184
- # Set up the environment
185
- npx ts-node src/agents/standards-expert/cli.ts setup
186
-
187
- # Download a Llama 3 model in GGUF format
188
- mkdir -p models
189
- # Download the model from https://huggingface.co/TheBloke/Llama-3-8B-Instruct-GGUF
190
- # and place it in the models directory
191
-
192
- # Process documentation (optional)
193
- npx ts-node src/agents/standards-expert/cli.ts process-docs -d /path/to/docs
194
-
195
- # Start the agent
196
- npx ts-node src/agents/standards-expert/cli.ts start
197
- ```
198
-
199
- ### Using with PM2
200
-
201
- For production deployment, you can use PM2 to keep the agent running:
202
-
203
- ```bash
204
- # Generate PM2 ecosystem file
205
- npx ts-node src/agents/standards-expert/cli.ts generate-pm2
206
-
207
- # Install PM2 globally
208
- npm install -g pm2
209
-
210
- # Start with PM2
211
- pm2 start ecosystem.config.js
212
- ```
213
-
214
- ### Environment Variables
215
-
216
- Create a `.env` file with the following variables:
217
-
218
- ```
219
- # Hedera Account Information
220
- HEDERA_ACCOUNT_ID=0.0.123456
221
- HEDERA_PRIVATE_KEY=302e...
222
-
223
- # Agent HCS Topics
224
- AGENT_INBOUND_TOPIC_ID=0.0.123456
225
- AGENT_OUTBOUND_TOPIC_ID=0.0.123457
226
-
227
- # Vector Store Configuration
228
- OPENAI_API_KEY=sk-...
229
-
230
- # Model Configuration
231
- LLAMA_MODEL_PATH=./models/llama-3-8b-instruct.Q4_K_M.gguf
232
- ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/standards-agent-kit.cjs",