@hashgraphonline/standards-agent-kit 0.0.3 → 0.0.5
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.
- package/README.md +56 -48
- package/dist/index.es.js +20420 -70990
- package/dist/index.es.js.map +1 -1
- package/dist/src/hcs10/HCS10Client.d.ts +19 -8
- package/dist/src/index.d.ts +2 -2
- package/dist/src/{demo-state.d.ts → open-convai-state.d.ts} +4 -3
- package/dist/src/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/src/tools/ConnectionTool.d.ts +14 -16
- package/dist/src/tools/InitiateConnectionTool.d.ts +8 -7
- package/dist/src/tools/ListConnectionsTool.d.ts +5 -5
- package/dist/src/tools/RegisterAgentTool.d.ts +3 -3
- package/dist/src/tools/SendMessageToConnectionTool.d.ts +5 -4
- package/dist/src/tools/SendMessageTool.d.ts +1 -0
- package/package.json +6 -4
- package/dist/examples/cli-demo.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
# Hashgraph Online
|
|
1
|
+
# Hashgraph Online Standards AI Agent Kit
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# **_This SDK is currently in alpha, use at your own risk._**
|
|
6
|
+
|
|
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/).
|
|
6
8
|
|
|
7
9
|
This kit provides:
|
|
10
|
+
|
|
8
11
|
- A client (`HCS10Client`) simplifying interactions with the HCS-10 standard via the `@hashgraphonline/standards-sdk`.
|
|
9
12
|
- LangChain Tools (`RegisterAgentTool`, `SendMessageTool`, `ConnectionTool`) for easy integration into LangChain agents.
|
|
10
13
|
- Example demos showcasing agent registration, connection monitoring, and messaging.
|
|
11
14
|
|
|
12
15
|
## Features
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
- **HCS-10 Compliance:** Built on top of the official `@hashgraphonline/standards-sdk` for standard compliance.
|
|
18
|
+
- **Agent Lifecycle Management:** Create, register, and manage HCS-10 agents on Hedera.
|
|
19
|
+
- **Trustless Communication:** Facilitates secure peer-to-peer communication setup between agents via Hedera Consensus Service (HCS).
|
|
20
|
+
- **LangChain Integration:** Provides ready-to-use LangChain `StructuredTool`s for common agent actions.
|
|
21
|
+
- **Message Handling:** Send and receive messages over HCS, including support for large messages via HCS-3 inscriptions (handled by the underlying SDK).
|
|
22
|
+
- **Connection Monitoring:** Automatically monitor inbound topics for connection requests and handle them.
|
|
23
|
+
- **Configurable:** Set Hedera network, credentials, and registry via environment variables.
|
|
21
24
|
|
|
22
25
|
## Prerequisites
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
- **Node.js:** Version 18 or higher recommended.
|
|
28
|
+
- **npm:** Node Package Manager (usually comes with Node.js).
|
|
29
|
+
- **Hedera Testnet Account:** You need an Account ID and Private Key for the Hedera Testnet. You can get one from [Hedera Portal](https://portal.hedera.com/).
|
|
30
|
+
- **(Optional) OpenAI API Key:** Required for running the LangChain agent demos (`examples/interactive-demo.ts`).
|
|
28
31
|
|
|
29
32
|
## Installation
|
|
30
33
|
|
|
31
34
|
1. **Clone the repository:**
|
|
35
|
+
|
|
32
36
|
```bash
|
|
33
37
|
git clone <your-repository-url>
|
|
34
38
|
cd hashgraph-online-agent-kit
|
|
@@ -43,11 +47,13 @@ This kit provides:
|
|
|
43
47
|
## Configuration
|
|
44
48
|
|
|
45
49
|
1. **Create a `.env` file:** Copy the example file:
|
|
50
|
+
|
|
46
51
|
```bash
|
|
47
52
|
cp .env.sample .env
|
|
48
53
|
```
|
|
49
54
|
|
|
50
55
|
2. **Edit `.env`:** Fill in your Hedera credentials and optionally other settings:
|
|
56
|
+
|
|
51
57
|
```dotenv
|
|
52
58
|
# Hedera Credentials (Required)
|
|
53
59
|
HEDERA_ACCOUNT_ID=0.0.xxxxxx
|
|
@@ -83,33 +89,32 @@ This kit provides:
|
|
|
83
89
|
The primary way to use the kit is by initializing the client and tools using the `initializeHCS10Client` function from the main entry point (`src/index.ts`). This requires your operator account ID and private key to be set in the environment variables.
|
|
84
90
|
|
|
85
91
|
```typescript
|
|
86
|
-
import { initializeHCS10Client } from
|
|
87
|
-
import dotenv from
|
|
92
|
+
import { initializeHCS10Client } from 'hashgraph-online-agent-kit'; // Adjust path based on usage
|
|
93
|
+
import dotenv from 'dotenv';
|
|
88
94
|
|
|
89
95
|
dotenv.config(); // Load .env variables
|
|
90
96
|
|
|
91
97
|
async function setup() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
98
|
+
try {
|
|
99
|
+
const { hcs10Client, tools } = await initializeHCS10Client({
|
|
100
|
+
// Options are optional
|
|
101
|
+
useEncryption: false, // Defaults to false
|
|
102
|
+
registryUrl: process.env.REGISTRY_URL, // Defaults to SDK's default
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log('HCS10 Client and Tools Initialized!');
|
|
106
|
+
|
|
107
|
+
// Now you can use hcs10Client directly or use the tools
|
|
108
|
+
const registerTool = tools.registerAgentTool;
|
|
109
|
+
const sendMessageTool = tools.sendMessageTool;
|
|
110
|
+
const connectionTool = tools.connectionTool;
|
|
111
|
+
|
|
112
|
+
// Example: Register an agent using the tool
|
|
113
|
+
// const registrationResult = await registerTool.call({ name: "MyDemoAgent" });
|
|
114
|
+
// console.log(registrationResult);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error('Initialization failed:', error);
|
|
117
|
+
}
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
setup();
|
|
@@ -117,27 +122,30 @@ setup();
|
|
|
117
122
|
|
|
118
123
|
### Core Components
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
- **`HCS10Client` (`src/hcs10/HCS10Client.ts`):**
|
|
126
|
+
- Wraps the `@hashgraphonline/standards-sdk` HCS10Client.
|
|
127
|
+
- Provides methods like `createAndRegisterAgent`, `sendMessage`, `getMessages`, `handleConnectionRequest`, `getMessageContent`.
|
|
128
|
+
- Initialized via the static async factory `HCS10Client.create(operatorId, privateKey, network, options)`.
|
|
129
|
+
- **Tools (`src/tools/`):**
|
|
130
|
+
- `RegisterAgentTool`: LangChain tool to create and register a new HCS-10 agent.
|
|
131
|
+
- `SendMessageTool`: LangChain tool to send a message to a topic and optionally monitor for a response.
|
|
132
|
+
- `ConnectionTool`: LangChain tool to start monitoring an agent's inbound topic for connection requests and handle them automatically in the background.
|
|
128
133
|
|
|
129
134
|
## Running Demos
|
|
130
135
|
|
|
131
136
|
Make sure you have configured your `.env` file correctly.
|
|
132
137
|
|
|
133
138
|
1. **Build the project:**
|
|
139
|
+
|
|
134
140
|
```bash
|
|
135
141
|
npm run build
|
|
136
142
|
```
|
|
137
|
-
|
|
143
|
+
|
|
144
|
+
_(Note: `npm install` also runs the build via the `prepare` script)_
|
|
138
145
|
|
|
139
146
|
2. **Run the CLI Demo:**
|
|
140
147
|
This demo provides an interactive menu to register an agent and monitor its connections.
|
|
148
|
+
|
|
141
149
|
```bash
|
|
142
150
|
npm run cli-demo
|
|
143
151
|
```
|
|
@@ -145,7 +153,7 @@ Make sure you have configured your `.env` file correctly.
|
|
|
145
153
|
3. **Run the LangChain Interactive Demo:**
|
|
146
154
|
This demo uses LangChain to create an agent that can use the HCS-10 tools. Requires `OPENAI_API_KEY` in `.env`.
|
|
147
155
|
```bash
|
|
148
|
-
npm run
|
|
156
|
+
npm run langchain-demo
|
|
149
157
|
```
|
|
150
158
|
|
|
151
159
|
## Project Structure
|
|
@@ -155,7 +163,7 @@ Make sure you have configured your `.env` file correctly.
|
|
|
155
163
|
├── dist/ # Compiled JavaScript output
|
|
156
164
|
├── examples/ # Demo usage scripts
|
|
157
165
|
│ ├── cli-demo.ts # Interactive CLI demo
|
|
158
|
-
│ ├──
|
|
166
|
+
│ ├── langchain-demo.ts # LangChain agent interactive demo
|
|
159
167
|
│ └── ...
|
|
160
168
|
├── src/ # Source code
|
|
161
169
|
│ ├── hcs10/ # HCS-10 client and types
|
|
@@ -180,4 +188,4 @@ Contributions are welcome! Please open an issue or submit a pull request. (Add m
|
|
|
180
188
|
|
|
181
189
|
## License
|
|
182
190
|
|
|
183
|
-
This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.
|
|
191
|
+
This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.
|