@hashgraphonline/standards-agent-kit 0.0.11 → 0.0.13

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.
@@ -1,6 +1,9 @@
1
1
  import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';
2
- import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse, HCSMessage, LogLevel } from '@hashgraphonline/standards-sdk';
2
+ import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse as SDKProfileResponse, HCSMessage, LogLevel, Logger, FeeConfigBuilderInterface } from '@hashgraphonline/standards-sdk';
3
3
  import { AgentMetadata, AgentChannels } from './types';
4
+ type StandardHandleConnectionRequest = InstanceType<typeof StandardSDKClient>['handleConnectionRequest'];
5
+ type HandleConnectionRequestResponse = Awaited<ReturnType<StandardHandleConnectionRequest>>;
6
+ export type StandardNetworkType = 'mainnet' | 'testnet';
4
7
  export interface HCSMessageWithTimestamp extends HCSMessage {
5
8
  timestamp: number;
6
9
  data: string;
@@ -9,11 +12,8 @@ export interface HCSMessageWithTimestamp extends HCSMessage {
9
12
  export interface ExtendedAgentMetadata extends AgentMetadata {
10
13
  pfpBuffer?: Buffer;
11
14
  pfpFileName?: string;
15
+ feeConfig?: FeeConfigBuilderInterface;
12
16
  }
13
- type StandardHandleConnectionRequest = InstanceType<typeof StandardSDKClient>['handleConnectionRequest'];
14
- type FeeConfigBuilderInterface = Parameters<StandardHandleConnectionRequest>[3];
15
- type HandleConnectionRequestResponse = Awaited<ReturnType<StandardHandleConnectionRequest>>;
16
- export type StandardNetworkType = 'mainnet' | 'testnet';
17
17
  /**
18
18
  * HCS10Client wraps the HCS-10 functionalities using the @hashgraphonline/standards-sdk.
19
19
  * - Creates and registers agents using the standard SDK flow.
@@ -25,6 +25,7 @@ export declare class HCS10Client {
25
25
  private useEncryption;
26
26
  agentChannels?: AgentChannels;
27
27
  guardedRegistryBaseUrl: string;
28
+ logger: Logger;
28
29
  constructor(operatorId: string, operatorPrivateKey: string, network: StandardNetworkType, options?: {
29
30
  useEncryption?: boolean;
30
31
  registryUrl?: string;
@@ -34,9 +35,9 @@ export declare class HCS10Client {
34
35
  getNetwork(): StandardNetworkType;
35
36
  handleConnectionRequest(inboundTopicId: string, requestingAccountId: string, connectionRequestId: number, feeConfig?: FeeConfigBuilderInterface): Promise<HandleConnectionRequestResponse>;
36
37
  /**
37
- * Exposes the standard SDK's retrieveProfile method.
38
+ * Retrieves the profile for a given account ID using the standard SDK.
38
39
  */
39
- retrieveProfile(accountId: string): Promise<ProfileResponse>;
40
+ getAgentProfile(accountId: string): Promise<SDKProfileResponse>;
40
41
  /**
41
42
  * Exposes the standard SDK's submitConnectionRequest method.
42
43
  */
@@ -44,12 +45,18 @@ export declare class HCS10Client {
44
45
  /**
45
46
  * Exposes the standard SDK's waitForConnectionConfirmation method.
46
47
  */
47
- waitForConnectionConfirmation(outboundTopicId: string, // Changed from inboundTopicId based on demo usage
48
- connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<WaitForConnectionConfirmationResponse>;
48
+ waitForConnectionConfirmation(outboundTopicId: string, connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<WaitForConnectionConfirmationResponse>;
49
49
  /**
50
50
  * Creates and registers an agent using the standard SDK's HCS10Client.
51
51
  * This handles account creation, key generation, topic setup, and registration.
52
- * @param metadata - The agent's metadata, potentially including pfpBuffer and pfpFileName.
52
+ *
53
+ * When metadata includes fee configuration:
54
+ * 1. The properties.feeConfig will be passed to the AgentBuilder
55
+ * 2. The properties.inboundTopicType will be set to FEE_BASED
56
+ * 3. The SDK's createAndRegisterAgent will apply the fees to the agent's inbound topic
57
+ *
58
+ * @param metadata - The agent's metadata, potentially including pfpBuffer, pfpFileName,
59
+ * and fee configuration in properties.feeConfig
53
60
  * @returns The registration result from the standard SDK, containing accountId, keys, topics etc.
54
61
  */
55
62
  createAndRegisterAgent(metadata: ExtendedAgentMetadata): Promise<AgentRegistrationResult>;
@@ -64,7 +71,7 @@ export declare class HCS10Client {
64
71
  * @param submitKey - Optional private key for topics requiring specific submit keys.
65
72
  * @returns A confirmation status string from the transaction receipt.
66
73
  */
67
- sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<number | undefined>;
74
+ sendMessage(topicId: string, data: string, memo?: string, submitKey?: any): Promise<number | undefined>;
68
75
  /**
69
76
  * Retrieves messages from a topic using the standard SDK client.
70
77
  *
@@ -90,6 +97,21 @@ export declare class HCS10Client {
90
97
  * @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.
91
98
  */
92
99
  getInboundTopicId(): Promise<string>;
100
+ /**
101
+ * Retrieves the configured operator account ID and private key.
102
+ * Required by tools needing to identify the current agent instance.
103
+ */
104
+ getAccountAndSigner(): {
105
+ accountId: string;
106
+ signer: PrivateKey;
107
+ };
108
+ /**
109
+ * Retrieves the outbound topic ID for the current operator.
110
+ * Fetches the operator's profile if necessary.
111
+ * @returns The outbound topic ID string.
112
+ * @throws If the outbound topic cannot be determined.
113
+ */
114
+ getOutboundTopicId(): Promise<string>;
93
115
  setClient(accountId: string, privateKey: string): StandardSDKClient;
94
116
  }
95
117
  export {};
@@ -1,3 +1,4 @@
1
+ import { FeeConfigBuilderInterface } from '@hashgraphonline/standards-sdk';
1
2
  /**
2
3
  * Agent metadata interface used during registration.
3
4
  */
@@ -10,6 +11,9 @@ export interface AgentMetadata {
10
11
  capabilities?: number[];
11
12
  social?: Record<string, string>;
12
13
  properties?: Record<string, unknown>;
14
+ socials?: Record<string, string>;
15
+ creator?: string;
16
+ feeConfig?: FeeConfigBuilderInterface;
13
17
  }
14
18
  /**
15
19
  * AgentChannels represents the communication topics for an agent.
@@ -1,26 +1,15 @@
1
- import { HCS10Client } from './hcs10/HCS10Client';
2
- import { RegisterAgentTool } from './tools/RegisterAgentTool';
3
- import { SendMessageTool } from './tools/SendMessageTool';
4
- import { ConnectionTool } from './tools/ConnectionTool';
5
- import { IStateManager } from './state/open-convai-state';
6
- export interface HCS10InitializationOptions {
7
- useEncryption?: boolean;
8
- registryUrl?: string;
9
- stateManager?: IStateManager;
10
- }
11
- /**
12
- * Initializes the HCS10 client and returns pre-registered LangChain tools.
13
- *
14
- * @param options - Optional settings including useEncryption, registryUrl, and stateManager.
15
- */
16
- export declare function initializeHCS10Client(options?: HCS10InitializationOptions): Promise<{
17
- hcs10Client: HCS10Client;
18
- tools: {
19
- registerAgentTool: RegisterAgentTool;
20
- sendMessageTool: SendMessageTool;
21
- connectionTool: ConnectionTool;
22
- };
23
- }>;
24
1
  export * from './hcs10';
25
2
  export * from './tools';
26
3
  export * from './state';
4
+ export * from './init';
5
+ export { ConnectionTool } from './tools/ConnectionTool';
6
+ export { ConnectionMonitorTool } from './tools/ConnectionMonitorTool';
7
+ export { ManageConnectionRequestsTool } from './tools/ManageConnectionRequestsTool';
8
+ export { AcceptConnectionRequestTool } from './tools/AcceptConnectionRequestTool';
9
+ export { InitiateConnectionTool } from './tools/InitiateConnectionTool';
10
+ export { ListConnectionsTool } from './tools/ListConnectionsTool';
11
+ export { CheckMessagesTool } from './tools/CheckMessagesTool';
12
+ export { FindRegistrationsTool } from './tools/FindRegistrationsTool';
13
+ export { SendMessageTool } from './tools/SendMessageTool';
14
+ export { SendMessageToConnectionTool } from './tools/SendMessageToConnectionTool';
15
+ export { ListUnapprovedConnectionRequestsTool } from './tools/ListUnapprovedConnectionRequestsTool';
@@ -0,0 +1,23 @@
1
+ import { HCS10Client } from './hcs10/HCS10Client';
2
+ import { RegisterAgentTool } from './tools/RegisterAgentTool';
3
+ import { SendMessageTool } from './tools/SendMessageTool';
4
+ import { ConnectionTool } from './tools/ConnectionTool';
5
+ import { IStateManager } from './state/open-convai-state';
6
+ export interface HCS10InitializationOptions {
7
+ useEncryption?: boolean;
8
+ registryUrl?: string;
9
+ stateManager?: IStateManager;
10
+ }
11
+ /**
12
+ * Initializes the HCS10 client and returns pre-registered LangChain tools.
13
+ *
14
+ * @param options - Optional settings including useEncryption, registryUrl, and stateManager.
15
+ */
16
+ export declare function initializeHCS10Client(options?: HCS10InitializationOptions): Promise<{
17
+ hcs10Client: HCS10Client;
18
+ tools: {
19
+ registerAgentTool: RegisterAgentTool;
20
+ sendMessageTool: SendMessageTool;
21
+ connectionTool: ConnectionTool;
22
+ };
23
+ }>;
@@ -5,36 +5,160 @@ export interface RegisteredAgent {
5
5
  outboundTopicId: string;
6
6
  profileTopicId?: string;
7
7
  }
8
+ export type ConnectionStatus = 'established' | 'pending' | 'needs confirmation' | 'unknown';
9
+ export interface AgentProfileInfo {
10
+ name?: string;
11
+ bio?: string;
12
+ avatar?: string;
13
+ type?: string;
14
+ }
15
+ export interface ConnectionRequestInfo {
16
+ id: number;
17
+ requestorId: string;
18
+ requestorName: string;
19
+ timestamp: Date;
20
+ memo?: string;
21
+ profile?: AgentProfileInfo;
22
+ }
8
23
  export interface ActiveConnection {
9
24
  targetAccountId: string;
10
25
  targetAgentName: string;
11
26
  targetInboundTopicId: string;
12
27
  connectionTopicId: string;
28
+ status?: ConnectionStatus;
29
+ created?: Date;
30
+ lastActivity?: Date;
31
+ isPending?: boolean;
32
+ needsConfirmation?: boolean;
33
+ profileInfo?: AgentProfileInfo;
13
34
  }
35
+ /**
36
+ * Core state management interface for the standards agent toolkit.
37
+ * All tools that need to maintain state should use an implementation of this interface.
38
+ */
14
39
  export interface IStateManager {
40
+ /**
41
+ * Sets the current active agent, clearing any previous connections.
42
+ */
15
43
  setCurrentAgent(agent: RegisteredAgent | null): void;
44
+ /**
45
+ * Gets the current active agent.
46
+ */
16
47
  getCurrentAgent(): RegisteredAgent | null;
48
+ /**
49
+ * Adds a new active connection to the state.
50
+ * Will not add duplicates based on connectionTopicId.
51
+ */
17
52
  addActiveConnection(connection: ActiveConnection): void;
53
+ /**
54
+ * Updates an existing connection or adds it if not found.
55
+ * Preserves existing properties when updating.
56
+ */
57
+ updateOrAddConnection(connection: ActiveConnection): void;
58
+ /**
59
+ * Lists all active connections for the current agent.
60
+ */
18
61
  listConnections(): ActiveConnection[];
62
+ /**
63
+ * Finds a connection by identifier, which can be:
64
+ * - A 1-based index number as shown in the connection list
65
+ * - A target account ID
66
+ * - A connection topic ID
67
+ */
19
68
  getConnectionByIdentifier(identifier: string): ActiveConnection | undefined;
69
+ /**
70
+ * Gets the last processed message timestamp for a connection.
71
+ */
20
72
  getLastTimestamp(connectionTopicId: string): number;
73
+ /**
74
+ * Updates the last processed message timestamp for a connection.
75
+ */
21
76
  updateTimestamp(connectionTopicId: string, timestampNanos: number): void;
77
+ /**
78
+ * Stores a connection request in the state.
79
+ */
80
+ addConnectionRequest(request: ConnectionRequestInfo): void;
81
+ /**
82
+ * Lists all pending connection requests.
83
+ */
84
+ listConnectionRequests(): ConnectionRequestInfo[];
85
+ /**
86
+ * Finds a connection request by its ID.
87
+ */
88
+ getConnectionRequestById(requestId: number): ConnectionRequestInfo | undefined;
89
+ /**
90
+ * Removes a connection request from the state.
91
+ */
92
+ removeConnectionRequest(requestId: number): void;
93
+ /**
94
+ * Clears all connection requests from the state.
95
+ */
96
+ clearConnectionRequests(): void;
22
97
  }
23
98
  /**
24
- * An example implementation of the `IStateManager` interface.
25
- * All tools should have a state manager instance.
99
+ * Implementation of the IStateManager interface for the OpenConvai system.
100
+ * Manages agent state and connection information with thread safety and
101
+ * proper timestamp tracking.
26
102
  */
27
103
  export declare class OpenConvaiState implements IStateManager {
28
- currentAgent: RegisteredAgent | null;
29
- activeConnections: ActiveConnection[];
30
- connectionMessageTimestamps: {
31
- [connectionTopicId: string]: number;
32
- };
104
+ private currentAgent;
105
+ private activeConnections;
106
+ private connectionMessageTimestamps;
107
+ private connectionRequests;
108
+ /**
109
+ * Sets the current active agent and clears any previous connection data.
110
+ * This should be called when switching between agents.
111
+ */
33
112
  setCurrentAgent(agent: RegisteredAgent | null): void;
113
+ /**
114
+ * Returns the currently active agent or null if none is set.
115
+ */
34
116
  getCurrentAgent(): RegisteredAgent | null;
117
+ /**
118
+ * Adds a new connection to the active connections list.
119
+ * Ensures no duplicates are added based on connectionTopicId.
120
+ * Initializes timestamp tracking for the connection.
121
+ */
35
122
  addActiveConnection(connection: ActiveConnection): void;
123
+ /**
124
+ * Updates an existing connection or adds it if not found.
125
+ * Preserves existing properties when updating by merging objects.
126
+ */
127
+ updateOrAddConnection(connection: ActiveConnection): void;
128
+ /**
129
+ * Returns a copy of all active connections.
130
+ */
36
131
  listConnections(): ActiveConnection[];
132
+ /**
133
+ * Finds a connection by its identifier, which can be:
134
+ * - A 1-based index as displayed in the connection list
135
+ * - A target account ID string
136
+ * - A connection topic ID string
137
+ */
37
138
  getConnectionByIdentifier(identifier: string): ActiveConnection | undefined;
139
+ /**
140
+ * Gets the last processed message timestamp for a connection.
141
+ * Returns 0 if no timestamp has been recorded.
142
+ */
38
143
  getLastTimestamp(connectionTopicId: string): number;
144
+ /**
145
+ * Updates the last processed message timestamp for a connection,
146
+ * but only if the new timestamp is more recent than the existing one.
147
+ */
39
148
  updateTimestamp(connectionTopicId: string, timestampNanos: number): void;
149
+ /**
150
+ * Helper method to find a connection's index by its topic ID.
151
+ * Returns -1 if not found.
152
+ */
153
+ private findConnectionIndex;
154
+ /**
155
+ * Helper method to initialize timestamp tracking for a connection
156
+ * if it doesn't already exist.
157
+ */
158
+ private initializeTimestampIfNeeded;
159
+ addConnectionRequest(request: ConnectionRequestInfo): void;
160
+ listConnectionRequests(): ConnectionRequestInfo[];
161
+ getConnectionRequestById(requestId: number): ConnectionRequestInfo | undefined;
162
+ removeConnectionRequest(requestId: number): void;
163
+ clearConnectionRequests(): void;
40
164
  }
@@ -0,0 +1,33 @@
1
+ import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
+ import { IStateManager } from '../state/open-convai-state';
5
+ export interface AcceptConnectionRequestToolParams extends ToolParams {
6
+ hcsClient: HCS10Client;
7
+ stateManager: IStateManager;
8
+ }
9
+ /**
10
+ * A tool specifically for accepting incoming connection requests.
11
+ */
12
+ export declare class AcceptConnectionRequestTool extends StructuredTool {
13
+ name: string;
14
+ description: string;
15
+ schema: z.ZodObject<{
16
+ requestId: z.ZodNumber;
17
+ hbarFee: z.ZodOptional<z.ZodNumber>;
18
+ exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ requestId: number;
21
+ hbarFee?: number | undefined;
22
+ exemptAccountIds?: string[] | undefined;
23
+ }, {
24
+ requestId: number;
25
+ hbarFee?: number | undefined;
26
+ exemptAccountIds?: string[] | undefined;
27
+ }>;
28
+ private hcsClient;
29
+ private stateManager;
30
+ private logger;
31
+ constructor({ hcsClient, stateManager, ...rest }: AcceptConnectionRequestToolParams);
32
+ protected _call({ requestId, hbarFee, exemptAccountIds, }: z.infer<this['schema']>): Promise<string>;
33
+ }
@@ -0,0 +1,96 @@
1
+ import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
+ import { IStateManager } from '../state/open-convai-state';
5
+ export interface FeeDefinition {
6
+ amount: number;
7
+ collectorAccount?: string;
8
+ }
9
+ export interface TokenFeeDefinition extends FeeDefinition {
10
+ tokenId: string;
11
+ }
12
+ export interface ConnectionMonitorToolParams extends ToolParams {
13
+ hcsClient: HCS10Client;
14
+ stateManager: IStateManager;
15
+ }
16
+ /**
17
+ * A tool for monitoring incoming connection requests and accepting them with optional fee settings.
18
+ */
19
+ export declare class ConnectionMonitorTool extends StructuredTool {
20
+ name: string;
21
+ description: string;
22
+ schema: z.ZodObject<{
23
+ acceptAll: z.ZodOptional<z.ZodBoolean>;
24
+ targetAccountId: z.ZodOptional<z.ZodString>;
25
+ hbarFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ amount: z.ZodNumber;
27
+ collectorAccount: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ amount: number;
30
+ collectorAccount?: string | undefined;
31
+ }, {
32
+ amount: number;
33
+ collectorAccount?: string | undefined;
34
+ }>, "many">>;
35
+ tokenFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
+ amount: z.ZodNumber;
37
+ tokenId: z.ZodString;
38
+ collectorAccount: z.ZodOptional<z.ZodString>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ amount: number;
41
+ tokenId: string;
42
+ collectorAccount?: string | undefined;
43
+ }, {
44
+ amount: number;
45
+ tokenId: string;
46
+ collectorAccount?: string | undefined;
47
+ }>, "many">>;
48
+ exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
49
+ monitorDurationSeconds: z.ZodOptional<z.ZodNumber>;
50
+ defaultCollectorAccount: z.ZodOptional<z.ZodString>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ hbarFees?: {
53
+ amount: number;
54
+ collectorAccount?: string | undefined;
55
+ }[] | undefined;
56
+ tokenFees?: {
57
+ amount: number;
58
+ tokenId: string;
59
+ collectorAccount?: string | undefined;
60
+ }[] | undefined;
61
+ exemptAccountIds?: string[] | undefined;
62
+ targetAccountId?: string | undefined;
63
+ acceptAll?: boolean | undefined;
64
+ monitorDurationSeconds?: number | undefined;
65
+ defaultCollectorAccount?: string | undefined;
66
+ }, {
67
+ hbarFees?: {
68
+ amount: number;
69
+ collectorAccount?: string | undefined;
70
+ }[] | undefined;
71
+ tokenFees?: {
72
+ amount: number;
73
+ tokenId: string;
74
+ collectorAccount?: string | undefined;
75
+ }[] | undefined;
76
+ exemptAccountIds?: string[] | undefined;
77
+ targetAccountId?: string | undefined;
78
+ acceptAll?: boolean | undefined;
79
+ monitorDurationSeconds?: number | undefined;
80
+ defaultCollectorAccount?: string | undefined;
81
+ }>;
82
+ private hcsClient;
83
+ private stateManager;
84
+ private logger;
85
+ private isMonitoring;
86
+ private listConnectionsTool;
87
+ private static processedRequests;
88
+ constructor({ hcsClient, stateManager, ...rest }: ConnectionMonitorToolParams);
89
+ updateClient(newClient: HCS10Client): void;
90
+ call(args: z.infer<this['schema']>): Promise<string>;
91
+ protected _call({ acceptAll, targetAccountId, hbarFees, tokenFees, exemptAccountIds, monitorDurationSeconds, defaultCollectorAccount, }: z.infer<this['schema']>): Promise<string>;
92
+ private createFeeConfig;
93
+ private extractAccountId;
94
+ private acceptConnectionRequest;
95
+ private formatFeeString;
96
+ }
@@ -26,5 +26,5 @@ export declare class InitiateConnectionTool extends StructuredTool {
26
26
  private stateManager;
27
27
  private logger;
28
28
  constructor({ hcsClient, stateManager, ...rest }: InitiateConnectionToolParams);
29
- protected _call({ targetAccountId, }: z.infer<this['schema']>): Promise<string>;
29
+ protected _call({ targetAccountId }: z.infer<this['schema']>): Promise<string>;
30
30
  }
@@ -1,17 +1,33 @@
1
1
  import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
2
  import { z } from 'zod';
3
3
  import { IStateManager } from '../state/open-convai-state';
4
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
5
  export interface ListConnectionsToolParams extends ToolParams {
5
6
  stateManager: IStateManager;
7
+ hcsClient?: HCS10Client;
6
8
  }
7
9
  /**
8
10
  * A tool to list currently active HCS-10 connections stored in the state manager.
11
+ * Enhanced to show more details similar to moonscape's implementation.
9
12
  */
10
13
  export declare class ListConnectionsTool extends StructuredTool {
11
14
  name: string;
12
15
  description: string;
13
- schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
16
+ schema: z.ZodObject<{
17
+ includeDetails: z.ZodOptional<z.ZodBoolean>;
18
+ showPending: z.ZodOptional<z.ZodBoolean>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ includeDetails?: boolean | undefined;
21
+ showPending?: boolean | undefined;
22
+ }, {
23
+ includeDetails?: boolean | undefined;
24
+ showPending?: boolean | undefined;
25
+ }>;
14
26
  private stateManager;
15
- constructor({ stateManager, ...rest }: ListConnectionsToolParams);
16
- protected _call(_: z.infer<this['schema']>): Promise<string>;
27
+ private hcsClient?;
28
+ constructor({ stateManager, hcsClient, ...rest }: ListConnectionsToolParams);
29
+ protected _call(args: z.infer<this['schema']>): Promise<string>;
30
+ private formatConnection;
31
+ private enhanceConnectionInfo;
32
+ private fetchOutboundMessages;
17
33
  }
@@ -0,0 +1,53 @@
1
+ import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import { IStateManager } from '../state/open-convai-state';
4
+ import { HCS10Client } from '../hcs10/HCS10Client';
5
+ type ListPendingRequestsToolParams = ToolParams & {
6
+ hcsClient: HCS10Client;
7
+ stateManager: IStateManager;
8
+ };
9
+ export declare class ListUnapprovedConnectionRequestsTool extends StructuredTool {
10
+ name: string;
11
+ description: string;
12
+ schema: z.ZodObject<{
13
+ sortBy: z.ZodOptional<z.ZodEnum<["time_asc", "time_desc", "name_asc", "name_desc"]>>;
14
+ limit: z.ZodOptional<z.ZodNumber>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc" | undefined;
17
+ limit?: number | undefined;
18
+ }, {
19
+ sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc" | undefined;
20
+ limit?: number | undefined;
21
+ }>;
22
+ private hcsClient;
23
+ private stateManager;
24
+ private logger;
25
+ constructor({ hcsClient, stateManager, ...rest }: ListPendingRequestsToolParams);
26
+ protected _call({ sortBy, limit, }: z.infer<this['schema']>): Promise<string>;
27
+ /**
28
+ * Processes the connection connectionMap to find all requests
29
+ * that are not fully established (incoming unapproved and outgoing pending).
30
+ */
31
+ private findAllPendingRequests;
32
+ /**
33
+ * Helper to attempt extracting target account ID from outbound request message.
34
+ */
35
+ private extractTargetAccountIdFromOutbound;
36
+ /**
37
+ * Maps HCS11Profile to the AgentProfileInfo used in state/display.
38
+ */
39
+ private mapSDKProfileToInfo;
40
+ /**
41
+ * Extracts the account ID from relevant fields in an HCSMessage.
42
+ */
43
+ private extractAccountIdFromMessage;
44
+ /**
45
+ * Formats the list of pending requests for display.
46
+ */
47
+ private formatRequestsList;
48
+ /**
49
+ * Sorts connection requests based on the specified criteria.
50
+ */
51
+ private sortRequests;
52
+ }
53
+ export {};
@@ -0,0 +1,39 @@
1
+ import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import { HCS10Client } from '../hcs10/HCS10Client';
4
+ import { IStateManager } from '../state/open-convai-state';
5
+ export interface ManageConnectionRequestsToolParams extends ToolParams {
6
+ hcsClient: HCS10Client;
7
+ stateManager: IStateManager;
8
+ }
9
+ /**
10
+ * A tool for managing incoming connection requests in a LangChain-compatible way.
11
+ * This tool allows an agent to list, view details of, and accept/reject incoming connection requests.
12
+ */
13
+ export declare class ManageConnectionRequestsTool extends StructuredTool {
14
+ name: string;
15
+ description: string;
16
+ schema: z.ZodObject<{
17
+ action: z.ZodEnum<["list", "view", "reject"]>;
18
+ requestId: z.ZodOptional<z.ZodNumber>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ action: "list" | "view" | "reject";
21
+ requestId?: number | undefined;
22
+ }, {
23
+ action: "list" | "view" | "reject";
24
+ requestId?: number | undefined;
25
+ }>;
26
+ private hcsClient;
27
+ private stateManager;
28
+ private logger;
29
+ private lastRefreshTime;
30
+ private refreshIntervalMs;
31
+ constructor({ hcsClient, stateManager, ...rest }: ManageConnectionRequestsToolParams);
32
+ protected _call({ action, requestId, }: z.infer<this['schema']>): Promise<string>;
33
+ private refreshRequestsIfNeeded;
34
+ private refreshRequests;
35
+ private listRequests;
36
+ private viewRequest;
37
+ private rejectRequest;
38
+ private extractAccountId;
39
+ }