@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,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=`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.`;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,...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
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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,MAAQ,CACX,IAAIe,oBAAkB,CACpBX,YACAS,eACAL,OAAQf,KAAKS,QAAQM,SAEvB,IAAIQ,wBAAsB,CACxBZ,YACAS,eACAL,OAAQf,KAAKS,QAAQM,SAEvB,IAAIS,sBAAoB,CACtBb,YACAS,eACAL,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KwG,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"}
|
|
@@ -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,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';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HCS10Plugin } from "./index2.js";
|
|
2
|
+
import { HCS2Plugin } from "./index3.js";
|
|
3
|
+
import { InscribePlugin } from "./index4.js";
|
|
4
|
+
import { ConversationalAgent } from "./index5.js";
|
|
5
|
+
export * from "hedera-agent-kit";
|
|
6
|
+
export {
|
|
7
|
+
ConversationalAgent,
|
|
8
|
+
HCS10Plugin,
|
|
9
|
+
HCS2Plugin,
|
|
10
|
+
InscribePlugin
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { BasePlugin } from "hedera-agent-kit";
|
|
2
|
+
import { OpenConvaiState, HCS10Builder, RegisterAgentTool, FindRegistrationsTool, RetrieveProfileTool, InitiateConnectionTool, ListConnectionsTool, SendMessageToConnectionTool, CheckMessagesTool, ConnectionMonitorTool, ManageConnectionRequestsTool, AcceptConnectionRequestTool, ListUnapprovedConnectionRequestsTool } from "@hashgraphonline/standards-agent-kit";
|
|
3
|
+
class HCS10Plugin extends BasePlugin {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.id = "hcs-10";
|
|
7
|
+
this.name = "HCS-10 Plugin";
|
|
8
|
+
this.description = "HCS-10 agent tools for decentralized agent registration, connections, and messaging on Hedera";
|
|
9
|
+
this.version = "1.0.0";
|
|
10
|
+
this.author = "Hashgraph Online";
|
|
11
|
+
this.namespace = "hcs10";
|
|
12
|
+
this.tools = [];
|
|
13
|
+
}
|
|
14
|
+
async initialize(context) {
|
|
15
|
+
await super.initialize(context);
|
|
16
|
+
const hederaKit = context.config.hederaKit;
|
|
17
|
+
if (!hederaKit) {
|
|
18
|
+
this.context.logger.warn(
|
|
19
|
+
"HederaKit not found in context. HCS-10 tools will not be available."
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
this.stateManager = context.stateManager || new OpenConvaiState();
|
|
25
|
+
this.initializeTools();
|
|
26
|
+
this.context.logger.info(
|
|
27
|
+
"HCS-10 Plugin initialized successfully"
|
|
28
|
+
);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
this.context.logger.error(
|
|
31
|
+
"Failed to initialize HCS-10 plugin:",
|
|
32
|
+
error
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
initializeTools() {
|
|
37
|
+
if (!this.stateManager) {
|
|
38
|
+
throw new Error("StateManager must be initialized before creating tools");
|
|
39
|
+
}
|
|
40
|
+
const hederaKit = this.context.config.hederaKit;
|
|
41
|
+
if (!hederaKit) {
|
|
42
|
+
throw new Error("HederaKit not found in context config");
|
|
43
|
+
}
|
|
44
|
+
const hcs10Builder = new HCS10Builder(hederaKit, this.stateManager);
|
|
45
|
+
this.tools = [
|
|
46
|
+
new RegisterAgentTool({
|
|
47
|
+
hederaKit,
|
|
48
|
+
hcs10Builder,
|
|
49
|
+
logger: this.context.logger
|
|
50
|
+
}),
|
|
51
|
+
new FindRegistrationsTool({
|
|
52
|
+
hederaKit,
|
|
53
|
+
hcs10Builder,
|
|
54
|
+
logger: this.context.logger
|
|
55
|
+
}),
|
|
56
|
+
new RetrieveProfileTool({
|
|
57
|
+
hederaKit,
|
|
58
|
+
hcs10Builder,
|
|
59
|
+
logger: this.context.logger
|
|
60
|
+
}),
|
|
61
|
+
new InitiateConnectionTool({
|
|
62
|
+
hederaKit,
|
|
63
|
+
hcs10Builder,
|
|
64
|
+
logger: this.context.logger
|
|
65
|
+
}),
|
|
66
|
+
new ListConnectionsTool({
|
|
67
|
+
hederaKit,
|
|
68
|
+
hcs10Builder,
|
|
69
|
+
logger: this.context.logger
|
|
70
|
+
}),
|
|
71
|
+
new SendMessageToConnectionTool({
|
|
72
|
+
hederaKit,
|
|
73
|
+
hcs10Builder,
|
|
74
|
+
logger: this.context.logger
|
|
75
|
+
}),
|
|
76
|
+
new CheckMessagesTool({
|
|
77
|
+
hederaKit,
|
|
78
|
+
hcs10Builder,
|
|
79
|
+
logger: this.context.logger
|
|
80
|
+
}),
|
|
81
|
+
new ConnectionMonitorTool({
|
|
82
|
+
hederaKit,
|
|
83
|
+
hcs10Builder,
|
|
84
|
+
logger: this.context.logger
|
|
85
|
+
}),
|
|
86
|
+
new ManageConnectionRequestsTool({
|
|
87
|
+
hederaKit,
|
|
88
|
+
hcs10Builder,
|
|
89
|
+
logger: this.context.logger
|
|
90
|
+
}),
|
|
91
|
+
new AcceptConnectionRequestTool({
|
|
92
|
+
hederaKit,
|
|
93
|
+
hcs10Builder,
|
|
94
|
+
logger: this.context.logger
|
|
95
|
+
}),
|
|
96
|
+
new ListUnapprovedConnectionRequestsTool({
|
|
97
|
+
hederaKit,
|
|
98
|
+
hcs10Builder,
|
|
99
|
+
logger: this.context.logger
|
|
100
|
+
})
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
getTools() {
|
|
104
|
+
return this.tools;
|
|
105
|
+
}
|
|
106
|
+
getStateManager() {
|
|
107
|
+
return this.stateManager;
|
|
108
|
+
}
|
|
109
|
+
async cleanup() {
|
|
110
|
+
this.tools = [];
|
|
111
|
+
delete this.stateManager;
|
|
112
|
+
if (this.context?.logger) {
|
|
113
|
+
this.context.logger.info(
|
|
114
|
+
"HCS-10 Plugin cleaned up"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
HCS10Plugin
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=index2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index2.js","sources":["../../src/plugins/hcs-10/HCS10Plugin.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"],"names":[],"mappings":";;AAuBO,MAAM,oBAAoB,WAAW;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AK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,oBAAoB;AAAA,QACtB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,4BAA4B;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,kBAAkB;AAAA,QACpB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,sBAAsB;AAAA,QACxB;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,6BAA6B;AAAA,QAC/B;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,4BAA4B;AAAA,QAC9B;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,MACD,IAAI,qCAAqC;AAAA,QACvC;AAAA,QACA;AAAA,QACA,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,kBAA6C;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AACb,WAAO,KAAK;AACZ,QAAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO;AAAA,QAClB;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BasePlugin } from "hedera-agent-kit";
|
|
2
|
+
import { HCS2Builder, CreateRegistryTool, RegisterEntryTool, UpdateEntryTool, DeleteEntryTool, MigrateRegistryTool, QueryRegistryTool } from "@hashgraphonline/standards-agent-kit";
|
|
3
|
+
class HCS2Plugin extends BasePlugin {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.id = "hcs-2";
|
|
7
|
+
this.name = "HCS-2 Plugin";
|
|
8
|
+
this.description = "HCS-2 registry management tools for decentralized registries on Hedera";
|
|
9
|
+
this.version = "1.0.0";
|
|
10
|
+
this.author = "Hashgraph Online";
|
|
11
|
+
this.namespace = "hcs2";
|
|
12
|
+
this.tools = [];
|
|
13
|
+
}
|
|
14
|
+
async initialize(context) {
|
|
15
|
+
await super.initialize(context);
|
|
16
|
+
const hederaKit = context.config.hederaKit;
|
|
17
|
+
if (!hederaKit) {
|
|
18
|
+
this.context.logger.warn(
|
|
19
|
+
"HederaKit not found in context. HCS-2 tools will not be available."
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
this.initializeTools();
|
|
25
|
+
this.context.logger.info(
|
|
26
|
+
"HCS-2 Plugin initialized successfully"
|
|
27
|
+
);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
this.context.logger.error(
|
|
30
|
+
"Failed to initialize HCS-2 plugin:",
|
|
31
|
+
error
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
initializeTools() {
|
|
36
|
+
const hederaKit = this.context.config.hederaKit;
|
|
37
|
+
if (!hederaKit) {
|
|
38
|
+
throw new Error("HederaKit not found in context config");
|
|
39
|
+
}
|
|
40
|
+
const hcs2Builder = new HCS2Builder(hederaKit);
|
|
41
|
+
this.tools = [
|
|
42
|
+
new CreateRegistryTool({
|
|
43
|
+
hederaKit,
|
|
44
|
+
hcs2Builder,
|
|
45
|
+
logger: this.context.logger
|
|
46
|
+
}),
|
|
47
|
+
new RegisterEntryTool({
|
|
48
|
+
hederaKit,
|
|
49
|
+
hcs2Builder,
|
|
50
|
+
logger: this.context.logger
|
|
51
|
+
}),
|
|
52
|
+
new UpdateEntryTool({
|
|
53
|
+
hederaKit,
|
|
54
|
+
hcs2Builder,
|
|
55
|
+
logger: this.context.logger
|
|
56
|
+
}),
|
|
57
|
+
new DeleteEntryTool({
|
|
58
|
+
hederaKit,
|
|
59
|
+
hcs2Builder,
|
|
60
|
+
logger: this.context.logger
|
|
61
|
+
}),
|
|
62
|
+
new MigrateRegistryTool({
|
|
63
|
+
hederaKit,
|
|
64
|
+
hcs2Builder,
|
|
65
|
+
logger: this.context.logger
|
|
66
|
+
}),
|
|
67
|
+
new QueryRegistryTool({
|
|
68
|
+
hederaKit,
|
|
69
|
+
hcs2Builder,
|
|
70
|
+
logger: this.context.logger
|
|
71
|
+
})
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
getTools() {
|
|
75
|
+
return this.tools;
|
|
76
|
+
}
|
|
77
|
+
async cleanup() {
|
|
78
|
+
this.tools = [];
|
|
79
|
+
if (this.context?.logger) {
|
|
80
|
+
this.context.logger.info("HCS-2 Plugin cleaned up");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
HCS2Plugin
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=index3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index3.js","sources":["../../src/plugins/hcs-2/HCS2Plugin.ts"],"sourcesContent":["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}"],"names":[],"mappings":";;AAmBO,MAAM,mBAAmB,WAAW;AAAA,EAApC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,UAAU;AACV,SAAA,SAAS;AACT,SAAA,YAAY;AAEZ,SAAQ,QAAsB,CAAA;AAAA,EAAC;AAAA,EAE/B,MAAe,WAAW,SAA8C;AACtE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AAI,KAAK,SAAS,QAAQ;AACxB,WAAK,QAAQ,OAAO,KAAK,yBAAyB;AAAA,IACpD;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BasePlugin } from "hedera-agent-kit";
|
|
2
|
+
import { InscriberBuilder, InscribeFromUrlTool, InscribeFromFileTool, InscribeFromBufferTool, InscribeHashinalTool, RetrieveInscriptionTool } from "@hashgraphonline/standards-agent-kit";
|
|
3
|
+
class InscribePlugin extends BasePlugin {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.id = "inscribe";
|
|
7
|
+
this.name = "Inscribe Plugin";
|
|
8
|
+
this.description = "Content inscription tools for storing data on Hedera Consensus Service";
|
|
9
|
+
this.version = "1.0.0";
|
|
10
|
+
this.author = "Hashgraph Online";
|
|
11
|
+
this.namespace = "inscribe";
|
|
12
|
+
this.tools = [];
|
|
13
|
+
}
|
|
14
|
+
async initialize(context) {
|
|
15
|
+
await super.initialize(context);
|
|
16
|
+
const hederaKit = context.config.hederaKit;
|
|
17
|
+
if (!hederaKit) {
|
|
18
|
+
this.context.logger.warn(
|
|
19
|
+
"HederaKit not found in context. Inscription tools will not be available."
|
|
20
|
+
);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
this.initializeTools();
|
|
25
|
+
this.context.logger.info(
|
|
26
|
+
"Inscribe Plugin initialized successfully"
|
|
27
|
+
);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
this.context.logger.error(
|
|
30
|
+
"Failed to initialize Inscribe plugin:",
|
|
31
|
+
error
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
initializeTools() {
|
|
36
|
+
const hederaKit = this.context.config.hederaKit;
|
|
37
|
+
if (!hederaKit) {
|
|
38
|
+
throw new Error("HederaKit not found in context config");
|
|
39
|
+
}
|
|
40
|
+
const inscriberBuilder = new InscriberBuilder(hederaKit);
|
|
41
|
+
this.tools = [
|
|
42
|
+
new InscribeFromUrlTool({
|
|
43
|
+
hederaKit,
|
|
44
|
+
inscriberBuilder,
|
|
45
|
+
logger: this.context.logger
|
|
46
|
+
}),
|
|
47
|
+
new InscribeFromFileTool({
|
|
48
|
+
hederaKit,
|
|
49
|
+
inscriberBuilder,
|
|
50
|
+
logger: this.context.logger
|
|
51
|
+
}),
|
|
52
|
+
new InscribeFromBufferTool({
|
|
53
|
+
hederaKit,
|
|
54
|
+
inscriberBuilder,
|
|
55
|
+
logger: this.context.logger
|
|
56
|
+
}),
|
|
57
|
+
new InscribeHashinalTool({
|
|
58
|
+
hederaKit,
|
|
59
|
+
inscriberBuilder,
|
|
60
|
+
logger: this.context.logger
|
|
61
|
+
}),
|
|
62
|
+
new RetrieveInscriptionTool({
|
|
63
|
+
hederaKit,
|
|
64
|
+
inscriberBuilder,
|
|
65
|
+
logger: this.context.logger
|
|
66
|
+
})
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
getTools() {
|
|
70
|
+
return this.tools;
|
|
71
|
+
}
|
|
72
|
+
async cleanup() {
|
|
73
|
+
this.tools = [];
|
|
74
|
+
if (this.context?.logger) {
|
|
75
|
+
this.context.logger.info("Inscribe Plugin cleaned up");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
InscribePlugin
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=index4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index4.js","sources":["../../src/plugins/inscribe/InscribePlugin.ts"],"sourcesContent":["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}"],"names":[],"mappings":";;AAkBO,MAAM,uBAAuB,WAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP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