@hashgraphonline/standards-agent-kit 0.0.13 → 0.0.16
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 +94 -136
- package/dist/index.es.js +8446 -6553
- package/dist/index.es.js.map +1 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/init.d.ts +45 -9
- package/dist/src/state/index.d.ts +1 -0
- package/dist/src/state/open-convai-state.d.ts +17 -97
- package/dist/src/state/state-types.d.ts +143 -0
- package/dist/src/tools/AcceptConnectionRequestTool.d.ts +1 -1
- package/dist/src/tools/CheckMessagesTool.d.ts +1 -1
- package/dist/src/tools/ConnectionMonitorTool.d.ts +1 -1
- package/dist/src/tools/ConnectionTool.d.ts +1 -1
- package/dist/src/tools/InitiateConnectionTool.d.ts +1 -1
- package/dist/src/tools/ListConnectionsTool.d.ts +1 -1
- package/dist/src/tools/ListUnapprovedConnectionRequestsTool.d.ts +1 -1
- package/dist/src/tools/ManageConnectionRequestsTool.d.ts +2 -2
- package/dist/src/tools/RegisterAgentTool.d.ts +59 -5
- package/dist/src/tools/RetrieveProfileTool.d.ts +34 -0
- package/dist/src/tools/SendMessageToConnectionTool.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -6,11 +6,17 @@
|
|
|
6
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
8
|
|
|
9
|
-
|
|
9
|
+
## Quick Start
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install @hashgraphonline/standards-agent-kit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
For complete documentation, examples, and API references, visit:
|
|
18
|
+
|
|
19
|
+
- [Standards Agent Kit Documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/)
|
|
14
20
|
|
|
15
21
|
## Features
|
|
16
22
|
|
|
@@ -18,174 +24,126 @@ This kit provides:
|
|
|
18
24
|
- **Agent Lifecycle Management:** Create, register, and manage HCS-10 agents on Hedera.
|
|
19
25
|
- **Trustless Communication:** Facilitates secure peer-to-peer communication setup between agents via Hedera Consensus Service (HCS).
|
|
20
26
|
- **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
|
|
27
|
+
- **Message Handling:** Send and receive messages over HCS, including support for large messages via HCS-3 inscriptions.
|
|
22
28
|
- **Connection Monitoring:** Automatically monitor inbound topics for connection requests and handle them.
|
|
23
29
|
- **Configurable:** Set Hedera network, credentials, and registry via environment variables.
|
|
24
30
|
|
|
25
|
-
##
|
|
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
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
## Running Demos
|
|
45
|
+
|
|
46
|
+
The Agent Kit includes demo implementations that showcase various features. Follow these steps to run them:
|
|
47
|
+
|
|
48
|
+
1. Clone the repository
|
|
31
49
|
|
|
32
|
-
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/hashgraph/standards-agent-kit.git
|
|
52
|
+
cd standards-agent-kit
|
|
53
|
+
```
|
|
33
54
|
|
|
34
|
-
|
|
55
|
+
2. Install dependencies
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
57
|
+
```bash
|
|
58
|
+
npm install --legacy-peer-deps
|
|
59
|
+
```
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
This project has known peer dependency conflicts between different versions of LangChain packages. Use the `--legacy-peer-deps` flag to install:
|
|
43
|
-
```bash
|
|
44
|
-
npm install --legacy-peer-deps
|
|
45
|
-
```
|
|
61
|
+
3. Set up environment variables
|
|
46
62
|
|
|
47
|
-
|
|
63
|
+
```bash
|
|
64
|
+
cp .env.sample .env
|
|
65
|
+
```
|
|
48
66
|
|
|
49
|
-
|
|
67
|
+
4. Edit the `.env` file with your Hedera credentials:
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
```
|
|
70
|
+
HEDERA_ACCOUNT_ID=0.0.xxxxxx
|
|
71
|
+
HEDERA_PRIVATE_KEY=302e020100300506032b6570...
|
|
72
|
+
HEDERA_NETWORK=testnet
|
|
73
|
+
REGISTRY_URL=https://moonscape.tech
|
|
74
|
+
OPENAI_API_KEY=sk-xxxxxxxxxx # For LangChain demos
|
|
75
|
+
```
|
|
54
76
|
|
|
55
|
-
|
|
77
|
+
5. Run the demos:
|
|
56
78
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
HEDERA_PRIVATE_KEY=302e020100300506032b6570...
|
|
79
|
+
```bash
|
|
80
|
+
# Run the CLI demo
|
|
81
|
+
npm run cli-demo
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
# Run the LangChain interactive demo
|
|
84
|
+
npm run langchain-demo
|
|
85
|
+
```
|
|
64
86
|
|
|
65
|
-
|
|
66
|
-
REGISTRY_URL=https://moonscape.tech
|
|
87
|
+
### Demo Descriptions
|
|
67
88
|
|
|
68
|
-
|
|
69
|
-
OPENAI_API_KEY=sk-xxxxxxxxxx
|
|
89
|
+
#### CLI Demo
|
|
70
90
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ALICE_OUTBOUND_TOPIC_ID=
|
|
77
|
-
BOB_ACCOUNT_ID=
|
|
78
|
-
BOB_PRIVATE_KEY=
|
|
79
|
-
BOB_INBOUND_TOPIC_ID=
|
|
80
|
-
BOB_OUTBOUND_TOPIC_ID=
|
|
81
|
-
CONNECTION_TOPIC_ID=
|
|
82
|
-
OPERATOR_ID=
|
|
83
|
-
```
|
|
91
|
+
The CLI demo provides an interactive menu to:
|
|
92
|
+
- Register new agents
|
|
93
|
+
- List managed agents
|
|
94
|
+
- Initiate and monitor connections
|
|
95
|
+
- Send and receive messages between agents
|
|
84
96
|
|
|
85
|
-
|
|
97
|
+
#### LangChain Interactive Demo
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
The LangChain demo demonstrates how to:
|
|
100
|
+
- Integrate Standards Agent Kit tools with LangChain
|
|
101
|
+
- Create AI agents that communicate over Hedera
|
|
102
|
+
- Process natural language requests into agent actions
|
|
103
|
+
- Handle the full lifecycle of agent-to-agent communication
|
|
88
104
|
|
|
89
|
-
|
|
105
|
+
## Basic Usage
|
|
90
106
|
|
|
91
107
|
```typescript
|
|
92
|
-
import { initializeHCS10Client } from '
|
|
108
|
+
import { initializeHCS10Client } from '@hashgraphonline/standards-agent-kit';
|
|
93
109
|
import dotenv from 'dotenv';
|
|
94
110
|
|
|
95
|
-
dotenv.config();
|
|
111
|
+
dotenv.config();
|
|
96
112
|
|
|
97
113
|
async function setup() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// console.log(registrationResult);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
console.error('Initialization failed:', error);
|
|
117
|
-
}
|
|
114
|
+
const { hcs10Client, tools, stateManager } = await initializeHCS10Client({
|
|
115
|
+
clientConfig: {
|
|
116
|
+
operatorId: process.env.HEDERA_ACCOUNT_ID,
|
|
117
|
+
operatorKey: process.env.HEDERA_PRIVATE_KEY,
|
|
118
|
+
network: 'testnet',
|
|
119
|
+
useEncryption: false
|
|
120
|
+
},
|
|
121
|
+
createAllTools: true,
|
|
122
|
+
monitoringClient: true
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Access tools
|
|
126
|
+
const { registerAgentTool, initiateConnectionTool, sendMessageTool } = tools;
|
|
127
|
+
|
|
128
|
+
// Use tools as needed
|
|
129
|
+
// ...
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
setup();
|
|
121
133
|
```
|
|
122
134
|
|
|
123
|
-
|
|
124
|
-
|
|
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.
|
|
133
|
-
|
|
134
|
-
## Running Demos
|
|
135
|
-
|
|
136
|
-
Make sure you have configured your `.env` file correctly.
|
|
137
|
-
|
|
138
|
-
1. **Build the project:**
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
npm run build
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
_(Note: `npm install` also runs the build via the `prepare` script)_
|
|
135
|
+
For detailed usage examples and API reference, please refer to the [official documentation](https://hashgraphonline.com/docs/libraries/standards-agent-kit/).
|
|
145
136
|
|
|
146
|
-
|
|
147
|
-
This demo provides an interactive menu to register an agent and monitor its connections.
|
|
137
|
+
## Resources
|
|
148
138
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
3. **Run the LangChain Interactive Demo:**
|
|
154
|
-
This demo uses LangChain to create an agent that can use the HCS-10 tools. Requires `OPENAI_API_KEY` in `.env`.
|
|
155
|
-
```bash
|
|
156
|
-
npm run langchain-demo
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Project Structure
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
.
|
|
163
|
-
├── dist/ # Compiled JavaScript output
|
|
164
|
-
├── examples/ # Demo usage scripts
|
|
165
|
-
│ ├── cli-demo.ts # Interactive CLI demo
|
|
166
|
-
│ ├── langchain-demo.ts # LangChain agent interactive demo
|
|
167
|
-
│ └── ...
|
|
168
|
-
├── src/ # Source code
|
|
169
|
-
│ ├── hcs10/ # HCS-10 client and types
|
|
170
|
-
│ │ ├── HCS10Client.ts # Main client wrapper
|
|
171
|
-
│ │ └── types.ts # Core data types
|
|
172
|
-
│ ├── tools/ # LangChain tools
|
|
173
|
-
│ │ ├── RegisterAgentTool.ts
|
|
174
|
-
│ │ ├── SendMessageTool.ts
|
|
175
|
-
│ │ └── ConnectionTool.ts
|
|
176
|
-
│ ├── utils/ # Utility functions (logging, Hedera client setup)
|
|
177
|
-
│ └── index.ts # Main entry point, initializes client/tools
|
|
178
|
-
├── tests/ # Unit tests
|
|
179
|
-
├── .env.sample # Sample environment file
|
|
180
|
-
├── package.json # Project dependencies and scripts
|
|
181
|
-
├── tsconfig.json # TypeScript configuration
|
|
182
|
-
└── README.md # This file
|
|
183
|
-
```
|
|
139
|
+
- [HCS Standards Documentation](https://hashgraphonline.com/docs/standards/)
|
|
140
|
+
- [Hedera Documentation](https://docs.hedera.com)
|
|
141
|
+
- [Standards SDK](https://hashgraphonline.com/docs/libraries/standards-sdk/)
|
|
184
142
|
|
|
185
143
|
## Contributing
|
|
186
144
|
|
|
187
|
-
Contributions are welcome! Please open an issue or submit a pull request.
|
|
145
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
188
146
|
|
|
189
147
|
## License
|
|
190
148
|
|
|
191
|
-
|
|
149
|
+
Apache-2.0
|