@hashgraphonline/standards-agent-kit 0.0.37 → 0.2.0
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/cjs/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/cjs/builders/index.d.ts +2 -0
- package/dist/cjs/builders/types.d.ts +10 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/init/init.d.ts +21 -22
- package/dist/cjs/plugins/PluginInterface.d.ts +4 -80
- package/dist/cjs/plugins/PluginRegistry.d.ts +1 -47
- package/dist/cjs/plugins/defi/index.d.ts +7 -4
- package/dist/cjs/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/cjs/plugins/index.d.ts +0 -5
- package/dist/cjs/plugins/weather/index.d.ts +6 -5
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/state/state-types.d.ts +8 -8
- package/dist/cjs/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/cjs/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/cjs/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/cjs/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/cjs/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs10/index.d.ts +13 -0
- package/dist/cjs/tools/index.d.ts +1 -13
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/es/builders/index.d.ts +2 -0
- package/dist/es/builders/types.d.ts +10 -0
- package/dist/es/index.d.ts +3 -1
- package/dist/es/init/init.d.ts +21 -22
- package/dist/es/plugins/PluginInterface.d.ts +4 -80
- package/dist/es/plugins/PluginRegistry.d.ts +1 -47
- package/dist/es/plugins/defi/index.d.ts +7 -4
- package/dist/es/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/es/plugins/index.d.ts +0 -5
- package/dist/es/plugins/weather/index.d.ts +6 -5
- package/dist/es/standards-agent-kit.es.js +10 -18
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +29 -76
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +61 -384
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +22 -190
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -138
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +35 -59
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +11 -117
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +1 -1
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +63 -46
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +25 -74
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +22 -13
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +1381 -188
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +3 -67
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +285 -347
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +22 -74
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +127 -154
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +21 -88
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +28 -86
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +27 -100
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +35 -117
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/state/state-types.d.ts +8 -8
- package/dist/es/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/es/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/es/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/es/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/es/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/es/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/es/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/es/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/es/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs10/index.d.ts +13 -0
- package/dist/es/tools/index.d.ts +1 -13
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/umd/builders/index.d.ts +2 -0
- package/dist/umd/builders/types.d.ts +10 -0
- package/dist/umd/index.d.ts +3 -1
- package/dist/umd/init/init.d.ts +21 -22
- package/dist/umd/plugins/PluginInterface.d.ts +4 -80
- package/dist/umd/plugins/PluginRegistry.d.ts +1 -47
- package/dist/umd/plugins/defi/index.d.ts +7 -4
- package/dist/umd/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/umd/plugins/index.d.ts +0 -5
- package/dist/umd/plugins/weather/index.d.ts +6 -5
- package/dist/umd/standards-agent-kit.umd.js +1 -164
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/state/state-types.d.ts +8 -8
- package/dist/umd/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/umd/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/umd/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/umd/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/umd/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/umd/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/umd/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs10/index.d.ts +13 -0
- package/dist/umd/tools/index.d.ts +1 -13
- package/package.json +41 -41
- package/src/builders/hcs10/hcs10-builder.ts +2108 -0
- package/src/builders/index.ts +2 -0
- package/src/builders/types.ts +11 -0
- package/src/hcs10/HCS10Client.ts +3 -2
- package/src/index.ts +4 -2
- package/src/init/init.ts +85 -63
- package/src/plugins/PluginInterface.ts +15 -94
- package/src/plugins/PluginRegistry.ts +2 -98
- package/src/plugins/defi/index.ts +31 -118
- package/src/plugins/hedera/HbarPricePlugin.ts +19 -100
- package/src/plugins/index.ts +0 -5
- package/src/plugins/weather/index.ts +56 -40
- package/src/state/state-types.ts +9 -11
- package/src/tools/hcs10/AcceptConnectionRequestTool.ts +56 -0
- package/src/tools/hcs10/CheckMessagesTool.ts +73 -0
- package/src/tools/hcs10/ConnectionMonitorTool.ts +111 -0
- package/src/tools/hcs10/FindRegistrationsTool.ts +64 -0
- package/src/tools/hcs10/InitiateConnectionTool.ts +66 -0
- package/src/tools/hcs10/ListConnectionsTool.ts +58 -0
- package/src/tools/hcs10/ListUnapprovedConnectionRequestsTool.ts +26 -0
- package/src/tools/hcs10/ManageConnectionRequestsTool.ts +48 -0
- package/src/tools/hcs10/RegisterAgentTool.ts +213 -0
- package/src/tools/hcs10/RetrieveProfileTool.ts +61 -0
- package/src/tools/hcs10/SendMessageToConnectionTool.ts +45 -0
- package/src/tools/hcs10/base-hcs10-tools.ts +65 -0
- package/src/tools/hcs10/hcs10-tool-params.ts +21 -0
- package/src/tools/hcs10/index.ts +13 -0
- package/src/tools/index.ts +2 -13
- package/src/utils/HederaClient.ts +2 -2
- package/src/utils/ensure-agent-has-hbar.ts +3 -4
- package/dist/cjs/agents/index.d.ts +0 -0
- package/dist/cjs/plugins/BasePlugin.d.ts +0 -28
- package/dist/cjs/plugins/GenericPlugin.d.ts +0 -17
- package/dist/cjs/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/cjs/plugins/PluginLoader.d.ts +0 -38
- package/dist/cjs/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/cjs/plugins/openconvai/index.d.ts +0 -1
- package/dist/cjs/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/cjs/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/cjs/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/cjs/tools/ConnectionTool.d.ts +0 -40
- package/dist/cjs/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/cjs/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/cjs/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/cjs/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/cjs/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/cjs/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/cjs/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/cjs/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/cjs/tools/SendMessageTool.d.ts +0 -40
- package/dist/es/agents/index.d.ts +0 -0
- package/dist/es/plugins/BasePlugin.d.ts +0 -28
- package/dist/es/plugins/GenericPlugin.d.ts +0 -17
- package/dist/es/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/es/plugins/PluginLoader.d.ts +0 -38
- package/dist/es/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/es/plugins/openconvai/index.d.ts +0 -1
- package/dist/es/standards-agent-kit.es21.js +0 -92
- package/dist/es/standards-agent-kit.es21.js.map +0 -1
- package/dist/es/standards-agent-kit.es22.js +0 -7
- package/dist/es/standards-agent-kit.es22.js.map +0 -1
- package/dist/es/standards-agent-kit.es23.js +0 -106
- package/dist/es/standards-agent-kit.es23.js.map +0 -1
- package/dist/es/standards-agent-kit.es24.js +0 -7
- package/dist/es/standards-agent-kit.es24.js.map +0 -1
- package/dist/es/standards-agent-kit.es25.js +0 -7
- package/dist/es/standards-agent-kit.es25.js.map +0 -1
- package/dist/es/standards-agent-kit.es26.js +0 -85
- package/dist/es/standards-agent-kit.es26.js.map +0 -1
- package/dist/es/standards-agent-kit.es27.js +0 -28
- package/dist/es/standards-agent-kit.es27.js.map +0 -1
- package/dist/es/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/es/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/es/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/es/tools/ConnectionTool.d.ts +0 -40
- package/dist/es/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/es/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/es/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/es/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/es/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/es/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/es/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/es/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/es/tools/SendMessageTool.d.ts +0 -40
- package/dist/umd/agents/index.d.ts +0 -0
- package/dist/umd/plugins/BasePlugin.d.ts +0 -28
- package/dist/umd/plugins/GenericPlugin.d.ts +0 -17
- package/dist/umd/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/umd/plugins/PluginLoader.d.ts +0 -38
- package/dist/umd/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/umd/plugins/openconvai/index.d.ts +0 -1
- package/dist/umd/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/umd/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/umd/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/umd/tools/ConnectionTool.d.ts +0 -40
- package/dist/umd/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/umd/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/umd/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/umd/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/umd/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/umd/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/umd/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/umd/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/umd/tools/SendMessageTool.d.ts +0 -40
- package/src/agents/index.ts +0 -1
- package/src/plugins/BasePlugin.ts +0 -37
- package/src/plugins/GenericPlugin.ts +0 -19
- package/src/plugins/HCS10Plugin.ts +0 -14
- package/src/plugins/PluginLoader.ts +0 -121
- package/src/plugins/README.md +0 -113
- package/src/plugins/openconvai/OpenConvAIPlugin.ts +0 -124
- package/src/plugins/openconvai/index.ts +0 -1
- package/src/tools/AcceptConnectionRequestTool.ts +0 -196
- package/src/tools/CheckMessagesTool.ts +0 -194
- package/src/tools/ConnectionMonitorTool.ts +0 -550
- package/src/tools/ConnectionTool.ts +0 -231
- package/src/tools/FindRegistrationsTool.ts +0 -114
- package/src/tools/InitiateConnectionTool.ts +0 -137
- package/src/tools/ListConnectionsTool.ts +0 -158
- package/src/tools/ListUnapprovedConnectionRequestsTool.ts +0 -173
- package/src/tools/ManageConnectionRequestsTool.ts +0 -275
- package/src/tools/RegisterAgentTool.ts +0 -590
- package/src/tools/RetrieveProfileTool.ts +0 -94
- package/src/tools/SendMessageToConnectionTool.ts +0 -142
- package/src/tools/SendMessageTool.ts +0 -116
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import { IStateManager } from '../state/state-types';
|
|
5
|
-
export interface InitiateConnectionToolParams extends ToolParams {
|
|
6
|
-
hcsClient: HCS10Client;
|
|
7
|
-
stateManager: IStateManager;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
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.
|
|
14
|
-
*/
|
|
15
|
-
export declare class InitiateConnectionTool extends StructuredTool {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
schema: z.ZodObject<{
|
|
19
|
-
targetAccountId: z.ZodString;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
targetAccountId?: string;
|
|
22
|
-
}, {
|
|
23
|
-
targetAccountId?: string;
|
|
24
|
-
}>;
|
|
25
|
-
private hcsClient;
|
|
26
|
-
private stateManager;
|
|
27
|
-
private logger;
|
|
28
|
-
constructor({ hcsClient, stateManager, ...rest }: InitiateConnectionToolParams);
|
|
29
|
-
protected _call({ targetAccountId }: z.infer<this['schema']>): Promise<string>;
|
|
30
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { IStateManager } from '../state/state-types';
|
|
4
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
5
|
-
export interface ListConnectionsToolParams extends ToolParams {
|
|
6
|
-
stateManager: IStateManager;
|
|
7
|
-
hcsClient?: HCS10Client;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
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.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ListConnectionsTool extends StructuredTool {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
schema: z.ZodObject<{
|
|
17
|
-
includeDetails: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
showPending: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
includeDetails?: boolean;
|
|
21
|
-
showPending?: boolean;
|
|
22
|
-
}, {
|
|
23
|
-
includeDetails?: boolean;
|
|
24
|
-
showPending?: boolean;
|
|
25
|
-
}>;
|
|
26
|
-
private stateManager;
|
|
27
|
-
private hcsClient?;
|
|
28
|
-
private logger;
|
|
29
|
-
constructor({ stateManager, hcsClient, ...rest }: ListConnectionsToolParams);
|
|
30
|
-
protected _call(args: z.infer<this['schema']>): Promise<string>;
|
|
31
|
-
private formatConnection;
|
|
32
|
-
private getEnhancedConnections;
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { IStateManager } from '../state/state-types';
|
|
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";
|
|
17
|
-
limit?: number;
|
|
18
|
-
}, {
|
|
19
|
-
sortBy?: "time_asc" | "time_desc" | "name_asc" | "name_desc";
|
|
20
|
-
limit?: number;
|
|
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
|
-
* Formats the list of pending requests for display.
|
|
34
|
-
*/
|
|
35
|
-
private formatRequestsList;
|
|
36
|
-
/**
|
|
37
|
-
* Sorts connection requests based on the specified criteria.
|
|
38
|
-
*/
|
|
39
|
-
private sortRequests;
|
|
40
|
-
}
|
|
41
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import { IStateManager } from '../state/state-types';
|
|
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
|
-
requestKey: z.ZodOptional<z.ZodString>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
action?: "list" | "view" | "reject";
|
|
21
|
-
requestKey?: string;
|
|
22
|
-
}, {
|
|
23
|
-
action?: "list" | "view" | "reject";
|
|
24
|
-
requestKey?: string;
|
|
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, requestKey, }: z.infer<this['schema']>): Promise<string>;
|
|
33
|
-
private refreshRequestsIfNeeded;
|
|
34
|
-
private refreshRequests;
|
|
35
|
-
private listRequests;
|
|
36
|
-
private viewRequest;
|
|
37
|
-
private rejectRequest;
|
|
38
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { IStateManager } from '../state/state-types';
|
|
5
|
-
/**
|
|
6
|
-
* RegisterAgentTool wraps the createAndRegisterAgent() function of HCS10Client.
|
|
7
|
-
* It creates and registers an agent on Hedera using the HCS-10 standard SDK flow.
|
|
8
|
-
* On success, returns a JSON string containing the new agent's details (including private key).
|
|
9
|
-
*/
|
|
10
|
-
export declare class RegisterAgentTool extends StructuredTool {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
private client;
|
|
14
|
-
private stateManager?;
|
|
15
|
-
schema: z.ZodObject<{
|
|
16
|
-
name: z.ZodString;
|
|
17
|
-
description: z.ZodOptional<z.ZodString>;
|
|
18
|
-
type: z.ZodOptional<z.ZodEnum<["autonomous", "manual"]>>;
|
|
19
|
-
model: z.ZodOptional<z.ZodString>;
|
|
20
|
-
capabilities: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
21
|
-
profilePicture: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
22
|
-
url: z.ZodString;
|
|
23
|
-
filename: z.ZodString;
|
|
24
|
-
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
url?: string;
|
|
26
|
-
filename?: string;
|
|
27
|
-
}, {
|
|
28
|
-
url?: string;
|
|
29
|
-
filename?: string;
|
|
30
|
-
}>, z.ZodObject<{
|
|
31
|
-
path: z.ZodString;
|
|
32
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
path?: string;
|
|
35
|
-
filename?: string;
|
|
36
|
-
}, {
|
|
37
|
-
path?: string;
|
|
38
|
-
filename?: string;
|
|
39
|
-
}>]>>;
|
|
40
|
-
feeCollectorAccountId: z.ZodOptional<z.ZodString>;
|
|
41
|
-
hbarFee: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
tokenFee: z.ZodOptional<z.ZodObject<{
|
|
43
|
-
amount: z.ZodNumber;
|
|
44
|
-
tokenId: z.ZodString;
|
|
45
|
-
}, "strip", z.ZodTypeAny, {
|
|
46
|
-
amount?: number;
|
|
47
|
-
tokenId?: string;
|
|
48
|
-
}, {
|
|
49
|
-
amount?: number;
|
|
50
|
-
tokenId?: string;
|
|
51
|
-
}>>;
|
|
52
|
-
hbarFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
-
amount: z.ZodNumber;
|
|
54
|
-
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
amount?: number;
|
|
57
|
-
collectorAccount?: string;
|
|
58
|
-
}, {
|
|
59
|
-
amount?: number;
|
|
60
|
-
collectorAccount?: string;
|
|
61
|
-
}>, "many">>;
|
|
62
|
-
tokenFees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
-
amount: z.ZodNumber;
|
|
64
|
-
tokenId: z.ZodString;
|
|
65
|
-
collectorAccount: z.ZodOptional<z.ZodString>;
|
|
66
|
-
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
amount?: number;
|
|
68
|
-
tokenId?: string;
|
|
69
|
-
collectorAccount?: string;
|
|
70
|
-
}, {
|
|
71
|
-
amount?: number;
|
|
72
|
-
tokenId?: string;
|
|
73
|
-
collectorAccount?: string;
|
|
74
|
-
}>, "many">>;
|
|
75
|
-
exemptAccountIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
76
|
-
setAsCurrent: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
-
persistence: z.ZodOptional<z.ZodObject<{
|
|
78
|
-
prefix: z.ZodOptional<z.ZodString>;
|
|
79
|
-
}, "strip", z.ZodTypeAny, {
|
|
80
|
-
prefix?: string;
|
|
81
|
-
}, {
|
|
82
|
-
prefix?: string;
|
|
83
|
-
}>>;
|
|
84
|
-
}, "strip", z.ZodTypeAny, {
|
|
85
|
-
capabilities?: number[];
|
|
86
|
-
type?: "autonomous" | "manual";
|
|
87
|
-
name?: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
model?: string;
|
|
90
|
-
profilePicture?: string | {
|
|
91
|
-
url?: string;
|
|
92
|
-
filename?: string;
|
|
93
|
-
} | {
|
|
94
|
-
path?: string;
|
|
95
|
-
filename?: string;
|
|
96
|
-
};
|
|
97
|
-
feeCollectorAccountId?: string;
|
|
98
|
-
hbarFee?: number;
|
|
99
|
-
tokenFee?: {
|
|
100
|
-
amount?: number;
|
|
101
|
-
tokenId?: string;
|
|
102
|
-
};
|
|
103
|
-
hbarFees?: {
|
|
104
|
-
amount?: number;
|
|
105
|
-
collectorAccount?: string;
|
|
106
|
-
}[];
|
|
107
|
-
tokenFees?: {
|
|
108
|
-
amount?: number;
|
|
109
|
-
tokenId?: string;
|
|
110
|
-
collectorAccount?: string;
|
|
111
|
-
}[];
|
|
112
|
-
exemptAccountIds?: string[];
|
|
113
|
-
setAsCurrent?: boolean;
|
|
114
|
-
persistence?: {
|
|
115
|
-
prefix?: string;
|
|
116
|
-
};
|
|
117
|
-
}, {
|
|
118
|
-
capabilities?: number[];
|
|
119
|
-
type?: "autonomous" | "manual";
|
|
120
|
-
name?: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
model?: string;
|
|
123
|
-
profilePicture?: string | {
|
|
124
|
-
url?: string;
|
|
125
|
-
filename?: string;
|
|
126
|
-
} | {
|
|
127
|
-
path?: string;
|
|
128
|
-
filename?: string;
|
|
129
|
-
};
|
|
130
|
-
feeCollectorAccountId?: string;
|
|
131
|
-
hbarFee?: number;
|
|
132
|
-
tokenFee?: {
|
|
133
|
-
amount?: number;
|
|
134
|
-
tokenId?: string;
|
|
135
|
-
};
|
|
136
|
-
hbarFees?: {
|
|
137
|
-
amount?: number;
|
|
138
|
-
collectorAccount?: string;
|
|
139
|
-
}[];
|
|
140
|
-
tokenFees?: {
|
|
141
|
-
amount?: number;
|
|
142
|
-
tokenId?: string;
|
|
143
|
-
collectorAccount?: string;
|
|
144
|
-
}[];
|
|
145
|
-
exemptAccountIds?: string[];
|
|
146
|
-
setAsCurrent?: boolean;
|
|
147
|
-
persistence?: {
|
|
148
|
-
prefix?: string;
|
|
149
|
-
};
|
|
150
|
-
}>;
|
|
151
|
-
/**
|
|
152
|
-
* Creates a new RegisterAgentTool instance
|
|
153
|
-
* @param client - Instance of HCS10Client (already configured with operator/network)
|
|
154
|
-
* @param stateManager - Optional state manager to store agent details
|
|
155
|
-
*/
|
|
156
|
-
constructor(client: HCS10Client, stateManager?: IStateManager);
|
|
157
|
-
/**
|
|
158
|
-
* Loads a profile picture from a local file or URL and returns a buffer
|
|
159
|
-
* @param profilePicture - Local file path or URL
|
|
160
|
-
* @returns Object containing buffer and filename
|
|
161
|
-
*/
|
|
162
|
-
private loadProfilePicture;
|
|
163
|
-
/**
|
|
164
|
-
* Calls createAndRegisterAgent() with the provided metadata.
|
|
165
|
-
* Returns a JSON string with agent details on success, or an error string.
|
|
166
|
-
*/
|
|
167
|
-
_call(input: z.infer<typeof this.schema>): Promise<string>;
|
|
168
|
-
/**
|
|
169
|
-
* Checks if the token fee configuration is valid
|
|
170
|
-
*/
|
|
171
|
-
private hasValidTokenFee;
|
|
172
|
-
/**
|
|
173
|
-
* Processes the registration result and returns formatted output
|
|
174
|
-
*/
|
|
175
|
-
private processRegistrationResult;
|
|
176
|
-
/**
|
|
177
|
-
* Ensures the agent has enough HBAR for operations
|
|
178
|
-
*/
|
|
179
|
-
private ensureAgentHasFunds;
|
|
180
|
-
/**
|
|
181
|
-
* Validates that all required fields are present in the registration result
|
|
182
|
-
*/
|
|
183
|
-
private validateRegistrationResult;
|
|
184
|
-
/**
|
|
185
|
-
* Creates a description of the fees configured for the agent
|
|
186
|
-
*/
|
|
187
|
-
private createFeeDescription;
|
|
188
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
/**
|
|
5
|
-
* Tool for retrieving the HCS-11 profile associated with a Hedera account ID.
|
|
6
|
-
* Utilizes the HCS10Client's retrieveProfile method, which handles fetching.
|
|
7
|
-
*/
|
|
8
|
-
export declare class RetrieveProfileTool extends StructuredTool {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
private client;
|
|
12
|
-
private logger;
|
|
13
|
-
schema: z.ZodObject<{
|
|
14
|
-
accountId: z.ZodOptional<z.ZodString>;
|
|
15
|
-
disableCache: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
accountId?: string;
|
|
18
|
-
disableCache?: boolean;
|
|
19
|
-
}, {
|
|
20
|
-
accountId?: string;
|
|
21
|
-
disableCache?: boolean;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new RetrieveProfileTool instance.
|
|
25
|
-
* @param client - An instance of HCS10Client.
|
|
26
|
-
*/
|
|
27
|
-
constructor(client: HCS10Client);
|
|
28
|
-
/**
|
|
29
|
-
* Executes the profile retrieval.
|
|
30
|
-
* @param input - The input object containing accountId and optional disableCache flag.
|
|
31
|
-
* @returns A JSON string of the profile on success, or an error message string.
|
|
32
|
-
*/
|
|
33
|
-
_call(input: z.infer<typeof this.schema>): Promise<string>;
|
|
34
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { StructuredTool, ToolParams } from '@langchain/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
4
|
-
import { IStateManager } from '../state/state-types';
|
|
5
|
-
export interface SendMessageToConnectionToolParams extends ToolParams {
|
|
6
|
-
hcsClient: HCS10Client;
|
|
7
|
-
stateManager: IStateManager;
|
|
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
|
-
disableMonitoring: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
message?: string;
|
|
21
|
-
disableMonitoring?: boolean;
|
|
22
|
-
targetIdentifier?: string;
|
|
23
|
-
}, {
|
|
24
|
-
message?: string;
|
|
25
|
-
disableMonitoring?: boolean;
|
|
26
|
-
targetIdentifier?: string;
|
|
27
|
-
}>;
|
|
28
|
-
private hcsClient;
|
|
29
|
-
private stateManager;
|
|
30
|
-
private logger;
|
|
31
|
-
constructor({ hcsClient, stateManager, ...rest }: SendMessageToConnectionToolParams);
|
|
32
|
-
protected _call({ targetIdentifier, message, disableMonitoring, }: z.infer<this['schema']>): Promise<string>;
|
|
33
|
-
private monitorResponses;
|
|
34
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
2
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
/**
|
|
5
|
-
* SendMessageTool wraps the sendMessage() function of HCS10Client.
|
|
6
|
-
* It sends a message to a specified Hedera topic and monitors for responses.
|
|
7
|
-
*/
|
|
8
|
-
export declare class SendMessageTool extends StructuredTool {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
private client;
|
|
12
|
-
private lastProcessedTimestamp;
|
|
13
|
-
private logger;
|
|
14
|
-
schema: z.ZodObject<{
|
|
15
|
-
topicId: z.ZodString;
|
|
16
|
-
message: z.ZodString;
|
|
17
|
-
disableMonitoring: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
message?: string;
|
|
20
|
-
topicId?: string;
|
|
21
|
-
disableMonitoring?: boolean;
|
|
22
|
-
}, {
|
|
23
|
-
message?: string;
|
|
24
|
-
topicId?: string;
|
|
25
|
-
disableMonitoring?: boolean;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* @param client - Instance of HCS10Client.
|
|
29
|
-
*/
|
|
30
|
-
constructor(client: HCS10Client);
|
|
31
|
-
/**
|
|
32
|
-
* Calls sendMessage() with the provided parameters.
|
|
33
|
-
*/
|
|
34
|
-
_call(input: {
|
|
35
|
-
topicId: string;
|
|
36
|
-
message: string;
|
|
37
|
-
disableMonitoring: boolean;
|
|
38
|
-
}): Promise<string>;
|
|
39
|
-
private monitorResponses;
|
|
40
|
-
}
|
package/src/agents/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Export all agent implementations
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { IPlugin, BasePluginContext } from './PluginInterface';
|
|
2
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Base class for plugins to simplify implementation
|
|
6
|
-
*/
|
|
7
|
-
export abstract class BasePlugin<T extends BasePluginContext = BasePluginContext> implements IPlugin<T> {
|
|
8
|
-
abstract id: string;
|
|
9
|
-
abstract name: string;
|
|
10
|
-
abstract description: string;
|
|
11
|
-
abstract version: string;
|
|
12
|
-
abstract author: string;
|
|
13
|
-
|
|
14
|
-
protected context!: T;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Initialize the plugin with the provided context
|
|
18
|
-
* @param context The context containing shared resources
|
|
19
|
-
*/
|
|
20
|
-
async initialize(context: T): Promise<void> {
|
|
21
|
-
this.context = context;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get the tools provided by this plugin
|
|
26
|
-
* @returns Array of tools provided by this plugin
|
|
27
|
-
*/
|
|
28
|
-
abstract getTools(): StructuredTool[];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Clean up resources when the plugin is unloaded
|
|
32
|
-
* Default implementation does nothing
|
|
33
|
-
*/
|
|
34
|
-
async cleanup(): Promise<void> {
|
|
35
|
-
// Default implementation does nothing
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BasePlugin } from './BasePlugin';
|
|
2
|
-
import { GenericPluginContext } from './PluginInterface';
|
|
3
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Base class for platform-agnostic plugins that can be used across different implementations
|
|
7
|
-
*/
|
|
8
|
-
export abstract class GenericPlugin extends BasePlugin<GenericPluginContext> {
|
|
9
|
-
/**
|
|
10
|
-
* Namespace for the plugin, used for organizing and categorizing plugins
|
|
11
|
-
*/
|
|
12
|
-
abstract namespace: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get the tools provided by this plugin
|
|
16
|
-
* @returns Array of tools provided by this plugin
|
|
17
|
-
*/
|
|
18
|
-
abstract override getTools(): StructuredTool[];
|
|
19
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BasePlugin } from './BasePlugin';
|
|
2
|
-
import { PluginContext } from './PluginInterface';
|
|
3
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Base class for plugins that require HCS10 specific functionality
|
|
7
|
-
*/
|
|
8
|
-
export abstract class HCS10Plugin extends BasePlugin<PluginContext> {
|
|
9
|
-
/**
|
|
10
|
-
* Get the tools provided by this plugin
|
|
11
|
-
* @returns Array of tools provided by this plugin
|
|
12
|
-
*/
|
|
13
|
-
abstract override getTools(): StructuredTool[];
|
|
14
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { PluginContext } from './PluginInterface';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import { IPlugin } from './PluginInterface';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configuration for loading a plugin
|
|
8
|
-
*/
|
|
9
|
-
export interface PluginLoadOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Whether to initialize the plugin after loading
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
initialize?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Utility for loading plugins from different sources
|
|
19
|
-
*/
|
|
20
|
-
export class PluginLoader {
|
|
21
|
-
/**
|
|
22
|
-
* Load a plugin from a directory
|
|
23
|
-
* @param directory Path to the directory containing the plugin
|
|
24
|
-
* @param context Context to provide to the plugin during initialization
|
|
25
|
-
* @param options Options for loading the plugin
|
|
26
|
-
* @returns The loaded plugin instance
|
|
27
|
-
*/
|
|
28
|
-
static async loadFromDirectory(
|
|
29
|
-
directory: string,
|
|
30
|
-
context: PluginContext,
|
|
31
|
-
options: PluginLoadOptions = { initialize: true }
|
|
32
|
-
): Promise<IPlugin> {
|
|
33
|
-
const manifestPath = path.join(directory, 'plugin.json');
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(manifestPath)) {
|
|
36
|
-
throw new Error(`Plugin manifest not found at ${manifestPath}`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const manifestContent = fs.readFileSync(manifestPath, 'utf8');
|
|
41
|
-
const manifest = JSON.parse(manifestContent);
|
|
42
|
-
|
|
43
|
-
// Validate manifest
|
|
44
|
-
if (!manifest.id || !manifest.main) {
|
|
45
|
-
throw new Error('Invalid plugin manifest: missing required fields (id, main)');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Load the plugin module
|
|
49
|
-
const mainPath = path.join(directory, manifest.main);
|
|
50
|
-
if (!fs.existsSync(mainPath)) {
|
|
51
|
-
throw new Error(`Plugin main file not found at ${mainPath}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Import the plugin module
|
|
55
|
-
const pluginModule = await import(mainPath);
|
|
56
|
-
const PluginClass = pluginModule.default || pluginModule[manifest.id];
|
|
57
|
-
|
|
58
|
-
if (!PluginClass) {
|
|
59
|
-
throw new Error(`Could not find plugin class in ${mainPath}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Create an instance of the plugin
|
|
63
|
-
const plugin = new PluginClass();
|
|
64
|
-
|
|
65
|
-
// Validate that it implements the IPlugin interface
|
|
66
|
-
if (!this.isValidPlugin(plugin)) {
|
|
67
|
-
throw new Error(`Plugin does not implement the IPlugin interface correctly`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Initialize the plugin if requested
|
|
71
|
-
if (options.initialize) {
|
|
72
|
-
await plugin.initialize(context);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return plugin;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
throw new Error(`Failed to load plugin from directory ${directory}: ${error instanceof Error ? error.message : String(error)}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Load a plugin from an npm package
|
|
83
|
-
* @param packageName Name of the npm package containing the plugin
|
|
84
|
-
* @param context Context to provide to the plugin during initialization
|
|
85
|
-
* @param options Options for loading the plugin
|
|
86
|
-
* @returns The loaded plugin instance
|
|
87
|
-
*/
|
|
88
|
-
static async loadFromPackage(
|
|
89
|
-
packageName: string,
|
|
90
|
-
context: PluginContext,
|
|
91
|
-
options: PluginLoadOptions = { initialize: true }
|
|
92
|
-
): Promise<IPlugin> {
|
|
93
|
-
try {
|
|
94
|
-
// Resolve the package path
|
|
95
|
-
const packagePath = require.resolve(packageName);
|
|
96
|
-
const packageDir = path.dirname(packagePath);
|
|
97
|
-
|
|
98
|
-
return this.loadFromDirectory(packageDir, context, options);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
throw new Error(`Failed to load plugin from package ${packageName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Check if an object implements the IPlugin interface
|
|
106
|
-
* @param obj Object to check
|
|
107
|
-
* @returns true if the object implements IPlugin, false otherwise
|
|
108
|
-
*/
|
|
109
|
-
private static isValidPlugin(obj: any): obj is IPlugin {
|
|
110
|
-
return (
|
|
111
|
-
obj &&
|
|
112
|
-
typeof obj.id === 'string' &&
|
|
113
|
-
typeof obj.name === 'string' &&
|
|
114
|
-
typeof obj.description === 'string' &&
|
|
115
|
-
typeof obj.version === 'string' &&
|
|
116
|
-
typeof obj.author === 'string' &&
|
|
117
|
-
typeof obj.initialize === 'function' &&
|
|
118
|
-
typeof obj.getTools === 'function'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|