@hashgraphonline/standards-agent-kit 0.2.105 → 0.2.107

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.
@@ -3,16 +3,22 @@ import { BaseHCS10TransactionTool } from './base-hcs10-tools';
3
3
  import { HCS10TransactionToolParams } from './hcs10-tool-params';
4
4
  import { BaseServiceBuilder } from 'hedera-agent-kit';
5
5
  declare const SendMessageToConnectionZodSchema: z.ZodObject<{
6
- targetIdentifier: z.ZodString;
6
+ targetIdentifier: z.ZodOptional<z.ZodString>;
7
+ connectionId: z.ZodOptional<z.ZodString>;
8
+ agentId: z.ZodOptional<z.ZodString>;
7
9
  message: z.ZodString;
8
10
  disableMonitoring: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
11
  }, "strip", z.ZodTypeAny, {
10
12
  message: string;
11
- targetIdentifier: string;
12
13
  disableMonitoring: boolean;
14
+ targetIdentifier?: string | undefined;
15
+ connectionId?: string | undefined;
16
+ agentId?: string | undefined;
13
17
  }, {
14
18
  message: string;
15
- targetIdentifier: string;
19
+ targetIdentifier?: string | undefined;
20
+ connectionId?: string | undefined;
21
+ agentId?: string | undefined;
16
22
  disableMonitoring?: boolean | undefined;
17
23
  }>;
18
24
  /**
@@ -22,16 +28,22 @@ export declare class SendMessageToConnectionTool extends BaseHCS10TransactionToo
22
28
  name: string;
23
29
  description: string;
24
30
  specificInputSchema: z.ZodObject<{
25
- targetIdentifier: z.ZodString;
31
+ targetIdentifier: z.ZodOptional<z.ZodString>;
32
+ connectionId: z.ZodOptional<z.ZodString>;
33
+ agentId: z.ZodOptional<z.ZodString>;
26
34
  message: z.ZodString;
27
35
  disableMonitoring: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
28
36
  }, "strip", z.ZodTypeAny, {
29
37
  message: string;
30
- targetIdentifier: string;
31
38
  disableMonitoring: boolean;
39
+ targetIdentifier?: string | undefined;
40
+ connectionId?: string | undefined;
41
+ agentId?: string | undefined;
32
42
  }, {
33
43
  message: string;
34
- targetIdentifier: string;
44
+ targetIdentifier?: string | undefined;
45
+ connectionId?: string | undefined;
46
+ agentId?: string | undefined;
35
47
  disableMonitoring?: boolean | undefined;
36
48
  }>;
37
49
  constructor(params: HCS10TransactionToolParams);
@@ -10,7 +10,7 @@ class ListConnectionsTool extends BaseHCS10QueryTool {
10
10
  constructor(params) {
11
11
  super(params);
12
12
  this.name = "list_connections";
13
- this.description = "Lists the currently active HCS-10 connections with detailed information. Shows connection status, agent details, and recent activity. Use this to get a comprehensive view of all active connections.";
13
+ this.description = "Lists all active HCS-10 connections. Use this FIRST before sending messages to check if you already have an active connection to a target agent. Shows connection details and agent information for each active connection.";
14
14
  this.specificInputSchema = ListConnectionsZodSchema;
15
15
  }
16
16
  async executeQuery(args) {
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es10.js","sources":["../../src/tools/hcs10/ListConnectionsTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to list currently active HCS-10 connections stored in the state manager.\n * Enhanced to show more details similar to moonscape's implementation.\n */\nconst ListConnectionsZodSchema = z.object({\n includeDetails: z\n .boolean()\n .optional()\n .describe(\n 'Whether to include detailed information about each connection'\n ),\n showPending: z\n .boolean()\n .optional()\n .describe('Whether to include pending connection requests'),\n});\n\nexport class ListConnectionsTool extends BaseHCS10QueryTool<\n typeof ListConnectionsZodSchema\n> {\n name = 'list_connections';\n description =\n 'Lists the currently active HCS-10 connections with detailed information. Shows connection status, agent details, and recent activity. Use this to get a comprehensive view of all active connections.';\n specificInputSchema = ListConnectionsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(\n args: z.infer<typeof ListConnectionsZodSchema>\n ): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { includeDetails?: boolean; showPending?: boolean } = {};\n if (args.includeDetails !== undefined) {\n params.includeDetails = args.includeDetails;\n }\n if (args.showPending !== undefined) {\n params.showPending = args.showPending;\n }\n await hcs10Builder.listConnections(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as { formattedOutput?: string; message?: string };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Connections listed'\n };\n }\n\n return result;\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,gBAAgB,EACb,UACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,aAAa,EACV,QAAA,EACA,SAAA,EACA,SAAS,gDAAgD;AAC9D,CAAC;AAEM,MAAM,4BAA4B,mBAEvC;AAAA,EAKA,YAAY,QAA8B;AACxC,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAAA,EAGtB;AAAA,EAEA,MAAgB,aACd,MACkB;AAClB,UAAM,eAAe,KAAK;AAC1B,UAAM,SAA8D,CAAA;AACpE,QAAI,KAAK,mBAAmB,QAAW;AACrC,aAAO,iBAAiB,KAAK;AAAA,IAC/B;AACA,QAAI,KAAK,gBAAgB,QAAW;AAClC,aAAO,cAAc,KAAK;AAAA,IAC5B;AACA,UAAM,aAAa,gBAAgB,MAAM;AAEzC,UAAM,SAAS,MAAM,aAAa,QAAA;AAElC,QAAI,OAAO,WAAW,eAAe,UAAU,OAAO,WAAW;AAC/D,YAAM,MAAM,OAAO;AACnB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,IAAI,mBAAmB,IAAI,WAAW;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"standards-agent-kit.es10.js","sources":["../../src/tools/hcs10/ListConnectionsTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to list currently active HCS-10 connections stored in the state manager.\n * Enhanced to show more details similar to moonscape's implementation.\n */\nconst ListConnectionsZodSchema = z.object({\n includeDetails: z\n .boolean()\n .optional()\n .describe(\n 'Whether to include detailed information about each connection'\n ),\n showPending: z\n .boolean()\n .optional()\n .describe('Whether to include pending connection requests'),\n});\n\nexport class ListConnectionsTool extends BaseHCS10QueryTool<\n typeof ListConnectionsZodSchema\n> {\n name = 'list_connections';\n description =\n 'Lists all active HCS-10 connections. Use this FIRST before sending messages to check if you already have an active connection to a target agent. Shows connection details and agent information for each active connection.';\n specificInputSchema = ListConnectionsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(\n args: z.infer<typeof ListConnectionsZodSchema>\n ): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { includeDetails?: boolean; showPending?: boolean } = {};\n if (args.includeDetails !== undefined) {\n params.includeDetails = args.includeDetails;\n }\n if (args.showPending !== undefined) {\n params.showPending = args.showPending;\n }\n await hcs10Builder.listConnections(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as { formattedOutput?: string; message?: string };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Connections listed'\n };\n }\n\n return result;\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,gBAAgB,EACb,UACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,aAAa,EACV,QAAA,EACA,SAAA,EACA,SAAS,gDAAgD;AAC9D,CAAC;AAEM,MAAM,4BAA4B,mBAEvC;AAAA,EAKA,YAAY,QAA8B;AACxC,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAAA,EAGtB;AAAA,EAEA,MAAgB,aACd,MACkB;AAClB,UAAM,eAAe,KAAK;AAC1B,UAAM,SAA8D,CAAA;AACpE,QAAI,KAAK,mBAAmB,QAAW;AACrC,aAAO,iBAAiB,KAAK;AAAA,IAC/B;AACA,QAAI,KAAK,gBAAgB,QAAW;AAClC,aAAO,cAAc,KAAK;AAAA,IAC5B;AACA,UAAM,aAAa,gBAAgB,MAAM;AAEzC,UAAM,SAAS,MAAM,aAAa,QAAA;AAElC,QAAI,OAAO,WAAW,eAAe,UAAU,OAAO,WAAW;AAC/D,YAAM,MAAM,OAAO;AACnB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,IAAI,mBAAmB,IAAI,WAAW;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACT;AACF;"}
@@ -683,31 +683,64 @@ class HCS10Builder extends BaseServiceBuilder {
683
683
  );
684
684
  }
685
685
  let connection;
686
- if (params.targetIdentifier.includes("@")) {
687
- const parts = params.targetIdentifier.split("@");
686
+ const identifier = params.targetIdentifier;
687
+ if (identifier.includes("@")) {
688
+ const parts = identifier.split("@");
688
689
  if (parts.length === 2) {
689
690
  const accountId = parts[1];
690
691
  connection = this.stateManager.getConnectionByIdentifier(accountId);
691
692
  if (!connection) {
692
693
  this.addNote(
693
- `Could not find connection using request key '${params.targetIdentifier}', extracted account ID '${accountId}'.`
694
+ `Could not find connection using request key '${identifier}', extracted account ID '${accountId}'.`
694
695
  );
695
696
  }
696
697
  }
697
698
  }
698
699
  if (!connection) {
699
- connection = this.stateManager.getConnectionByIdentifier(
700
- params.targetIdentifier
701
- );
700
+ connection = this.stateManager.getConnectionByIdentifier(identifier);
701
+ }
702
+ if (!connection && !identifier.startsWith("0.0.") && /^\d+$/.test(identifier)) {
703
+ const accountIdWithPrefix = `0.0.${identifier}`;
704
+ connection = this.stateManager.getConnectionByIdentifier(accountIdWithPrefix);
705
+ if (connection) {
706
+ this.addNote(
707
+ `Found connection using account ID with prefix: ${accountIdWithPrefix}`
708
+ );
709
+ }
710
+ }
711
+ if (!connection && /^[1-9]\d*$/.test(identifier)) {
712
+ const connections = this.stateManager.listConnections();
713
+ const index = parseInt(identifier) - 1;
714
+ if (index >= 0 && index < connections.length) {
715
+ connection = connections[index];
716
+ if (connection) {
717
+ this.addNote(
718
+ `Found connection by index ${identifier}: ${connection.targetAccountId}`
719
+ );
720
+ }
721
+ }
702
722
  }
703
723
  if (!connection) {
704
724
  const connections = this.stateManager.listConnections();
705
725
  const availableIds = connections.map(
706
- (c) => `${c.targetAccountId} (${c.connectionTopicId})`
707
- );
708
- throw new Error(
709
- `Connection not found for identifier: ${params.targetIdentifier}. Available connections: ${availableIds.join(", ") || "none"}. Use 'list_connections' to see details.`
726
+ (c, i) => `${i + 1}. ${c.targetAccountId} (Topic: ${c.connectionTopicId})`
710
727
  );
728
+ let errorMsg = `Connection not found for identifier: "${identifier}"
729
+ `;
730
+ errorMsg += `Available connections:
731
+ ${availableIds.join("\n") || "No active connections"}`;
732
+ errorMsg += `
733
+
734
+ You can use:
735
+ `;
736
+ errorMsg += `- Connection number (e.g., "1", "2")
737
+ `;
738
+ errorMsg += `- Account ID (e.g., "0.0.6412936")
739
+ `;
740
+ errorMsg += `- Connection topic ID
741
+ `;
742
+ errorMsg += `Use 'list_connections' to see all active connections.`;
743
+ throw new Error(errorMsg);
711
744
  }
712
745
  let connectionTopicId = connection.connectionTopicId;
713
746
  if (connectionTopicId && typeof connectionTopicId === "object" && "toString" in connectionTopicId) {