@hashgraphonline/standards-agent-kit 0.0.12 → 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.
- package/dist/index.es.js +5324 -4885
- package/dist/index.es.js.map +1 -1
- package/dist/src/hcs10/HCS10Client.d.ts +15 -7
- package/dist/src/hcs10/types.d.ts +4 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/tools/ConnectionMonitorTool.d.ts +6 -6
- package/dist/src/tools/ListUnapprovedConnectionRequestsTool.d.ts +53 -0
- package/dist/src/tools/ManageConnectionRequestsTool.d.ts +1 -1
- package/dist/src/tools/RegisterAgentTool.d.ts +69 -3
- package/dist/src/utils/connectionUtils.d.ts +15 -0
- package/package.json +2 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';
|
|
2
|
-
import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse as SDKProfileResponse, 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;
|
|
@@ -48,7 +49,14 @@ export declare class HCS10Client {
|
|
|
48
49
|
/**
|
|
49
50
|
* Creates and registers an agent using the standard SDK's HCS10Client.
|
|
50
51
|
* This handles account creation, key generation, topic setup, and registration.
|
|
51
|
-
*
|
|
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
|
|
52
60
|
* @returns The registration result from the standard SDK, containing accountId, keys, topics etc.
|
|
53
61
|
*/
|
|
54
62
|
createAndRegisterAgent(metadata: ExtendedAgentMetadata): Promise<AgentRegistrationResult>;
|
|
@@ -63,7 +71,7 @@ export declare class HCS10Client {
|
|
|
63
71
|
* @param submitKey - Optional private key for topics requiring specific submit keys.
|
|
64
72
|
* @returns A confirmation status string from the transaction receipt.
|
|
65
73
|
*/
|
|
66
|
-
sendMessage(topicId: string, data: string, memo?: string, submitKey?:
|
|
74
|
+
sendMessage(topicId: string, data: string, memo?: string, submitKey?: any): Promise<number | undefined>;
|
|
67
75
|
/**
|
|
68
76
|
* Retrieves messages from a topic using the standard SDK client.
|
|
69
77
|
*
|
|
@@ -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.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,3 +2,14 @@ export * from './hcs10';
|
|
|
2
2
|
export * from './tools';
|
|
3
3
|
export * from './state';
|
|
4
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';
|
|
@@ -49,9 +49,6 @@ export declare class ConnectionMonitorTool extends StructuredTool {
|
|
|
49
49
|
monitorDurationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
50
50
|
defaultCollectorAccount: z.ZodOptional<z.ZodString>;
|
|
51
51
|
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
exemptAccountIds?: string[] | undefined;
|
|
53
|
-
targetAccountId?: string | undefined;
|
|
54
|
-
acceptAll?: boolean | undefined;
|
|
55
52
|
hbarFees?: {
|
|
56
53
|
amount: number;
|
|
57
54
|
collectorAccount?: string | undefined;
|
|
@@ -61,12 +58,12 @@ export declare class ConnectionMonitorTool extends StructuredTool {
|
|
|
61
58
|
tokenId: string;
|
|
62
59
|
collectorAccount?: string | undefined;
|
|
63
60
|
}[] | undefined;
|
|
64
|
-
monitorDurationSeconds?: number | undefined;
|
|
65
|
-
defaultCollectorAccount?: string | undefined;
|
|
66
|
-
}, {
|
|
67
61
|
exemptAccountIds?: string[] | undefined;
|
|
68
62
|
targetAccountId?: string | undefined;
|
|
69
63
|
acceptAll?: boolean | undefined;
|
|
64
|
+
monitorDurationSeconds?: number | undefined;
|
|
65
|
+
defaultCollectorAccount?: string | undefined;
|
|
66
|
+
}, {
|
|
70
67
|
hbarFees?: {
|
|
71
68
|
amount: number;
|
|
72
69
|
collectorAccount?: string | undefined;
|
|
@@ -76,6 +73,9 @@ export declare class ConnectionMonitorTool extends StructuredTool {
|
|
|
76
73
|
tokenId: string;
|
|
77
74
|
collectorAccount?: string | undefined;
|
|
78
75
|
}[] | undefined;
|
|
76
|
+
exemptAccountIds?: string[] | undefined;
|
|
77
|
+
targetAccountId?: string | undefined;
|
|
78
|
+
acceptAll?: boolean | undefined;
|
|
79
79
|
monitorDurationSeconds?: number | undefined;
|
|
80
80
|
defaultCollectorAccount?: string | undefined;
|
|
81
81
|
}>;
|
|
@@ -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 {};
|
|
@@ -29,7 +29,7 @@ export declare class ManageConnectionRequestsTool extends StructuredTool {
|
|
|
29
29
|
private lastRefreshTime;
|
|
30
30
|
private refreshIntervalMs;
|
|
31
31
|
constructor({ hcsClient, stateManager, ...rest }: ManageConnectionRequestsToolParams);
|
|
32
|
-
protected _call({ action, requestId }: z.infer<this['schema']>): Promise<string>;
|
|
32
|
+
protected _call({ action, requestId, }: z.infer<this['schema']>): Promise<string>;
|
|
33
33
|
private refreshRequestsIfNeeded;
|
|
34
34
|
private refreshRequests;
|
|
35
35
|
private listRequests;
|
|
@@ -28,36 +28,78 @@ export declare class RegisterAgentTool extends StructuredTool {
|
|
|
28
28
|
amount: number;
|
|
29
29
|
tokenId: string;
|
|
30
30
|
}>>;
|
|
31
|
+
hbarFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
+
amount: z.ZodNumber;
|
|
33
|
+
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
amount: number;
|
|
36
|
+
collectorAccount?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
amount: number;
|
|
39
|
+
collectorAccount?: string | undefined;
|
|
40
|
+
}>, "many">>;
|
|
41
|
+
tokenFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
42
|
+
amount: z.ZodNumber;
|
|
43
|
+
tokenId: z.ZodString;
|
|
44
|
+
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
amount: number;
|
|
47
|
+
tokenId: string;
|
|
48
|
+
collectorAccount?: string | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
amount: number;
|
|
51
|
+
tokenId: string;
|
|
52
|
+
collectorAccount?: string | undefined;
|
|
53
|
+
}>, "many">>;
|
|
31
54
|
exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
32
55
|
}, "strip", z.ZodTypeAny, {
|
|
33
56
|
name: string;
|
|
57
|
+
capabilities?: number[] | undefined;
|
|
34
58
|
description?: string | undefined;
|
|
35
59
|
type?: "autonomous" | "manual" | undefined;
|
|
36
60
|
model?: string | undefined;
|
|
37
|
-
capabilities?: number[] | undefined;
|
|
38
61
|
feeCollectorAccountId?: string | undefined;
|
|
39
62
|
hbarFee?: number | undefined;
|
|
40
63
|
tokenFee?: {
|
|
41
64
|
amount: number;
|
|
42
65
|
tokenId: string;
|
|
43
66
|
} | undefined;
|
|
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;
|
|
44
76
|
exemptAccountIds?: string[] | undefined;
|
|
45
77
|
}, {
|
|
46
78
|
name: string;
|
|
79
|
+
capabilities?: number[] | undefined;
|
|
47
80
|
description?: string | undefined;
|
|
48
81
|
type?: "autonomous" | "manual" | undefined;
|
|
49
82
|
model?: string | undefined;
|
|
50
|
-
capabilities?: number[] | undefined;
|
|
51
83
|
feeCollectorAccountId?: string | undefined;
|
|
52
84
|
hbarFee?: number | undefined;
|
|
53
85
|
tokenFee?: {
|
|
54
86
|
amount: number;
|
|
55
87
|
tokenId: string;
|
|
56
88
|
} | undefined;
|
|
89
|
+
hbarFees?: {
|
|
90
|
+
amount: number;
|
|
91
|
+
collectorAccount?: string | undefined;
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
tokenFees?: {
|
|
94
|
+
amount: number;
|
|
95
|
+
tokenId: string;
|
|
96
|
+
collectorAccount?: string | undefined;
|
|
97
|
+
}[] | undefined;
|
|
57
98
|
exemptAccountIds?: string[] | undefined;
|
|
58
99
|
}>;
|
|
59
100
|
/**
|
|
60
|
-
*
|
|
101
|
+
* Creates a new RegisterAgentTool instance
|
|
102
|
+
* @param client - Instance of HCS10Client (already configured with operator/network)
|
|
61
103
|
*/
|
|
62
104
|
constructor(client: HCS10Client);
|
|
63
105
|
/**
|
|
@@ -65,4 +107,28 @@ export declare class RegisterAgentTool extends StructuredTool {
|
|
|
65
107
|
* Returns a JSON string with agent details on success, or an error string.
|
|
66
108
|
*/
|
|
67
109
|
_call(input: z.infer<typeof this.schema>): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Checks if the token fee configuration is valid
|
|
112
|
+
*/
|
|
113
|
+
private hasValidTokenFee;
|
|
114
|
+
/**
|
|
115
|
+
* Processes the registration result and returns formatted output
|
|
116
|
+
*/
|
|
117
|
+
private processRegistrationResult;
|
|
118
|
+
/**
|
|
119
|
+
* Updates the environment file with the new agent details
|
|
120
|
+
*/
|
|
121
|
+
private updateEnvironmentFile;
|
|
122
|
+
/**
|
|
123
|
+
* Ensures the agent has enough HBAR for operations
|
|
124
|
+
*/
|
|
125
|
+
private ensureAgentHasFunds;
|
|
126
|
+
/**
|
|
127
|
+
* Validates that all required fields are present in the registration result
|
|
128
|
+
*/
|
|
129
|
+
private validateRegistrationResult;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a description of the fees configured for the agent
|
|
132
|
+
*/
|
|
133
|
+
private createFeeDescription;
|
|
68
134
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
|
+
import { HCSMessage, HCS11Profile } from '@hashgraphonline/standards-sdk';
|
|
3
|
+
export interface ConnectionMap {
|
|
4
|
+
inboundRequests: Map<number, HCSMessage>;
|
|
5
|
+
outboundConfirmations: Map<number, HCSMessage>;
|
|
6
|
+
outboundRequests: Map<number, HCSMessage>;
|
|
7
|
+
inboundConfirmations: Map<number, HCSMessage>;
|
|
8
|
+
profileMap: Map<string, HCS11Profile>;
|
|
9
|
+
confirmedRequestIds: Set<number>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetches and processes inbound/outbound messages and profiles
|
|
13
|
+
* to provide a map of connection states.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchConnectionMap(hcsClient: HCS10Client): Promise<ConnectionMap>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-agent-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.es.js",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@hashgraph/sdk": "^2.62.0",
|
|
71
|
-
"@hashgraphonline/standards-sdk": "0.0.
|
|
71
|
+
"@hashgraphonline/standards-sdk": "0.0.72",
|
|
72
72
|
"@langchain/community": "^0.3.37",
|
|
73
73
|
"@langchain/openai": "^0.5.1",
|
|
74
74
|
"dotenv": "^16.4.1",
|