@hashgraphonline/standards-agent-kit 0.0.26 → 0.0.27

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 (52) hide show
  1. package/dist/cjs/src/plugins/GenericPlugin.d.ts +4 -0
  2. package/dist/cjs/src/plugins/hedera/index.d.ts +1 -0
  3. package/dist/cjs/src/plugins/index.d.ts +1 -0
  4. package/dist/cjs/src/plugins/openconvai/OpenConvAIPlugin.d.ts +23 -0
  5. package/dist/cjs/src/plugins/openconvai/index.d.ts +1 -0
  6. package/dist/cjs/src/plugins/weather/index.d.ts +1 -0
  7. package/dist/cjs/standards-agent-kit.cjs +1 -1
  8. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  9. package/dist/es/src/plugins/GenericPlugin.d.ts +4 -0
  10. package/dist/es/src/plugins/hedera/index.d.ts +1 -0
  11. package/dist/es/src/plugins/index.d.ts +1 -0
  12. package/dist/es/src/plugins/openconvai/OpenConvAIPlugin.d.ts +23 -0
  13. package/dist/es/src/plugins/openconvai/index.d.ts +1 -0
  14. package/dist/es/src/plugins/weather/index.d.ts +1 -0
  15. package/dist/es/standards-agent-kit.es.js +2 -0
  16. package/dist/es/standards-agent-kit.es.js.map +1 -1
  17. package/dist/es/standards-agent-kit.es17.js +1 -1
  18. package/dist/es/standards-agent-kit.es2.js +1 -3
  19. package/dist/es/standards-agent-kit.es2.js.map +1 -1
  20. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  21. package/dist/es/standards-agent-kit.es23.js +98 -21
  22. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  23. package/dist/es/standards-agent-kit.es24.js +25 -3
  24. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  25. package/dist/es/standards-agent-kit.es25.js +3 -81
  26. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  27. package/dist/es/standards-agent-kit.es26.js +85 -0
  28. package/dist/es/standards-agent-kit.es26.js.map +1 -0
  29. package/dist/es/standards-agent-kit.es3.js +1 -1
  30. package/dist/es/standards-agent-kit.es4.js +1 -1
  31. package/dist/umd/src/plugins/GenericPlugin.d.ts +4 -0
  32. package/dist/umd/src/plugins/hedera/index.d.ts +1 -0
  33. package/dist/umd/src/plugins/index.d.ts +1 -0
  34. package/dist/umd/src/plugins/openconvai/OpenConvAIPlugin.d.ts +23 -0
  35. package/dist/umd/src/plugins/openconvai/index.d.ts +1 -0
  36. package/dist/umd/src/plugins/weather/index.d.ts +1 -0
  37. package/dist/umd/standards-agent-kit.umd.js +24 -24
  38. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  39. package/package.json +2 -1
  40. package/src/init.ts +3 -14
  41. package/src/plugins/GenericPlugin.ts +5 -0
  42. package/src/plugins/hedera/index.ts +1 -0
  43. package/src/plugins/index.ts +1 -0
  44. package/src/plugins/openconvai/OpenConvAIPlugin.ts +124 -0
  45. package/src/plugins/openconvai/index.ts +1 -0
  46. package/src/plugins/weather/index.ts +1 -0
  47. package/dist/cjs/src/plugins/hedera/__tests__/HbarPricePlugin.test.d.ts +0 -1
  48. package/dist/es/src/plugins/hedera/__tests__/HbarPricePlugin.test.d.ts +0 -1
  49. package/dist/umd/src/plugins/hedera/__tests__/HbarPricePlugin.test.d.ts +0 -1
  50. package/src/plugins/defi/plugin.json +0 -8
  51. package/src/plugins/hedera/__tests__/HbarPricePlugin.test.ts +0 -125
  52. package/src/plugins/weather/plugin.json +0 -8
@@ -5,6 +5,10 @@ import { StructuredTool } from '@langchain/core/tools';
5
5
  * Base class for platform-agnostic plugins that can be used across different implementations
6
6
  */
7
7
  export declare abstract class GenericPlugin extends BasePlugin<GenericPluginContext> {
8
+ /**
9
+ * Namespace for the plugin, used for organizing and categorizing plugins
10
+ */
11
+ abstract namespace: string;
8
12
  /**
9
13
  * Get the tools provided by this plugin
10
14
  * @returns Array of tools provided by this plugin
@@ -0,0 +1 @@
1
+ export * from './HbarPricePlugin';
@@ -4,3 +4,4 @@ export * from './BasePlugin';
4
4
  export * from './PluginLoader';
5
5
  export * from './hedera/HbarPricePlugin';
6
6
  export * from './GenericPlugin';
7
+ export * from './openconvai';
@@ -0,0 +1,23 @@
1
+ import { GenericPlugin } from '../GenericPlugin';
2
+ import { GenericPluginContext } from '../PluginInterface';
3
+ import { StructuredTool } from '@langchain/core/tools';
4
+ /**
5
+ * OpenConvAI Plugin that provides all the tools from standards-agent-kit
6
+ * This plugin enables full HCS-10 agent functionality including registration,
7
+ * connection management, and messaging capabilities.
8
+ */
9
+ export declare class OpenConvAIPlugin extends GenericPlugin {
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ version: string;
14
+ author: string;
15
+ namespace: string;
16
+ private hcs10Client?;
17
+ private stateManager?;
18
+ private tools;
19
+ initialize(context: GenericPluginContext): Promise<void>;
20
+ private initializeTools;
21
+ getTools(): StructuredTool[];
22
+ cleanup(): Promise<void>;
23
+ }
@@ -0,0 +1 @@
1
+ export * from './OpenConvAIPlugin';
@@ -9,6 +9,7 @@ export default class WeatherPlugin extends GenericPlugin {
9
9
  description: string;
10
10
  version: string;
11
11
  author: string;
12
+ namespace: string;
12
13
  private apiKey?;
13
14
  initialize(context: GenericPluginContext): Promise<void>;
14
15
  getTools(): StructuredTool[];
@@ -19,6 +19,7 @@ import { BasePlugin } from "./standards-agent-kit.es19.js";
19
19
  import { PluginLoader } from "./standards-agent-kit.es20.js";
20
20
  import { GetHbarPriceTool, HbarPricePlugin } from "./standards-agent-kit.es21.js";
21
21
  import { GenericPlugin } from "./standards-agent-kit.es22.js";
22
+ import { OpenConvAIPlugin } from "./standards-agent-kit.es23.js";
22
23
  export {
23
24
  AcceptConnectionRequestTool,
24
25
  BasePlugin,
@@ -34,6 +35,7 @@ export {
34
35
  ListConnectionsTool,
35
36
  ListUnapprovedConnectionRequestsTool,
36
37
  ManageConnectionRequestsTool,
38
+ OpenConvAIPlugin,
37
39
  OpenConvaiState,
38
40
  PluginLoader,
39
41
  PluginRegistry,
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"standards-agent-kit.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import process from "vite-plugin-node-polyfills/shims/process";
2
- import { updateEnvFile } from "./standards-agent-kit.es23.js";
2
+ import { updateEnvFile } from "./standards-agent-kit.es24.js";
3
3
  import { Logger, ConnectionsManager } from "@hashgraphonline/standards-sdk";
4
4
  class OpenConvaiState {
5
5
  /**
@@ -15,7 +15,7 @@ import { AcceptConnectionRequestTool } from "./standards-agent-kit.es14.js";
15
15
  import { RetrieveProfileTool } from "./standards-agent-kit.es15.js";
16
16
  import { ListUnapprovedConnectionRequestsTool } from "./standards-agent-kit.es16.js";
17
17
  import { Logger } from "@hashgraphonline/standards-sdk";
18
- import { ENV_FILE_PATH } from "./standards-agent-kit.es23.js";
18
+ import { ENV_FILE_PATH } from "./standards-agent-kit.es24.js";
19
19
  function initializeHCS10Client(options) {
20
20
  const config = options?.clientConfig || {};
21
21
  const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;
@@ -43,7 +43,6 @@ function initializeHCS10Client(options) {
43
43
  const stateManager = options?.stateManager || new OpenConvaiState({
44
44
  defaultEnvFilePath: ENV_FILE_PATH,
45
45
  defaultPrefix: "TODD"
46
- // Keep backward compatibility with existing demos
47
46
  });
48
47
  logger.info("State manager initialized");
49
48
  const hcs10Client = new HCS10Client(operatorId, operatorPrivateKey, network, {
@@ -61,7 +60,6 @@ function initializeHCS10Client(options) {
61
60
  useEncryption: config.useEncryption,
62
61
  registryUrl: config.registryUrl,
63
62
  logLevel: "error"
64
- // Reduce logging noise for monitoring client
65
63
  }
66
64
  );
67
65
  logger.info("Monitoring client initialized");
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es2.js","sources":["../../src/init.ts"],"sourcesContent":["import { HCS10Client, StandardNetworkType } from './hcs10/HCS10Client';\nimport { RegisterAgentTool } from './tools/RegisterAgentTool';\nimport { SendMessageTool } from './tools/SendMessageTool';\nimport { ConnectionTool } from './tools/ConnectionTool';\nimport { IStateManager } from './state/state-types';\nimport { OpenConvaiState } from './state/open-convai-state';\nimport { FindRegistrationsTool } from './tools/FindRegistrationsTool';\nimport { InitiateConnectionTool } from './tools/InitiateConnectionTool';\nimport { ListConnectionsTool } from './tools/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from './tools/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from './tools/CheckMessagesTool';\nimport { ConnectionMonitorTool } from './tools/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from './tools/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from './tools/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from './tools/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from './tools/ListUnapprovedConnectionRequestsTool';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { ENV_FILE_PATH } from './utils/state-tools';\n\nexport interface HCS10ClientConfig {\n operatorId?: string;\n operatorKey?: string;\n network?: StandardNetworkType;\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface HCS10InitializationOptions {\n clientConfig?: HCS10ClientConfig;\n stateManager?: IStateManager;\n createAllTools?: boolean;\n monitoringClient?: boolean;\n}\n\n/**\n * Tool collection containing all available tools from the standards-agent-kit\n */\nexport interface HCS10Tools {\n registerAgentTool: RegisterAgentTool;\n findRegistrationsTool: FindRegistrationsTool;\n retrieveProfileTool: RetrieveProfileTool;\n initiateConnectionTool: InitiateConnectionTool;\n listConnectionsTool: ListConnectionsTool;\n sendMessageToConnectionTool: SendMessageToConnectionTool;\n checkMessagesTool: CheckMessagesTool;\n sendMessageTool: SendMessageTool;\n connectionTool: ConnectionTool;\n connectionMonitorTool: ConnectionMonitorTool;\n manageConnectionRequestsTool: ManageConnectionRequestsTool;\n acceptConnectionRequestTool: AcceptConnectionRequestTool;\n listUnapprovedConnectionRequestsTool: ListUnapprovedConnectionRequestsTool;\n}\n\n/**\n * Initializes the HCS10 client and returns pre-registered LangChain tools.\n *\n * @param options - Initialization options\n * @returns Object containing hcs10Client and requested tools\n */\nexport function initializeHCS10Client(options?: HCS10InitializationOptions): {\n hcs10Client: HCS10Client;\n monitoringClient?: HCS10Client;\n tools: Partial<HCS10Tools>;\n stateManager: IStateManager;\n} {\n // Set up the configuration\n const config = options?.clientConfig || {};\n\n // Use environment variables as fallbacks if not explicitly provided\n const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;\n const operatorPrivateKey =\n config.operatorKey || process.env.HEDERA_OPERATOR_KEY;\n\n // Get network from config or env, default to testnet\n const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';\n\n // Validate and cast network type\n let network: StandardNetworkType;\n if (networkEnv === 'mainnet') {\n network = 'mainnet';\n } else if (networkEnv === 'testnet') {\n network = 'testnet';\n } else {\n console.warn(\n `Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`\n );\n network = 'testnet'; // Default to testnet if invalid/unsupported\n }\n\n if (!operatorId || !operatorPrivateKey) {\n throw new Error(\n 'Operator ID and private key must be provided either through options or environment variables.'\n );\n }\n\n // Set up logging\n const logger = Logger.getInstance({\n level: config.logLevel || 'info',\n });\n\n // Create or use provided state manager\n const stateManager =\n options?.stateManager ||\n new OpenConvaiState({\n defaultEnvFilePath: ENV_FILE_PATH,\n defaultPrefix: 'TODD', // Keep backward compatibility with existing demos\n });\n logger.info('State manager initialized');\n\n // Instantiate primary HCS10Client\n const hcs10Client = new HCS10Client(operatorId, operatorPrivateKey, network, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n });\n logger.info(`HCS10Client initialized for ${operatorId} on ${network}`);\n\n // Create monitoring client if requested\n let monitoringClient: HCS10Client | undefined;\n if (options?.monitoringClient) {\n monitoringClient = new HCS10Client(\n operatorId,\n operatorPrivateKey,\n network,\n {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: 'error', // Reduce logging noise for monitoring client\n }\n );\n logger.info('Monitoring client initialized');\n }\n\n // Initialize the tools object\n const tools: Partial<HCS10Tools> = {};\n\n // Always create these core tools\n tools.registerAgentTool = new RegisterAgentTool(hcs10Client, stateManager);\n tools.sendMessageTool = new SendMessageTool(hcs10Client);\n tools.connectionTool = new ConnectionTool({\n client: monitoringClient || hcs10Client,\n stateManager,\n });\n\n // Create all tools if requested\n if (options?.createAllTools) {\n tools.findRegistrationsTool = new FindRegistrationsTool({\n hcsClient: hcs10Client,\n });\n tools.retrieveProfileTool = new RetrieveProfileTool(hcs10Client);\n tools.initiateConnectionTool = new InitiateConnectionTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.listConnectionsTool = new ListConnectionsTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.sendMessageToConnectionTool = new SendMessageToConnectionTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.checkMessagesTool = new CheckMessagesTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.connectionMonitorTool = new ConnectionMonitorTool({\n hcsClient: monitoringClient || hcs10Client,\n stateManager,\n });\n tools.manageConnectionRequestsTool = new ManageConnectionRequestsTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.acceptConnectionRequestTool = new AcceptConnectionRequestTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.listUnapprovedConnectionRequestsTool =\n new ListUnapprovedConnectionRequestsTool({\n stateManager,\n hcsClient: hcs10Client,\n });\n\n logger.info('All tools initialized');\n }\n\n return {\n hcs10Client,\n monitoringClient,\n tools,\n stateManager,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA4DO,SAAS,sBAAsB,SAKpC;AAEM,QAAA,SAAS,SAAS,gBAAgB,CAAC;AAGzC,QAAM,aAAa,OAAO,cAAc,QAAQ,IAAI;AACpD,QAAM,qBACJ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B;AAAA,MACtD,WAAW;AAAA,IAAA,CACZ;AACK,UAAA,sBAAsB,IAAI,oBAAoB,WAAW;AACzD,UAAA,yBAAyB,IAAI,uBAAuB;AAAA,MACxD,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,sBAAsB,IAAI,oBAAoB;AAAA,MAClD,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,8BAA8B,IAAI,4BAA4B;AAAA,MAClE,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,oBAAoB,IAAI,kBAAkB;AAAA,MAC9C,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,wBAAwB,IAAI,sBAAsB;AAAA,MACtD,WAAW,oBAAoB;AAAA,MAC/B;AAAA,IAAA,CACD;AACK,UAAA,+BAA+B,IAAI,6BAA6B;AAAA,MACpE,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,8BAA8B,IAAI,4BAA4B;AAAA,MAClE,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,uCACJ,IAAI,qCAAqC;AAAA,MACvC;AAAA,MACA,WAAW;AAAA,IAAA,CACZ;AAEH,WAAO,KAAK,uBAAuB;AAAA,EAAA;AAG9B,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"standards-agent-kit.es2.js","sources":["../../src/init.ts"],"sourcesContent":["import { HCS10Client, StandardNetworkType } from './hcs10/HCS10Client';\nimport { RegisterAgentTool } from './tools/RegisterAgentTool';\nimport { SendMessageTool } from './tools/SendMessageTool';\nimport { ConnectionTool } from './tools/ConnectionTool';\nimport { IStateManager } from './state/state-types';\nimport { OpenConvaiState } from './state/open-convai-state';\nimport { FindRegistrationsTool } from './tools/FindRegistrationsTool';\nimport { InitiateConnectionTool } from './tools/InitiateConnectionTool';\nimport { ListConnectionsTool } from './tools/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from './tools/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from './tools/CheckMessagesTool';\nimport { ConnectionMonitorTool } from './tools/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from './tools/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from './tools/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from './tools/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from './tools/ListUnapprovedConnectionRequestsTool';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { ENV_FILE_PATH } from './utils/state-tools';\n\nexport interface HCS10ClientConfig {\n operatorId?: string;\n operatorKey?: string;\n network?: StandardNetworkType;\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface HCS10InitializationOptions {\n clientConfig?: HCS10ClientConfig;\n stateManager?: IStateManager;\n createAllTools?: boolean;\n monitoringClient?: boolean;\n}\n\n/**\n * Tool collection containing all available tools from the standards-agent-kit\n */\nexport interface HCS10Tools {\n registerAgentTool: RegisterAgentTool;\n findRegistrationsTool: FindRegistrationsTool;\n retrieveProfileTool: RetrieveProfileTool;\n initiateConnectionTool: InitiateConnectionTool;\n listConnectionsTool: ListConnectionsTool;\n sendMessageToConnectionTool: SendMessageToConnectionTool;\n checkMessagesTool: CheckMessagesTool;\n sendMessageTool: SendMessageTool;\n connectionTool: ConnectionTool;\n connectionMonitorTool: ConnectionMonitorTool;\n manageConnectionRequestsTool: ManageConnectionRequestsTool;\n acceptConnectionRequestTool: AcceptConnectionRequestTool;\n listUnapprovedConnectionRequestsTool: ListUnapprovedConnectionRequestsTool;\n}\n\n/**\n * Initializes the HCS10 client and returns pre-registered LangChain tools.\n *\n * @param options - Initialization options\n * @returns Object containing hcs10Client and requested tools\n */\nexport function initializeHCS10Client(options?: HCS10InitializationOptions): {\n hcs10Client: HCS10Client;\n monitoringClient?: HCS10Client;\n tools: Partial<HCS10Tools>;\n stateManager: IStateManager;\n} {\n const config = options?.clientConfig || {};\n\n const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;\n const operatorPrivateKey =\n config.operatorKey || process.env.HEDERA_OPERATOR_KEY;\n\n const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';\n\n let network: StandardNetworkType;\n if (networkEnv === 'mainnet') {\n network = 'mainnet';\n } else if (networkEnv === 'testnet') {\n network = 'testnet';\n } else {\n console.warn(\n `Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`\n );\n network = 'testnet';\n }\n\n if (!operatorId || !operatorPrivateKey) {\n throw new Error(\n 'Operator ID and private key must be provided either through options or environment variables.'\n );\n }\n\n const logger = Logger.getInstance({\n level: config.logLevel || 'info',\n });\n\n const stateManager =\n options?.stateManager ||\n new OpenConvaiState({\n defaultEnvFilePath: ENV_FILE_PATH,\n defaultPrefix: 'TODD',\n });\n logger.info('State manager initialized');\n\n const hcs10Client = new HCS10Client(operatorId, operatorPrivateKey, network, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n });\n logger.info(`HCS10Client initialized for ${operatorId} on ${network}`);\n\n let monitoringClient: HCS10Client | undefined;\n if (options?.monitoringClient) {\n monitoringClient = new HCS10Client(\n operatorId,\n operatorPrivateKey,\n network,\n {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: 'error',\n }\n );\n logger.info('Monitoring client initialized');\n }\n\n const tools: Partial<HCS10Tools> = {};\n\n tools.registerAgentTool = new RegisterAgentTool(hcs10Client, stateManager);\n tools.sendMessageTool = new SendMessageTool(hcs10Client);\n tools.connectionTool = new ConnectionTool({\n client: monitoringClient || hcs10Client,\n stateManager,\n });\n\n if (options?.createAllTools) {\n tools.findRegistrationsTool = new FindRegistrationsTool({\n hcsClient: hcs10Client,\n });\n tools.retrieveProfileTool = new RetrieveProfileTool(hcs10Client);\n tools.initiateConnectionTool = new InitiateConnectionTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.listConnectionsTool = new ListConnectionsTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.sendMessageToConnectionTool = new SendMessageToConnectionTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.checkMessagesTool = new CheckMessagesTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.connectionMonitorTool = new ConnectionMonitorTool({\n hcsClient: monitoringClient || hcs10Client,\n stateManager,\n });\n tools.manageConnectionRequestsTool = new ManageConnectionRequestsTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.acceptConnectionRequestTool = new AcceptConnectionRequestTool({\n hcsClient: hcs10Client,\n stateManager,\n });\n tools.listUnapprovedConnectionRequestsTool =\n new ListUnapprovedConnectionRequestsTool({\n stateManager,\n hcsClient: hcs10Client,\n });\n\n logger.info('All tools initialized');\n }\n\n return {\n hcs10Client,\n monitoringClient,\n tools,\n stateManager,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA4DO,SAAS,sBAAsB,SAKpC;AACM,QAAA,SAAS,SAAS,gBAAgB,CAAC;AAEzC,QAAM,aAAa,OAAO,cAAc,QAAQ,IAAI;AACpD,QAAM,qBACJ,OAAO,eAAe,QAAQ,IAAI;AAEpC,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI,kBAAkB;AAE/D,MAAA;AACJ,MAAI,eAAe,WAAW;AAClB,cAAA;AAAA,EAAA,WACD,eAAe,WAAW;AACzB,cAAA;AAAA,EAAA,OACL;AACG,YAAA;AAAA,MACN,mCAAmC,UAAU;AAAA,IAC/C;AACU,cAAA;AAAA,EAAA;AAGR,MAAA,CAAC,cAAc,CAAC,oBAAoB;AACtC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,SAAS,OAAO,YAAY;AAAA,IAChC,OAAO,OAAO,YAAY;AAAA,EAAA,CAC3B;AAED,QAAM,eACJ,SAAS,gBACT,IAAI,gBAAgB;AAAA,IAClB,oBAAoB;AAAA,IACpB,eAAe;AAAA,EAAA,CAChB;AACH,SAAO,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AA,IAAA,CACD;AACK,UAAA,8BAA8B,IAAI,4BAA4B;AAAA,MAClE,WAAW;AAAA,MACX;AAAA,IAAA,CACD;AACK,UAAA,uCACJ,IAAI,qCAAqC;AAAA,MACvC;AAAA,MACA,WAAW;AAAA,IAAA,CACZ;AAEH,WAAO,KAAK,uBAAuB;AAAA,EAAA;AAG9B,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es22.js","sources":["../../src/plugins/GenericPlugin.ts"],"sourcesContent":["import { BasePlugin } from './BasePlugin';\nimport { GenericPluginContext } from './PluginInterface';\nimport { StructuredTool } from '@langchain/core/tools';\n\n/**\n * Base class for platform-agnostic plugins that can be used across different implementations\n */\nexport abstract class GenericPlugin extends BasePlugin<GenericPluginContext> {\n /**\n * Get the tools provided by this plugin\n * @returns Array of tools provided by this plugin\n */\n abstract getTools(): StructuredTool[];\n}"],"names":[],"mappings":";AAOO,MAAe,sBAAsB,WAAiC;AAM7E;"}
1
+ {"version":3,"file":"standards-agent-kit.es22.js","sources":["../../src/plugins/GenericPlugin.ts"],"sourcesContent":["import { BasePlugin } from './BasePlugin';\nimport { GenericPluginContext } from './PluginInterface';\nimport { StructuredTool } from '@langchain/core/tools';\n\n/**\n * Base class for platform-agnostic plugins that can be used across different implementations\n */\nexport abstract class GenericPlugin extends BasePlugin<GenericPluginContext> {\n /**\n * Namespace for the plugin, used for organizing and categorizing plugins\n */\n abstract namespace: string;\n\n /**\n * Get the tools provided by this plugin\n * @returns Array of tools provided by this plugin\n */\n abstract getTools(): StructuredTool[];\n}"],"names":[],"mappings":";AAOO,MAAe,sBAAsB,WAAiC;AAW7E;"}
@@ -1,29 +1,106 @@
1
- import process from "vite-plugin-node-polyfills/shims/process";
2
- import "@hashgraphonline/standards-sdk";
3
- import fs__default from "fs";
4
- import path__default from "path";
5
- const ENV_FILE_PATH = path__default.join(process.cwd(), ".env");
6
- async function updateEnvFile(envFilePath, variables) {
7
- let envContent = "";
8
- if (fs__default.existsSync(envFilePath)) {
9
- envContent = fs__default.readFileSync(envFilePath, "utf8");
1
+ import { GenericPlugin } from "./standards-agent-kit.es22.js";
2
+ import { HCS10Client } from "./standards-agent-kit.es3.js";
3
+ import { OpenConvaiState } from "./standards-agent-kit.es17.js";
4
+ import { RegisterAgentTool } from "./standards-agent-kit.es4.js";
5
+ import { SendMessageTool } from "./standards-agent-kit.es5.js";
6
+ import { ConnectionTool } from "./standards-agent-kit.es6.js";
7
+ import { FindRegistrationsTool } from "./standards-agent-kit.es11.js";
8
+ import { InitiateConnectionTool } from "./standards-agent-kit.es8.js";
9
+ import { ListConnectionsTool } from "./standards-agent-kit.es9.js";
10
+ import { SendMessageToConnectionTool } from "./standards-agent-kit.es7.js";
11
+ import { CheckMessagesTool } from "./standards-agent-kit.es10.js";
12
+ import { ConnectionMonitorTool } from "./standards-agent-kit.es12.js";
13
+ import { ManageConnectionRequestsTool } from "./standards-agent-kit.es13.js";
14
+ import { AcceptConnectionRequestTool } from "./standards-agent-kit.es14.js";
15
+ import { RetrieveProfileTool } from "./standards-agent-kit.es15.js";
16
+ import { ListUnapprovedConnectionRequestsTool } from "./standards-agent-kit.es16.js";
17
+ class OpenConvAIPlugin extends GenericPlugin {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.id = "openconvai-standards-agent-kit";
21
+ this.name = "OpenConvAI Standards Agent Kit Plugin";
22
+ this.description = "Comprehensive plugin providing all HCS-10 agent tools for registration, connections, and messaging";
23
+ this.version = "1.0.0";
24
+ this.author = "Hashgraph Online";
25
+ this.namespace = "openconvai";
26
+ this.tools = [];
10
27
  }
11
- const envLines = envContent.split("\n");
12
- const updatedLines = [...envLines];
13
- for (const [key, value] of Object.entries(variables)) {
14
- const lineIndex = updatedLines.findIndex(
15
- (line) => line.startsWith(`${key}=`)
28
+ async initialize(context) {
29
+ await super.initialize(context);
30
+ if (!(context.client instanceof HCS10Client)) {
31
+ throw new Error("OpenConvAIPlugin requires an HCS10Client instance");
32
+ }
33
+ this.hcs10Client = context.client;
34
+ this.stateManager = context.stateManager || new OpenConvaiState();
35
+ this.initializeTools();
36
+ this.context.logger.info(
37
+ "OpenConvAI Standards Agent Kit Plugin initialized successfully"
16
38
  );
17
- if (lineIndex !== -1) {
18
- updatedLines[lineIndex] = `${key}=${value}`;
19
- } else {
20
- updatedLines.push(`${key}=${value}`);
39
+ }
40
+ initializeTools() {
41
+ if (!this.hcs10Client || !this.stateManager) {
42
+ throw new Error(
43
+ "HCS10Client and StateManager must be initialized before creating tools"
44
+ );
21
45
  }
46
+ this.tools = [
47
+ new RegisterAgentTool(this.hcs10Client, this.stateManager),
48
+ new SendMessageTool(this.hcs10Client),
49
+ new ConnectionTool({
50
+ client: this.hcs10Client,
51
+ stateManager: this.stateManager
52
+ }),
53
+ new FindRegistrationsTool({
54
+ hcsClient: this.hcs10Client
55
+ }),
56
+ new RetrieveProfileTool(this.hcs10Client),
57
+ new InitiateConnectionTool({
58
+ hcsClient: this.hcs10Client,
59
+ stateManager: this.stateManager
60
+ }),
61
+ new ListConnectionsTool({
62
+ hcsClient: this.hcs10Client,
63
+ stateManager: this.stateManager
64
+ }),
65
+ new SendMessageToConnectionTool({
66
+ hcsClient: this.hcs10Client,
67
+ stateManager: this.stateManager
68
+ }),
69
+ new CheckMessagesTool({
70
+ hcsClient: this.hcs10Client,
71
+ stateManager: this.stateManager
72
+ }),
73
+ new ConnectionMonitorTool({
74
+ hcsClient: this.hcs10Client,
75
+ stateManager: this.stateManager
76
+ }),
77
+ new ManageConnectionRequestsTool({
78
+ hcsClient: this.hcs10Client,
79
+ stateManager: this.stateManager
80
+ }),
81
+ new AcceptConnectionRequestTool({
82
+ hcsClient: this.hcs10Client,
83
+ stateManager: this.stateManager
84
+ }),
85
+ new ListUnapprovedConnectionRequestsTool({
86
+ stateManager: this.stateManager,
87
+ hcsClient: this.hcs10Client
88
+ })
89
+ ];
90
+ }
91
+ getTools() {
92
+ return this.tools;
93
+ }
94
+ async cleanup() {
95
+ this.tools = [];
96
+ this.hcs10Client = void 0;
97
+ this.stateManager = void 0;
98
+ this.context.logger.info(
99
+ "OpenConvAI Standards Agent Kit Plugin cleaned up"
100
+ );
22
101
  }
23
- fs__default.writeFileSync(envFilePath, updatedLines.join("\n"));
24
102
  }
25
103
  export {
26
- ENV_FILE_PATH,
27
- updateEnvFile
104
+ OpenConvAIPlugin
28
105
  };
29
106
  //# sourceMappingURL=standards-agent-kit.es23.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es23.js","sources":["../../src/utils/state-tools.ts"],"sourcesContent":["import {\n HCS10Client,\n AgentBuilder,\n Logger,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport { ensureAgentHasEnoughHbar } from './ensure-agent-has-hbar';\n\nexport const ENV_FILE_PATH = path.join(process.cwd(), '.env');\n\nexport interface AgentData {\n accountId: string;\n operatorId: string;\n inboundTopicId: string;\n outboundTopicId: string;\n client: HCS10Client;\n}\n\nexport interface RegistrationProgressData {\n registered: boolean;\n accountId?: string;\n privateKey?: string;\n publicKey?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport async function getAgentFromEnv(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n envPrefix: string\n): Promise<AgentData | null> {\n const accountIdEnvVar = `${envPrefix}_ACCOUNT_ID`;\n const privateKeyEnvVar = `${envPrefix}_PRIVATE_KEY`;\n const inboundTopicIdEnvVar = `${envPrefix}_INBOUND_TOPIC_ID`;\n const outboundTopicIdEnvVar = `${envPrefix}_OUTBOUND_TOPIC_ID`;\n\n const accountId = process.env[accountIdEnvVar];\n const privateKey = process.env[privateKeyEnvVar];\n const inboundTopicId = process.env[inboundTopicIdEnvVar];\n const outboundTopicId = process.env[outboundTopicIdEnvVar];\n\n if (!accountId || !privateKey || !inboundTopicId || !outboundTopicId) {\n logger.info(`${agentName} agent not found in environment variables`);\n return null;\n }\n\n logger.info(`${agentName} agent found in environment variables`);\n logger.info(`${agentName} account ID: ${accountId}`);\n logger.info(`${agentName} inbound topic ID: ${inboundTopicId}`);\n logger.info(`${agentName} outbound topic ID: ${outboundTopicId}`);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n await ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName);\n\n return {\n accountId,\n operatorId: `${inboundTopicId}@${accountId}`,\n inboundTopicId,\n outboundTopicId,\n client,\n };\n}\n\nexport async function createAgent(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n agentBuilder: AgentBuilder,\n envPrefix: string\n): Promise<AgentData | null> {\n try {\n logger.info(`Creating ${agentName} agent...`);\n\n const result = await baseClient.createAndRegisterAgent(agentBuilder);\n\n if (!result.metadata) {\n logger.error(`${agentName} agent creation failed`);\n return null;\n }\n\n logger.info(`${agentName} agent created successfully`);\n logger.info(`${agentName} account ID: ${result.metadata.accountId}`);\n logger.info(`${agentName} private key: ${result.metadata.privateKey}`);\n logger.info(\n `${agentName} inbound topic ID: ${result.metadata.inboundTopicId}`\n );\n logger.info(\n `${agentName} outbound topic ID: ${result.metadata.outboundTopicId}`\n );\n\n const envVars = {\n [`${envPrefix}_ACCOUNT_ID`]: result.metadata.accountId,\n [`${envPrefix}_PRIVATE_KEY`]: result.metadata.privateKey,\n [`${envPrefix}_INBOUND_TOPIC_ID`]: result.metadata.inboundTopicId,\n [`${envPrefix}_OUTBOUND_TOPIC_ID`]: result.metadata.outboundTopicId,\n };\n\n await updateEnvFile(ENV_FILE_PATH, envVars);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: result.metadata.accountId,\n operatorPrivateKey: result.metadata.privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n return {\n accountId: result.metadata.accountId,\n operatorId: `${result.metadata.inboundTopicId}@${result.metadata.accountId}`,\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n client,\n };\n } catch (error) {\n console.log('error', error, baseClient);\n logger.error(`Error creating ${agentName} agent:`, error);\n return null;\n }\n}\n\nexport async function updateEnvFile(\n envFilePath: string,\n variables: Record<string, string>\n): Promise<void> {\n let envContent = '';\n\n if (fs.existsSync(envFilePath)) {\n envContent = fs.readFileSync(envFilePath, 'utf8');\n }\n\n const envLines = envContent.split('\\n');\n const updatedLines = [...envLines];\n\n for (const [key, value] of Object.entries(variables)) {\n const lineIndex = updatedLines.findIndex((line) =>\n line.startsWith(`${key}=`)\n );\n\n if (lineIndex !== -1) {\n updatedLines[lineIndex] = `${key}=${value}`;\n } else {\n updatedLines.push(`${key}=${value}`);\n }\n }\n\n fs.writeFileSync(envFilePath, updatedLines.join('\\n'));\n}\n"],"names":["path","fs"],"mappings":";;;;AASO,MAAM,gBAAgBA,cAAK,KAAK,QAAQ,OAAO,MAAM;AA4HtC,eAAA,cACpB,aACA,WACe;AACf,MAAI,aAAa;AAEb,MAAAC,YAAG,WAAW,WAAW,GAAG;AACjB,iBAAAA,YAAG,aAAa,aAAa,MAAM;AAAA,EAAA;AAG5C,QAAA,WAAW,WAAW,MAAM,IAAI;AAChC,QAAA,eAAe,CAAC,GAAG,QAAQ;AAEjC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,SAAS,GAAG;AACpD,UAAM,YAAY,aAAa;AAAA,MAAU,CAAC,SACxC,KAAK,WAAW,GAAG,GAAG,GAAG;AAAA,IAC3B;AAEA,QAAI,cAAc,IAAI;AACpB,mBAAa,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK;AAAA,IAAA,OACpC;AACL,mBAAa,KAAK,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,IAAA;AAAA,EACrC;AAGFA,cAAG,cAAc,aAAa,aAAa,KAAK,IAAI,CAAC;AACvD;"}
1
+ {"version":3,"file":"standards-agent-kit.es23.js","sources":["../../src/plugins/openconvai/OpenConvAIPlugin.ts"],"sourcesContent":["import { GenericPlugin } from '../GenericPlugin';\nimport { GenericPluginContext } from '../PluginInterface';\nimport { StructuredTool } from '@langchain/core/tools';\nimport { HCS10Client } from '../../hcs10/HCS10Client';\nimport { IStateManager } from '../../state/state-types';\nimport { OpenConvaiState } from '../../state/open-convai-state';\n\nimport { RegisterAgentTool } from '../../tools/RegisterAgentTool';\nimport { SendMessageTool } from '../../tools/SendMessageTool';\nimport { ConnectionTool } from '../../tools/ConnectionTool';\nimport { FindRegistrationsTool } from '../../tools/FindRegistrationsTool';\nimport { InitiateConnectionTool } from '../../tools/InitiateConnectionTool';\nimport { ListConnectionsTool } from '../../tools/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from '../../tools/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from '../../tools/CheckMessagesTool';\nimport { ConnectionMonitorTool } from '../../tools/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from '../../tools/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from '../../tools/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from '../../tools/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from '../../tools/ListUnapprovedConnectionRequestsTool';\n\n/**\n * OpenConvAI Plugin that provides all the tools from standards-agent-kit\n * This plugin enables full HCS-10 agent functionality including registration,\n * connection management, and messaging capabilities.\n */\nexport class OpenConvAIPlugin extends GenericPlugin {\n id = 'openconvai-standards-agent-kit';\n name = 'OpenConvAI Standards Agent Kit Plugin';\n description =\n 'Comprehensive plugin providing all HCS-10 agent tools for registration, connections, and messaging';\n version = '1.0.0';\n author = 'Hashgraph Online';\n namespace = 'openconvai';\n\n private hcs10Client?: HCS10Client;\n private stateManager?: IStateManager;\n private tools: StructuredTool[] = [];\n\n async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n if (!(context.client instanceof HCS10Client)) {\n throw new Error('OpenConvAIPlugin requires an HCS10Client instance');\n }\n\n this.hcs10Client = context.client as HCS10Client;\n\n this.stateManager =\n (context.stateManager as IStateManager) || new OpenConvaiState();\n\n this.initializeTools();\n\n this.context.logger.info(\n 'OpenConvAI Standards Agent Kit Plugin initialized successfully'\n );\n }\n\n private initializeTools(): void {\n if (!this.hcs10Client || !this.stateManager) {\n throw new Error(\n 'HCS10Client and StateManager must be initialized before creating tools'\n );\n }\n\n this.tools = [\n new RegisterAgentTool(this.hcs10Client, this.stateManager),\n new SendMessageTool(this.hcs10Client),\n new ConnectionTool({\n client: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new FindRegistrationsTool({\n hcsClient: this.hcs10Client,\n }),\n new RetrieveProfileTool(this.hcs10Client),\n new InitiateConnectionTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new ListConnectionsTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new SendMessageToConnectionTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new CheckMessagesTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new ConnectionMonitorTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new ManageConnectionRequestsTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new AcceptConnectionRequestTool({\n hcsClient: this.hcs10Client,\n stateManager: this.stateManager,\n }),\n new ListUnapprovedConnectionRequestsTool({\n stateManager: this.stateManager,\n hcsClient: this.hcs10Client,\n }),\n ];\n }\n\n getTools(): StructuredTool[] {\n return this.tools;\n }\n\n async cleanup(): Promise<void> {\n this.tools = [];\n this.hcs10Client = undefined;\n this.stateManager = undefined;\n this.context.logger.info(\n 'OpenConvAI Standards Agent Kit Plugin cleaned up'\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0BO,MAAM,yBAAyB,cAAc;AAAA,EAA7C,cAAA;AAAA,U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,KAAK;AAAA,MAAA,CACpB;AAAA,MACD,IAAI,sBAAsB;AAAA,QACxB,WAAW,KAAK;AAAA,QAChB,cAAc,KAAK;AAAA,MAAA,CACpB;AAAA,MACD,IAAI,6BAA6B;AAAA,QAC/B,WAAW,KAAK;AAAA,QAChB,cAAc,KAAK;AAAA,MAAA,CACpB;AAAA,MACD,IAAI,4BAA4B;AAAA,QAC9B,WAAW,KAAK;AAAA,QAChB,cAAc,KAAK;AAAA,MAAA,CACpB;AAAA,MACD,IAAI,qCAAqC;AAAA,QACvC,cAAc,KAAK;AAAA,QACnB,WAAW,KAAK;AAAA,MACjB,CAAA;AAAA,IACH;AAAA,EAAA;AAAA,EAGF,WAA6B;AAC3B,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,MAAM,UAAyB;AAC7B,SAAK,QAAQ,CAAC;AACd,SAAK,cAAc;AACnB,SAAK,eAAe;AACpB,SAAK,QAAQ,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,EAAA;AAEJ;"}
@@ -1,7 +1,29 @@
1
- function encryptMessage(message) {
2
- return message;
1
+ import process from "vite-plugin-node-polyfills/shims/process";
2
+ import "@hashgraphonline/standards-sdk";
3
+ import fs__default from "fs";
4
+ import path__default from "path";
5
+ const ENV_FILE_PATH = path__default.join(process.cwd(), ".env");
6
+ async function updateEnvFile(envFilePath, variables) {
7
+ let envContent = "";
8
+ if (fs__default.existsSync(envFilePath)) {
9
+ envContent = fs__default.readFileSync(envFilePath, "utf8");
10
+ }
11
+ const envLines = envContent.split("\n");
12
+ const updatedLines = [...envLines];
13
+ for (const [key, value] of Object.entries(variables)) {
14
+ const lineIndex = updatedLines.findIndex(
15
+ (line) => line.startsWith(`${key}=`)
16
+ );
17
+ if (lineIndex !== -1) {
18
+ updatedLines[lineIndex] = `${key}=${value}`;
19
+ } else {
20
+ updatedLines.push(`${key}=${value}`);
21
+ }
22
+ }
23
+ fs__default.writeFileSync(envFilePath, updatedLines.join("\n"));
3
24
  }
4
25
  export {
5
- encryptMessage
26
+ ENV_FILE_PATH,
27
+ updateEnvFile
6
28
  };
7
29
  //# sourceMappingURL=standards-agent-kit.es24.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es24.js","sources":["../../src/utils/Encryption.ts"],"sourcesContent":["// src/utils/Encryption.ts\n/**\n * Placeholder for encryption functionality.\n * Currently, encryption is disabled. The useEncryption flag is false by default.\n * TODO: Implement actual encryption/decryption logic.\n */\n\nexport function encryptMessage(message: string): string {\n // TODO: Add encryption logic here if useEncryption flag is true.\n return message; // currently returns plaintext.\n}\n\nexport function decryptMessage(encryptedMessage: string): string {\n // TODO: Add decryption logic here.\n return encryptedMessage;\n}\n"],"names":[],"mappings":"AAOO,SAAS,eAAe,SAAyB;AAE7C,SAAA;AACX;"}
1
+ {"version":3,"file":"standards-agent-kit.es24.js","sources":["../../src/utils/state-tools.ts"],"sourcesContent":["import {\n HCS10Client,\n AgentBuilder,\n Logger,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport { ensureAgentHasEnoughHbar } from './ensure-agent-has-hbar';\n\nexport const ENV_FILE_PATH = path.join(process.cwd(), '.env');\n\nexport interface AgentData {\n accountId: string;\n operatorId: string;\n inboundTopicId: string;\n outboundTopicId: string;\n client: HCS10Client;\n}\n\nexport interface RegistrationProgressData {\n registered: boolean;\n accountId?: string;\n privateKey?: string;\n publicKey?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport async function getAgentFromEnv(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n envPrefix: string\n): Promise<AgentData | null> {\n const accountIdEnvVar = `${envPrefix}_ACCOUNT_ID`;\n const privateKeyEnvVar = `${envPrefix}_PRIVATE_KEY`;\n const inboundTopicIdEnvVar = `${envPrefix}_INBOUND_TOPIC_ID`;\n const outboundTopicIdEnvVar = `${envPrefix}_OUTBOUND_TOPIC_ID`;\n\n const accountId = process.env[accountIdEnvVar];\n const privateKey = process.env[privateKeyEnvVar];\n const inboundTopicId = process.env[inboundTopicIdEnvVar];\n const outboundTopicId = process.env[outboundTopicIdEnvVar];\n\n if (!accountId || !privateKey || !inboundTopicId || !outboundTopicId) {\n logger.info(`${agentName} agent not found in environment variables`);\n return null;\n }\n\n logger.info(`${agentName} agent found in environment variables`);\n logger.info(`${agentName} account ID: ${accountId}`);\n logger.info(`${agentName} inbound topic ID: ${inboundTopicId}`);\n logger.info(`${agentName} outbound topic ID: ${outboundTopicId}`);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n await ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName);\n\n return {\n accountId,\n operatorId: `${inboundTopicId}@${accountId}`,\n inboundTopicId,\n outboundTopicId,\n client,\n };\n}\n\nexport async function createAgent(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n agentBuilder: AgentBuilder,\n envPrefix: string\n): Promise<AgentData | null> {\n try {\n logger.info(`Creating ${agentName} agent...`);\n\n const result = await baseClient.createAndRegisterAgent(agentBuilder);\n\n if (!result.metadata) {\n logger.error(`${agentName} agent creation failed`);\n return null;\n }\n\n logger.info(`${agentName} agent created successfully`);\n logger.info(`${agentName} account ID: ${result.metadata.accountId}`);\n logger.info(`${agentName} private key: ${result.metadata.privateKey}`);\n logger.info(\n `${agentName} inbound topic ID: ${result.metadata.inboundTopicId}`\n );\n logger.info(\n `${agentName} outbound topic ID: ${result.metadata.outboundTopicId}`\n );\n\n const envVars = {\n [`${envPrefix}_ACCOUNT_ID`]: result.metadata.accountId,\n [`${envPrefix}_PRIVATE_KEY`]: result.metadata.privateKey,\n [`${envPrefix}_INBOUND_TOPIC_ID`]: result.metadata.inboundTopicId,\n [`${envPrefix}_OUTBOUND_TOPIC_ID`]: result.metadata.outboundTopicId,\n };\n\n await updateEnvFile(ENV_FILE_PATH, envVars);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: result.metadata.accountId,\n operatorPrivateKey: result.metadata.privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n return {\n accountId: result.metadata.accountId,\n operatorId: `${result.metadata.inboundTopicId}@${result.metadata.accountId}`,\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n client,\n };\n } catch (error) {\n console.log('error', error, baseClient);\n logger.error(`Error creating ${agentName} agent:`, error);\n return null;\n }\n}\n\nexport async function updateEnvFile(\n envFilePath: string,\n variables: Record<string, string>\n): Promise<void> {\n let envContent = '';\n\n if (fs.existsSync(envFilePath)) {\n envContent = fs.readFileSync(envFilePath, 'utf8');\n }\n\n const envLines = envContent.split('\\n');\n const updatedLines = [...envLines];\n\n for (const [key, value] of Object.entries(variables)) {\n const lineIndex = updatedLines.findIndex((line) =>\n line.startsWith(`${key}=`)\n );\n\n if (lineIndex !== -1) {\n updatedLines[lineIndex] = `${key}=${value}`;\n } else {\n updatedLines.push(`${key}=${value}`);\n }\n }\n\n fs.writeFileSync(envFilePath, updatedLines.join('\\n'));\n}\n"],"names":["path","fs"],"mappings":";;;;AASO,MAAM,gBAAgBA,cAAK,KAAK,QAAQ,OAAO,MAAM;AA4HtC,eAAA,cACpB,aACA,WACe;AACf,MAAI,aAAa;AAEb,MAAAC,YAAG,WAAW,WAAW,GAAG;AACjB,iBAAAA,YAAG,aAAa,aAAa,MAAM;AAAA,EAAA;AAG5C,QAAA,WAAW,WAAW,MAAM,IAAI;AAChC,QAAA,eAAe,CAAC,GAAG,QAAQ;AAEjC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,SAAS,GAAG;AACpD,UAAM,YAAY,aAAa;AAAA,MAAU,CAAC,SACxC,KAAK,WAAW,GAAG,GAAG,GAAG;AAAA,IAC3B;AAEA,QAAI,cAAc,IAAI;AACpB,mBAAa,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK;AAAA,IAAA,OACpC;AACL,mBAAa,KAAK,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,IAAA;AAAA,EACrC;AAGFA,cAAG,cAAc,aAAa,aAAa,KAAK,IAAI,CAAC;AACvD;"}
@@ -1,85 +1,7 @@
1
- import { TransferTransaction, Hbar } from "@hashgraph/sdk";
2
- import { HederaMirrorNode } from "@hashgraphonline/standards-sdk";
3
- const MIN_REQUIRED_USD = 2;
4
- const MIN_REQUIRED_HBAR_USD = 10;
5
- async function ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName) {
6
- try {
7
- const account = await baseClient.requestAccount(accountId);
8
- const balance = account.balance.balance;
9
- const hbarBalance = balance / 1e8;
10
- logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);
11
- try {
12
- const mirrorNode = new HederaMirrorNode("testnet", logger);
13
- const hbarPrice = await mirrorNode.getHBARPrice(/* @__PURE__ */ new Date());
14
- if (hbarPrice) {
15
- const balanceInUsd = hbarBalance * hbarPrice;
16
- logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);
17
- if (balanceInUsd < MIN_REQUIRED_USD) {
18
- logger.warn(
19
- `${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(
20
- 2
21
- )}). Attempting to fund.`
22
- );
23
- try {
24
- const funder = baseClient.getAccountAndSigner();
25
- const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;
26
- const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);
27
- if (amountToTransferHbar > 0) {
28
- const transferTx = new TransferTransaction().addHbarTransfer(
29
- funder.accountId,
30
- Hbar.fromTinybars(
31
- Math.round(amountToTransferHbar * -1e8)
32
- )
33
- ).addHbarTransfer(
34
- accountId,
35
- Hbar.fromTinybars(
36
- Math.round(amountToTransferHbar * 1e8)
37
- )
38
- );
39
- logger.info(
40
- `Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(
41
- 2
42
- )} HBAR from ${funder.accountId}`
43
- );
44
- const fundTxResponse = await transferTx.execute(
45
- baseClient.getClient()
46
- );
47
- await fundTxResponse.getReceipt(baseClient.getClient());
48
- logger.info(
49
- `Successfully funded ${agentName} account ${accountId}.`
50
- );
51
- } else {
52
- logger.info(
53
- `${agentName} account ${accountId} does not require additional funding.`
54
- );
55
- }
56
- } catch (fundingError) {
57
- logger.error(
58
- `Failed to automatically fund ${agentName} account ${accountId}:`,
59
- fundingError
60
- );
61
- logger.warn(
62
- `Please fund the account ${accountId} manually with at least ${(MIN_REQUIRED_HBAR_USD / hbarPrice).toFixed(2)} HBAR.`
63
- );
64
- }
65
- }
66
- } else {
67
- logger.warn(
68
- "Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR."
69
- );
70
- }
71
- } catch (error) {
72
- logger.warn(
73
- "Failed to check USD balance. Please ensure the account has enough HBAR."
74
- );
75
- }
76
- } catch (error) {
77
- logger.error(`Failed to check ${agentName} account balance:`, error);
78
- }
1
+ function encryptMessage(message) {
2
+ return message;
79
3
  }
80
4
  export {
81
- MIN_REQUIRED_HBAR_USD,
82
- MIN_REQUIRED_USD,
83
- ensureAgentHasEnoughHbar
5
+ encryptMessage
84
6
  };
85
7
  //# sourceMappingURL=standards-agent-kit.es25.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es25.js","sources":["../../src/utils/ensure-agent-has-hbar.ts"],"sourcesContent":["import { Hbar } from \"@hashgraph/sdk\";\nimport { TransferTransaction } from \"@hashgraph/sdk\";\nimport { Logger, HCS10Client, HederaMirrorNode } from \"@hashgraphonline/standards-sdk\";\n\nexport const MIN_REQUIRED_USD = 2.0;\nexport const MIN_REQUIRED_HBAR_USD = 10.0;\n\nexport async function ensureAgentHasEnoughHbar(\n logger: Logger,\n baseClient: HCS10Client,\n accountId: string,\n agentName: string\n): Promise<void> {\n try {\n const account = await baseClient.requestAccount(accountId);\n const balance = account.balance.balance;\n const hbarBalance = balance / 100_000_000;\n\n logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);\n\n try {\n const mirrorNode = new HederaMirrorNode('testnet', logger);\n const hbarPrice = await mirrorNode.getHBARPrice(new Date());\n\n if (hbarPrice) {\n const balanceInUsd = hbarBalance * hbarPrice;\n logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);\n\n if (balanceInUsd < MIN_REQUIRED_USD) {\n logger.warn(\n `${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(\n 2\n )}). Attempting to fund.`\n );\n\n try {\n const funder = baseClient.getAccountAndSigner();\n const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;\n const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);\n\n if (amountToTransferHbar > 0) {\n const transferTx = new TransferTransaction()\n .addHbarTransfer(\n funder.accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * -100_000_000)\n )\n )\n .addHbarTransfer(\n accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * 100_000_000)\n )\n );\n\n logger.info(\n `Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(\n 2\n )} HBAR from ${funder.accountId}`\n );\n\n const fundTxResponse = await transferTx.execute(\n baseClient.getClient() as any\n );\n await fundTxResponse.getReceipt(baseClient.getClient() as any);\n logger.info(\n `Successfully funded ${agentName} account ${accountId}.`\n );\n } else {\n logger.info(\n `${agentName} account ${accountId} does not require additional funding.`\n );\n }\n } catch (fundingError) {\n logger.error(\n `Failed to automatically fund ${agentName} account ${accountId}:`,\n fundingError\n );\n logger.warn(\n `Please fund the account ${accountId} manually with at least ${(\n MIN_REQUIRED_HBAR_USD / hbarPrice\n ).toFixed(2)} HBAR.`\n );\n }\n }\n } else {\n logger.warn(\n 'Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.warn(\n 'Failed to check USD balance. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.error(`Failed to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AU;AAAA,cACvB;AACA,oBAAM,eAAe,WAAW,WAAW,UAAA,CAAkB;AACtD,qBAAA;AAAA,gBACL,uBAAuB,SAAS,YAAY,SAAS;AAAA,cACvD;AAAA,YAAA,OACK;AACE,qBAAA;AAAA,gBACL,GAAG,SAAS,YAAY,SAAS;AAAA,cACnC;AAAA,YAAA;AAAA,mBAEK,cAAc;AACd,mBAAA;AAAA,cACL,gCAAgC,SAAS,YAAY,SAAS;AAAA,cAC9D;AAAA,YACF;AACO,mBAAA;AAAA,cACL,2BAA2B,SAAS,4BAClC,wBAAwB,WACxB,QAAQ,CAAC,CAAC;AAAA,YACd;AAAA,UAAA;AAAA,QACF;AAAA,MACF,OACK;AACE,eAAA;AAAA,UACL;AAAA,QACF;AAAA,MAAA;AAAA,aAEK,OAAO;AACP,aAAA;AAAA,QACL;AAAA,MACF;AAAA,IAAA;AAAA,WAEK,OAAO;AACd,WAAO,MAAM,mBAAmB,SAAS,qBAAqB,KAAK;AAAA,EAAA;AAEvE;"}
1
+ {"version":3,"file":"standards-agent-kit.es25.js","sources":["../../src/utils/Encryption.ts"],"sourcesContent":["// src/utils/Encryption.ts\n/**\n * Placeholder for encryption functionality.\n * Currently, encryption is disabled. The useEncryption flag is false by default.\n * TODO: Implement actual encryption/decryption logic.\n */\n\nexport function encryptMessage(message: string): string {\n // TODO: Add encryption logic here if useEncryption flag is true.\n return message; // currently returns plaintext.\n}\n\nexport function decryptMessage(encryptedMessage: string): string {\n // TODO: Add decryption logic here.\n return encryptedMessage;\n}\n"],"names":[],"mappings":"AAOO,SAAS,eAAe,SAAyB;AAE7C,SAAA;AACX;"}
@@ -0,0 +1,85 @@
1
+ import { TransferTransaction, Hbar } from "@hashgraph/sdk";
2
+ import { HederaMirrorNode } from "@hashgraphonline/standards-sdk";
3
+ const MIN_REQUIRED_USD = 2;
4
+ const MIN_REQUIRED_HBAR_USD = 10;
5
+ async function ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName) {
6
+ try {
7
+ const account = await baseClient.requestAccount(accountId);
8
+ const balance = account.balance.balance;
9
+ const hbarBalance = balance / 1e8;
10
+ logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);
11
+ try {
12
+ const mirrorNode = new HederaMirrorNode("testnet", logger);
13
+ const hbarPrice = await mirrorNode.getHBARPrice(/* @__PURE__ */ new Date());
14
+ if (hbarPrice) {
15
+ const balanceInUsd = hbarBalance * hbarPrice;
16
+ logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);
17
+ if (balanceInUsd < MIN_REQUIRED_USD) {
18
+ logger.warn(
19
+ `${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(
20
+ 2
21
+ )}). Attempting to fund.`
22
+ );
23
+ try {
24
+ const funder = baseClient.getAccountAndSigner();
25
+ const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;
26
+ const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);
27
+ if (amountToTransferHbar > 0) {
28
+ const transferTx = new TransferTransaction().addHbarTransfer(
29
+ funder.accountId,
30
+ Hbar.fromTinybars(
31
+ Math.round(amountToTransferHbar * -1e8)
32
+ )
33
+ ).addHbarTransfer(
34
+ accountId,
35
+ Hbar.fromTinybars(
36
+ Math.round(amountToTransferHbar * 1e8)
37
+ )
38
+ );
39
+ logger.info(
40
+ `Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(
41
+ 2
42
+ )} HBAR from ${funder.accountId}`
43
+ );
44
+ const fundTxResponse = await transferTx.execute(
45
+ baseClient.getClient()
46
+ );
47
+ await fundTxResponse.getReceipt(baseClient.getClient());
48
+ logger.info(
49
+ `Successfully funded ${agentName} account ${accountId}.`
50
+ );
51
+ } else {
52
+ logger.info(
53
+ `${agentName} account ${accountId} does not require additional funding.`
54
+ );
55
+ }
56
+ } catch (fundingError) {
57
+ logger.error(
58
+ `Failed to automatically fund ${agentName} account ${accountId}:`,
59
+ fundingError
60
+ );
61
+ logger.warn(
62
+ `Please fund the account ${accountId} manually with at least ${(MIN_REQUIRED_HBAR_USD / hbarPrice).toFixed(2)} HBAR.`
63
+ );
64
+ }
65
+ }
66
+ } else {
67
+ logger.warn(
68
+ "Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR."
69
+ );
70
+ }
71
+ } catch (error) {
72
+ logger.warn(
73
+ "Failed to check USD balance. Please ensure the account has enough HBAR."
74
+ );
75
+ }
76
+ } catch (error) {
77
+ logger.error(`Failed to check ${agentName} account balance:`, error);
78
+ }
79
+ }
80
+ export {
81
+ MIN_REQUIRED_HBAR_USD,
82
+ MIN_REQUIRED_USD,
83
+ ensureAgentHasEnoughHbar
84
+ };
85
+ //# sourceMappingURL=standards-agent-kit.es26.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards-agent-kit.es26.js","sources":["../../src/utils/ensure-agent-has-hbar.ts"],"sourcesContent":["import { Hbar } from \"@hashgraph/sdk\";\nimport { TransferTransaction } from \"@hashgraph/sdk\";\nimport { Logger, HCS10Client, HederaMirrorNode } from \"@hashgraphonline/standards-sdk\";\n\nexport const MIN_REQUIRED_USD = 2.0;\nexport const MIN_REQUIRED_HBAR_USD = 10.0;\n\nexport async function ensureAgentHasEnoughHbar(\n logger: Logger,\n baseClient: HCS10Client,\n accountId: string,\n agentName: string\n): Promise<void> {\n try {\n const account = await baseClient.requestAccount(accountId);\n const balance = account.balance.balance;\n const hbarBalance = balance / 100_000_000;\n\n logger.info(`${agentName} account ${accountId} has ${hbarBalance} HBAR`);\n\n try {\n const mirrorNode = new HederaMirrorNode('testnet', logger);\n const hbarPrice = await mirrorNode.getHBARPrice(new Date());\n\n if (hbarPrice) {\n const balanceInUsd = hbarBalance * hbarPrice;\n logger.info(`${agentName} balance in USD: $${balanceInUsd.toFixed(2)}`);\n\n if (balanceInUsd < MIN_REQUIRED_USD) {\n logger.warn(\n `${agentName} account ${accountId} has less than $${MIN_REQUIRED_USD} (${balanceInUsd.toFixed(\n 2\n )}). Attempting to fund.`\n );\n\n try {\n const funder = baseClient.getAccountAndSigner();\n const targetHbar = MIN_REQUIRED_HBAR_USD / hbarPrice;\n const amountToTransferHbar = Math.max(0, targetHbar - hbarBalance);\n\n if (amountToTransferHbar > 0) {\n const transferTx = new TransferTransaction()\n .addHbarTransfer(\n funder.accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * -100_000_000)\n )\n )\n .addHbarTransfer(\n accountId,\n Hbar.fromTinybars(\n Math.round(amountToTransferHbar * 100_000_000)\n )\n );\n\n logger.info(\n `Funding ${agentName} account ${accountId} with ${amountToTransferHbar.toFixed(\n 2\n )} HBAR from ${funder.accountId}`\n );\n\n const fundTxResponse = await transferTx.execute(\n baseClient.getClient() as any\n );\n await fundTxResponse.getReceipt(baseClient.getClient() as any);\n logger.info(\n `Successfully funded ${agentName} account ${accountId}.`\n );\n } else {\n logger.info(\n `${agentName} account ${accountId} does not require additional funding.`\n );\n }\n } catch (fundingError) {\n logger.error(\n `Failed to automatically fund ${agentName} account ${accountId}:`,\n fundingError\n );\n logger.warn(\n `Please fund the account ${accountId} manually with at least ${(\n MIN_REQUIRED_HBAR_USD / hbarPrice\n ).toFixed(2)} HBAR.`\n );\n }\n }\n } else {\n logger.warn(\n 'Failed to get HBAR price from Mirror Node. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.warn(\n 'Failed to check USD balance. Please ensure the account has enough HBAR.'\n );\n }\n } catch (error) {\n logger.error(`Failed to check ${agentName} account balance:`, error);\n }\n}"],"names":[],"mappings":";;AAIO,MAAM,mBAAmB;AACzB,MAAM,wBAAwB;AAErC,eAAsB,yBACpB,QACA,YACA,WACA,WACe;AACX,MAAA;AACF,UAAM,UAAU,MAAM,WAAW,eAAe,SAAS;AACnD,UAAA,UAAU,QAAQ,QAAQ;AAChC,UAAM,cAAc,UAAU;AAE9B,WAAO,KAAK,GAAG,SAAS,YAAY,SAAS,QAAQ,WAAW,OAAO;AAEnE,QAAA;AACF,YAAM,aAAa,IAAI,iBAA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,SAAS,4BAClC,wBAAwB,WACxB,QAAQ,CAAC,CAAC;AAAA,YACd;AAAA,UAAA;AAAA,QACF;AAAA,MACF,OACK;AACE,eAAA;AAAA,UACL;AAAA,QACF;AAAA,MAAA;AAAA,aAEK,OAAO;AACP,aAAA;AAAA,QACL;AAAA,MACF;AAAA,IAAA;AAAA,WAEK,OAAO;AACd,WAAO,MAAM,mBAAmB,SAAS,qBAAqB,KAAK;AAAA,EAAA;AAEvE;"}
@@ -1,5 +1,5 @@
1
1
  import { HCS10Client as HCS10Client$1, Logger, AgentBuilder, AIAgentCapability, InboundTopicType } from "@hashgraphonline/standards-sdk";
2
- import { encryptMessage } from "./standards-agent-kit.es24.js";
2
+ import { encryptMessage } from "./standards-agent-kit.es25.js";
3
3
  class HCS10Client {
4
4
  constructor(operatorId, operatorPrivateKey, network, options) {
5
5
  this.standardClient = new HCS10Client$1({
@@ -1,6 +1,6 @@
1
1
  import Buffer from "vite-plugin-node-polyfills/shims/buffer";
2
2
  import { Logger, AIAgentCapability, FeeConfigBuilder } from "@hashgraphonline/standards-sdk";
3
- import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.es25.js";
3
+ import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.es26.js";
4
4
  import { StructuredTool } from "@langchain/core/tools";
5
5
  import { z } from "zod";
6
6
  import fs__default from "fs";