@hashgraphonline/conversational-agent 0.0.1
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/LICENSE +189 -0
- package/README.md +387 -0
- package/dist/cjs/config/system-message.d.ts +1 -0
- package/dist/cjs/conversational-agent.d.ts +92 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/plugins/hcs-10/HCS10Plugin.d.ts +18 -0
- package/dist/cjs/plugins/hcs-10/index.d.ts +1 -0
- package/dist/cjs/plugins/hcs-2/HCS2Plugin.d.ts +18 -0
- package/dist/cjs/plugins/hcs-2/index.d.ts +1 -0
- package/dist/cjs/plugins/index.d.ts +3 -0
- package/dist/cjs/plugins/inscribe/InscribePlugin.d.ts +18 -0
- package/dist/cjs/plugins/inscribe/index.d.ts +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index2.js +122 -0
- package/dist/esm/index2.js.map +1 -0
- package/dist/esm/index3.js +87 -0
- package/dist/esm/index3.js.map +1 -0
- package/dist/esm/index4.js +82 -0
- package/dist/esm/index4.js.map +1 -0
- package/dist/esm/index5.js +217 -0
- package/dist/esm/index5.js.map +1 -0
- package/dist/esm/index6.js +16 -0
- package/dist/esm/index6.js.map +1 -0
- package/dist/types/config/system-message.d.ts +1 -0
- package/dist/types/conversational-agent.d.ts +92 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/plugins/hcs-10/HCS10Plugin.d.ts +18 -0
- package/dist/types/plugins/hcs-10/index.d.ts +1 -0
- package/dist/types/plugins/hcs-2/HCS2Plugin.d.ts +18 -0
- package/dist/types/plugins/hcs-2/index.d.ts +1 -0
- package/dist/types/plugins/index.d.ts +3 -0
- package/dist/types/plugins/inscribe/InscribePlugin.d.ts +18 -0
- package/dist/types/plugins/inscribe/index.d.ts +1 -0
- package/package.json +103 -0
- package/src/config/system-message.ts +12 -0
- package/src/conversational-agent.ts +309 -0
- package/src/index.ts +9 -0
- package/src/plugins/hcs-10/HCS10Plugin.ts +152 -0
- package/src/plugins/hcs-10/index.ts +1 -0
- package/src/plugins/hcs-2/HCS2Plugin.ts +108 -0
- package/src/plugins/hcs-2/index.ts +1 -0
- package/src/plugins/index.ts +3 -0
- package/src/plugins/inscribe/InscribePlugin.ts +102 -0
- package/src/plugins/inscribe/index.ts +1 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ServerSigner,
|
|
3
|
+
HederaConversationalAgent,
|
|
4
|
+
getAllHederaCorePlugins,
|
|
5
|
+
BasePlugin,
|
|
6
|
+
} from 'hedera-agent-kit';
|
|
7
|
+
import type {
|
|
8
|
+
AgentOperationalMode,
|
|
9
|
+
AgentResponse,
|
|
10
|
+
HederaConversationalAgentConfig,
|
|
11
|
+
MirrorNodeConfig,
|
|
12
|
+
} from 'hedera-agent-kit';
|
|
13
|
+
import { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';
|
|
14
|
+
import { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';
|
|
15
|
+
import { InscribePlugin } from './plugins/inscribe/InscribePlugin';
|
|
16
|
+
import { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';
|
|
17
|
+
import type { IStateManager } from '@hashgraphonline/standards-agent-kit';
|
|
18
|
+
import {
|
|
19
|
+
Logger,
|
|
20
|
+
HederaMirrorNode,
|
|
21
|
+
type NetworkType,
|
|
22
|
+
} from '@hashgraphonline/standards-sdk';
|
|
23
|
+
import { PrivateKey } from '@hashgraph/sdk';
|
|
24
|
+
import { SYSTEM_MESSAGE } from './config/system-message';
|
|
25
|
+
|
|
26
|
+
export interface ConversationalAgentOptions {
|
|
27
|
+
accountId: string;
|
|
28
|
+
privateKey: string;
|
|
29
|
+
network?: NetworkType;
|
|
30
|
+
openAIApiKey: string;
|
|
31
|
+
openAIModelName?: string;
|
|
32
|
+
verbose?: boolean;
|
|
33
|
+
operationalMode?: AgentOperationalMode;
|
|
34
|
+
userAccountId?: string;
|
|
35
|
+
customSystemMessagePreamble?: string;
|
|
36
|
+
customSystemMessagePostamble?: string;
|
|
37
|
+
additionalPlugins?: BasePlugin[];
|
|
38
|
+
stateManager?: IStateManager;
|
|
39
|
+
scheduleUserTransactionsInBytesMode?: boolean;
|
|
40
|
+
mirrorNodeConfig?: MirrorNodeConfig;
|
|
41
|
+
disableLogging?: boolean;
|
|
42
|
+
enabledPlugins?: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,
|
|
47
|
+
* which includes the OpenConvAIPlugin and the OpenConvaiState by default.
|
|
48
|
+
* If you want to use a different plugin or state manager, you can pass them in the options.
|
|
49
|
+
* This class is not required and the plugin can be used directly with the HederaConversationalAgent class.
|
|
50
|
+
*
|
|
51
|
+
* @param options - The options for the ConversationalAgent.
|
|
52
|
+
* @returns A new instance of the ConversationalAgent class.
|
|
53
|
+
*/
|
|
54
|
+
export class ConversationalAgent {
|
|
55
|
+
public conversationalAgent?: HederaConversationalAgent;
|
|
56
|
+
public hcs10Plugin: HCS10Plugin;
|
|
57
|
+
public hcs2Plugin: HCS2Plugin;
|
|
58
|
+
public inscribePlugin: InscribePlugin;
|
|
59
|
+
public stateManager: IStateManager;
|
|
60
|
+
private options: ConversationalAgentOptions;
|
|
61
|
+
private logger: Logger;
|
|
62
|
+
|
|
63
|
+
constructor(options: ConversationalAgentOptions) {
|
|
64
|
+
this.options = options;
|
|
65
|
+
this.stateManager = options.stateManager || new OpenConvaiState();
|
|
66
|
+
this.hcs10Plugin = new HCS10Plugin();
|
|
67
|
+
this.hcs2Plugin = new HCS2Plugin();
|
|
68
|
+
this.inscribePlugin = new InscribePlugin();
|
|
69
|
+
this.logger = new Logger({ module: 'ConversationalAgent' });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async initialize(): Promise<void> {
|
|
73
|
+
const {
|
|
74
|
+
accountId,
|
|
75
|
+
privateKey,
|
|
76
|
+
network = 'testnet',
|
|
77
|
+
openAIApiKey,
|
|
78
|
+
openAIModelName = 'gpt-4o',
|
|
79
|
+
verbose = false,
|
|
80
|
+
operationalMode = 'autonomous',
|
|
81
|
+
userAccountId,
|
|
82
|
+
customSystemMessagePreamble,
|
|
83
|
+
customSystemMessagePostamble,
|
|
84
|
+
additionalPlugins = [],
|
|
85
|
+
scheduleUserTransactionsInBytesMode,
|
|
86
|
+
mirrorNodeConfig,
|
|
87
|
+
disableLogging,
|
|
88
|
+
} = this.options;
|
|
89
|
+
|
|
90
|
+
if (!accountId || !privateKey) {
|
|
91
|
+
throw new Error('Account ID and private key are required');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const mirrorNode = new HederaMirrorNode(network, this.logger);
|
|
96
|
+
const accountInfo = await mirrorNode.requestAccount(accountId);
|
|
97
|
+
const keyType = accountInfo?.key?._type || '';
|
|
98
|
+
|
|
99
|
+
let privateKeyInstance: PrivateKey;
|
|
100
|
+
if (keyType?.toLowerCase()?.includes('ecdsa')) {
|
|
101
|
+
privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);
|
|
102
|
+
} else {
|
|
103
|
+
privateKeyInstance = PrivateKey.fromStringED25519(privateKey);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const serverSigner = new ServerSigner(
|
|
107
|
+
accountId,
|
|
108
|
+
privateKeyInstance,
|
|
109
|
+
network
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const standardPlugins = [
|
|
113
|
+
this.hcs10Plugin,
|
|
114
|
+
this.hcs2Plugin,
|
|
115
|
+
this.inscribePlugin,
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
const corePlugins = getAllHederaCorePlugins();
|
|
119
|
+
|
|
120
|
+
let allPlugins: BasePlugin[];
|
|
121
|
+
|
|
122
|
+
if (this.options.enabledPlugins) {
|
|
123
|
+
const enabledSet = new Set(this.options.enabledPlugins);
|
|
124
|
+
const filteredPlugins = [...standardPlugins, ...corePlugins].filter(
|
|
125
|
+
(plugin) => enabledSet.has(plugin.id)
|
|
126
|
+
);
|
|
127
|
+
allPlugins = [...filteredPlugins, ...additionalPlugins];
|
|
128
|
+
} else {
|
|
129
|
+
allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const agentConfig: HederaConversationalAgentConfig = {
|
|
133
|
+
pluginConfig: {
|
|
134
|
+
plugins: allPlugins,
|
|
135
|
+
appConfig: {
|
|
136
|
+
stateManager: this.stateManager,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
openAIApiKey,
|
|
140
|
+
openAIModelName,
|
|
141
|
+
verbose,
|
|
142
|
+
operationalMode,
|
|
143
|
+
userAccountId,
|
|
144
|
+
customSystemMessagePreamble:
|
|
145
|
+
customSystemMessagePreamble || SYSTEM_MESSAGE,
|
|
146
|
+
...(customSystemMessagePostamble !== undefined && {
|
|
147
|
+
customSystemMessagePostamble,
|
|
148
|
+
}),
|
|
149
|
+
...(scheduleUserTransactionsInBytesMode !== undefined && {
|
|
150
|
+
scheduleUserTransactionsInBytesMode,
|
|
151
|
+
}),
|
|
152
|
+
...(mirrorNodeConfig !== undefined && { mirrorNodeConfig }),
|
|
153
|
+
...(disableLogging !== undefined && { disableLogging }),
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
this.conversationalAgent = new HederaConversationalAgent(
|
|
157
|
+
serverSigner,
|
|
158
|
+
agentConfig
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
await this.conversationalAgent.initialize();
|
|
162
|
+
} catch (error) {
|
|
163
|
+
this.logger.error('Failed to initialize ConversationalAgent:', error);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
getPlugin(): HCS10Plugin {
|
|
169
|
+
return this.hcs10Plugin;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
getStateManager(): IStateManager {
|
|
173
|
+
return this.stateManager;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getConversationalAgent(): HederaConversationalAgent {
|
|
177
|
+
if (!this.conversationalAgent) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
'ConversationalAgent not initialized. Call initialize() first.'
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return this.conversationalAgent;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async processMessage(
|
|
186
|
+
message: string,
|
|
187
|
+
chatHistory: {
|
|
188
|
+
type: 'human' | 'ai';
|
|
189
|
+
content: string;
|
|
190
|
+
}[] = []
|
|
191
|
+
): Promise<AgentResponse> {
|
|
192
|
+
if (!this.conversationalAgent) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
'ConversationalAgent not initialized. Call initialize() first.'
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return this.conversationalAgent.processMessage(message, chatHistory);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled
|
|
202
|
+
*/
|
|
203
|
+
static withHTS(options: ConversationalAgentOptions): ConversationalAgent {
|
|
204
|
+
return new ConversationalAgent({
|
|
205
|
+
...options,
|
|
206
|
+
enabledPlugins: ['hts-token'],
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Create a ConversationalAgent with only HCS-2 tools enabled
|
|
212
|
+
*/
|
|
213
|
+
static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {
|
|
214
|
+
return new ConversationalAgent({
|
|
215
|
+
...options,
|
|
216
|
+
enabledPlugins: ['hcs-2'],
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Create a ConversationalAgent with only HCS-10 tools enabled
|
|
222
|
+
*/
|
|
223
|
+
static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {
|
|
224
|
+
return new ConversationalAgent({
|
|
225
|
+
...options,
|
|
226
|
+
enabledPlugins: ['hcs-10'],
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Create a ConversationalAgent with only inscription tools enabled
|
|
232
|
+
*/
|
|
233
|
+
static withInscribe(
|
|
234
|
+
options: ConversationalAgentOptions
|
|
235
|
+
): ConversationalAgent {
|
|
236
|
+
return new ConversationalAgent({
|
|
237
|
+
...options,
|
|
238
|
+
enabledPlugins: ['inscribe'],
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Create a ConversationalAgent with only account management tools enabled
|
|
244
|
+
*/
|
|
245
|
+
static withAccount(options: ConversationalAgentOptions): ConversationalAgent {
|
|
246
|
+
return new ConversationalAgent({
|
|
247
|
+
...options,
|
|
248
|
+
enabledPlugins: ['account'],
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Create a ConversationalAgent with only file service tools enabled
|
|
254
|
+
*/
|
|
255
|
+
static withFileService(
|
|
256
|
+
options: ConversationalAgentOptions
|
|
257
|
+
): ConversationalAgent {
|
|
258
|
+
return new ConversationalAgent({
|
|
259
|
+
...options,
|
|
260
|
+
enabledPlugins: ['file-service'],
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Create a ConversationalAgent with only consensus service tools enabled
|
|
266
|
+
*/
|
|
267
|
+
static withConsensusService(
|
|
268
|
+
options: ConversationalAgentOptions
|
|
269
|
+
): ConversationalAgent {
|
|
270
|
+
return new ConversationalAgent({
|
|
271
|
+
...options,
|
|
272
|
+
enabledPlugins: ['consensus-service'],
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Create a ConversationalAgent with only smart contract tools enabled
|
|
278
|
+
*/
|
|
279
|
+
static withSmartContract(
|
|
280
|
+
options: ConversationalAgentOptions
|
|
281
|
+
): ConversationalAgent {
|
|
282
|
+
return new ConversationalAgent({
|
|
283
|
+
...options,
|
|
284
|
+
enabledPlugins: ['smart-contract'],
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Create a ConversationalAgent with all HCS standards plugins
|
|
290
|
+
*/
|
|
291
|
+
static withAllStandards(
|
|
292
|
+
options: ConversationalAgentOptions
|
|
293
|
+
): ConversationalAgent {
|
|
294
|
+
return new ConversationalAgent({
|
|
295
|
+
...options,
|
|
296
|
+
enabledPlugins: ['hcs-10', 'hcs-2', 'inscribe'],
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Create a ConversationalAgent with minimal Hedera tools (no HCS standards)
|
|
302
|
+
*/
|
|
303
|
+
static minimal(options: ConversationalAgentOptions): ConversationalAgent {
|
|
304
|
+
return new ConversationalAgent({
|
|
305
|
+
...options,
|
|
306
|
+
enabledPlugins: [],
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';
|
|
2
|
+
export { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';
|
|
3
|
+
export { InscribePlugin } from './plugins/inscribe/InscribePlugin';
|
|
4
|
+
export { ConversationalAgent } from './conversational-agent';
|
|
5
|
+
export type { ConversationalAgentOptions } from './conversational-agent';
|
|
6
|
+
|
|
7
|
+
export * from 'hedera-agent-kit';
|
|
8
|
+
|
|
9
|
+
export type { IStateManager } from '@hashgraphonline/standards-agent-kit';
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenericPluginContext,
|
|
3
|
+
HederaTool,
|
|
4
|
+
BasePlugin,
|
|
5
|
+
HederaAgentKit,
|
|
6
|
+
} from 'hedera-agent-kit';
|
|
7
|
+
import {
|
|
8
|
+
IStateManager,
|
|
9
|
+
OpenConvaiState,
|
|
10
|
+
HCS10Builder,
|
|
11
|
+
RegisterAgentTool,
|
|
12
|
+
FindRegistrationsTool,
|
|
13
|
+
InitiateConnectionTool,
|
|
14
|
+
ListConnectionsTool,
|
|
15
|
+
SendMessageToConnectionTool,
|
|
16
|
+
CheckMessagesTool,
|
|
17
|
+
ConnectionMonitorTool,
|
|
18
|
+
ManageConnectionRequestsTool,
|
|
19
|
+
AcceptConnectionRequestTool,
|
|
20
|
+
RetrieveProfileTool,
|
|
21
|
+
ListUnapprovedConnectionRequestsTool,
|
|
22
|
+
} from '@hashgraphonline/standards-agent-kit';
|
|
23
|
+
|
|
24
|
+
export class HCS10Plugin extends BasePlugin {
|
|
25
|
+
id = 'hcs-10';
|
|
26
|
+
name = 'HCS-10 Plugin';
|
|
27
|
+
description =
|
|
28
|
+
'HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera';
|
|
29
|
+
version = '1.0.0';
|
|
30
|
+
author = 'Hashgraph Online';
|
|
31
|
+
namespace = 'hcs10';
|
|
32
|
+
|
|
33
|
+
private stateManager?: IStateManager;
|
|
34
|
+
private tools: HederaTool[] = [];
|
|
35
|
+
|
|
36
|
+
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
37
|
+
await super.initialize(context);
|
|
38
|
+
|
|
39
|
+
const hederaKit = context.config.hederaKit as HederaAgentKit;
|
|
40
|
+
if (!hederaKit) {
|
|
41
|
+
this.context.logger.warn(
|
|
42
|
+
'HederaKit not found in context. HCS-10 tools will not be available.'
|
|
43
|
+
);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
this.stateManager =
|
|
49
|
+
(context.stateManager as IStateManager) || new OpenConvaiState();
|
|
50
|
+
|
|
51
|
+
this.initializeTools();
|
|
52
|
+
|
|
53
|
+
this.context.logger.info(
|
|
54
|
+
'HCS-10 Plugin initialized successfully'
|
|
55
|
+
);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
this.context.logger.error(
|
|
58
|
+
'Failed to initialize HCS-10 plugin:',
|
|
59
|
+
error
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private initializeTools(): void {
|
|
65
|
+
if (!this.stateManager) {
|
|
66
|
+
throw new Error('StateManager must be initialized before creating tools');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const hederaKit = this.context.config.hederaKit as HederaAgentKit;
|
|
70
|
+
if (!hederaKit) {
|
|
71
|
+
throw new Error('HederaKit not found in context config');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const hcs10Builder = new HCS10Builder(hederaKit, this.stateManager);
|
|
75
|
+
|
|
76
|
+
this.tools = [
|
|
77
|
+
new RegisterAgentTool({
|
|
78
|
+
hederaKit: hederaKit,
|
|
79
|
+
hcs10Builder: hcs10Builder,
|
|
80
|
+
logger: this.context.logger,
|
|
81
|
+
}),
|
|
82
|
+
new FindRegistrationsTool({
|
|
83
|
+
hederaKit: hederaKit,
|
|
84
|
+
hcs10Builder: hcs10Builder,
|
|
85
|
+
logger: this.context.logger,
|
|
86
|
+
}),
|
|
87
|
+
new RetrieveProfileTool({
|
|
88
|
+
hederaKit: hederaKit,
|
|
89
|
+
hcs10Builder: hcs10Builder,
|
|
90
|
+
logger: this.context.logger,
|
|
91
|
+
}),
|
|
92
|
+
new InitiateConnectionTool({
|
|
93
|
+
hederaKit: hederaKit,
|
|
94
|
+
hcs10Builder: hcs10Builder,
|
|
95
|
+
logger: this.context.logger,
|
|
96
|
+
}),
|
|
97
|
+
new ListConnectionsTool({
|
|
98
|
+
hederaKit: hederaKit,
|
|
99
|
+
hcs10Builder: hcs10Builder,
|
|
100
|
+
logger: this.context.logger,
|
|
101
|
+
}),
|
|
102
|
+
new SendMessageToConnectionTool({
|
|
103
|
+
hederaKit: hederaKit,
|
|
104
|
+
hcs10Builder: hcs10Builder,
|
|
105
|
+
logger: this.context.logger,
|
|
106
|
+
}),
|
|
107
|
+
new CheckMessagesTool({
|
|
108
|
+
hederaKit: hederaKit,
|
|
109
|
+
hcs10Builder: hcs10Builder,
|
|
110
|
+
logger: this.context.logger,
|
|
111
|
+
}),
|
|
112
|
+
new ConnectionMonitorTool({
|
|
113
|
+
hederaKit: hederaKit,
|
|
114
|
+
hcs10Builder: hcs10Builder,
|
|
115
|
+
logger: this.context.logger,
|
|
116
|
+
}),
|
|
117
|
+
new ManageConnectionRequestsTool({
|
|
118
|
+
hederaKit: hederaKit,
|
|
119
|
+
hcs10Builder: hcs10Builder,
|
|
120
|
+
logger: this.context.logger,
|
|
121
|
+
}),
|
|
122
|
+
new AcceptConnectionRequestTool({
|
|
123
|
+
hederaKit: hederaKit,
|
|
124
|
+
hcs10Builder: hcs10Builder,
|
|
125
|
+
logger: this.context.logger,
|
|
126
|
+
}),
|
|
127
|
+
new ListUnapprovedConnectionRequestsTool({
|
|
128
|
+
hederaKit: hederaKit,
|
|
129
|
+
hcs10Builder: hcs10Builder,
|
|
130
|
+
logger: this.context.logger,
|
|
131
|
+
}),
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getTools(): HederaTool[] {
|
|
136
|
+
return this.tools;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getStateManager(): IStateManager | undefined {
|
|
140
|
+
return this.stateManager;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override async cleanup(): Promise<void> {
|
|
144
|
+
this.tools = [];
|
|
145
|
+
delete this.stateManager;
|
|
146
|
+
if (this.context?.logger) {
|
|
147
|
+
this.context.logger.info(
|
|
148
|
+
'HCS-10 Plugin cleaned up'
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HCS10Plugin } from './HCS10Plugin';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenericPluginContext,
|
|
3
|
+
HederaTool,
|
|
4
|
+
BasePlugin,
|
|
5
|
+
HederaAgentKit,
|
|
6
|
+
} from 'hedera-agent-kit';
|
|
7
|
+
import {
|
|
8
|
+
HCS2Builder,
|
|
9
|
+
CreateRegistryTool,
|
|
10
|
+
RegisterEntryTool,
|
|
11
|
+
UpdateEntryTool,
|
|
12
|
+
DeleteEntryTool,
|
|
13
|
+
MigrateRegistryTool,
|
|
14
|
+
QueryRegistryTool,
|
|
15
|
+
} from '@hashgraphonline/standards-agent-kit';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Plugin providing HCS-2 registry management tools
|
|
19
|
+
*/
|
|
20
|
+
export class HCS2Plugin extends BasePlugin {
|
|
21
|
+
id = 'hcs-2';
|
|
22
|
+
name = 'HCS-2 Plugin';
|
|
23
|
+
description =
|
|
24
|
+
'HCS-2 registry management tools for decentralized registries on Hedera';
|
|
25
|
+
version = '1.0.0';
|
|
26
|
+
author = 'Hashgraph Online';
|
|
27
|
+
namespace = 'hcs2';
|
|
28
|
+
|
|
29
|
+
private tools: HederaTool[] = [];
|
|
30
|
+
|
|
31
|
+
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
32
|
+
await super.initialize(context);
|
|
33
|
+
|
|
34
|
+
const hederaKit = context.config.hederaKit as HederaAgentKit;
|
|
35
|
+
if (!hederaKit) {
|
|
36
|
+
this.context.logger.warn(
|
|
37
|
+
'HederaKit not found in context. HCS-2 tools will not be available.'
|
|
38
|
+
);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
this.initializeTools();
|
|
44
|
+
|
|
45
|
+
this.context.logger.info(
|
|
46
|
+
'HCS-2 Plugin initialized successfully'
|
|
47
|
+
);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
this.context.logger.error(
|
|
50
|
+
'Failed to initialize HCS-2 plugin:',
|
|
51
|
+
error
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private initializeTools(): void {
|
|
57
|
+
const hederaKit = this.context.config.hederaKit as HederaAgentKit;
|
|
58
|
+
if (!hederaKit) {
|
|
59
|
+
throw new Error('HederaKit not found in context config');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const hcs2Builder = new HCS2Builder(hederaKit);
|
|
63
|
+
|
|
64
|
+
this.tools = [
|
|
65
|
+
new CreateRegistryTool({
|
|
66
|
+
hederaKit: hederaKit,
|
|
67
|
+
hcs2Builder: hcs2Builder,
|
|
68
|
+
logger: this.context.logger,
|
|
69
|
+
}),
|
|
70
|
+
new RegisterEntryTool({
|
|
71
|
+
hederaKit: hederaKit,
|
|
72
|
+
hcs2Builder: hcs2Builder,
|
|
73
|
+
logger: this.context.logger,
|
|
74
|
+
}),
|
|
75
|
+
new UpdateEntryTool({
|
|
76
|
+
hederaKit: hederaKit,
|
|
77
|
+
hcs2Builder: hcs2Builder,
|
|
78
|
+
logger: this.context.logger,
|
|
79
|
+
}),
|
|
80
|
+
new DeleteEntryTool({
|
|
81
|
+
hederaKit: hederaKit,
|
|
82
|
+
hcs2Builder: hcs2Builder,
|
|
83
|
+
logger: this.context.logger,
|
|
84
|
+
}),
|
|
85
|
+
new MigrateRegistryTool({
|
|
86
|
+
hederaKit: hederaKit,
|
|
87
|
+
hcs2Builder: hcs2Builder,
|
|
88
|
+
logger: this.context.logger,
|
|
89
|
+
}),
|
|
90
|
+
new QueryRegistryTool({
|
|
91
|
+
hederaKit: hederaKit,
|
|
92
|
+
hcs2Builder: hcs2Builder,
|
|
93
|
+
logger: this.context.logger,
|
|
94
|
+
}),
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getTools(): HederaTool[] {
|
|
99
|
+
return this.tools;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
override async cleanup(): Promise<void> {
|
|
103
|
+
this.tools = [];
|
|
104
|
+
if (this.context?.logger) {
|
|
105
|
+
this.context.logger.info('HCS-2 Plugin cleaned up');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HCS2Plugin } from './HCS2Plugin';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenericPluginContext,
|
|
3
|
+
HederaTool,
|
|
4
|
+
BasePlugin,
|
|
5
|
+
HederaAgentKit,
|
|
6
|
+
} from 'hedera-agent-kit';
|
|
7
|
+
import {
|
|
8
|
+
InscriberBuilder,
|
|
9
|
+
InscribeFromUrlTool,
|
|
10
|
+
InscribeFromFileTool,
|
|
11
|
+
InscribeFromBufferTool,
|
|
12
|
+
InscribeHashinalTool,
|
|
13
|
+
RetrieveInscriptionTool,
|
|
14
|
+
} from '@hashgraphonline/standards-agent-kit';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Plugin providing content inscription tools for Hedera
|
|
18
|
+
*/
|
|
19
|
+
export class InscribePlugin extends BasePlugin {
|
|
20
|
+
id = 'inscribe';
|
|
21
|
+
name = 'Inscribe Plugin';
|
|
22
|
+
description =
|
|
23
|
+
'Content inscription tools for storing data on Hedera Consensus Service';
|
|
24
|
+
version = '1.0.0';
|
|
25
|
+
author = 'Hashgraph Online';
|
|
26
|
+
namespace = 'inscribe';
|
|
27
|
+
|
|
28
|
+
private tools: HederaTool[] = [];
|
|
29
|
+
|
|
30
|
+
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
31
|
+
await super.initialize(context);
|
|
32
|
+
|
|
33
|
+
const hederaKit = context.config.hederaKit as HederaAgentKit;
|
|
34
|
+
if (!hederaKit) {
|
|
35
|
+
this.context.logger.warn(
|
|
36
|
+
'HederaKit not found in context. Inscription tools will not be available.'
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
this.initializeTools();
|
|
43
|
+
|
|
44
|
+
this.context.logger.info(
|
|
45
|
+
'Inscribe Plugin initialized successfully'
|
|
46
|
+
);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
this.context.logger.error(
|
|
49
|
+
'Failed to initialize Inscribe plugin:',
|
|
50
|
+
error
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private initializeTools(): void {
|
|
56
|
+
const hederaKit = this.context.config.hederaKit as HederaAgentKit;
|
|
57
|
+
if (!hederaKit) {
|
|
58
|
+
throw new Error('HederaKit not found in context config');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const inscriberBuilder = new InscriberBuilder(hederaKit);
|
|
62
|
+
|
|
63
|
+
this.tools = [
|
|
64
|
+
new InscribeFromUrlTool({
|
|
65
|
+
hederaKit: hederaKit,
|
|
66
|
+
inscriberBuilder: inscriberBuilder,
|
|
67
|
+
logger: this.context.logger,
|
|
68
|
+
}),
|
|
69
|
+
new InscribeFromFileTool({
|
|
70
|
+
hederaKit: hederaKit,
|
|
71
|
+
inscriberBuilder: inscriberBuilder,
|
|
72
|
+
logger: this.context.logger,
|
|
73
|
+
}),
|
|
74
|
+
new InscribeFromBufferTool({
|
|
75
|
+
hederaKit: hederaKit,
|
|
76
|
+
inscriberBuilder: inscriberBuilder,
|
|
77
|
+
logger: this.context.logger,
|
|
78
|
+
}),
|
|
79
|
+
new InscribeHashinalTool({
|
|
80
|
+
hederaKit: hederaKit,
|
|
81
|
+
inscriberBuilder: inscriberBuilder,
|
|
82
|
+
logger: this.context.logger,
|
|
83
|
+
}),
|
|
84
|
+
new RetrieveInscriptionTool({
|
|
85
|
+
hederaKit: hederaKit,
|
|
86
|
+
inscriberBuilder: inscriberBuilder,
|
|
87
|
+
logger: this.context.logger,
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getTools(): HederaTool[] {
|
|
93
|
+
return this.tools;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override async cleanup(): Promise<void> {
|
|
97
|
+
this.tools = [];
|
|
98
|
+
if (this.context?.logger) {
|
|
99
|
+
this.context.logger.info('Inscribe Plugin cleaned up');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InscribePlugin } from './InscribePlugin';
|