@hashgraphonline/standards-agent-kit 0.0.4 → 0.0.6

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,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;
@@ -23,6 +28,7 @@ export declare class HCS10Client {
23
28
  constructor(operatorId: string, operatorPrivateKey: string, network: StandardNetworkType, options?: {
24
29
  useEncryption?: boolean;
25
30
  registryUrl?: string;
31
+ logLevel?: LogLevel;
26
32
  });
27
33
  getOperatorId(): string;
28
34
  getNetwork(): StandardNetworkType;
@@ -58,7 +64,7 @@ export declare class HCS10Client {
58
64
  * @param submitKey - Optional private key for topics requiring specific submit keys.
59
65
  * @returns A confirmation status string from the transaction receipt.
60
66
  */
61
- sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<string>;
67
+ sendMessage(topicId: string, data: string, memo?: string, submitKey?: PrivateKey): Promise<number | undefined>;
62
68
  /**
63
69
  * Retrieves messages from a topic using the standard SDK client.
64
70
  *
@@ -66,11 +72,7 @@ export declare class HCS10Client {
66
72
  * @returns Messages from the topic, mapped to the expected format.
67
73
  */
68
74
  getMessages(topicId: string): Promise<{
69
- messages: Array<{
70
- timestamp: number;
71
- data: string;
72
- sequence_number: number;
73
- }>;
75
+ messages: HCSMessageWithTimestamp[];
74
76
  }>;
75
77
  getMessageStream(topicId: string): Promise<{
76
78
  messages: HCSMessage[];
@@ -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 { DemoState } from './demo-state';
5
+ import { OpenConvaiState as StateManagerInterface } from './open-convai-state';
6
6
  export interface HCS10InitializationOptions {
7
7
  useEncryption?: boolean;
8
8
  registryUrl?: string;
9
- demoState?: 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 the shared state for the interactive demo.
16
- * Tools will need access to this instance to read/update state.
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 DemoState {
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 { DemoState } from '../demo-state';
4
+ import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
5
5
  export interface CheckMessagesToolParams extends ToolParams {
6
6
  hcsClient: HCS10Client;
7
- demoState: DemoState;
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
- private hcsClient;
23
- private demoState;
22
+ hcsClient: HCS10Client;
23
+ private stateManager;
24
24
  private logger;
25
- constructor({ hcsClient, demoState, ...rest }: CheckMessagesToolParams);
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,10 +1,11 @@
1
1
  import { HCS10Client } from '../hcs10/HCS10Client';
2
2
  import { StructuredTool, ToolParams } from '@langchain/core/tools';
3
3
  import { z } from 'zod';
4
- import { DemoState } from '../demo-state';
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
- demoState: DemoState;
8
+ stateManager: StateManagerInterface;
8
9
  }
9
10
  /**
10
11
  * ConnectionTool monitors the *current* agent's inbound topic for connection requests
@@ -15,22 +16,22 @@ export interface ConnectionToolParams extends ToolParams {
15
16
  export declare class ConnectionTool extends StructuredTool {
16
17
  name: string;
17
18
  description: string;
18
- private client;
19
- private logger;
20
- private demoState;
19
+ client: HCS10Client;
20
+ logger: Logger;
21
+ private stateManager;
21
22
  private isMonitoring;
22
23
  private monitoringTopic;
23
24
  schema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
24
25
  /**
25
26
  * @param client - Instance of HCS10Client.
26
- * @param demoState - Instance of DemoState for shared state management.
27
+ * @param stateManager - Instance of StateManager for shared state management.
27
28
  */
28
- constructor({ client, demoState, ...rest }: ConnectionToolParams);
29
+ constructor({ client, stateManager, ...rest }: ConnectionToolParams);
29
30
  /**
30
31
  * Initiates the connection request monitoring process in the background.
31
32
  * Gets the inbound topic ID from the configured client.
32
33
  */
33
- _call(input: z.infer<typeof this.schema>): Promise<string>;
34
+ _call(_input: z.infer<typeof this.schema>): Promise<string>;
34
35
  /**
35
36
  * The core monitoring loop.
36
37
  */
@@ -1,15 +1,15 @@
1
1
  import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
2
  import { z } from 'zod';
3
3
  import { HCS10Client } from '../hcs10/HCS10Client';
4
- import { DemoState } from '../demo-state';
4
+ import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
5
5
  export interface InitiateConnectionToolParams extends ToolParams {
6
6
  hcsClient: HCS10Client;
7
- demoState: DemoState;
7
+ stateManager: StateManagerInterface;
8
8
  }
9
9
  /**
10
10
  * A tool to actively START a NEW HCS-10 connection TO a target agent.
11
11
  * Requires the target agent's account ID.
12
- * It retrieves their profile, sends a connection request, waits for confirmation, and stores the connection.
12
+ * It retrieves their profile, sends a connection request, waits for confirmation, and stores the connection using the provided stateManager.
13
13
  * Use this tool ONLY to actively INITIATE an OUTGOING connection.
14
14
  */
15
15
  export declare class InitiateConnectionTool extends StructuredTool {
@@ -23,8 +23,8 @@ export declare class InitiateConnectionTool extends StructuredTool {
23
23
  targetAccountId: string;
24
24
  }>;
25
25
  private hcsClient;
26
- private demoState;
26
+ private stateManager;
27
27
  private logger;
28
- constructor({ hcsClient, demoState, ...rest }: InitiateConnectionToolParams);
28
+ constructor({ hcsClient, stateManager, ...rest }: InitiateConnectionToolParams);
29
29
  protected _call({ targetAccountId, }: z.infer<this['schema']>): Promise<string>;
30
30
  }
@@ -1,17 +1,17 @@
1
1
  import { StructuredTool, ToolParams } from '@langchain/core/tools';
2
2
  import { z } from 'zod';
3
- import { DemoState } from '../demo-state';
3
+ import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
4
4
  export interface ListConnectionsToolParams extends ToolParams {
5
- demoState: DemoState;
5
+ stateManager: StateManagerInterface;
6
6
  }
7
7
  /**
8
- * A tool to list currently active HCS-10 connections stored in the DemoState.
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 demoState;
15
- constructor({ demoState, ...rest }: ListConnectionsToolParams);
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 { StructuredTool, ToolParams } from '@langchain/core/tools';
2
2
  import { z } from 'zod';
3
3
  import { HCS10Client } from '../hcs10/HCS10Client';
4
- import { DemoState } from '../demo-state';
4
+ import { OpenConvaiState as StateManagerInterface } from '../open-convai-state';
5
5
  export interface SendMessageToConnectionToolParams extends ToolParams {
6
6
  hcsClient: HCS10Client;
7
- demoState: DemoState;
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 demoState;
26
+ private stateManager;
27
27
  private logger;
28
- constructor({ hcsClient, demoState, ...rest }: SendMessageToConnectionToolParams);
28
+ constructor({ hcsClient, stateManager, ...rest }: SendMessageToConnectionToolParams);
29
29
  protected _call({ targetIdentifier, message, }: z.infer<this['schema']>): Promise<string>;
30
+ private monitorResponses;
30
31
  }
@@ -10,6 +10,7 @@ export declare class SendMessageTool extends StructuredTool {
10
10
  description: string;
11
11
  private client;
12
12
  private lastProcessedTimestamp;
13
+ private logger;
13
14
  schema: z.ZodObject<{
14
15
  topicId: z.ZodString;
15
16
  message: z.ZodString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "An Agents implementation of Hashgraph Online's Standards SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.es.js",
@@ -18,7 +18,7 @@
18
18
  "release": "npm publish --access public",
19
19
  "cli-demo": "tsx examples/cli-demo.ts",
20
20
  "interactive-demo": "tsx examples/interactive-demo.ts",
21
- "langchain-demo": "tsx examples/langchain-demo.js"
21
+ "langchain-demo": "tsx examples/langchain-demo.ts"
22
22
  },
23
23
  "keywords": [
24
24
  "hedera",
@@ -30,8 +30,8 @@
30
30
  "author": "Hashgraph Online",
31
31
  "license": "Apache-2.0",
32
32
  "dependencies": {
33
- "@hashgraph/sdk": "^2.39.0",
34
- "@hashgraphonline/standards-sdk": "0.0.61",
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 {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { HCS10Client, AgentBuilder, Logger } from '@hashgraphonline/standards-sdk';
2
- export declare const MIN_REQUIRED_USD = 2;
3
- export declare const MIN_REQUIRED_HBAR_USD = 10;
4
- export declare const ENV_FILE_PATH: string;
5
- export interface AgentData {
6
- accountId: string;
7
- operatorId: string;
8
- inboundTopicId: string;
9
- outboundTopicId: string;
10
- client: HCS10Client;
11
- }
12
- export interface RegistrationProgressData {
13
- registered: boolean;
14
- accountId?: string;
15
- privateKey?: string;
16
- publicKey?: string;
17
- inboundTopicId?: string;
18
- outboundTopicId?: string;
19
- }
20
- export declare function ensureAgentHasEnoughHbar(logger: Logger, baseClient: HCS10Client, accountId: string, agentName: string): Promise<void>;
21
- export declare function getAgentFromEnv(logger: Logger, baseClient: HCS10Client, agentName: string, envPrefix: string): Promise<AgentData | null>;
22
- export declare function createAgent(logger: Logger, baseClient: HCS10Client, agentName: string, agentBuilder: AgentBuilder, envPrefix: string): Promise<AgentData | null>;
23
- export declare function updateEnvFile(envFilePath: string, variables: Record<string, string>): Promise<void>;
24
- export declare function createBobBuilder(pfpBuffer?: Buffer): any;
25
- export declare function getOrCreateBob(logger: Logger, baseClient: HCS10Client): Promise<AgentData | null>;
26
- export declare function getOrCreateAlice(logger: Logger, baseClient: HCS10Client): Promise<AgentData | null>;