@hashgraphonline/standards-agent-kit 0.0.3 → 0.0.5
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/README.md +56 -48
- package/dist/index.es.js +20420 -70990
- package/dist/index.es.js.map +1 -1
- package/dist/src/hcs10/HCS10Client.d.ts +19 -8
- package/dist/src/index.d.ts +2 -2
- package/dist/src/{demo-state.d.ts → open-convai-state.d.ts} +4 -3
- package/dist/src/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/src/tools/ConnectionTool.d.ts +14 -16
- package/dist/src/tools/InitiateConnectionTool.d.ts +8 -7
- package/dist/src/tools/ListConnectionsTool.d.ts +5 -5
- package/dist/src/tools/RegisterAgentTool.d.ts +3 -3
- package/dist/src/tools/SendMessageToConnectionTool.d.ts +5 -4
- package/dist/src/tools/SendMessageTool.d.ts +1 -0
- package/package.json +6 -4
- package/dist/examples/cli-demo.d.ts +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';
|
|
2
|
-
import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse, HCSMessage } from '@hashgraphonline/standards-sdk';
|
|
2
|
+
import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse, HCSMessage, LogLevel } from '@hashgraphonline/standards-sdk';
|
|
3
3
|
import { AgentMetadata, AgentChannels } from './types';
|
|
4
|
+
export interface HCSMessageWithTimestamp extends HCSMessage {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
data: string;
|
|
7
|
+
sequence_number: number;
|
|
8
|
+
}
|
|
4
9
|
export interface ExtendedAgentMetadata extends AgentMetadata {
|
|
5
10
|
pfpBuffer?: Buffer;
|
|
6
11
|
pfpFileName?: string;
|
|
@@ -16,12 +21,14 @@ export type StandardNetworkType = 'mainnet' | 'testnet';
|
|
|
16
21
|
* - Sends messages on Hedera topics (currently manual, potential for standard SDK integration).
|
|
17
22
|
*/
|
|
18
23
|
export declare class HCS10Client {
|
|
19
|
-
|
|
24
|
+
standardClient: StandardSDKClient;
|
|
20
25
|
private useEncryption;
|
|
21
26
|
agentChannels?: AgentChannels;
|
|
27
|
+
guardedRegistryBaseUrl: string;
|
|
22
28
|
constructor(operatorId: string, operatorPrivateKey: string, network: StandardNetworkType, options?: {
|
|
23
29
|
useEncryption?: boolean;
|
|
24
30
|
registryUrl?: string;
|
|
31
|
+
logLevel?: LogLevel;
|
|
25
32
|
});
|
|
26
33
|
getOperatorId(): string;
|
|
27
34
|
getNetwork(): StandardNetworkType;
|
|
@@ -57,7 +64,7 @@ export declare class HCS10Client {
|
|
|
57
64
|
* @param submitKey - Optional private key for topics requiring specific submit keys.
|
|
58
65
|
* @returns A confirmation status string from the transaction receipt.
|
|
59
66
|
*/
|
|
60
|
-
sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<
|
|
67
|
+
sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<number | undefined>;
|
|
61
68
|
/**
|
|
62
69
|
* Retrieves messages from a topic using the standard SDK client.
|
|
63
70
|
*
|
|
@@ -65,11 +72,7 @@ export declare class HCS10Client {
|
|
|
65
72
|
* @returns Messages from the topic, mapped to the expected format.
|
|
66
73
|
*/
|
|
67
74
|
getMessages(topicId: string): Promise<{
|
|
68
|
-
messages:
|
|
69
|
-
timestamp: number;
|
|
70
|
-
data: string;
|
|
71
|
-
sequence_number: number;
|
|
72
|
-
}>;
|
|
75
|
+
messages: HCSMessageWithTimestamp[];
|
|
73
76
|
}>;
|
|
74
77
|
getMessageStream(topicId: string): Promise<{
|
|
75
78
|
messages: HCSMessage[];
|
|
@@ -80,5 +83,13 @@ export declare class HCS10Client {
|
|
|
80
83
|
* @returns The resolved message content.
|
|
81
84
|
*/
|
|
82
85
|
getMessageContent(inscriptionIdOrData: string): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the inbound topic ID associated with the current operator.
|
|
88
|
+
* This typically involves fetching the operator's own HCS-10 profile.
|
|
89
|
+
* @returns A promise that resolves to the operator's inbound topic ID.
|
|
90
|
+
* @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.
|
|
91
|
+
*/
|
|
92
|
+
getInboundTopicId(): Promise<string>;
|
|
93
|
+
setClient(accountId: string, privateKey: string): StandardSDKClient;
|
|
83
94
|
}
|
|
84
95
|
export {};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { HCS10Client } from './hcs10/HCS10Client';
|
|
|
2
2
|
import { RegisterAgentTool } from './tools/RegisterAgentTool';
|
|
3
3
|
import { SendMessageTool } from './tools/SendMessageTool';
|
|
4
4
|
import { ConnectionTool } from './tools/ConnectionTool';
|
|
5
|
-
import {
|
|
5
|
+
import { OpenConvaiState as StateManagerInterface } from './open-convai-state';
|
|
6
6
|
export interface HCS10InitializationOptions {
|
|
7
7
|
useEncryption?: boolean;
|
|
8
8
|
registryUrl?: string;
|
|
9
|
-
demoState?:
|
|
9
|
+
demoState?: StateManagerInterface;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Initializes the HCS10 client and returns pre-registered LangChain tools.
|
|
@@ -12,10 +12,11 @@ export interface ActiveConnection {
|
|
|
12
12
|
connectionTopicId: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Holds
|
|
16
|
-
* Tools
|
|
15
|
+
* Holds shared state, primarily for demonstration purposes.
|
|
16
|
+
* Tools can use an instance of this (or a similar custom class)
|
|
17
|
+
* via their `stateManager` constructor parameter to track connections.
|
|
17
18
|
*/
|
|
18
|
-
export declare class
|
|
19
|
+
export declare class OpenConvaiState {
|
|
19
20
|
currentAgent: RegisteredAgent | null;
|
|
20
21
|
activeConnections: ActiveConnection[];
|
|
21
22
|
connectionMessageTimestamps: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
|
|
5
5
|
export interface CheckMessagesToolParams extends ToolParams {
|
|
6
6
|
hcsClient: HCS10Client;
|
|
7
|
-
|
|
7
|
+
stateManager: StateManagerInterface;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* A tool to check for new messages on an active HCS-10 connection topic.
|
|
@@ -19,9 +19,9 @@ export declare class CheckMessagesTool extends StructuredTool {
|
|
|
19
19
|
}, {
|
|
20
20
|
targetIdentifier: string;
|
|
21
21
|
}>;
|
|
22
|
-
|
|
23
|
-
private
|
|
22
|
+
hcsClient: HCS10Client;
|
|
23
|
+
private stateManager;
|
|
24
24
|
private logger;
|
|
25
|
-
constructor({ hcsClient,
|
|
26
|
-
protected _call({ targetIdentifier }: z.infer<this['schema']>): Promise<string>;
|
|
25
|
+
constructor({ hcsClient, stateManager, ...rest }: CheckMessagesToolParams);
|
|
26
|
+
protected _call({ targetIdentifier, }: z.infer<this['schema']>): Promise<string>;
|
|
27
27
|
}
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
2
|
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
4
|
+
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
5
|
+
import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
|
|
5
6
|
export interface ConnectionToolParams extends ToolParams {
|
|
6
7
|
client: HCS10Client;
|
|
7
|
-
|
|
8
|
+
stateManager: StateManagerInterface;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
|
-
* ConnectionTool monitors
|
|
11
|
+
* ConnectionTool monitors the *current* agent's inbound topic for connection requests
|
|
11
12
|
* and automatically handles them using the HCS-10 standard SDK flow.
|
|
13
|
+
* Use this ONLY to passively LISTEN for other agents trying to connect TO YOU.
|
|
14
|
+
* This tool takes NO arguments and does NOT start outgoing connections.
|
|
12
15
|
*/
|
|
13
16
|
export declare class ConnectionTool extends StructuredTool {
|
|
14
17
|
name: string;
|
|
15
18
|
description: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
+
client: HCS10Client;
|
|
20
|
+
logger: Logger;
|
|
21
|
+
private stateManager;
|
|
19
22
|
private isMonitoring;
|
|
20
23
|
private monitoringTopic;
|
|
21
|
-
schema: z.ZodObject<{
|
|
22
|
-
inboundTopicId: z.ZodString;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
inboundTopicId: string;
|
|
25
|
-
}, {
|
|
26
|
-
inboundTopicId: string;
|
|
27
|
-
}>;
|
|
24
|
+
schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
28
25
|
/**
|
|
29
26
|
* @param client - Instance of HCS10Client.
|
|
30
|
-
* @param
|
|
27
|
+
* @param stateManager - Instance of StateManager for shared state management.
|
|
31
28
|
*/
|
|
32
|
-
constructor({ client,
|
|
29
|
+
constructor({ client, stateManager, ...rest }: ConnectionToolParams);
|
|
33
30
|
/**
|
|
34
31
|
* Initiates the connection request monitoring process in the background.
|
|
32
|
+
* Gets the inbound topic ID from the configured client.
|
|
35
33
|
*/
|
|
36
|
-
_call(
|
|
34
|
+
_call(_input: z.infer<typeof this.schema>): Promise<string>;
|
|
37
35
|
/**
|
|
38
36
|
* The core monitoring loop.
|
|
39
37
|
*/
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
|
|
5
5
|
export interface InitiateConnectionToolParams extends ToolParams {
|
|
6
6
|
hcsClient: HCS10Client;
|
|
7
|
-
|
|
7
|
+
stateManager: StateManagerInterface;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* A tool to
|
|
11
|
-
*
|
|
12
|
-
* waits for confirmation, and
|
|
10
|
+
* A tool to actively START a NEW HCS-10 connection TO a target agent.
|
|
11
|
+
* Requires the target agent's account ID.
|
|
12
|
+
* It retrieves their profile, sends a connection request, waits for confirmation, and stores the connection using the provided stateManager.
|
|
13
|
+
* Use this tool ONLY to actively INITIATE an OUTGOING connection.
|
|
13
14
|
*/
|
|
14
15
|
export declare class InitiateConnectionTool extends StructuredTool {
|
|
15
16
|
name: string;
|
|
@@ -22,8 +23,8 @@ export declare class InitiateConnectionTool extends StructuredTool {
|
|
|
22
23
|
targetAccountId: string;
|
|
23
24
|
}>;
|
|
24
25
|
private hcsClient;
|
|
25
|
-
private
|
|
26
|
+
private stateManager;
|
|
26
27
|
private logger;
|
|
27
|
-
constructor({ hcsClient,
|
|
28
|
+
constructor({ hcsClient, stateManager, ...rest }: InitiateConnectionToolParams);
|
|
28
29
|
protected _call({ targetAccountId, }: z.infer<this['schema']>): Promise<string>;
|
|
29
30
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
|
|
4
4
|
export interface ListConnectionsToolParams extends ToolParams {
|
|
5
|
-
|
|
5
|
+
stateManager: StateManagerInterface;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* A tool to list currently active HCS-10 connections stored in the
|
|
8
|
+
* A tool to list currently active HCS-10 connections stored in the state manager.
|
|
9
9
|
*/
|
|
10
10
|
export declare class ListConnectionsTool extends StructuredTool {
|
|
11
11
|
name: string;
|
|
12
12
|
description: string;
|
|
13
13
|
schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
14
|
-
private
|
|
15
|
-
constructor({
|
|
14
|
+
private stateManager;
|
|
15
|
+
constructor({ stateManager, ...rest }: ListConnectionsToolParams);
|
|
16
16
|
protected _call(_: z.infer<this['schema']>): Promise<string>;
|
|
17
17
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
2
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { RegisteredAgent } from '../demo-state';
|
|
5
4
|
/**
|
|
6
5
|
* RegisterAgentTool wraps the createAndRegisterAgent() function of HCS10Client.
|
|
7
6
|
* It creates and registers an agent on Hedera using the HCS-10 standard SDK flow.
|
|
7
|
+
* On success, returns a JSON string containing the new agent's details (including private key).
|
|
8
8
|
*/
|
|
9
9
|
export declare class RegisterAgentTool extends StructuredTool {
|
|
10
10
|
name: string;
|
|
@@ -32,7 +32,7 @@ export declare class RegisterAgentTool extends StructuredTool {
|
|
|
32
32
|
constructor(client: HCS10Client);
|
|
33
33
|
/**
|
|
34
34
|
* Calls createAndRegisterAgent() with the provided metadata.
|
|
35
|
-
* Returns
|
|
35
|
+
* Returns a JSON string with agent details on success, or an error string.
|
|
36
36
|
*/
|
|
37
|
-
_call(input: z.infer<typeof this.schema>): Promise<
|
|
37
|
+
_call(input: z.infer<typeof this.schema>): Promise<string>;
|
|
38
38
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
|
|
5
5
|
export interface SendMessageToConnectionToolParams extends ToolParams {
|
|
6
6
|
hcsClient: HCS10Client;
|
|
7
|
-
|
|
7
|
+
stateManager: StateManagerInterface;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* A tool to send a message to an agent over an established HCS-10 connection.
|
|
@@ -23,8 +23,9 @@ export declare class SendMessageToConnectionTool extends StructuredTool {
|
|
|
23
23
|
targetIdentifier: string;
|
|
24
24
|
}>;
|
|
25
25
|
private hcsClient;
|
|
26
|
-
private
|
|
26
|
+
private stateManager;
|
|
27
27
|
private logger;
|
|
28
|
-
constructor({ hcsClient,
|
|
28
|
+
constructor({ hcsClient, stateManager, ...rest }: SendMessageToConnectionToolParams);
|
|
29
29
|
protected _call({ targetIdentifier, message, }: z.infer<this['schema']>): Promise<string>;
|
|
30
|
+
private monitorResponses;
|
|
30
31
|
}
|
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.5",
|
|
4
4
|
"description": "An Agents implementation of Hashgraph Online's Standards SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.es.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"author": "Hashgraph Online",
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hashgraph/sdk": "^2.
|
|
34
|
-
"@hashgraphonline/standards-sdk": "0.0.
|
|
33
|
+
"@hashgraph/sdk": "^2.62.0",
|
|
34
|
+
"@hashgraphonline/standards-sdk": "0.0.62",
|
|
35
35
|
"@langchain/community": "^0.3.37",
|
|
36
36
|
"@langchain/openai": "^0.5.1",
|
|
37
37
|
"dotenv": "^16.4.1",
|
|
@@ -49,10 +49,12 @@
|
|
|
49
49
|
"jest": "^29.7.0",
|
|
50
50
|
"@swc/core": "^1.11.16",
|
|
51
51
|
"@swc/jest": "^0.2.36",
|
|
52
|
-
"ts-node": "^10.9.2",
|
|
53
52
|
"tsconfig-paths": "^4.2.0",
|
|
54
53
|
"tsx": "^4.19.3",
|
|
55
54
|
"vite": "^6.2.3",
|
|
56
55
|
"vite-plugin-dts": "^4.5.3"
|
|
56
|
+
},
|
|
57
|
+
"resolutions": {
|
|
58
|
+
"@hashgraph/sdk": "^2.62.0"
|
|
57
59
|
}
|
|
58
60
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|