@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.
Files changed (47) hide show
  1. package/LICENSE +189 -0
  2. package/README.md +387 -0
  3. package/dist/cjs/config/system-message.d.ts +1 -0
  4. package/dist/cjs/conversational-agent.d.ts +92 -0
  5. package/dist/cjs/index.cjs +2 -0
  6. package/dist/cjs/index.cjs.map +1 -0
  7. package/dist/cjs/index.d.ts +7 -0
  8. package/dist/cjs/plugins/hcs-10/HCS10Plugin.d.ts +18 -0
  9. package/dist/cjs/plugins/hcs-10/index.d.ts +1 -0
  10. package/dist/cjs/plugins/hcs-2/HCS2Plugin.d.ts +18 -0
  11. package/dist/cjs/plugins/hcs-2/index.d.ts +1 -0
  12. package/dist/cjs/plugins/index.d.ts +3 -0
  13. package/dist/cjs/plugins/inscribe/InscribePlugin.d.ts +18 -0
  14. package/dist/cjs/plugins/inscribe/index.d.ts +1 -0
  15. package/dist/esm/index.js +12 -0
  16. package/dist/esm/index.js.map +1 -0
  17. package/dist/esm/index2.js +122 -0
  18. package/dist/esm/index2.js.map +1 -0
  19. package/dist/esm/index3.js +87 -0
  20. package/dist/esm/index3.js.map +1 -0
  21. package/dist/esm/index4.js +82 -0
  22. package/dist/esm/index4.js.map +1 -0
  23. package/dist/esm/index5.js +217 -0
  24. package/dist/esm/index5.js.map +1 -0
  25. package/dist/esm/index6.js +16 -0
  26. package/dist/esm/index6.js.map +1 -0
  27. package/dist/types/config/system-message.d.ts +1 -0
  28. package/dist/types/conversational-agent.d.ts +92 -0
  29. package/dist/types/index.d.ts +7 -0
  30. package/dist/types/plugins/hcs-10/HCS10Plugin.d.ts +18 -0
  31. package/dist/types/plugins/hcs-10/index.d.ts +1 -0
  32. package/dist/types/plugins/hcs-2/HCS2Plugin.d.ts +18 -0
  33. package/dist/types/plugins/hcs-2/index.d.ts +1 -0
  34. package/dist/types/plugins/index.d.ts +3 -0
  35. package/dist/types/plugins/inscribe/InscribePlugin.d.ts +18 -0
  36. package/dist/types/plugins/inscribe/index.d.ts +1 -0
  37. package/package.json +103 -0
  38. package/src/config/system-message.ts +12 -0
  39. package/src/conversational-agent.ts +309 -0
  40. package/src/index.ts +9 -0
  41. package/src/plugins/hcs-10/HCS10Plugin.ts +152 -0
  42. package/src/plugins/hcs-10/index.ts +1 -0
  43. package/src/plugins/hcs-2/HCS2Plugin.ts +108 -0
  44. package/src/plugins/hcs-2/index.ts +1 -0
  45. package/src/plugins/index.ts +3 -0
  46. package/src/plugins/inscribe/InscribePlugin.ts +102 -0
  47. package/src/plugins/inscribe/index.ts +1 -0
@@ -0,0 +1,217 @@
1
+ import { ServerSigner, getAllHederaCorePlugins, HederaConversationalAgent } from "hedera-agent-kit";
2
+ import { HCS10Plugin } from "./index2.js";
3
+ import { HCS2Plugin } from "./index3.js";
4
+ import { InscribePlugin } from "./index4.js";
5
+ import { OpenConvaiState } from "@hashgraphonline/standards-agent-kit";
6
+ import { Logger, HederaMirrorNode } from "@hashgraphonline/standards-sdk";
7
+ import { PrivateKey } from "@hashgraph/sdk";
8
+ import { SYSTEM_MESSAGE } from "./index6.js";
9
+ class ConversationalAgent {
10
+ constructor(options) {
11
+ this.options = options;
12
+ this.stateManager = options.stateManager || new OpenConvaiState();
13
+ this.hcs10Plugin = new HCS10Plugin();
14
+ this.hcs2Plugin = new HCS2Plugin();
15
+ this.inscribePlugin = new InscribePlugin();
16
+ this.logger = new Logger({ module: "ConversationalAgent" });
17
+ }
18
+ async initialize() {
19
+ const {
20
+ accountId,
21
+ privateKey,
22
+ network = "testnet",
23
+ openAIApiKey,
24
+ openAIModelName = "gpt-4o",
25
+ verbose = false,
26
+ operationalMode = "autonomous",
27
+ userAccountId,
28
+ customSystemMessagePreamble,
29
+ customSystemMessagePostamble,
30
+ additionalPlugins = [],
31
+ scheduleUserTransactionsInBytesMode,
32
+ mirrorNodeConfig,
33
+ disableLogging
34
+ } = this.options;
35
+ if (!accountId || !privateKey) {
36
+ throw new Error("Account ID and private key are required");
37
+ }
38
+ try {
39
+ const mirrorNode = new HederaMirrorNode(network, this.logger);
40
+ const accountInfo = await mirrorNode.requestAccount(accountId);
41
+ const keyType = accountInfo?.key?._type || "";
42
+ let privateKeyInstance;
43
+ if (keyType?.toLowerCase()?.includes("ecdsa")) {
44
+ privateKeyInstance = PrivateKey.fromStringECDSA(privateKey);
45
+ } else {
46
+ privateKeyInstance = PrivateKey.fromStringED25519(privateKey);
47
+ }
48
+ const serverSigner = new ServerSigner(
49
+ accountId,
50
+ privateKeyInstance,
51
+ network
52
+ );
53
+ const standardPlugins = [
54
+ this.hcs10Plugin,
55
+ this.hcs2Plugin,
56
+ this.inscribePlugin
57
+ ];
58
+ const corePlugins = getAllHederaCorePlugins();
59
+ let allPlugins;
60
+ if (this.options.enabledPlugins) {
61
+ const enabledSet = new Set(this.options.enabledPlugins);
62
+ const filteredPlugins = [...standardPlugins, ...corePlugins].filter(
63
+ (plugin) => enabledSet.has(plugin.id)
64
+ );
65
+ allPlugins = [...filteredPlugins, ...additionalPlugins];
66
+ } else {
67
+ allPlugins = [...standardPlugins, ...corePlugins, ...additionalPlugins];
68
+ }
69
+ const agentConfig = {
70
+ pluginConfig: {
71
+ plugins: allPlugins,
72
+ appConfig: {
73
+ stateManager: this.stateManager
74
+ }
75
+ },
76
+ openAIApiKey,
77
+ openAIModelName,
78
+ verbose,
79
+ operationalMode,
80
+ userAccountId,
81
+ customSystemMessagePreamble: customSystemMessagePreamble || SYSTEM_MESSAGE,
82
+ ...customSystemMessagePostamble !== void 0 && {
83
+ customSystemMessagePostamble
84
+ },
85
+ ...scheduleUserTransactionsInBytesMode !== void 0 && {
86
+ scheduleUserTransactionsInBytesMode
87
+ },
88
+ ...mirrorNodeConfig !== void 0 && { mirrorNodeConfig },
89
+ ...disableLogging !== void 0 && { disableLogging }
90
+ };
91
+ this.conversationalAgent = new HederaConversationalAgent(
92
+ serverSigner,
93
+ agentConfig
94
+ );
95
+ await this.conversationalAgent.initialize();
96
+ } catch (error) {
97
+ this.logger.error("Failed to initialize ConversationalAgent:", error);
98
+ throw error;
99
+ }
100
+ }
101
+ getPlugin() {
102
+ return this.hcs10Plugin;
103
+ }
104
+ getStateManager() {
105
+ return this.stateManager;
106
+ }
107
+ getConversationalAgent() {
108
+ if (!this.conversationalAgent) {
109
+ throw new Error(
110
+ "ConversationalAgent not initialized. Call initialize() first."
111
+ );
112
+ }
113
+ return this.conversationalAgent;
114
+ }
115
+ async processMessage(message, chatHistory = []) {
116
+ if (!this.conversationalAgent) {
117
+ throw new Error(
118
+ "ConversationalAgent not initialized. Call initialize() first."
119
+ );
120
+ }
121
+ return this.conversationalAgent.processMessage(message, chatHistory);
122
+ }
123
+ /**
124
+ * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled
125
+ */
126
+ static withHTS(options) {
127
+ return new ConversationalAgent({
128
+ ...options,
129
+ enabledPlugins: ["hts-token"]
130
+ });
131
+ }
132
+ /**
133
+ * Create a ConversationalAgent with only HCS-2 tools enabled
134
+ */
135
+ static withHCS2(options) {
136
+ return new ConversationalAgent({
137
+ ...options,
138
+ enabledPlugins: ["hcs-2"]
139
+ });
140
+ }
141
+ /**
142
+ * Create a ConversationalAgent with only HCS-10 tools enabled
143
+ */
144
+ static withHCS10(options) {
145
+ return new ConversationalAgent({
146
+ ...options,
147
+ enabledPlugins: ["hcs-10"]
148
+ });
149
+ }
150
+ /**
151
+ * Create a ConversationalAgent with only inscription tools enabled
152
+ */
153
+ static withInscribe(options) {
154
+ return new ConversationalAgent({
155
+ ...options,
156
+ enabledPlugins: ["inscribe"]
157
+ });
158
+ }
159
+ /**
160
+ * Create a ConversationalAgent with only account management tools enabled
161
+ */
162
+ static withAccount(options) {
163
+ return new ConversationalAgent({
164
+ ...options,
165
+ enabledPlugins: ["account"]
166
+ });
167
+ }
168
+ /**
169
+ * Create a ConversationalAgent with only file service tools enabled
170
+ */
171
+ static withFileService(options) {
172
+ return new ConversationalAgent({
173
+ ...options,
174
+ enabledPlugins: ["file-service"]
175
+ });
176
+ }
177
+ /**
178
+ * Create a ConversationalAgent with only consensus service tools enabled
179
+ */
180
+ static withConsensusService(options) {
181
+ return new ConversationalAgent({
182
+ ...options,
183
+ enabledPlugins: ["consensus-service"]
184
+ });
185
+ }
186
+ /**
187
+ * Create a ConversationalAgent with only smart contract tools enabled
188
+ */
189
+ static withSmartContract(options) {
190
+ return new ConversationalAgent({
191
+ ...options,
192
+ enabledPlugins: ["smart-contract"]
193
+ });
194
+ }
195
+ /**
196
+ * Create a ConversationalAgent with all HCS standards plugins
197
+ */
198
+ static withAllStandards(options) {
199
+ return new ConversationalAgent({
200
+ ...options,
201
+ enabledPlugins: ["hcs-10", "hcs-2", "inscribe"]
202
+ });
203
+ }
204
+ /**
205
+ * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)
206
+ */
207
+ static minimal(options) {
208
+ return new ConversationalAgent({
209
+ ...options,
210
+ enabledPlugins: []
211
+ });
212
+ }
213
+ }
214
+ export {
215
+ ConversationalAgent
216
+ };
217
+ //# sourceMappingURL=index5.js.map
@@ -0,0 +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;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IAAA,IACE,KAAK;AAET,QAAI,CAAC,aAAa,CAAC,YAAY;AAC7B,YAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AAEA,QAAI;AACF,YAAM,aAAa,IAAI,iBAAiB,SAAS,KAAK,MAAM;AAC5D,YAAM,cAAc,MAAM,WAAW,eAAe,SAAS;AAC7D,YAAM,UAAU,aAAa,KAAK,SAAS;AAE3C,UAAI;AACJ,UAAI,SAAS,YAAA,GAAe,SAAS,OAAO,GAAG;AAC7C,6BAAqB,WAAW,gBAAg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B;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;"}
@@ -0,0 +1,16 @@
1
+ const SYSTEM_MESSAGE = `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.
2
+
3
+ You have access to tools for:
4
+ - HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
5
+ - HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
6
+ - Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
7
+
8
+ *** IMPORTANT CONTEXT ***
9
+ You are currently operating as agent: ${accountId} on the Hashgraph Online network
10
+ When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId}
11
+
12
+ Remember the connection numbers when listing connections, as users might refer to them.`;
13
+ export {
14
+ SYSTEM_MESSAGE
15
+ };
16
+ //# sourceMappingURL=index6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index6.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["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.`"],"names":[],"mappings":"AAAO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAQU,SAAS;AAAA,gGAC+C,SAAS;AAAA;AAAA;"}
@@ -0,0 +1 @@
1
+ export declare const SYSTEM_MESSAGE: string;
@@ -0,0 +1,92 @@
1
+ import { HederaConversationalAgent, BasePlugin, AgentOperationalMode, AgentResponse, MirrorNodeConfig } from 'hedera-agent-kit';
2
+ import { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';
3
+ import { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';
4
+ import { InscribePlugin } from './plugins/inscribe/InscribePlugin';
5
+ import { IStateManager } from '@hashgraphonline/standards-agent-kit';
6
+ import { NetworkType } from '@hashgraphonline/standards-sdk';
7
+
8
+ export interface ConversationalAgentOptions {
9
+ accountId: string;
10
+ privateKey: string;
11
+ network?: NetworkType;
12
+ openAIApiKey: string;
13
+ openAIModelName?: string;
14
+ verbose?: boolean;
15
+ operationalMode?: AgentOperationalMode;
16
+ userAccountId?: string;
17
+ customSystemMessagePreamble?: string;
18
+ customSystemMessagePostamble?: string;
19
+ additionalPlugins?: BasePlugin[];
20
+ stateManager?: IStateManager;
21
+ scheduleUserTransactionsInBytesMode?: boolean;
22
+ mirrorNodeConfig?: MirrorNodeConfig;
23
+ disableLogging?: boolean;
24
+ enabledPlugins?: string[];
25
+ }
26
+ /**
27
+ * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,
28
+ * which includes the OpenConvAIPlugin and the OpenConvaiState by default.
29
+ * If you want to use a different plugin or state manager, you can pass them in the options.
30
+ * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.
31
+ *
32
+ * @param options - The options for the ConversationalAgent.
33
+ * @returns A new instance of the ConversationalAgent class.
34
+ */
35
+ export declare class ConversationalAgent {
36
+ conversationalAgent?: HederaConversationalAgent;
37
+ hcs10Plugin: HCS10Plugin;
38
+ hcs2Plugin: HCS2Plugin;
39
+ inscribePlugin: InscribePlugin;
40
+ stateManager: IStateManager;
41
+ private options;
42
+ private logger;
43
+ constructor(options: ConversationalAgentOptions);
44
+ initialize(): Promise<void>;
45
+ getPlugin(): HCS10Plugin;
46
+ getStateManager(): IStateManager;
47
+ getConversationalAgent(): HederaConversationalAgent;
48
+ processMessage(message: string, chatHistory?: {
49
+ type: 'human' | 'ai';
50
+ content: string;
51
+ }[]): Promise<AgentResponse>;
52
+ /**
53
+ * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled
54
+ */
55
+ static withHTS(options: ConversationalAgentOptions): ConversationalAgent;
56
+ /**
57
+ * Create a ConversationalAgent with only HCS-2 tools enabled
58
+ */
59
+ static withHCS2(options: ConversationalAgentOptions): ConversationalAgent;
60
+ /**
61
+ * Create a ConversationalAgent with only HCS-10 tools enabled
62
+ */
63
+ static withHCS10(options: ConversationalAgentOptions): ConversationalAgent;
64
+ /**
65
+ * Create a ConversationalAgent with only inscription tools enabled
66
+ */
67
+ static withInscribe(options: ConversationalAgentOptions): ConversationalAgent;
68
+ /**
69
+ * Create a ConversationalAgent with only account management tools enabled
70
+ */
71
+ static withAccount(options: ConversationalAgentOptions): ConversationalAgent;
72
+ /**
73
+ * Create a ConversationalAgent with only file service tools enabled
74
+ */
75
+ static withFileService(options: ConversationalAgentOptions): ConversationalAgent;
76
+ /**
77
+ * Create a ConversationalAgent with only consensus service tools enabled
78
+ */
79
+ static withConsensusService(options: ConversationalAgentOptions): ConversationalAgent;
80
+ /**
81
+ * Create a ConversationalAgent with only smart contract tools enabled
82
+ */
83
+ static withSmartContract(options: ConversationalAgentOptions): ConversationalAgent;
84
+ /**
85
+ * Create a ConversationalAgent with all HCS standards plugins
86
+ */
87
+ static withAllStandards(options: ConversationalAgentOptions): ConversationalAgent;
88
+ /**
89
+ * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)
90
+ */
91
+ static minimal(options: ConversationalAgentOptions): ConversationalAgent;
92
+ }
@@ -0,0 +1,7 @@
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
+ export * from 'hedera-agent-kit';
7
+ export type { IStateManager } from '@hashgraphonline/standards-agent-kit';
@@ -0,0 +1,18 @@
1
+ import { GenericPluginContext, HederaTool, BasePlugin } from 'hedera-agent-kit';
2
+ import { IStateManager } from '@hashgraphonline/standards-agent-kit';
3
+
4
+ export declare class HCS10Plugin extends BasePlugin {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ version: string;
9
+ author: string;
10
+ namespace: string;
11
+ private stateManager?;
12
+ private tools;
13
+ initialize(context: GenericPluginContext): Promise<void>;
14
+ private initializeTools;
15
+ getTools(): HederaTool[];
16
+ getStateManager(): IStateManager | undefined;
17
+ cleanup(): Promise<void>;
18
+ }
@@ -0,0 +1 @@
1
+ export { HCS10Plugin } from './HCS10Plugin';
@@ -0,0 +1,18 @@
1
+ import { GenericPluginContext, HederaTool, BasePlugin } from 'hedera-agent-kit';
2
+
3
+ /**
4
+ * Plugin providing HCS-2 registry management tools
5
+ */
6
+ export declare class HCS2Plugin extends BasePlugin {
7
+ id: string;
8
+ name: string;
9
+ description: string;
10
+ version: string;
11
+ author: string;
12
+ namespace: string;
13
+ private tools;
14
+ initialize(context: GenericPluginContext): Promise<void>;
15
+ private initializeTools;
16
+ getTools(): HederaTool[];
17
+ cleanup(): Promise<void>;
18
+ }
@@ -0,0 +1 @@
1
+ export { HCS2Plugin } from './HCS2Plugin';
@@ -0,0 +1,3 @@
1
+ export { HCS10Plugin } from './hcs-10';
2
+ export { HCS2Plugin } from './hcs-2';
3
+ export { InscribePlugin } from './inscribe';
@@ -0,0 +1,18 @@
1
+ import { GenericPluginContext, HederaTool, BasePlugin } from 'hedera-agent-kit';
2
+
3
+ /**
4
+ * Plugin providing content inscription tools for Hedera
5
+ */
6
+ export declare class InscribePlugin extends BasePlugin {
7
+ id: string;
8
+ name: string;
9
+ description: string;
10
+ version: string;
11
+ author: string;
12
+ namespace: string;
13
+ private tools;
14
+ initialize(context: GenericPluginContext): Promise<void>;
15
+ private initializeTools;
16
+ getTools(): HederaTool[];
17
+ cleanup(): Promise<void>;
18
+ }
@@ -0,0 +1 @@
1
+ export { InscribePlugin } from './InscribePlugin';
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@hashgraphonline/conversational-agent",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/cjs/index.cjs",
6
+ "module": "./dist/esm/index.js",
7
+ "types": "./dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "browser": {
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/umd/conversational-agent.umd.js"
14
+ },
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/cjs/index.cjs"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src",
23
+ "LICENSE",
24
+ "README.md"
25
+ ],
26
+ "keywords": [
27
+ "hedera",
28
+ "hashgraph",
29
+ "consensus",
30
+ "standards",
31
+ "hcs",
32
+ "hcs-10",
33
+ "hcs-2",
34
+ "agent",
35
+ "ai",
36
+ "conversational",
37
+ "inscription",
38
+ "registry",
39
+ "openconvai",
40
+ "hashgraph-online"
41
+ ],
42
+ "author": "Hashgraph Online",
43
+ "license": "Apache-2.0",
44
+ "description": "Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera",
45
+ "devDependencies": {
46
+ "@eslint/eslintrc": "^3.3.1",
47
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
48
+ "@typescript-eslint/parser": "^8.38.0",
49
+ "dotenv": "^17.2.1",
50
+ "eslint": "^8.57.1",
51
+ "eslint-config-next": "14.1.0",
52
+ "eslint-plugin-sonarjs": "^3.0.4",
53
+ "rimraf": "^6.0.1",
54
+ "rollup-plugin-polyfill-node": "^0.13.0",
55
+ "terser": "^5.43.1",
56
+ "tsx": "^4.20.3",
57
+ "typescript": "^5.8.3",
58
+ "vite": "^6.3.5",
59
+ "vite-plugin-dts": "^3.9.1",
60
+ "vite-plugin-node-polyfills": "^0.23.0",
61
+ "vite-plugin-string-replace": "^1.1.5",
62
+ "vitest": "^3.2.4"
63
+ },
64
+ "dependencies": {
65
+ "@hashgraph/sdk": "^2.69.0",
66
+ "@hashgraphonline/standards-agent-kit": "^0.2.102",
67
+ "@hashgraphonline/standards-sdk": "^0.0.155",
68
+ "@langchain/core": "^0.3.66",
69
+ "hedera-agent-kit": "^2.0.3",
70
+ "zod": "^3.25.76"
71
+ },
72
+ "repository": {
73
+ "type": "git",
74
+ "url": "git+https://github.com/hashgraph-online/conversational-agent.git"
75
+ },
76
+ "directories": {
77
+ "test": "tests"
78
+ },
79
+ "bugs": {
80
+ "url": "https://github.com/hashgraph-online/conversational-agent/issues"
81
+ },
82
+ "homepage": "https://github.com/hashgraph-online/conversational-agent#readme",
83
+ "scripts": {
84
+ "test": "vitest run",
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
+ }
@@ -0,0 +1,12 @@
1
+ export const SYSTEM_MESSAGE = `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, and content inscription.
2
+
3
+ You have access to tools for:
4
+ - HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
5
+ - HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
6
+ - Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
7
+
8
+ *** IMPORTANT CONTEXT ***
9
+ You are currently operating as agent: ${accountId} on the Hashgraph Online network
10
+ When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId}
11
+
12
+ Remember the connection numbers when listing connections, as users might refer to them.`