@hashgraphonline/standards-agent-kit 0.0.3 → 0.0.4

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
@@ -1,34 +1,38 @@
1
- # Hashgraph Online Stnadards AI Agent Kit
1
+ # Hashgraph Online Standards AI Agent Kit
2
2
 
3
3
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4
4
 
5
- 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://hcs-improvement-proposals.pages.dev/standards/hcs-10).
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
- * **HCS-10 Compliance:** Built on top of the official `@hashgraphonline/standards-sdk` for standard compliance.
15
- * **Agent Lifecycle Management:** Create, register, and manage HCS-10 agents on Hedera.
16
- * **Trustless Communication:** Facilitates secure peer-to-peer communication setup between agents via Hedera Consensus Service (HCS).
17
- * **LangChain Integration:** Provides ready-to-use LangChain `StructuredTool`s for common agent actions.
18
- * **Message Handling:** Send and receive messages over HCS, including support for large messages via HCS-3 inscriptions (handled by the underlying SDK).
19
- * **Connection Monitoring:** Automatically monitor inbound topics for connection requests and handle them.
20
- * **Configurable:** Set Hedera network, credentials, and registry via environment variables.
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
- * **Node.js:** Version 18 or higher recommended.
25
- * **npm:** Node Package Manager (usually comes with Node.js).
26
- * **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/).
27
- * **(Optional) OpenAI API Key:** Required for running the LangChain agent demos (`examples/interactive-demo.ts`).
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 "hashgraph-online-agent-kit"; // Adjust path based on usage
87
- import dotenv from "dotenv";
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
- try {
93
- const { hcs10Client, tools } = await initializeHCS10Client({
94
- // Options are optional
95
- useEncryption: false, // Defaults to false
96
- registryUrl: process.env.REGISTRY_URL // Defaults to SDK's default
97
- });
98
-
99
- console.log("HCS10 Client and Tools Initialized!");
100
-
101
- // Now you can use hcs10Client directly or use the tools
102
- const registerTool = tools.registerAgentTool;
103
- const sendMessageTool = tools.sendMessageTool;
104
- const connectionTool = tools.connectionTool;
105
-
106
- // Example: Register an agent using the tool
107
- // const registrationResult = await registerTool.call({ name: "MyDemoAgent" });
108
- // console.log(registrationResult);
109
-
110
- } catch (error) {
111
- console.error("Initialization failed:", error);
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
- * **`HCS10Client` (`src/hcs10/HCS10Client.ts`):**
121
- * Wraps the `@hashgraphonline/standards-sdk` HCS10Client.
122
- * Provides methods like `createAndRegisterAgent`, `sendMessage`, `getMessages`, `handleConnectionRequest`, `getMessageContent`.
123
- * Initialized via the static async factory `HCS10Client.create(operatorId, privateKey, network, options)`.
124
- * **Tools (`src/tools/`):**
125
- * `RegisterAgentTool`: LangChain tool to create and register a new HCS-10 agent.
126
- * `SendMessageTool`: LangChain tool to send a message to a topic and optionally monitor for a response.
127
- * `ConnectionTool`: LangChain tool to start monitoring an agent's inbound topic for connection requests and handle them automatically in the background.
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
- *(Note: `npm install` also runs the build via the `prepare` script)*
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 interactive
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
- │ ├── interactive-demo.ts # LangChain agent interactive demo
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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { HCS10Client, AgentBuilder, Logger } from '@hashgraphonline/standards-sdk';
2
+ export declare const MIN_REQUIRED_USD = 2;
3
+ export declare const MIN_REQUIRED_HBAR_USD = 10;
4
+ export declare const ENV_FILE_PATH: string;
5
+ export interface AgentData {
6
+ accountId: string;
7
+ operatorId: string;
8
+ inboundTopicId: string;
9
+ outboundTopicId: string;
10
+ client: HCS10Client;
11
+ }
12
+ export interface RegistrationProgressData {
13
+ registered: boolean;
14
+ accountId?: string;
15
+ privateKey?: string;
16
+ publicKey?: string;
17
+ inboundTopicId?: string;
18
+ outboundTopicId?: string;
19
+ }
20
+ export declare function ensureAgentHasEnoughHbar(logger: Logger, baseClient: HCS10Client, accountId: string, agentName: string): Promise<void>;
21
+ export declare function getAgentFromEnv(logger: Logger, baseClient: HCS10Client, agentName: string, envPrefix: string): Promise<AgentData | null>;
22
+ export declare function createAgent(logger: Logger, baseClient: HCS10Client, agentName: string, agentBuilder: AgentBuilder, envPrefix: string): Promise<AgentData | null>;
23
+ export declare function updateEnvFile(envFilePath: string, variables: Record<string, string>): Promise<void>;
24
+ export declare function createBobBuilder(pfpBuffer?: Buffer): any;
25
+ export declare function getOrCreateBob(logger: Logger, baseClient: HCS10Client): Promise<AgentData | null>;
26
+ export declare function getOrCreateAlice(logger: Logger, baseClient: HCS10Client): Promise<AgentData | null>;