@hashgraphonline/conversational-agent 0.0.1 → 0.0.3
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 +127 -38
- package/dist/cjs/config/system-message.d.ts +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index5.js.map +1 -1
- package/dist/esm/index6.js +2 -2
- package/dist/esm/index6.js.map +1 -1
- package/dist/types/config/system-message.d.ts +1 -1
- package/package.json +24 -22
- package/src/config/system-message.ts +1 -1
- package/src/conversational-agent.ts +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Hashgraph Online Conversational Agent
|
|
2
2
|
|
|
3
3
|
|  | A conversational AI agent that implements Hashgraph Consensus Standards (HCS) for agent communication, registry management, and content inscription on the Hedera network.<br><br>This package is built and maintained by [Hashgraph Online](https://hashgraphonline.com), a consortium of leading Hashgraph organizations within the Hedera ecosystem.<br><br>[📚 Conversational Agent Documentation](https://hashgraphonline.com/docs/libraries/conversational-agent/)<br>[📖 HCS Standards Documentation](https://hcs-improvement-proposals.pages.dev/docs/standards) |
|
|
4
|
-
|
|
|
4
|
+
| :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
5
|
+
|
|
6
|
+

|
|
5
7
|
|
|
6
8
|
## Overview
|
|
7
9
|
|
|
8
|
-
The Hashgraph Online Conversational Agent provides a comprehensive AI agent implementation that supports:
|
|
10
|
+
The Hashgraph Online Conversational Agent provides a comprehensive AI agent implementation that supports all tools from the `hedera-agent-kit` v2 package and the following HCS standards:
|
|
9
11
|
|
|
10
12
|
- **HCS-10**: AI Agent Communication standard for trustless peer-to-peer messaging
|
|
11
13
|
- **HCS-2**: Registry management for decentralized data storage
|
|
@@ -37,7 +39,7 @@ const agent = new ConversationalAgent({
|
|
|
37
39
|
network: 'testnet',
|
|
38
40
|
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
39
41
|
openAIModelName: 'gpt-4o',
|
|
40
|
-
verbose: true
|
|
42
|
+
verbose: true,
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
// Initialize (automatically detects key type)
|
|
@@ -48,9 +50,85 @@ const response = await agent.processMessage(
|
|
|
48
50
|
'Register me as an AI agent with the name TestBot, a random unique alias, and description "A test bot"'
|
|
49
51
|
);
|
|
50
52
|
|
|
53
|
+
// Transfer HBAR
|
|
54
|
+
const transferResponse = await agent.processMessage(
|
|
55
|
+
'I want to transfer 1 HBAR to the account 0.0.800'
|
|
56
|
+
);
|
|
57
|
+
|
|
51
58
|
console.log(response.response);
|
|
59
|
+
|
|
60
|
+
// Or use returnBytes mode for external signing
|
|
61
|
+
const bytesAgent = new ConversationalAgent({
|
|
62
|
+
accountId: process.env.HEDERA_ACCOUNT_ID!,
|
|
63
|
+
privateKey: process.env.HEDERA_PRIVATE_KEY!,
|
|
64
|
+
network: 'testnet',
|
|
65
|
+
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
66
|
+
operationalMode: 'returnBytes',
|
|
67
|
+
userAccountId: '0.0.12345',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await bytesAgent.initialize();
|
|
71
|
+
|
|
72
|
+
const bytesResponse = await bytesAgent.processMessage(
|
|
73
|
+
'Transfer 5 HBAR to 0.0.98765'
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (bytesResponse.transactionBytes) {
|
|
77
|
+
console.log('Transaction bytes:', bytesResponse.transactionBytes);
|
|
78
|
+
}
|
|
52
79
|
```
|
|
53
80
|
|
|
81
|
+
### Using returnBytes Mode
|
|
82
|
+
|
|
83
|
+
The agent can be configured to return transaction bytes instead of executing them directly. This is useful when you want to review or sign transactions externally. Here's how to execute the transaction after getting the bytes:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { ConversationalAgent } from '@hashgraphonline/conversational-agent';
|
|
87
|
+
import { Client, Transaction, PrivateKey } from '@hashgraph/sdk';
|
|
88
|
+
|
|
89
|
+
const agent = new ConversationalAgent({
|
|
90
|
+
accountId: process.env.HEDERA_ACCOUNT_ID!,
|
|
91
|
+
privateKey: process.env.HEDERA_PRIVATE_KEY!,
|
|
92
|
+
network: 'testnet',
|
|
93
|
+
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
94
|
+
operationalMode: 'returnBytes', // Return transaction bytes instead of executing
|
|
95
|
+
userAccountId: '0.0.12345', // The account that will sign the transaction
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await agent.initialize();
|
|
99
|
+
|
|
100
|
+
// The agent will return transaction bytes for operations
|
|
101
|
+
const response = await agent.processMessage('Transfer 5 HBAR to 0.0.98765');
|
|
102
|
+
|
|
103
|
+
if (response.transactionBytes) {
|
|
104
|
+
// Decode the transaction bytes
|
|
105
|
+
const transaction = Transaction.fromBytes(
|
|
106
|
+
Buffer.from(response.transactionBytes, 'base64')
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// Sign the transaction with your private key
|
|
110
|
+
const privateKey = PrivateKey.fromString(process.env.USER_PRIVATE_KEY!);
|
|
111
|
+
const signedTransaction = transaction.sign(privateKey);
|
|
112
|
+
|
|
113
|
+
// Submit to the Hedera network
|
|
114
|
+
const client = Client.forTestnet();
|
|
115
|
+
client.setOperator('0.0.12345', privateKey);
|
|
116
|
+
|
|
117
|
+
const txResponse = await signedTransaction.execute(client);
|
|
118
|
+
const receipt = await txResponse.getReceipt(client);
|
|
119
|
+
|
|
120
|
+
console.log('Transaction status:', receipt.status.toString());
|
|
121
|
+
console.log('Transaction ID:', txResponse.transactionId.toString());
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
When using `returnBytes` mode:
|
|
126
|
+
|
|
127
|
+
- The agent prepares transactions but doesn't execute them
|
|
128
|
+
- Transaction bytes are returned as base64-encoded strings
|
|
129
|
+
- You can decode, sign, and submit the transaction using the Hedera SDK
|
|
130
|
+
- This mode is ideal for wallet integrations, multi-signature scenarios, and when you need transaction review before execution
|
|
131
|
+
|
|
54
132
|
## Features
|
|
55
133
|
|
|
56
134
|
- **Automatic Key Detection**: Smart detection of ED25519 and ECDSA key types via mirror node
|
|
@@ -62,9 +140,10 @@ console.log(response.response);
|
|
|
62
140
|
|
|
63
141
|
## Available Tools
|
|
64
142
|
|
|
65
|
-
The Conversational Agent includes all tools from the
|
|
143
|
+
The Conversational Agent includes all tools from the `hedera-agent-kit` v2 package, providing comprehensive access to Hedera network functionality:
|
|
66
144
|
|
|
67
145
|
### Core Hedera Tools (from hedera-agent-kit)
|
|
146
|
+
|
|
68
147
|
- **Account Management**: Create accounts, transfer HBAR, manage allowances, get account info
|
|
69
148
|
- **Token Service (HTS)**: Create tokens/NFTs, mint, burn, transfer, manage token properties
|
|
70
149
|
- **Smart Contract Service**: Deploy contracts, execute functions, query contract state
|
|
@@ -73,6 +152,7 @@ The Conversational Agent includes all tools from the `@hashgraphonline/hedera-ag
|
|
|
73
152
|
- **Network Queries**: Get network info, HBAR price, transaction details
|
|
74
153
|
|
|
75
154
|
### HCS-10 Agent Communication Tools
|
|
155
|
+
|
|
76
156
|
- **RegisterAgentTool**: Register new agents with capabilities and tags
|
|
77
157
|
- **FindRegistrationsTool**: Search for agents by account ID or tags
|
|
78
158
|
- **RetrieveProfileTool**: Get detailed agent profiles
|
|
@@ -86,6 +166,7 @@ The Conversational Agent includes all tools from the `@hashgraphonline/hedera-ag
|
|
|
86
166
|
- **CheckMessagesTool**: Retrieve messages from connections
|
|
87
167
|
|
|
88
168
|
### HCS-2 Registry Tools
|
|
169
|
+
|
|
89
170
|
- **CreateRegistryTool**: Create new HCS-2 registry topics
|
|
90
171
|
- **RegisterEntryTool**: Add entries to existing registries
|
|
91
172
|
- **UpdateEntryTool**: Modify existing entries in registries
|
|
@@ -94,6 +175,7 @@ The Conversational Agent includes all tools from the `@hashgraphonline/hedera-ag
|
|
|
94
175
|
- **QueryRegistryTool**: Retrieve entries from registries
|
|
95
176
|
|
|
96
177
|
### Inscription Tools
|
|
178
|
+
|
|
97
179
|
- **InscribeFromUrlTool**: Inscribe content from URLs
|
|
98
180
|
- **InscribeFromFileTool**: Inscribe content from local files
|
|
99
181
|
- **InscribeFromBufferTool**: Inscribe content from memory buffers
|
|
@@ -181,7 +263,9 @@ const MyToolSchema = z.object({
|
|
|
181
263
|
param2: z.number().optional().describe('Optional second parameter'),
|
|
182
264
|
});
|
|
183
265
|
|
|
184
|
-
export class MyCustomTool extends BaseHederaTransactionTool<
|
|
266
|
+
export class MyCustomTool extends BaseHederaTransactionTool<
|
|
267
|
+
typeof MyToolSchema
|
|
268
|
+
> {
|
|
185
269
|
name = 'my-custom-tool';
|
|
186
270
|
description = 'Performs a custom Hedera transaction';
|
|
187
271
|
specificInputSchema = MyToolSchema;
|
|
@@ -216,13 +300,15 @@ const agent = new ConversationalAgent({
|
|
|
216
300
|
network: 'testnet',
|
|
217
301
|
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
218
302
|
// Add your custom plugins
|
|
219
|
-
additionalPlugins: [new MyCustomPlugin()]
|
|
303
|
+
additionalPlugins: [new MyCustomPlugin()],
|
|
220
304
|
});
|
|
221
305
|
|
|
222
306
|
await agent.initialize();
|
|
223
307
|
|
|
224
308
|
// Your custom tools are now available to the agent
|
|
225
|
-
const response = await agent.processMessage(
|
|
309
|
+
const response = await agent.processMessage(
|
|
310
|
+
'Use my custom tool with param1 "test"'
|
|
311
|
+
);
|
|
226
312
|
```
|
|
227
313
|
|
|
228
314
|
### Plugin Best Practices
|
|
@@ -237,24 +323,24 @@ For more details, see our [Plugin Development Guide](docs/PLUGIN_DEVELOPMENT.md)
|
|
|
237
323
|
|
|
238
324
|
## Configuration Options
|
|
239
325
|
|
|
240
|
-
| Option
|
|
241
|
-
|
|
242
|
-
| `accountId`
|
|
243
|
-
| `privateKey`
|
|
244
|
-
| `network`
|
|
245
|
-
| `openAIApiKey`
|
|
246
|
-
| `openAIModelName`
|
|
247
|
-
| `verbose`
|
|
248
|
-
| `operationalMode`
|
|
249
|
-
| `userAccountId`
|
|
250
|
-
| `customSystemMessagePreamble`
|
|
251
|
-
| `customSystemMessagePostamble`
|
|
252
|
-
| `additionalPlugins`
|
|
253
|
-
| `stateManager`
|
|
254
|
-
| `scheduleUserTransactionsInBytesMode` | boolean
|
|
255
|
-
| `mirrorNodeConfig`
|
|
256
|
-
| `disableLogging`
|
|
257
|
-
| `enabledPlugins`
|
|
326
|
+
| Option | Type | Default | Description |
|
|
327
|
+
| ------------------------------------- | -------------------- | --------------- | ---------------------------------------------- |
|
|
328
|
+
| `accountId` | string | **required** | Hedera account ID (e.g., '0.0.12345') |
|
|
329
|
+
| `privateKey` | string | **required** | Private key for the account |
|
|
330
|
+
| `network` | NetworkType | 'testnet' | Network to connect to ('mainnet' or 'testnet') |
|
|
331
|
+
| `openAIApiKey` | string | **required** | OpenAI API key for the LLM |
|
|
332
|
+
| `openAIModelName` | string | 'gpt-4o' | OpenAI model to use |
|
|
333
|
+
| `verbose` | boolean | false | Enable verbose logging |
|
|
334
|
+
| `operationalMode` | AgentOperationalMode | 'autonomous' | 'autonomous' or 'returnBytes' |
|
|
335
|
+
| `userAccountId` | string | undefined | User's account ID for transaction context |
|
|
336
|
+
| `customSystemMessagePreamble` | string | instructions | Custom system message prefix |
|
|
337
|
+
| `customSystemMessagePostamble` | string | undefined | Custom system message suffix |
|
|
338
|
+
| `additionalPlugins` | BasePlugin[] | [] | Additional plugins to load |
|
|
339
|
+
| `stateManager` | IStateManager | OpenConvaiState | Custom state manager |
|
|
340
|
+
| `scheduleUserTransactionsInBytesMode` | boolean | false | Schedule transactions in bytes mode |
|
|
341
|
+
| `mirrorNodeConfig` | MirrorNodeConfig | undefined | Custom mirror node configuration |
|
|
342
|
+
| `disableLogging` | boolean | false | Disable all logging |
|
|
343
|
+
| `enabledPlugins` | string[] | undefined | Filter which plugins to enable by ID |
|
|
258
344
|
|
|
259
345
|
## Environment Variables
|
|
260
346
|
|
|
@@ -273,7 +359,9 @@ HEDERA_NETWORK=testnet # defaults to testnet
|
|
|
273
359
|
### Direct Plugin Access
|
|
274
360
|
|
|
275
361
|
```typescript
|
|
276
|
-
const agent = new ConversationalAgent({
|
|
362
|
+
const agent = new ConversationalAgent({
|
|
363
|
+
/* config */
|
|
364
|
+
});
|
|
277
365
|
await agent.initialize();
|
|
278
366
|
|
|
279
367
|
// Access plugins directly
|
|
@@ -298,7 +386,7 @@ const customStateManager = new OpenConvaiState();
|
|
|
298
386
|
|
|
299
387
|
const agent = new ConversationalAgent({
|
|
300
388
|
// ... other config
|
|
301
|
-
stateManager: customStateManager
|
|
389
|
+
stateManager: customStateManager,
|
|
302
390
|
});
|
|
303
391
|
```
|
|
304
392
|
|
|
@@ -312,7 +400,7 @@ const htsAgent = ConversationalAgent.withHTS({
|
|
|
312
400
|
accountId: process.env.HEDERA_ACCOUNT_ID!,
|
|
313
401
|
privateKey: process.env.HEDERA_PRIVATE_KEY!,
|
|
314
402
|
network: 'testnet',
|
|
315
|
-
openAIApiKey: process.env.OPENAI_API_KEY
|
|
403
|
+
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
316
404
|
});
|
|
317
405
|
|
|
318
406
|
// Create agent with only HCS-2 registry tools
|
|
@@ -320,7 +408,7 @@ const hcs2Agent = ConversationalAgent.withHCS2({
|
|
|
320
408
|
accountId: process.env.HEDERA_ACCOUNT_ID!,
|
|
321
409
|
privateKey: process.env.HEDERA_PRIVATE_KEY!,
|
|
322
410
|
network: 'testnet',
|
|
323
|
-
openAIApiKey: process.env.OPENAI_API_KEY
|
|
411
|
+
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
324
412
|
});
|
|
325
413
|
|
|
326
414
|
// Other presets available:
|
|
@@ -345,11 +433,12 @@ const agent = new ConversationalAgent({
|
|
|
345
433
|
network: 'testnet',
|
|
346
434
|
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
347
435
|
// Only enable specific plugins by their ID
|
|
348
|
-
enabledPlugins: ['hcs-10', 'hts-token', 'account']
|
|
436
|
+
enabledPlugins: ['hcs-10', 'hts-token', 'account'],
|
|
349
437
|
});
|
|
350
438
|
```
|
|
351
439
|
|
|
352
440
|
Available plugin IDs:
|
|
441
|
+
|
|
353
442
|
- Standard plugins: `hcs-10`, `hcs-2`, `inscribe`
|
|
354
443
|
- Core Hedera plugins: `hts-token`, `account`, `file-service`, `consensus-service`, `smart-contract`, `network`
|
|
355
444
|
|
|
@@ -359,19 +448,19 @@ If you need to use this with hedera-agent-kit 2.0.3:
|
|
|
359
448
|
|
|
360
449
|
```typescript
|
|
361
450
|
import { HederaConversationalAgent, ServerSigner } from 'hedera-agent-kit';
|
|
362
|
-
import {
|
|
451
|
+
import {
|
|
452
|
+
HCS10Plugin,
|
|
453
|
+
HCS2Plugin,
|
|
454
|
+
InscribePlugin,
|
|
455
|
+
} from '@hashgraphonline/conversational-agent';
|
|
363
456
|
|
|
364
457
|
const signer = new ServerSigner(accountId, privateKey, network);
|
|
365
458
|
|
|
366
459
|
const agent = new HederaConversationalAgent(signer, {
|
|
367
460
|
pluginConfig: {
|
|
368
|
-
plugins: [
|
|
369
|
-
new HCS10Plugin(),
|
|
370
|
-
new HCS2Plugin(),
|
|
371
|
-
new InscribePlugin()
|
|
372
|
-
]
|
|
461
|
+
plugins: [new HCS10Plugin(), new HCS2Plugin(), new InscribePlugin()],
|
|
373
462
|
},
|
|
374
|
-
openAIApiKey: process.env.OPENAI_API_KEY
|
|
463
|
+
openAIApiKey: process.env.OPENAI_API_KEY!,
|
|
375
464
|
});
|
|
376
465
|
```
|
|
377
466
|
|
|
@@ -384,4 +473,4 @@ const agent = new HederaConversationalAgent(signer, {
|
|
|
384
473
|
|
|
385
474
|
## License
|
|
386
475
|
|
|
387
|
-
Apache-2.0
|
|
476
|
+
Apache-2.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getSystemMessage: (accountId: string) => string;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("hedera-agent-kit"),t=require("@hashgraphonline/standards-agent-kit"),i=require("@hashgraphonline/standards-sdk"),n=require("@hashgraph/sdk");class o extends e.BasePlugin{constructor(){super(...arguments),this.id="hcs-10",this.name="HCS-10 Plugin",this.description="HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="hcs10",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.stateManager=e.stateManager||new t.OpenConvaiState,this.initializeTools(),this.context.logger.info("HCS-10 Plugin initialized successfully")}catch(i){this.context.logger.error("Failed to initialize HCS-10 plugin:",i)}else this.context.logger.warn("HederaKit not found in context. HCS-10 tools will not be available.")}initializeTools(){if(!this.stateManager)throw new Error("StateManager must be initialized before creating tools");const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.HCS10Builder(e,this.stateManager);this.tools=[new t.RegisterAgentTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.FindRegistrationsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.RetrieveProfileTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.InitiateConnectionTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ListConnectionsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.SendMessageToConnectionTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.CheckMessagesTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ConnectionMonitorTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ManageConnectionRequestsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.AcceptConnectionRequestTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ListUnapprovedConnectionRequestsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger})]}getTools(){return this.tools}getStateManager(){return this.stateManager}async cleanup(){this.tools=[],delete this.stateManager,this.context?.logger&&this.context.logger.info("HCS-10 Plugin cleaned up")}}class s extends e.BasePlugin{constructor(){super(...arguments),this.id="hcs-2",this.name="HCS-2 Plugin",this.description="HCS-2 registry management tools for decentralized registries on Hedera",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="hcs2",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.initializeTools(),this.context.logger.info("HCS-2 Plugin initialized successfully")}catch(t){this.context.logger.error("Failed to initialize HCS-2 plugin:",t)}else this.context.logger.warn("HederaKit not found in context. HCS-2 tools will not be available.")}initializeTools(){const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.HCS2Builder(e);this.tools=[new t.CreateRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.RegisterEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.UpdateEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.DeleteEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.MigrateRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.QueryRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger})]}getTools(){return this.tools}async cleanup(){this.tools=[],this.context?.logger&&this.context.logger.info("HCS-2 Plugin cleaned up")}}class r extends e.BasePlugin{constructor(){super(...arguments),this.id="inscribe",this.name="Inscribe Plugin",this.description="Content inscription tools for storing data on Hedera Consensus Service",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="inscribe",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.initializeTools(),this.context.logger.info("Inscribe Plugin initialized successfully")}catch(t){this.context.logger.error("Failed to initialize Inscribe plugin:",t)}else this.context.logger.warn("HederaKit not found in context. Inscription tools will not be available.")}initializeTools(){const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.InscriberBuilder(e);this.tools=[new t.InscribeFromUrlTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeFromFileTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeFromBufferTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeHashinalTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.RetrieveInscriptionTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger})]}getTools(){return this.tools}async cleanup(){this.tools=[],this.context?.logger&&this.context.logger.info("Inscribe Plugin cleaned up")}}const a
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("hedera-agent-kit"),t=require("@hashgraphonline/standards-agent-kit"),i=require("@hashgraphonline/standards-sdk"),n=require("@hashgraph/sdk");class o extends e.BasePlugin{constructor(){super(...arguments),this.id="hcs-10",this.name="HCS-10 Plugin",this.description="HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="hcs10",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.stateManager=e.stateManager||new t.OpenConvaiState,this.initializeTools(),this.context.logger.info("HCS-10 Plugin initialized successfully")}catch(i){this.context.logger.error("Failed to initialize HCS-10 plugin:",i)}else this.context.logger.warn("HederaKit not found in context. HCS-10 tools will not be available.")}initializeTools(){if(!this.stateManager)throw new Error("StateManager must be initialized before creating tools");const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.HCS10Builder(e,this.stateManager);this.tools=[new t.RegisterAgentTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.FindRegistrationsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.RetrieveProfileTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.InitiateConnectionTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ListConnectionsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.SendMessageToConnectionTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.CheckMessagesTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ConnectionMonitorTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ManageConnectionRequestsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.AcceptConnectionRequestTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger}),new t.ListUnapprovedConnectionRequestsTool({hederaKit:e,hcs10Builder:i,logger:this.context.logger})]}getTools(){return this.tools}getStateManager(){return this.stateManager}async cleanup(){this.tools=[],delete this.stateManager,this.context?.logger&&this.context.logger.info("HCS-10 Plugin cleaned up")}}class s extends e.BasePlugin{constructor(){super(...arguments),this.id="hcs-2",this.name="HCS-2 Plugin",this.description="HCS-2 registry management tools for decentralized registries on Hedera",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="hcs2",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.initializeTools(),this.context.logger.info("HCS-2 Plugin initialized successfully")}catch(t){this.context.logger.error("Failed to initialize HCS-2 plugin:",t)}else this.context.logger.warn("HederaKit not found in context. HCS-2 tools will not be available.")}initializeTools(){const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.HCS2Builder(e);this.tools=[new t.CreateRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.RegisterEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.UpdateEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.DeleteEntryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.MigrateRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger}),new t.QueryRegistryTool({hederaKit:e,hcs2Builder:i,logger:this.context.logger})]}getTools(){return this.tools}async cleanup(){this.tools=[],this.context?.logger&&this.context.logger.info("HCS-2 Plugin cleaned up")}}class r extends e.BasePlugin{constructor(){super(...arguments),this.id="inscribe",this.name="Inscribe Plugin",this.description="Content inscription tools for storing data on Hedera Consensus Service",this.version="1.0.0",this.author="Hashgraph Online",this.namespace="inscribe",this.tools=[]}async initialize(e){await super.initialize(e);if(e.config.hederaKit)try{this.initializeTools(),this.context.logger.info("Inscribe Plugin initialized successfully")}catch(t){this.context.logger.error("Failed to initialize Inscribe plugin:",t)}else this.context.logger.warn("HederaKit not found in context. Inscription tools will not be available.")}initializeTools(){const e=this.context.config.hederaKit;if(!e)throw new Error("HederaKit not found in context config");const i=new t.InscriberBuilder(e);this.tools=[new t.InscribeFromUrlTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeFromFileTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeFromBufferTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.InscribeHashinalTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger}),new t.RetrieveInscriptionTool({hederaKit:e,inscriberBuilder:i,logger:this.context.logger})]}getTools(){return this.tools}async cleanup(){this.tools=[],this.context?.logger&&this.context.logger.info("Inscribe Plugin cleaned up")}}const a=e=>`You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${e} on the Hashgraph Online network\nWhen users ask about "my profile", "my account", "my connections", etc., use this account ID: ${e}\n\nRemember the connection numbers when listing connections, as users might refer to them.`;class l{constructor(e){this.options=e,this.stateManager=e.stateManager||new t.OpenConvaiState,this.hcs10Plugin=new o,this.hcs2Plugin=new s,this.inscribePlugin=new r,this.logger=new i.Logger({module:"ConversationalAgent"})}async initialize(){const{accountId:t,privateKey:o,network:s="testnet",openAIApiKey:r,openAIModelName:l="gpt-4o",verbose:g=!1,operationalMode:c="autonomous",userAccountId:h,customSystemMessagePreamble:u,customSystemMessagePostamble:d,additionalPlugins:w=[],scheduleUserTransactionsInBytesMode:p,mirrorNodeConfig:f,disableLogging:b}=this.options;if(!t||!o)throw new Error("Account ID and private key are required");try{const x=new i.HederaMirrorNode(s,this.logger),C=await x.requestAccount(t),m=C?.key?._type||"";let y;y=m?.toLowerCase()?.includes("ecdsa")?n.PrivateKey.fromStringECDSA(o):n.PrivateKey.fromStringED25519(o);const P=new e.ServerSigner(t,y,s),S=[this.hcs10Plugin,this.hcs2Plugin,this.inscribePlugin],v=e.getAllHederaCorePlugins();let H;if(this.options.enabledPlugins){const e=new Set(this.options.enabledPlugins);H=[...[...S,...v].filter(t=>e.has(t.id)),...w]}else H=[...S,...v,...w];const T={pluginConfig:{plugins:H,appConfig:{stateManager:this.stateManager}},openAIApiKey:r,openAIModelName:l,verbose:g,operationalMode:c,userAccountId:h,customSystemMessagePreamble:u||a(t),...void 0!==d&&{customSystemMessagePostamble:d},...void 0!==p&&{scheduleUserTransactionsInBytesMode:p},...void 0!==f&&{mirrorNodeConfig:f},...void 0!==b&&{disableLogging:b}};this.conversationalAgent=new e.HederaConversationalAgent(P,T),await this.conversationalAgent.initialize()}catch(x){throw this.logger.error("Failed to initialize ConversationalAgent:",x),x}}getPlugin(){return this.hcs10Plugin}getStateManager(){return this.stateManager}getConversationalAgent(){if(!this.conversationalAgent)throw new Error("ConversationalAgent not initialized. Call initialize() first.");return this.conversationalAgent}async processMessage(e,t=[]){if(!this.conversationalAgent)throw new Error("ConversationalAgent not initialized. Call initialize() first.");return this.conversationalAgent.processMessage(e,t)}static withHTS(e){return new l({...e,enabledPlugins:["hts-token"]})}static withHCS2(e){return new l({...e,enabledPlugins:["hcs-2"]})}static withHCS10(e){return new l({...e,enabledPlugins:["hcs-10"]})}static withInscribe(e){return new l({...e,enabledPlugins:["inscribe"]})}static withAccount(e){return new l({...e,enabledPlugins:["account"]})}static withFileService(e){return new l({...e,enabledPlugins:["file-service"]})}static withConsensusService(e){return new l({...e,enabledPlugins:["consensus-service"]})}static withSmartContract(e){return new l({...e,enabledPlugins:["smart-contract"]})}static withAllStandards(e){return new l({...e,enabledPlugins:["hcs-10","hcs-2","inscribe"]})}static minimal(e){return new l({...e,enabledPlugins:[]})}}exports.ConversationalAgent=l,exports.HCS10Plugin=o,exports.HCS2Plugin=s,exports.InscribePlugin=r,Object.keys(e).forEach(t=>{"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:()=>e[t]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/plugins/hcs-10/HCS10Plugin.ts","../../src/plugins/hcs-2/HCS2Plugin.ts","../../src/plugins/inscribe/InscribePlugin.ts","../../src/config/system-message.ts","../../src/conversational-agent.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n IStateManager,\n OpenConvaiState,\n HCS10Builder,\n RegisterAgentTool,\n FindRegistrationsTool,\n InitiateConnectionTool,\n ListConnectionsTool,\n SendMessageToConnectionTool,\n CheckMessagesTool,\n ConnectionMonitorTool,\n ManageConnectionRequestsTool,\n AcceptConnectionRequestTool,\n RetrieveProfileTool,\n ListUnapprovedConnectionRequestsTool,\n} from '@hashgraphonline/standards-agent-kit';\n\nexport class HCS10Plugin extends BasePlugin {\n id = 'hcs-10';\n name = 'HCS-10 Plugin';\n description =\n 'HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs10';\n\n private stateManager?: IStateManager;\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-10 tools will not be available.'\n );\n return;\n }\n\n try {\n this.stateManager =\n (context.stateManager as IStateManager) || new OpenConvaiState();\n\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-10 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-10 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n if (!this.stateManager) {\n throw new Error('StateManager must be initialized before creating tools');\n }\n\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs10Builder = new HCS10Builder(hederaKit, this.stateManager);\n\n this.tools = [\n new RegisterAgentTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new FindRegistrationsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new RetrieveProfileTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new InitiateConnectionTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ListConnectionsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new SendMessageToConnectionTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new CheckMessagesTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ConnectionMonitorTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ManageConnectionRequestsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new AcceptConnectionRequestTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ListUnapprovedConnectionRequestsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n getStateManager(): IStateManager | undefined {\n return this.stateManager;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n delete this.stateManager;\n if (this.context?.logger) {\n this.context.logger.info(\n 'HCS-10 Plugin cleaned up'\n );\n }\n }\n}\n","import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n HCS2Builder,\n CreateRegistryTool,\n RegisterEntryTool,\n UpdateEntryTool,\n DeleteEntryTool,\n MigrateRegistryTool,\n QueryRegistryTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing HCS-2 registry management tools\n */\nexport class HCS2Plugin extends BasePlugin {\n id = 'hcs-2';\n name = 'HCS-2 Plugin';\n description =\n 'HCS-2 registry management tools for decentralized registries on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs2';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-2 tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-2 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-2 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs2Builder = new HCS2Builder(hederaKit);\n\n this.tools = [\n new CreateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new RegisterEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new UpdateEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new DeleteEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new MigrateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new QueryRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('HCS-2 Plugin cleaned up');\n }\n }\n}","import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}","export const SYSTEM_MESSAGE = `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hashgraph Online network\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\nRemember the connection numbers when listing connections, as users might refer to them.`","import {\n ServerSigner,\n HederaConversationalAgent,\n getAllHederaCorePlugins,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type {\n AgentOperationalMode,\n AgentResponse,\n HederaConversationalAgentConfig,\n MirrorNodeConfig,\n} from 'hedera-agent-kit';\nimport { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';\nimport { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';\nimport { InscribePlugin } from './plugins/inscribe/InscribePlugin';\nimport { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';\nimport type { IStateManager } from '@hashgraphonline/standards-agent-kit';\nimport {\n Logger,\n HederaMirrorNode,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\nimport { PrivateKey } from '@hashgraph/sdk';\nimport { SYSTEM_MESSAGE } from './config/system-message';\n\nexport interface ConversationalAgentOptions {\n accountId: string;\n privateKey: string;\n network?: NetworkType;\n openAIApiKey: string;\n openAIModelName?: string;\n verbose?: boolean;\n operationalMode?: AgentOperationalMode;\n userAccountId?: string;\n customSystemMessagePreamble?: string;\n customSystemMessagePostamble?: string;\n additionalPlugins?: BasePlugin[];\n stateManager?: IStateManager;\n scheduleUserTransactionsInBytesMode?: boolean;\n mirrorNodeConfig?: MirrorNodeConfig;\n disableLogging?: boolean;\n enabledPlugins?: string[];\n}\n\n/**\n * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,\n * which includes the OpenConvAIPlugin and the OpenConvaiState by default.\n * If you want to use a different plugin or state manager, you can pass them in the options.\n * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.\n *\n * @param options - The options for the ConversationalAgent.\n * @returns A new instance of the ConversationalAgent class.\n */\nexport class ConversationalAgent {\n public conversationalAgent?: HederaConversationalAgent;\n public hcs10Plugin: HCS10Plugin;\n public hcs2Plugin: HCS2Plugin;\n public inscribePlugin: InscribePlugin;\n public stateManager: IStateManager;\n private options: ConversationalAgentOptions;\n private logger: Logger;\n\n constructor(options: ConversationalAgentOptions) {\n this.options = options;\n this.stateManager = options.stateManager || new OpenConvaiState();\n this.hcs10Plugin = new HCS10Plugin();\n this.hcs2Plugin = new HCS2Plugin();\n this.inscribePlugin = new InscribePlugin();\n this.logger = new Logger({ module: 'ConversationalAgent' });\n }\n\n async initialize(): Promise<void> {\n const {\n accountId,\n privateKey,\n network = 'testnet',\n openAIApiKey,\n openAIModelName = 'gpt-4o',\n verbose = false,\n operationalMode = 'autonomous',\n userAccountId,\n customSystemMessagePreamble,\n customSystemMessagePostamble,\n additionalPlugins = [],\n scheduleUserTransactionsInBytesMode,\n mirrorNodeConfig,\n disableLogging,\n } = this.options;\n\n if (!accountId || !privateKey) {\n throw new Error('Account ID and private key are required');\n }\n\n try {\n const mirrorNode = new HederaMirrorNode(network, this.logger);\n const accountInfo = await mirrorNode.requestAccount(accountId);\n const keyType = accountInfo?.key?._type || '';\n\n let privateKeyInstance: PrivateKey;\n if (keyType?.toLowerCase()?.includes('ecdsa')) {\n privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);\n } else {\n privateKeyInstance = PrivateKey.fromStringED25519(privateKey);\n }\n\n const serverSigner = new ServerSigner(\n accountId,\n privateKeyInstance,\n network\n );\n\n const standardPlugins = [\n this.hcs10Plugin,\n this.hcs2Plugin,\n this.inscribePlugin,\n ];\n\n const corePlugins = getAllHederaCorePlugins();\n\n let allPlugins: BasePlugin[];\n\n if (this.options.enabledPlugins) {\n const enabledSet = new Set(this.options.enabledPlugins);\n const filteredPlugins = [...standardPlugins, ...corePlugins].filter(\n (plugin) => enabledSet.has(plugin.id)\n );\n allPlugins = [...filteredPlugins, ...additionalPlugins];\n } else {\n allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];\n }\n\n const agentConfig: HederaConversationalAgentConfig = {\n pluginConfig: {\n plugins: allPlugins,\n appConfig: {\n stateManager: this.stateManager,\n },\n },\n openAIApiKey,\n openAIModelName,\n verbose,\n operationalMode,\n userAccountId,\n customSystemMessagePreamble:\n customSystemMessagePreamble || SYSTEM_MESSAGE,\n ...(customSystemMessagePostamble !== undefined && {\n customSystemMessagePostamble,\n }),\n ...(scheduleUserTransactionsInBytesMode !== undefined && {\n scheduleUserTransactionsInBytesMode,\n }),\n ...(mirrorNodeConfig !== undefined && { mirrorNodeConfig }),\n ...(disableLogging !== undefined && { disableLogging }),\n };\n\n this.conversationalAgent = new HederaConversationalAgent(\n serverSigner,\n agentConfig\n );\n\n await this.conversationalAgent.initialize();\n } catch (error) {\n this.logger.error('Failed to initialize ConversationalAgent:', error);\n throw error;\n }\n }\n\n getPlugin(): HCS10Plugin {\n return this.hcs10Plugin;\n }\n\n getStateManager(): IStateManager {\n return this.stateManager;\n }\n\n getConversationalAgent(): HederaConversationalAgent {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent;\n }\n\n async processMessage(\n message: string,\n chatHistory: {\n type: 'human' | 'ai';\n content: string;\n }[] = []\n ): Promise<AgentResponse> {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent.processMessage(message, chatHistory);\n }\n\n /**\n * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled\n */\n static withHTS(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hts-token'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-2 tools enabled\n */\n static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-2'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-10 tools enabled\n */\n static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only inscription tools enabled\n */\n static withInscribe(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only account management tools enabled\n */\n static withAccount(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['account'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only file service tools enabled\n */\n static withFileService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['file-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only consensus service tools enabled\n */\n static withConsensusService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['consensus-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only smart contract tools enabled\n */\n static withSmartContract(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['smart-contract'],\n });\n }\n\n /**\n * Create a ConversationalAgent with all HCS standards plugins\n */\n static withAllStandards(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10', 'hcs-2', 'inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)\n */\n static minimal(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: [],\n });\n }\n}\n"],"names":["HCS10Plugin","BasePlugin","constructor","super","arguments","this","id","name","description","version","author","namespace","tools","initialize","context","config","hederaKit","stateManager","OpenConvaiState","initializeTools","logger","info","error","warn","Error","hcs10Builder","HCS10Builder","RegisterAgentTool","FindRegistrationsTool","RetrieveProfileTool","InitiateConnectionTool","ListConnectionsTool","SendMessageToConnectionTool","CheckMessagesTool","ConnectionMonitorTool","ManageConnectionRequestsTool","AcceptConnectionRequestTool","ListUnapprovedConnectionRequestsTool","getTools","getStateManager","cleanup","HCS2Plugin","hcs2Builder","HCS2Builder","CreateRegistryTool","RegisterEntryTool","UpdateEntryTool","DeleteEntryTool","MigrateRegistryTool","QueryRegistryTool","InscribePlugin","inscriberBuilder","InscriberBuilder","InscribeFromUrlTool","InscribeFromFileTool","InscribeFromBufferTool","InscribeHashinalTool","RetrieveInscriptionTool","SYSTEM_MESSAGE","accountId","ConversationalAgent","options","hcs10Plugin","hcs2Plugin","inscribePlugin","Logger","module","privateKey","network","openAIApiKey","openAIModelName","verbose","operationalMode","userAccountId","customSystemMessagePreamble","customSystemMessagePostamble","additionalPlugins","scheduleUserTransactionsInBytesMode","mirrorNodeConfig","disableLogging","mirrorNode","HederaMirrorNode","accountInfo","requestAccount","keyType","key","_type","privateKeyInstance","toLowerCase","includes","PrivateKey","fromStringECDSA","fromStringED25519","serverSigner","ServerSigner","standardPlugins","corePlugins","getAllHederaCorePlugins","allPlugins","enabledPlugins","enabledSet","Set","filter","plugin","has","agentConfig","pluginConfig","plugins","appConfig","conversationalAgent","HederaConversationalAgent","getPlugin","getConversationalAgent","processMessage","message","chatHistory","withHTS","withHCS2","withHCS10","withInscribe","withAccount","withFileService","withConsensusService","withSmartContract","withAllStandards","minimal"],"mappings":"8OAuBO,MAAMA,UAAoBC,EAAAA,WAA1B,WAAAC,GAAAC,SAAAC,WACLC,KAAAC,GAAK,SACLD,KAAAE,KAAO,gBACPF,KAAAG,YACE,gGACFH,KAAAI,QAAU,QACVJ,KAAAK,OAAS,mBACTL,KAAAM,UAAY,QAGZN,KAAQO,MAAsB,EAAC,CAE/B,gBAAeC,CAAWC,SAClBX,MAAMU,WAAWC,GAGvB,GADkBA,EAAQC,OAAOC,UAQjC,IACEX,KAAKY,aACFH,EAAQG,cAAkC,IAAIC,EAAAA,gBAEjDb,KAAKc,kBAELd,KAAKS,QAAQM,OAAOC,KAClB,yCAEJ,OAASC,GACPjB,KAAKS,QAAQM,OAAOE,MAClB,sCACAA,EAEJ,MApBEjB,KAAKS,QAAQM,OAAOG,KAClB,sEAoBN,CAEQ,eAAAJ,GACN,IAAKd,KAAKY,aACR,MAAM,IAAIO,MAAM,0DAGlB,MAAMR,EAAYX,KAAKS,QAAQC,OAAOC,UACtC,IAAKA,EACH,MAAM,IAAIQ,MAAM,yCAGlB,MAAMC,EAAe,IAAIC,EAAAA,aAAaV,EAAWX,KAAKY,cAEtDZ,KAAKO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eAAAvB,GACE,OAAOlC,KAAKY,YACd,CAEA,sBAAA+F,GACE,IAAK3G,KAAKwG,oBACR,MAAM,IAAIrF,MACR,iEAGJ,OAAOnB,KAAKwG,mBACd,CAEA,oBAAMI,CACJC,EACAC,EAGM,IAEN,IAAK9G,KAAKwG,oBACR,MAAM,IAAIrF,MACR,iEAGJ,OAAOnB,KAAKwG,oBAAoBI,eAAeC,EAASC,EAC1D,CAKA,cAAOC,CAAQvD,GACb,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,cAErB,CAKA,eAAOkB,CAASxD,GACd,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,UAErB,CAKA,gBAAOmB,CAAUzD,GACf,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,WAErB,CAKA,mBAAOoB,CACL1D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,aAErB,CAKA,kBAAOqB,CAAY3D,GACjB,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,YAErB,CAKA,sBAAOsB,CACL5D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,iBAErB,CAKA,2BAAOuB,CACL7D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,sBAErB,CAKA,wBAAOwB,CACL9D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,mBAErB,CAKA,uBAAOyB,CACL/D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,SAAU,QAAS,aAExC,CAKA,cAAO0B,CAAQhE,GACb,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,IAEpB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/plugins/hcs-10/HCS10Plugin.ts","../../src/plugins/hcs-2/HCS2Plugin.ts","../../src/plugins/inscribe/InscribePlugin.ts","../../src/config/system-message.ts","../../src/conversational-agent.ts"],"sourcesContent":["import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n IStateManager,\n OpenConvaiState,\n HCS10Builder,\n RegisterAgentTool,\n FindRegistrationsTool,\n InitiateConnectionTool,\n ListConnectionsTool,\n SendMessageToConnectionTool,\n CheckMessagesTool,\n ConnectionMonitorTool,\n ManageConnectionRequestsTool,\n AcceptConnectionRequestTool,\n RetrieveProfileTool,\n ListUnapprovedConnectionRequestsTool,\n} from '@hashgraphonline/standards-agent-kit';\n\nexport class HCS10Plugin extends BasePlugin {\n id = 'hcs-10';\n name = 'HCS-10 Plugin';\n description =\n 'HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs10';\n\n private stateManager?: IStateManager;\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-10 tools will not be available.'\n );\n return;\n }\n\n try {\n this.stateManager =\n (context.stateManager as IStateManager) || new OpenConvaiState();\n\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-10 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-10 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n if (!this.stateManager) {\n throw new Error('StateManager must be initialized before creating tools');\n }\n\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs10Builder = new HCS10Builder(hederaKit, this.stateManager);\n\n this.tools = [\n new RegisterAgentTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new FindRegistrationsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new RetrieveProfileTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new InitiateConnectionTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ListConnectionsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new SendMessageToConnectionTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new CheckMessagesTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ConnectionMonitorTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ManageConnectionRequestsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new AcceptConnectionRequestTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n new ListUnapprovedConnectionRequestsTool({\n hederaKit: hederaKit,\n hcs10Builder: hcs10Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n getStateManager(): IStateManager | undefined {\n return this.stateManager;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n delete this.stateManager;\n if (this.context?.logger) {\n this.context.logger.info(\n 'HCS-10 Plugin cleaned up'\n );\n }\n }\n}\n","import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n HCS2Builder,\n CreateRegistryTool,\n RegisterEntryTool,\n UpdateEntryTool,\n DeleteEntryTool,\n MigrateRegistryTool,\n QueryRegistryTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing HCS-2 registry management tools\n */\nexport class HCS2Plugin extends BasePlugin {\n id = 'hcs-2';\n name = 'HCS-2 Plugin';\n description =\n 'HCS-2 registry management tools for decentralized registries on Hedera';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'hcs2';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. HCS-2 tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'HCS-2 Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize HCS-2 plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const hcs2Builder = new HCS2Builder(hederaKit);\n\n this.tools = [\n new CreateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new RegisterEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new UpdateEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new DeleteEntryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new MigrateRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n new QueryRegistryTool({\n hederaKit: hederaKit,\n hcs2Builder: hcs2Builder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('HCS-2 Plugin cleaned up');\n }\n }\n}","import {\n GenericPluginContext,\n HederaTool,\n BasePlugin,\n HederaAgentKit,\n} from 'hedera-agent-kit';\nimport {\n InscriberBuilder,\n InscribeFromUrlTool,\n InscribeFromFileTool,\n InscribeFromBufferTool,\n InscribeHashinalTool,\n RetrieveInscriptionTool,\n} from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Plugin providing content inscription tools for Hedera\n */\nexport class InscribePlugin extends BasePlugin {\n id = 'inscribe';\n name = 'Inscribe Plugin';\n description =\n 'Content inscription tools for storing data on Hedera Consensus Service';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'inscribe';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n this.context.logger.warn(\n 'HederaKit not found in context. Inscription tools will not be available.'\n );\n return;\n }\n\n try {\n this.initializeTools();\n\n this.context.logger.info(\n 'Inscribe Plugin initialized successfully'\n );\n } catch (error) {\n this.context.logger.error(\n 'Failed to initialize Inscribe plugin:',\n error\n );\n }\n }\n\n private initializeTools(): void {\n const hederaKit = this.context.config.hederaKit as HederaAgentKit;\n if (!hederaKit) {\n throw new Error('HederaKit not found in context config');\n }\n\n const inscriberBuilder = new InscriberBuilder(hederaKit);\n\n this.tools = [\n new InscribeFromUrlTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromFileTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeFromBufferTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new InscribeHashinalTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n new RetrieveInscriptionTool({\n hederaKit: hederaKit,\n inscriberBuilder: inscriberBuilder,\n logger: this.context.logger,\n }),\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n if (this.context?.logger) {\n this.context.logger.info('Inscribe Plugin cleaned up');\n }\n }\n}","export const getSystemMessage = (accountId: string): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hashgraph Online network\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\nRemember the connection numbers when listing connections, as users might refer to them.`","import {\n ServerSigner,\n HederaConversationalAgent,\n getAllHederaCorePlugins,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type {\n AgentOperationalMode,\n AgentResponse,\n HederaConversationalAgentConfig,\n MirrorNodeConfig,\n} from 'hedera-agent-kit';\nimport { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';\nimport { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';\nimport { InscribePlugin } from './plugins/inscribe/InscribePlugin';\nimport { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';\nimport type { IStateManager } from '@hashgraphonline/standards-agent-kit';\nimport {\n Logger,\n HederaMirrorNode,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\nimport { PrivateKey } from '@hashgraph/sdk';\nimport { getSystemMessage } from './config/system-message';\n\nexport interface ConversationalAgentOptions {\n accountId: string;\n privateKey: string;\n network?: NetworkType;\n openAIApiKey: string;\n openAIModelName?: string;\n verbose?: boolean;\n operationalMode?: AgentOperationalMode;\n userAccountId?: string;\n customSystemMessagePreamble?: string;\n customSystemMessagePostamble?: string;\n additionalPlugins?: BasePlugin[];\n stateManager?: IStateManager;\n scheduleUserTransactionsInBytesMode?: boolean;\n mirrorNodeConfig?: MirrorNodeConfig;\n disableLogging?: boolean;\n enabledPlugins?: string[];\n}\n\n/**\n * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,\n * which includes the OpenConvAIPlugin and the OpenConvaiState by default.\n * If you want to use a different plugin or state manager, you can pass them in the options.\n * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.\n *\n * @param options - The options for the ConversationalAgent.\n * @returns A new instance of the ConversationalAgent class.\n */\nexport class ConversationalAgent {\n public conversationalAgent?: HederaConversationalAgent;\n public hcs10Plugin: HCS10Plugin;\n public hcs2Plugin: HCS2Plugin;\n public inscribePlugin: InscribePlugin;\n public stateManager: IStateManager;\n private options: ConversationalAgentOptions;\n private logger: Logger;\n\n constructor(options: ConversationalAgentOptions) {\n this.options = options;\n this.stateManager = options.stateManager || new OpenConvaiState();\n this.hcs10Plugin = new HCS10Plugin();\n this.hcs2Plugin = new HCS2Plugin();\n this.inscribePlugin = new InscribePlugin();\n this.logger = new Logger({ module: 'ConversationalAgent' });\n }\n\n async initialize(): Promise<void> {\n const {\n accountId,\n privateKey,\n network = 'testnet',\n openAIApiKey,\n openAIModelName = 'gpt-4o',\n verbose = false,\n operationalMode = 'autonomous',\n userAccountId,\n customSystemMessagePreamble,\n customSystemMessagePostamble,\n additionalPlugins = [],\n scheduleUserTransactionsInBytesMode,\n mirrorNodeConfig,\n disableLogging,\n } = this.options;\n\n if (!accountId || !privateKey) {\n throw new Error('Account ID and private key are required');\n }\n\n try {\n const mirrorNode = new HederaMirrorNode(network, this.logger);\n const accountInfo = await mirrorNode.requestAccount(accountId);\n const keyType = accountInfo?.key?._type || '';\n\n let privateKeyInstance: PrivateKey;\n if (keyType?.toLowerCase()?.includes('ecdsa')) {\n privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);\n } else {\n privateKeyInstance = PrivateKey.fromStringED25519(privateKey);\n }\n\n const serverSigner = new ServerSigner(\n accountId,\n privateKeyInstance,\n network\n );\n\n const standardPlugins = [\n this.hcs10Plugin,\n this.hcs2Plugin,\n this.inscribePlugin,\n ];\n\n const corePlugins = getAllHederaCorePlugins();\n\n let allPlugins: BasePlugin[];\n\n if (this.options.enabledPlugins) {\n const enabledSet = new Set(this.options.enabledPlugins);\n const filteredPlugins = [...standardPlugins, ...corePlugins].filter(\n (plugin) => enabledSet.has(plugin.id)\n );\n allPlugins = [...filteredPlugins, ...additionalPlugins];\n } else {\n allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];\n }\n\n const agentConfig: HederaConversationalAgentConfig = {\n pluginConfig: {\n plugins: allPlugins,\n appConfig: {\n stateManager: this.stateManager,\n },\n },\n openAIApiKey,\n openAIModelName,\n verbose,\n operationalMode,\n userAccountId,\n customSystemMessagePreamble:\n customSystemMessagePreamble || getSystemMessage(accountId),\n ...(customSystemMessagePostamble !== undefined && {\n customSystemMessagePostamble,\n }),\n ...(scheduleUserTransactionsInBytesMode !== undefined && {\n scheduleUserTransactionsInBytesMode,\n }),\n ...(mirrorNodeConfig !== undefined && { mirrorNodeConfig }),\n ...(disableLogging !== undefined && { disableLogging }),\n };\n\n this.conversationalAgent = new HederaConversationalAgent(\n serverSigner,\n agentConfig\n );\n\n await this.conversationalAgent.initialize();\n } catch (error) {\n this.logger.error('Failed to initialize ConversationalAgent:', error);\n throw error;\n }\n }\n\n getPlugin(): HCS10Plugin {\n return this.hcs10Plugin;\n }\n\n getStateManager(): IStateManager {\n return this.stateManager;\n }\n\n getConversationalAgent(): HederaConversationalAgent {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent;\n }\n\n async processMessage(\n message: string,\n chatHistory: {\n type: 'human' | 'ai';\n content: string;\n }[] = []\n ): Promise<AgentResponse> {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent.processMessage(message, chatHistory);\n }\n\n /**\n * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled\n */\n static withHTS(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hts-token'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-2 tools enabled\n */\n static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-2'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-10 tools enabled\n */\n static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only inscription tools enabled\n */\n static withInscribe(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only account management tools enabled\n */\n static withAccount(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['account'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only file service tools enabled\n */\n static withFileService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['file-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only consensus service tools enabled\n */\n static withConsensusService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['consensus-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only smart contract tools enabled\n */\n static withSmartContract(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['smart-contract'],\n });\n }\n\n /**\n * Create a ConversationalAgent with all HCS standards plugins\n */\n static withAllStandards(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10', 'hcs-2', 'inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)\n */\n static minimal(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: [],\n });\n }\n}\n"],"names":["HCS10Plugin","BasePlugin","constructor","super","arguments","this","id","name","description","version","author","namespace","tools","initialize","context","config","hederaKit","stateManager","OpenConvaiState","initializeTools","logger","info","error","warn","Error","hcs10Builder","HCS10Builder","RegisterAgentTool","FindRegistrationsTool","RetrieveProfileTool","InitiateConnectionTool","ListConnectionsTool","SendMessageToConnectionTool","CheckMessagesTool","ConnectionMonitorTool","ManageConnectionRequestsTool","AcceptConnectionRequestTool","ListUnapprovedConnectionRequestsTool","getTools","getStateManager","cleanup","HCS2Plugin","hcs2Builder","HCS2Builder","CreateRegistryTool","RegisterEntryTool","UpdateEntryTool","DeleteEntryTool","MigrateRegistryTool","QueryRegistryTool","InscribePlugin","inscriberBuilder","InscriberBuilder","InscribeFromUrlTool","InscribeFromFileTool","InscribeFromBufferTool","InscribeHashinalTool","RetrieveInscriptionTool","getSystemMessage","accountId","ConversationalAgent","options","hcs10Plugin","hcs2Plugin","inscribePlugin","Logger","module","privateKey","network","openAIApiKey","openAIModelName","verbose","operationalMode","userAccountId","customSystemMessagePreamble","customSystemMessagePostamble","additionalPlugins","scheduleUserTransactionsInBytesMode","mirrorNodeConfig","disableLogging","mirrorNode","HederaMirrorNode","accountInfo","requestAccount","keyType","key","_type","privateKeyInstance","toLowerCase","includes","PrivateKey","fromStringECDSA","fromStringED25519","serverSigner","ServerSigner","standardPlugins","corePlugins","getAllHederaCorePlugins","allPlugins","enabledPlugins","enabledSet","Set","filter","plugin","has","agentConfig","pluginConfig","plugins","appConfig","conversationalAgent","HederaConversationalAgent","getPlugin","getConversationalAgent","processMessage","message","chatHistory","withHTS","withHCS2","withHCS10","withInscribe","withAccount","withFileService","withConsensusService","withSmartContract","withAllStandards","minimal"],"mappings":"8OAuBO,MAAMA,UAAoBC,EAAAA,WAA1B,WAAAC,GAAAC,SAAAC,WACLC,KAAAC,GAAK,SACLD,KAAAE,KAAO,gBACPF,KAAAG,YACE,gGACFH,KAAAI,QAAU,QACVJ,KAAAK,OAAS,mBACTL,KAAAM,UAAY,QAGZN,KAAQO,MAAsB,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OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,iBAErB,CAKA,2BAAOuB,CACL7D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,sBAErB,CAKA,wBAAOwB,CACL9D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,mBAErB,CAKA,uBAAOyB,CACL/D,GAEA,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,CAAC,SAAU,QAAS,aAExC,CAKA,cAAO0B,CAAQhE,GACb,OAAO,IAAID,EAAoB,IAC1BC,EACHsC,eAAgB,IAEpB"}
|
package/dist/esm/index5.js
CHANGED
|
@@ -5,7 +5,7 @@ import { InscribePlugin } from "./index4.js";
|
|
|
5
5
|
import { OpenConvaiState } from "@hashgraphonline/standards-agent-kit";
|
|
6
6
|
import { Logger, HederaMirrorNode } from "@hashgraphonline/standards-sdk";
|
|
7
7
|
import { PrivateKey } from "@hashgraph/sdk";
|
|
8
|
-
import {
|
|
8
|
+
import { getSystemMessage } from "./index6.js";
|
|
9
9
|
class ConversationalAgent {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
this.options = options;
|
|
@@ -78,7 +78,7 @@ class ConversationalAgent {
|
|
|
78
78
|
verbose,
|
|
79
79
|
operationalMode,
|
|
80
80
|
userAccountId,
|
|
81
|
-
customSystemMessagePreamble: customSystemMessagePreamble ||
|
|
81
|
+
customSystemMessagePreamble: customSystemMessagePreamble || getSystemMessage(accountId),
|
|
82
82
|
...customSystemMessagePostamble !== void 0 && {
|
|
83
83
|
customSystemMessagePostamble
|
|
84
84
|
},
|
package/dist/esm/index5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index5.js","sources":["../../src/conversational-agent.ts"],"sourcesContent":["import {\n ServerSigner,\n HederaConversationalAgent,\n getAllHederaCorePlugins,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type {\n AgentOperationalMode,\n AgentResponse,\n HederaConversationalAgentConfig,\n MirrorNodeConfig,\n} from 'hedera-agent-kit';\nimport { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';\nimport { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';\nimport { InscribePlugin } from './plugins/inscribe/InscribePlugin';\nimport { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';\nimport type { IStateManager } from '@hashgraphonline/standards-agent-kit';\nimport {\n Logger,\n HederaMirrorNode,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\nimport { PrivateKey } from '@hashgraph/sdk';\nimport { SYSTEM_MESSAGE } from './config/system-message';\n\nexport interface ConversationalAgentOptions {\n accountId: string;\n privateKey: string;\n network?: NetworkType;\n openAIApiKey: string;\n openAIModelName?: string;\n verbose?: boolean;\n operationalMode?: AgentOperationalMode;\n userAccountId?: string;\n customSystemMessagePreamble?: string;\n customSystemMessagePostamble?: string;\n additionalPlugins?: BasePlugin[];\n stateManager?: IStateManager;\n scheduleUserTransactionsInBytesMode?: boolean;\n mirrorNodeConfig?: MirrorNodeConfig;\n disableLogging?: boolean;\n enabledPlugins?: string[];\n}\n\n/**\n * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,\n * which includes the OpenConvAIPlugin and the OpenConvaiState by default.\n * If you want to use a different plugin or state manager, you can pass them in the options.\n * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.\n *\n * @param options - The options for the ConversationalAgent.\n * @returns A new instance of the ConversationalAgent class.\n */\nexport class ConversationalAgent {\n public conversationalAgent?: HederaConversationalAgent;\n public hcs10Plugin: HCS10Plugin;\n public hcs2Plugin: HCS2Plugin;\n public inscribePlugin: InscribePlugin;\n public stateManager: IStateManager;\n private options: ConversationalAgentOptions;\n private logger: Logger;\n\n constructor(options: ConversationalAgentOptions) {\n this.options = options;\n this.stateManager = options.stateManager || new OpenConvaiState();\n this.hcs10Plugin = new HCS10Plugin();\n this.hcs2Plugin = new HCS2Plugin();\n this.inscribePlugin = new InscribePlugin();\n this.logger = new Logger({ module: 'ConversationalAgent' });\n }\n\n async initialize(): Promise<void> {\n const {\n accountId,\n privateKey,\n network = 'testnet',\n openAIApiKey,\n openAIModelName = 'gpt-4o',\n verbose = false,\n operationalMode = 'autonomous',\n userAccountId,\n customSystemMessagePreamble,\n customSystemMessagePostamble,\n additionalPlugins = [],\n scheduleUserTransactionsInBytesMode,\n mirrorNodeConfig,\n disableLogging,\n } = this.options;\n\n if (!accountId || !privateKey) {\n throw new Error('Account ID and private key are required');\n }\n\n try {\n const mirrorNode = new HederaMirrorNode(network, this.logger);\n const accountInfo = await mirrorNode.requestAccount(accountId);\n const keyType = accountInfo?.key?._type || '';\n\n let privateKeyInstance: PrivateKey;\n if (keyType?.toLowerCase()?.includes('ecdsa')) {\n privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);\n } else {\n privateKeyInstance = PrivateKey.fromStringED25519(privateKey);\n }\n\n const serverSigner = new ServerSigner(\n accountId,\n privateKeyInstance,\n network\n );\n\n const standardPlugins = [\n this.hcs10Plugin,\n this.hcs2Plugin,\n this.inscribePlugin,\n ];\n\n const corePlugins = getAllHederaCorePlugins();\n\n let allPlugins: BasePlugin[];\n\n if (this.options.enabledPlugins) {\n const enabledSet = new Set(this.options.enabledPlugins);\n const filteredPlugins = [...standardPlugins, ...corePlugins].filter(\n (plugin) => enabledSet.has(plugin.id)\n );\n allPlugins = [...filteredPlugins, ...additionalPlugins];\n } else {\n allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];\n }\n\n const agentConfig: HederaConversationalAgentConfig = {\n pluginConfig: {\n plugins: allPlugins,\n appConfig: {\n stateManager: this.stateManager,\n },\n },\n openAIApiKey,\n openAIModelName,\n verbose,\n operationalMode,\n userAccountId,\n customSystemMessagePreamble:\n customSystemMessagePreamble || SYSTEM_MESSAGE,\n ...(customSystemMessagePostamble !== undefined && {\n customSystemMessagePostamble,\n }),\n ...(scheduleUserTransactionsInBytesMode !== undefined && {\n scheduleUserTransactionsInBytesMode,\n }),\n ...(mirrorNodeConfig !== undefined && { mirrorNodeConfig }),\n ...(disableLogging !== undefined && { disableLogging }),\n };\n\n this.conversationalAgent = new HederaConversationalAgent(\n serverSigner,\n agentConfig\n );\n\n await this.conversationalAgent.initialize();\n } catch (error) {\n this.logger.error('Failed to initialize ConversationalAgent:', error);\n throw error;\n }\n }\n\n getPlugin(): HCS10Plugin {\n return this.hcs10Plugin;\n }\n\n getStateManager(): IStateManager {\n return this.stateManager;\n }\n\n getConversationalAgent(): HederaConversationalAgent {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent;\n }\n\n async processMessage(\n message: string,\n chatHistory: {\n type: 'human' | 'ai';\n content: string;\n }[] = []\n ): Promise<AgentResponse> {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent.processMessage(message, chatHistory);\n }\n\n /**\n * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled\n */\n static withHTS(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hts-token'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-2 tools enabled\n */\n static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-2'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-10 tools enabled\n */\n static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only inscription tools enabled\n */\n static withInscribe(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only account management tools enabled\n */\n static withAccount(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['account'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only file service tools enabled\n */\n static withFileService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['file-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only consensus service tools enabled\n */\n static withConsensusService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['consensus-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only smart contract tools enabled\n */\n static withSmartContract(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['smart-contract'],\n });\n }\n\n /**\n * Create a ConversationalAgent with all HCS standards plugins\n */\n static withAllStandards(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10', 'hcs-2', 'inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)\n */\n static minimal(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: [],\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAqDO,MAAM,oBAAoB;AAAA,EAS/B,YAAY,SAAqC;AAC/C,SAAK,UAAU;AACf,SAAK,eAAe,QAAQ,gBAAgB,IAAI,gBAAA;AAChD,SAAK,cAAc,IAAI,YAAA;AACvB,SAAK,aAAa,IAAI,WAAA;AACtB,SAAK,iBAAiB,IAAI,eAAA;AAC1B,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,uBAAuB;AAAA,EAC5D;AAAA,EAEA,MAAM,aAA4B;AAChC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,kBAAkB;AAAA,MAClB,UAAU;AAAA,MACV,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAoB,CAAA;AAA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AA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,aACL,SACqB;AACrB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,UAAU;AAAA,IAAA,CAC5B;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,YAAY,SAA0D;AAC3E,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,SAAS;AAAA,IAAA,CAC3B;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,gBACL,SACqB;AACrB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,cAAc;AAAA,IAAA,CAChC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,qBACL,SACqB;AACrB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,mBAAmB;AAAA,IAAA,CACrC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,kBACL,SACqB;AACrB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,gBAAgB;AAAA,IAAA,CAClC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBACL,SACqB;AACrB,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAC,UAAU,SAAS,UAAU;AAAA,IAAA,CAC/C;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAQ,SAA0D;AACvE,WAAO,IAAI,oBAAoB;AAAA,MAC7B,GAAG;AAAA,MACH,gBAAgB,CAAA;AAAA,IAAC,CAClB;AAAA,EACH;AACF;"}
|
|
1
|
+
{"version":3,"file":"index5.js","sources":["../../src/conversational-agent.ts"],"sourcesContent":["import {\n ServerSigner,\n HederaConversationalAgent,\n getAllHederaCorePlugins,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type {\n AgentOperationalMode,\n AgentResponse,\n HederaConversationalAgentConfig,\n MirrorNodeConfig,\n} from 'hedera-agent-kit';\nimport { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';\nimport { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';\nimport { InscribePlugin } from './plugins/inscribe/InscribePlugin';\nimport { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';\nimport type { IStateManager } from '@hashgraphonline/standards-agent-kit';\nimport {\n Logger,\n HederaMirrorNode,\n type NetworkType,\n} from '@hashgraphonline/standards-sdk';\nimport { PrivateKey } from '@hashgraph/sdk';\nimport { getSystemMessage } from './config/system-message';\n\nexport interface ConversationalAgentOptions {\n accountId: string;\n privateKey: string;\n network?: NetworkType;\n openAIApiKey: string;\n openAIModelName?: string;\n verbose?: boolean;\n operationalMode?: AgentOperationalMode;\n userAccountId?: string;\n customSystemMessagePreamble?: string;\n customSystemMessagePostamble?: string;\n additionalPlugins?: BasePlugin[];\n stateManager?: IStateManager;\n scheduleUserTransactionsInBytesMode?: boolean;\n mirrorNodeConfig?: MirrorNodeConfig;\n disableLogging?: boolean;\n enabledPlugins?: string[];\n}\n\n/**\n * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,\n * which includes the OpenConvAIPlugin and the OpenConvaiState by default.\n * If you want to use a different plugin or state manager, you can pass them in the options.\n * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.\n *\n * @param options - The options for the ConversationalAgent.\n * @returns A new instance of the ConversationalAgent class.\n */\nexport class ConversationalAgent {\n public conversationalAgent?: HederaConversationalAgent;\n public hcs10Plugin: HCS10Plugin;\n public hcs2Plugin: HCS2Plugin;\n public inscribePlugin: InscribePlugin;\n public stateManager: IStateManager;\n private options: ConversationalAgentOptions;\n private logger: Logger;\n\n constructor(options: ConversationalAgentOptions) {\n this.options = options;\n this.stateManager = options.stateManager || new OpenConvaiState();\n this.hcs10Plugin = new HCS10Plugin();\n this.hcs2Plugin = new HCS2Plugin();\n this.inscribePlugin = new InscribePlugin();\n this.logger = new Logger({ module: 'ConversationalAgent' });\n }\n\n async initialize(): Promise<void> {\n const {\n accountId,\n privateKey,\n network = 'testnet',\n openAIApiKey,\n openAIModelName = 'gpt-4o',\n verbose = false,\n operationalMode = 'autonomous',\n userAccountId,\n customSystemMessagePreamble,\n customSystemMessagePostamble,\n additionalPlugins = [],\n scheduleUserTransactionsInBytesMode,\n mirrorNodeConfig,\n disableLogging,\n } = this.options;\n\n if (!accountId || !privateKey) {\n throw new Error('Account ID and private key are required');\n }\n\n try {\n const mirrorNode = new HederaMirrorNode(network, this.logger);\n const accountInfo = await mirrorNode.requestAccount(accountId);\n const keyType = accountInfo?.key?._type || '';\n\n let privateKeyInstance: PrivateKey;\n if (keyType?.toLowerCase()?.includes('ecdsa')) {\n privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);\n } else {\n privateKeyInstance = PrivateKey.fromStringED25519(privateKey);\n }\n\n const serverSigner = new ServerSigner(\n accountId,\n privateKeyInstance,\n network\n );\n\n const standardPlugins = [\n this.hcs10Plugin,\n this.hcs2Plugin,\n this.inscribePlugin,\n ];\n\n const corePlugins = getAllHederaCorePlugins();\n\n let allPlugins: BasePlugin[];\n\n if (this.options.enabledPlugins) {\n const enabledSet = new Set(this.options.enabledPlugins);\n const filteredPlugins = [...standardPlugins, ...corePlugins].filter(\n (plugin) => enabledSet.has(plugin.id)\n );\n allPlugins = [...filteredPlugins, ...additionalPlugins];\n } else {\n allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];\n }\n\n const agentConfig: HederaConversationalAgentConfig = {\n pluginConfig: {\n plugins: allPlugins,\n appConfig: {\n stateManager: this.stateManager,\n },\n },\n openAIApiKey,\n openAIModelName,\n verbose,\n operationalMode,\n userAccountId,\n customSystemMessagePreamble:\n customSystemMessagePreamble || getSystemMessage(accountId),\n ...(customSystemMessagePostamble !== undefined && {\n customSystemMessagePostamble,\n }),\n ...(scheduleUserTransactionsInBytesMode !== undefined && {\n scheduleUserTransactionsInBytesMode,\n }),\n ...(mirrorNodeConfig !== undefined && { mirrorNodeConfig }),\n ...(disableLogging !== undefined && { disableLogging }),\n };\n\n this.conversationalAgent = new HederaConversationalAgent(\n serverSigner,\n agentConfig\n );\n\n await this.conversationalAgent.initialize();\n } catch (error) {\n this.logger.error('Failed to initialize ConversationalAgent:', error);\n throw error;\n }\n }\n\n getPlugin(): HCS10Plugin {\n return this.hcs10Plugin;\n }\n\n getStateManager(): IStateManager {\n return this.stateManager;\n }\n\n getConversationalAgent(): HederaConversationalAgent {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent;\n }\n\n async processMessage(\n message: string,\n chatHistory: {\n type: 'human' | 'ai';\n content: string;\n }[] = []\n ): Promise<AgentResponse> {\n if (!this.conversationalAgent) {\n throw new Error(\n 'ConversationalAgent not initialized. Call initialize() first.'\n );\n }\n return this.conversationalAgent.processMessage(message, chatHistory);\n }\n\n /**\n * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled\n */\n static withHTS(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hts-token'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-2 tools enabled\n */\n static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-2'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only HCS-10 tools enabled\n */\n static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only inscription tools enabled\n */\n static withInscribe(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only account management tools enabled\n */\n static withAccount(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['account'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only file service tools enabled\n */\n static withFileService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['file-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only consensus service tools enabled\n */\n static withConsensusService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['consensus-service'],\n });\n }\n\n /**\n * Create a ConversationalAgent with only smart contract tools enabled\n */\n static withSmartContract(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['smart-contract'],\n });\n }\n\n /**\n * Create a ConversationalAgent with all HCS standards plugins\n */\n static withAllStandards(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: ['hcs-10', 'hcs-2', 'inscribe'],\n });\n }\n\n /**\n * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)\n */\n static minimal(options: ConversationalAgentOptions): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: [],\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAqDO,MAAM,oBAAoB;AAAA,EAS/B,YAAY,SAAqC;AAC/C,SAAK,UAAU;AACf,SAAK,eAAe,QAAQ,gBAAgB,IAAI,gBAAA;AAChD,SAAK,cAAc,IAAI,YAAA;AACvB,SAAK,aAAa,IAAI,WAAA;AACtB,SAAK,iBAAiB,IAAI,eAAA;AAC1B,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,uBAAuB;AAAA,EAC5D;AAAA,EAEA,MAAM,aAA4B;AAChC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,kBAAkB;AAAA,MAClB,UAAU;AAAA,MACV,kBAAkB;AAAA,MAClB;AAA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|
-
const
|
|
1
|
+
const getSystemMessage = (accountId) => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.
|
|
2
2
|
|
|
3
3
|
You have access to tools for:
|
|
4
4
|
- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
|
|
@@ -11,6 +11,6 @@ When users ask about "my profile", "my account", "my connections", etc., use thi
|
|
|
11
11
|
|
|
12
12
|
Remember the connection numbers when listing connections, as users might refer to them.`;
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
getSystemMessage
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=index6.js.map
|
package/dist/esm/index6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index6.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const
|
|
1
|
+
{"version":3,"file":"index6.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (accountId: string): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hashgraph Online network\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\nRemember the connection numbers when listing connections, as users might refer to them.`"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAAC,cAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAQvB,SAAS;AAAA,gGAC+C,SAAS;AAAA;AAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getSystemMessage: (accountId: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/conversational-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -23,6 +23,27 @@
|
|
|
23
23
|
"LICENSE",
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:integration": "vitest run tests/integration",
|
|
29
|
+
"clean": "rimraf dist",
|
|
30
|
+
"build:es": "BUILD_FORMAT=es vite build",
|
|
31
|
+
"build:cjs": "BUILD_FORMAT=cjs vite build",
|
|
32
|
+
"build:umd": "BUILD_FORMAT=umd vite build",
|
|
33
|
+
"build": "pnpm run clean && pnpm run build:es && pnpm run build:cjs",
|
|
34
|
+
"prepublishOnly": "pnpm run build",
|
|
35
|
+
"release": "pnpm publish --access public",
|
|
36
|
+
"release:canary": "pnpm run prepublishOnly && pnpm publish --tag canary --access public",
|
|
37
|
+
"version:canary": "pnpm version prerelease --preid canary --no-git-tag-version",
|
|
38
|
+
"publish:canary": "pnpm run version:canary && pnpm run release:canary",
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint . --fix",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"cli:build": "pnpm run build && cd cli && pnpm install && pnpm build",
|
|
43
|
+
"cli": "tsx cli/scripts/run-cli.ts",
|
|
44
|
+
"cli:dev": "cd cli && pnpm dev",
|
|
45
|
+
"postinstall": "cd cli && pnpm install --silent 2>/dev/null || true"
|
|
46
|
+
},
|
|
26
47
|
"keywords": [
|
|
27
48
|
"hedera",
|
|
28
49
|
"hashgraph",
|
|
@@ -80,24 +101,5 @@
|
|
|
80
101
|
"url": "https://github.com/hashgraph-online/conversational-agent/issues"
|
|
81
102
|
},
|
|
82
103
|
"homepage": "https://github.com/hashgraph-online/conversational-agent#readme",
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"test:integration": "vitest run tests/integration",
|
|
86
|
-
"clean": "rimraf dist",
|
|
87
|
-
"build:es": "BUILD_FORMAT=es vite build",
|
|
88
|
-
"build:cjs": "BUILD_FORMAT=cjs vite build",
|
|
89
|
-
"build:umd": "BUILD_FORMAT=umd vite build",
|
|
90
|
-
"build": "pnpm run clean && pnpm run build:es && pnpm run build:cjs",
|
|
91
|
-
"release": "pnpm publish --access public",
|
|
92
|
-
"release:canary": "pnpm run prepublishOnly && pnpm publish --tag canary --access public",
|
|
93
|
-
"version:canary": "pnpm version prerelease --preid canary --no-git-tag-version",
|
|
94
|
-
"publish:canary": "pnpm run version:canary && pnpm run release:canary",
|
|
95
|
-
"lint": "eslint .",
|
|
96
|
-
"lint:fix": "eslint . --fix",
|
|
97
|
-
"typecheck": "tsc --noEmit",
|
|
98
|
-
"cli:build": "pnpm run build && cd cli && pnpm install && pnpm build",
|
|
99
|
-
"cli": "tsx cli/scripts/run-cli.ts",
|
|
100
|
-
"cli:dev": "cd cli && pnpm dev",
|
|
101
|
-
"postinstall": "cd cli && pnpm install --silent 2>/dev/null || true"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
+
"packageManager": "pnpm@10.11.1+sha512.e519b9f7639869dc8d5c3c5dfef73b3f091094b0a006d7317353c72b124e80e1afd429732e28705ad6bfa1ee879c1fce46c128ccebd3192101f43dd67c667912"
|
|
105
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getSystemMessage = (accountId: string): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.
|
|
2
2
|
|
|
3
3
|
You have access to tools for:
|
|
4
4
|
- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
type NetworkType,
|
|
22
22
|
} from '@hashgraphonline/standards-sdk';
|
|
23
23
|
import { PrivateKey } from '@hashgraph/sdk';
|
|
24
|
-
import {
|
|
24
|
+
import { getSystemMessage } from './config/system-message';
|
|
25
25
|
|
|
26
26
|
export interface ConversationalAgentOptions {
|
|
27
27
|
accountId: string;
|
|
@@ -142,7 +142,7 @@ export class ConversationalAgent {
|
|
|
142
142
|
operationalMode,
|
|
143
143
|
userAccountId,
|
|
144
144
|
customSystemMessagePreamble:
|
|
145
|
-
customSystemMessagePreamble ||
|
|
145
|
+
customSystemMessagePreamble || getSystemMessage(accountId),
|
|
146
146
|
...(customSystemMessagePostamble !== undefined && {
|
|
147
147
|
customSystemMessagePostamble,
|
|
148
148
|
}),
|