@hashgraphonline/standards-agent-kit 0.0.1 → 0.0.3
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/LICENSE +189 -0
- package/dist/index.es.js +11903 -10540
- package/dist/index.es.js.map +1 -1
- package/dist/src/demo-state.d.ts +31 -0
- package/dist/src/hcs10/HCS10Client.d.ts +13 -10
- package/dist/src/index.d.ts +16 -13
- package/dist/src/tools/CheckMessagesTool.d.ts +27 -0
- package/dist/src/tools/ConnectionTool.d.ts +11 -4
- package/dist/src/tools/InitiateConnectionTool.d.ts +29 -0
- package/dist/src/tools/ListConnectionsTool.d.ts +17 -0
- package/dist/src/tools/RegisterAgentTool.d.ts +4 -2
- package/dist/src/tools/SendMessageToConnectionTool.d.ts +30 -0
- package/dist/src/tools/SendMessageTool.d.ts +1 -1
- package/dist/src/utils/HederaClient.d.ts +1 -1
- package/package.json +10 -7
- package/dist/tests/hcs10/HCS10Client.test.d.ts +0 -1
- package/dist/tests/tools/Tools.test.d.ts +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface RegisteredAgent {
|
|
2
|
+
name: string;
|
|
3
|
+
accountId: string;
|
|
4
|
+
inboundTopicId: string;
|
|
5
|
+
outboundTopicId: string;
|
|
6
|
+
profileTopicId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ActiveConnection {
|
|
9
|
+
targetAccountId: string;
|
|
10
|
+
targetAgentName: string;
|
|
11
|
+
targetInboundTopicId: string;
|
|
12
|
+
connectionTopicId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Holds the shared state for the interactive demo.
|
|
16
|
+
* Tools will need access to this instance to read/update state.
|
|
17
|
+
*/
|
|
18
|
+
export declare class DemoState {
|
|
19
|
+
currentAgent: RegisteredAgent | null;
|
|
20
|
+
activeConnections: ActiveConnection[];
|
|
21
|
+
connectionMessageTimestamps: {
|
|
22
|
+
[connectionTopicId: string]: number;
|
|
23
|
+
};
|
|
24
|
+
setCurrentAgent(agent: RegisteredAgent | null): void;
|
|
25
|
+
getCurrentAgent(): RegisteredAgent | null;
|
|
26
|
+
addActiveConnection(connection: ActiveConnection): void;
|
|
27
|
+
listConnections(): ActiveConnection[];
|
|
28
|
+
getConnectionByIdentifier(identifier: string): ActiveConnection | undefined;
|
|
29
|
+
getLastTimestamp(connectionTopicId: string): number;
|
|
30
|
+
updateTimestamp(connectionTopicId: string, timestampNanos: number): void;
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';
|
|
2
|
-
import { HCS10Client as StandardSDKClient } from '@hashgraphonline/standards-sdk';
|
|
3
|
-
import { AgentMetadata, AgentChannels } from './types
|
|
2
|
+
import { HCS10Client as StandardSDKClient, AgentRegistrationResult, WaitForConnectionConfirmationResponse, ProfileResponse, HCSMessage } from '@hashgraphonline/standards-sdk';
|
|
3
|
+
import { AgentMetadata, AgentChannels } from './types';
|
|
4
4
|
export interface ExtendedAgentMetadata extends AgentMetadata {
|
|
5
5
|
pfpBuffer?: Buffer;
|
|
6
6
|
pfpFileName?: string;
|
|
@@ -8,7 +8,7 @@ export interface ExtendedAgentMetadata extends AgentMetadata {
|
|
|
8
8
|
type StandardHandleConnectionRequest = InstanceType<typeof StandardSDKClient>['handleConnectionRequest'];
|
|
9
9
|
type FeeConfigBuilderInterface = Parameters<StandardHandleConnectionRequest>[3];
|
|
10
10
|
type HandleConnectionRequestResponse = Awaited<ReturnType<StandardHandleConnectionRequest>>;
|
|
11
|
-
type StandardNetworkType = 'mainnet' | 'testnet';
|
|
11
|
+
export type StandardNetworkType = 'mainnet' | 'testnet';
|
|
12
12
|
/**
|
|
13
13
|
* HCS10Client wraps the HCS-10 functionalities using the @hashgraphonline/standards-sdk.
|
|
14
14
|
* - Creates and registers agents using the standard SDK flow.
|
|
@@ -29,23 +29,23 @@ export declare class HCS10Client {
|
|
|
29
29
|
/**
|
|
30
30
|
* Exposes the standard SDK's retrieveProfile method.
|
|
31
31
|
*/
|
|
32
|
-
retrieveProfile(accountId: string): Promise<
|
|
32
|
+
retrieveProfile(accountId: string): Promise<ProfileResponse>;
|
|
33
33
|
/**
|
|
34
34
|
* Exposes the standard SDK's submitConnectionRequest method.
|
|
35
35
|
*/
|
|
36
|
-
submitConnectionRequest(inboundTopicId: string,
|
|
36
|
+
submitConnectionRequest(inboundTopicId: string, memo: string): Promise<TransactionReceipt>;
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
* Exposes the standard SDK's waitForConnectionConfirmation method.
|
|
39
|
+
*/
|
|
40
40
|
waitForConnectionConfirmation(outboundTopicId: string, // Changed from inboundTopicId based on demo usage
|
|
41
|
-
connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<
|
|
41
|
+
connectionRequestId: number, maxAttempts?: number, delayMs?: number): Promise<WaitForConnectionConfirmationResponse>;
|
|
42
42
|
/**
|
|
43
43
|
* Creates and registers an agent using the standard SDK's HCS10Client.
|
|
44
44
|
* This handles account creation, key generation, topic setup, and registration.
|
|
45
45
|
* @param metadata - The agent's metadata, potentially including pfpBuffer and pfpFileName.
|
|
46
46
|
* @returns The registration result from the standard SDK, containing accountId, keys, topics etc.
|
|
47
47
|
*/
|
|
48
|
-
createAndRegisterAgent(metadata: ExtendedAgentMetadata): Promise<
|
|
48
|
+
createAndRegisterAgent(metadata: ExtendedAgentMetadata): Promise<AgentRegistrationResult>;
|
|
49
49
|
/**
|
|
50
50
|
* Sends a structured HCS-10 message to the specified topic using the standard SDK client.
|
|
51
51
|
* Handles potential inscription for large messages.
|
|
@@ -57,7 +57,7 @@ export declare class HCS10Client {
|
|
|
57
57
|
* @param submitKey - Optional private key for topics requiring specific submit keys.
|
|
58
58
|
* @returns A confirmation status string from the transaction receipt.
|
|
59
59
|
*/
|
|
60
|
-
sendMessage(topicId: string,
|
|
60
|
+
sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<string>;
|
|
61
61
|
/**
|
|
62
62
|
* Retrieves messages from a topic using the standard SDK client.
|
|
63
63
|
*
|
|
@@ -71,6 +71,9 @@ export declare class HCS10Client {
|
|
|
71
71
|
sequence_number: number;
|
|
72
72
|
}>;
|
|
73
73
|
}>;
|
|
74
|
+
getMessageStream(topicId: string): Promise<{
|
|
75
|
+
messages: HCSMessage[];
|
|
76
|
+
}>;
|
|
74
77
|
/**
|
|
75
78
|
* Retrieves content from an inscribed message using the standard SDK client.
|
|
76
79
|
* @param inscriptionIdOrData - The inscription ID (hcs://...) or potentially raw data string.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { HCS10Client } from './hcs10/HCS10Client
|
|
2
|
-
import { RegisterAgentTool } from './tools/RegisterAgentTool
|
|
3
|
-
import { SendMessageTool } from './tools/SendMessageTool
|
|
4
|
-
import { ConnectionTool } from './tools/ConnectionTool
|
|
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 { DemoState } from './demo-state';
|
|
6
|
+
export interface HCS10InitializationOptions {
|
|
7
|
+
useEncryption?: boolean;
|
|
8
|
+
registryUrl?: string;
|
|
9
|
+
demoState?: DemoState;
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* Initializes the HCS10 client and returns pre-registered LangChain tools.
|
|
7
13
|
*
|
|
8
|
-
* @param options - Optional settings
|
|
14
|
+
* @param options - Optional settings including useEncryption, registryUrl, and demoState.
|
|
9
15
|
*/
|
|
10
|
-
export declare function initializeHCS10Client(options?: {
|
|
11
|
-
useEncryption?: boolean;
|
|
12
|
-
registryUrl?: string;
|
|
13
|
-
}): Promise<{
|
|
16
|
+
export declare function initializeHCS10Client(options?: HCS10InitializationOptions): Promise<{
|
|
14
17
|
hcs10Client: HCS10Client;
|
|
15
18
|
tools: {
|
|
16
19
|
registerAgentTool: RegisterAgentTool;
|
|
@@ -18,7 +21,7 @@ export declare function initializeHCS10Client(options?: {
|
|
|
18
21
|
connectionTool: ConnectionTool;
|
|
19
22
|
};
|
|
20
23
|
}>;
|
|
21
|
-
export * from './hcs10/HCS10Client
|
|
22
|
-
export * from './tools/RegisterAgentTool
|
|
23
|
-
export * from './tools/SendMessageTool
|
|
24
|
-
export * from './tools/ConnectionTool
|
|
24
|
+
export * from './hcs10/HCS10Client';
|
|
25
|
+
export * from './tools/RegisterAgentTool';
|
|
26
|
+
export * from './tools/SendMessageTool';
|
|
27
|
+
export * from './tools/ConnectionTool';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
+
import { DemoState } from '../demo-state';
|
|
5
|
+
export interface CheckMessagesToolParams extends ToolParams {
|
|
6
|
+
hcsClient: HCS10Client;
|
|
7
|
+
demoState: DemoState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A tool to check for new messages on an active HCS-10 connection topic.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CheckMessagesTool extends StructuredTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
schema: z.ZodObject<{
|
|
16
|
+
targetIdentifier: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
targetIdentifier: string;
|
|
19
|
+
}, {
|
|
20
|
+
targetIdentifier: string;
|
|
21
|
+
}>;
|
|
22
|
+
private hcsClient;
|
|
23
|
+
private demoState;
|
|
24
|
+
private logger;
|
|
25
|
+
constructor({ hcsClient, demoState, ...rest }: CheckMessagesToolParams);
|
|
26
|
+
protected _call({ targetIdentifier }: z.infer<this['schema']>): Promise<string>;
|
|
27
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { HCS10Client } from '../hcs10/HCS10Client
|
|
2
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
1
|
+
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
|
+
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { DemoState } from '../demo-state';
|
|
5
|
+
export interface ConnectionToolParams extends ToolParams {
|
|
6
|
+
client: HCS10Client;
|
|
7
|
+
demoState: DemoState;
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* ConnectionTool monitors an agent's inbound topic for connection requests
|
|
6
11
|
* and automatically handles them using the HCS-10 standard SDK flow.
|
|
@@ -10,6 +15,7 @@ export declare class ConnectionTool extends StructuredTool {
|
|
|
10
15
|
description: string;
|
|
11
16
|
private client;
|
|
12
17
|
private logger;
|
|
18
|
+
private demoState;
|
|
13
19
|
private isMonitoring;
|
|
14
20
|
private monitoringTopic;
|
|
15
21
|
schema: z.ZodObject<{
|
|
@@ -20,9 +26,10 @@ export declare class ConnectionTool extends StructuredTool {
|
|
|
20
26
|
inboundTopicId: string;
|
|
21
27
|
}>;
|
|
22
28
|
/**
|
|
23
|
-
* @param client - Instance of HCS10Client
|
|
29
|
+
* @param client - Instance of HCS10Client.
|
|
30
|
+
* @param demoState - Instance of DemoState for shared state management.
|
|
24
31
|
*/
|
|
25
|
-
constructor(client:
|
|
32
|
+
constructor({ client, demoState, ...rest }: ConnectionToolParams);
|
|
26
33
|
/**
|
|
27
34
|
* Initiates the connection request monitoring process in the background.
|
|
28
35
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
+
import { DemoState } from '../demo-state';
|
|
5
|
+
export interface InitiateConnectionToolParams extends ToolParams {
|
|
6
|
+
hcsClient: HCS10Client;
|
|
7
|
+
demoState: DemoState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A tool to orchestrate the HCS-10 connection initiation process.
|
|
11
|
+
* Takes a target agent's account ID, retrieves their profile, submits a connection request,
|
|
12
|
+
* waits for confirmation, and updates the demo state.
|
|
13
|
+
*/
|
|
14
|
+
export declare class InitiateConnectionTool extends StructuredTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
schema: z.ZodObject<{
|
|
18
|
+
targetAccountId: z.ZodString;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
targetAccountId: string;
|
|
21
|
+
}, {
|
|
22
|
+
targetAccountId: string;
|
|
23
|
+
}>;
|
|
24
|
+
private hcsClient;
|
|
25
|
+
private demoState;
|
|
26
|
+
private logger;
|
|
27
|
+
constructor({ hcsClient, demoState, ...rest }: InitiateConnectionToolParams);
|
|
28
|
+
protected _call({ targetAccountId, }: z.infer<this['schema']>): Promise<string>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { DemoState } from '../demo-state';
|
|
4
|
+
export interface ListConnectionsToolParams extends ToolParams {
|
|
5
|
+
demoState: DemoState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A tool to list currently active HCS-10 connections stored in the DemoState.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ListConnectionsTool extends StructuredTool {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
14
|
+
private demoState;
|
|
15
|
+
constructor({ demoState, ...rest }: ListConnectionsToolParams);
|
|
16
|
+
protected _call(_: z.infer<this['schema']>): Promise<string>;
|
|
17
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { HCS10Client } from '../hcs10/HCS10Client
|
|
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';
|
|
4
5
|
/**
|
|
5
6
|
* RegisterAgentTool wraps the createAndRegisterAgent() function of HCS10Client.
|
|
6
7
|
* It creates and registers an agent on Hedera using the HCS-10 standard SDK flow.
|
|
@@ -31,6 +32,7 @@ export declare class RegisterAgentTool extends StructuredTool {
|
|
|
31
32
|
constructor(client: HCS10Client);
|
|
32
33
|
/**
|
|
33
34
|
* Calls createAndRegisterAgent() with the provided metadata.
|
|
35
|
+
* Returns the details of the registered agent.
|
|
34
36
|
*/
|
|
35
|
-
_call(input: z.infer<typeof this.schema>): Promise<string>;
|
|
37
|
+
_call(input: z.infer<typeof this.schema>): Promise<RegisteredAgent | string>;
|
|
36
38
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
+
import { DemoState } from '../demo-state';
|
|
5
|
+
export interface SendMessageToConnectionToolParams extends ToolParams {
|
|
6
|
+
hcsClient: HCS10Client;
|
|
7
|
+
demoState: DemoState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A tool to send a message to an agent over an established HCS-10 connection.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SendMessageToConnectionTool extends StructuredTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
schema: z.ZodObject<{
|
|
16
|
+
targetIdentifier: z.ZodString;
|
|
17
|
+
message: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
message: string;
|
|
20
|
+
targetIdentifier: string;
|
|
21
|
+
}, {
|
|
22
|
+
message: string;
|
|
23
|
+
targetIdentifier: string;
|
|
24
|
+
}>;
|
|
25
|
+
private hcsClient;
|
|
26
|
+
private demoState;
|
|
27
|
+
private logger;
|
|
28
|
+
constructor({ hcsClient, demoState, ...rest }: SendMessageToConnectionToolParams);
|
|
29
|
+
protected _call({ targetIdentifier, message, }: z.infer<this['schema']>): Promise<string>;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-agent-kit",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "An
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "An Agents implementation of Hashgraph Online's Standards SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -12,11 +12,13 @@
|
|
|
12
12
|
"build": "vite build",
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"lint": "eslint . --ext .ts",
|
|
15
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
15
16
|
"prepare": "npm run build",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
18
|
+
"release": "npm publish --access public",
|
|
16
19
|
"cli-demo": "tsx examples/cli-demo.ts",
|
|
17
20
|
"interactive-demo": "tsx examples/interactive-demo.ts",
|
|
18
|
-
"langchain-demo": "tsx examples/langchain-demo.ts"
|
|
19
|
-
"release": "npm publish --access public"
|
|
21
|
+
"langchain-demo": "tsx examples/langchain-demo.ts"
|
|
20
22
|
},
|
|
21
23
|
"keywords": [
|
|
22
24
|
"hedera",
|
|
@@ -25,11 +27,11 @@
|
|
|
25
27
|
"sdk",
|
|
26
28
|
"ai-agent"
|
|
27
29
|
],
|
|
28
|
-
"author": "
|
|
30
|
+
"author": "Hashgraph Online",
|
|
29
31
|
"license": "Apache-2.0",
|
|
30
32
|
"dependencies": {
|
|
31
33
|
"@hashgraph/sdk": "^2.39.0",
|
|
32
|
-
"@hashgraphonline/standards-sdk": "
|
|
34
|
+
"@hashgraphonline/standards-sdk": "0.0.59",
|
|
33
35
|
"@langchain/community": "^0.3.37",
|
|
34
36
|
"@langchain/openai": "^0.5.1",
|
|
35
37
|
"dotenv": "^16.4.1",
|
|
@@ -45,7 +47,8 @@
|
|
|
45
47
|
"@typescript-eslint/parser": "^6.20.0",
|
|
46
48
|
"eslint": "^8.56.0",
|
|
47
49
|
"jest": "^29.7.0",
|
|
48
|
-
"
|
|
50
|
+
"@swc/core": "^1.11.16",
|
|
51
|
+
"@swc/jest": "^0.2.36",
|
|
49
52
|
"ts-node": "^10.9.2",
|
|
50
53
|
"tsconfig-paths": "^4.2.0",
|
|
51
54
|
"tsx": "^4.19.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|