@hashgraphonline/standards-agent-kit 0.0.13 → 0.0.15

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 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
- This kit provides:
9
+ ## Quick Start
10
10
 
11
- - A client (`HCS10Client`) simplifying interactions with the HCS-10 standard via the `@hashgraphonline/standards-sdk`.
12
- - LangChain Tools (`RegisterAgentTool`, `SendMessageTool`, `ConnectionTool`) for easy integration into LangChain agents.
13
- - Example demos showcasing agent registration, connection monitoring, and messaging.
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 (handled by the underlying SDK).
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
- ## Prerequisites
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
- - **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`).
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
- ## Installation
50
+ ```bash
51
+ git clone https://github.com/hashgraph/standards-agent-kit.git
52
+ cd standards-agent-kit
53
+ ```
33
54
 
34
- 1. **Clone the repository:**
55
+ 2. Install dependencies
35
56
 
36
- ```bash
37
- git clone <your-repository-url>
38
- cd hashgraph-online-agent-kit
39
- ```
57
+ ```bash
58
+ npm install --legacy-peer-deps
59
+ ```
40
60
 
41
- 2. **Install dependencies:**
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
- ## Configuration
63
+ ```bash
64
+ cp .env.sample .env
65
+ ```
48
66
 
49
- 1. **Create a `.env` file:** Copy the example file:
67
+ 4. Edit the `.env` file with your Hedera credentials:
50
68
 
51
- ```bash
52
- cp .env.sample .env
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
- 2. **Edit `.env`:** Fill in your Hedera credentials and optionally other settings:
77
+ 5. Run the demos:
56
78
 
57
- ```dotenv
58
- # Hedera Credentials (Required)
59
- HEDERA_ACCOUNT_ID=0.0.xxxxxx
60
- HEDERA_PRIVATE_KEY=302e020100300506032b6570...
79
+ ```bash
80
+ # Run the CLI demo
81
+ npm run cli-demo
61
82
 
62
- # Hedera Network (Optional - defaults to 'testnet')
63
- HEDERA_NETWORK=testnet
83
+ # Run the LangChain interactive demo
84
+ npm run langchain-demo
85
+ ```
64
86
 
65
- # HCS-10 Registry URL (Optional - defaults to SDK's default https://moonscape.tech)
66
- REGISTRY_URL=https://moonscape.tech
87
+ ### Demo Descriptions
67
88
 
68
- # OpenAI API Key (Optional - needed for LangChain demos)
69
- OPENAI_API_KEY=sk-xxxxxxxxxx
89
+ #### CLI Demo
70
90
 
71
- # --- Agent Specific Variables (Optional - used/set by demos) ---
72
- # These might be populated automatically by demos like cli-demo
73
- ALICE_ACCOUNT_ID=
74
- ALICE_PRIVATE_KEY=
75
- ALICE_INBOUND_TOPIC_ID=
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
- ## Usage
97
+ #### LangChain Interactive Demo
86
98
 
87
- ### Initialization
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
- 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.
105
+ ## Basic Usage
90
106
 
91
107
  ```typescript
92
- import { initializeHCS10Client } from 'hashgraph-online-agent-kit'; // Adjust path based on usage
108
+ import { initializeHCS10Client } from '@hashgraphonline/standards-agent-kit';
93
109
  import dotenv from 'dotenv';
94
110
 
95
- dotenv.config(); // Load .env variables
111
+ dotenv.config();
96
112
 
97
113
  async function setup() {
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
- }
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
- ### Core Components
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
- 2. **Run the CLI Demo:**
147
- This demo provides an interactive menu to register an agent and monitor its connections.
137
+ ## Resources
148
138
 
149
- ```bash
150
- npm run cli-demo
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. (Add more specific guidelines if needed).
145
+ Contributions are welcome! Please open an issue or submit a pull request.
188
146
 
189
147
  ## License
190
148
 
191
- This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.
149
+ Apache-2.0