@hashgraphonline/standards-agent-kit 0.2.1 → 0.2.102
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 +4 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/cjs/builders/hcs2/index.d.ts +1 -0
- package/dist/cjs/builders/index.d.ts +2 -0
- package/dist/cjs/builders/inscriber/index.d.ts +1 -0
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/cjs/tools/hcs10/index.d.ts +1 -0
- package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/cjs/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/cjs/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs2/index.d.ts +8 -0
- package/dist/cjs/tools/index.d.ts +2 -0
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/cjs/tools/inscriber/index.d.ts +7 -0
- package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/es/builders/hcs2/index.d.ts +1 -0
- package/dist/es/builders/index.d.ts +2 -0
- package/dist/es/builders/inscriber/index.d.ts +1 -0
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/es/index.d.ts +1 -1
- package/dist/es/standards-agent-kit.es.js +50 -16
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +17 -23
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +36 -58
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +43 -18
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +53 -16
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +18 -28
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +26 -12
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +37 -241
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +16 -136
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +154 -27
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -22
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +27 -13
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +42 -3
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +48 -0
- package/dist/es/standards-agent-kit.es21.js.map +1 -0
- package/dist/es/standards-agent-kit.es22.js +51 -0
- package/dist/es/standards-agent-kit.es22.js.map +1 -0
- package/dist/es/standards-agent-kit.es23.js +45 -0
- package/dist/es/standards-agent-kit.es23.js.map +1 -0
- package/dist/es/standards-agent-kit.es24.js +48 -0
- package/dist/es/standards-agent-kit.es24.js.map +1 -0
- package/dist/es/standards-agent-kit.es25.js +45 -0
- package/dist/es/standards-agent-kit.es25.js.map +1 -0
- package/dist/es/standards-agent-kit.es26.js +32 -0
- package/dist/es/standards-agent-kit.es26.js.map +1 -0
- package/dist/es/standards-agent-kit.es27.js +71 -0
- package/dist/es/standards-agent-kit.es27.js.map +1 -0
- package/dist/es/standards-agent-kit.es28.js +71 -0
- package/dist/es/standards-agent-kit.es28.js.map +1 -0
- package/dist/es/standards-agent-kit.es29.js +79 -0
- package/dist/es/standards-agent-kit.es29.js.map +1 -0
- package/dist/es/standards-agent-kit.es3.js +59 -296
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +90 -0
- package/dist/es/standards-agent-kit.es30.js.map +1 -0
- package/dist/es/standards-agent-kit.es31.js +45 -0
- package/dist/es/standards-agent-kit.es31.js.map +1 -0
- package/dist/es/standards-agent-kit.es32.js +249 -0
- package/dist/es/standards-agent-kit.es32.js.map +1 -0
- package/dist/es/standards-agent-kit.es33.js +141 -0
- package/dist/es/standards-agent-kit.es33.js.map +1 -0
- package/dist/es/standards-agent-kit.es34.js +33 -0
- package/dist/es/standards-agent-kit.es34.js.map +1 -0
- package/dist/es/standards-agent-kit.es35.js +28 -0
- package/dist/es/standards-agent-kit.es35.js.map +1 -0
- package/dist/es/standards-agent-kit.es36.js +7 -0
- package/dist/es/standards-agent-kit.es36.js.map +1 -0
- package/dist/es/standards-agent-kit.es4.js +44 -20
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +312 -121
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +24 -23
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +220 -20
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +20 -29
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +26 -36
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/es/tools/hcs10/index.d.ts +1 -0
- package/dist/es/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/es/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/es/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/es/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs2/index.d.ts +8 -0
- package/dist/es/tools/index.d.ts +2 -0
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/es/tools/inscriber/index.d.ts +7 -0
- package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/umd/builders/hcs2/index.d.ts +1 -0
- package/dist/umd/builders/index.d.ts +2 -0
- package/dist/umd/builders/inscriber/index.d.ts +1 -0
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/umd/index.d.ts +1 -1
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/umd/tools/hcs10/index.d.ts +1 -0
- package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/umd/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/umd/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/umd/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs2/index.d.ts +8 -0
- package/dist/umd/tools/index.d.ts +2 -0
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/umd/tools/inscriber/index.d.ts +7 -0
- package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/package.json +32 -30
- package/src/builders/hcs10/hcs10-builder.ts +37 -16
- package/src/builders/hcs2/hcs2-builder.ts +148 -0
- package/src/builders/hcs2/index.ts +1 -0
- package/src/builders/index.ts +3 -1
- package/src/builders/inscriber/index.ts +1 -0
- package/src/builders/inscriber/inscriber-builder.ts +112 -0
- package/src/index.ts +1 -1
- package/src/tools/hcs10/FindRegistrationsTool.ts +19 -4
- package/src/tools/hcs10/RegisterAgentTool.ts +147 -9
- package/src/tools/hcs10/index.ts +2 -1
- package/src/tools/hcs10/natural-language-mapper.ts +194 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +63 -0
- package/src/tools/hcs2/DeleteEntryTool.ts +58 -0
- package/src/tools/hcs2/MigrateRegistryTool.ts +64 -0
- package/src/tools/hcs2/QueryRegistryTool.ts +70 -0
- package/src/tools/hcs2/RegisterEntryTool.ts +63 -0
- package/src/tools/hcs2/UpdateEntryTool.ts +68 -0
- package/src/tools/hcs2/base-hcs2-tools.ts +65 -0
- package/src/tools/hcs2/hcs2-tool-params.ts +21 -0
- package/src/tools/hcs2/index.ts +8 -0
- package/src/tools/index.ts +3 -2
- package/src/tools/inscriber/InscribeFromBufferTool.ts +105 -0
- package/src/tools/inscriber/InscribeFromFileTool.ts +93 -0
- package/src/tools/inscriber/InscribeFromUrlTool.ts +93 -0
- package/src/tools/inscriber/InscribeHashinalTool.ts +117 -0
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +59 -0
- package/src/tools/inscriber/base-inscriber-tools.ts +65 -0
- package/src/tools/inscriber/index.ts +7 -0
- package/src/tools/inscriber/inscriber-tool-params.ts +21 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BaseServiceBuilder } from 'hedera-agent-kit';
|
|
2
|
+
import type { HederaAgentKit } from 'hedera-agent-kit';
|
|
3
|
+
import {
|
|
4
|
+
inscribe,
|
|
5
|
+
inscribeWithSigner,
|
|
6
|
+
retrieveInscription,
|
|
7
|
+
InscriptionInput,
|
|
8
|
+
InscriptionOptions,
|
|
9
|
+
InscriptionResponse,
|
|
10
|
+
RetrievedInscriptionResult,
|
|
11
|
+
HederaClientConfig,
|
|
12
|
+
NetworkType,
|
|
13
|
+
} from '@hashgraphonline/standards-sdk';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Type definition for DAppSigner since we don't have the actual package
|
|
17
|
+
*/
|
|
18
|
+
interface DAppSigner {
|
|
19
|
+
getAccountId(): { toString(): string };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Type definition for InscriptionSDK since we don't have the actual package
|
|
24
|
+
*/
|
|
25
|
+
interface InscriptionSDK {
|
|
26
|
+
inscribeAndExecute(request: any, config: any): Promise<any>;
|
|
27
|
+
inscribe(request: any, signer: any): Promise<any>;
|
|
28
|
+
waitForInscription(txId: string, maxAttempts: number, intervalMs: number, checkCompletion: boolean, progressCallback?: Function): Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Builder for Inscription operations
|
|
33
|
+
*/
|
|
34
|
+
export class InscriberBuilder extends BaseServiceBuilder {
|
|
35
|
+
protected inscriptionSDK?: InscriptionSDK;
|
|
36
|
+
|
|
37
|
+
constructor(hederaKit: HederaAgentKit) {
|
|
38
|
+
super(hederaKit);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get or create Inscription SDK - temporarily returns null since we don't have the actual SDK
|
|
43
|
+
*/
|
|
44
|
+
protected async getInscriptionSDK(
|
|
45
|
+
options: InscriptionOptions
|
|
46
|
+
): Promise<InscriptionSDK | null> {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Inscribe content using server-side authentication
|
|
52
|
+
*/
|
|
53
|
+
async inscribe(
|
|
54
|
+
input: InscriptionInput,
|
|
55
|
+
options: InscriptionOptions
|
|
56
|
+
): Promise<InscriptionResponse> {
|
|
57
|
+
const operatorId = this.hederaKit.signer.getAccountId().toString();
|
|
58
|
+
const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()
|
|
59
|
+
? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()
|
|
60
|
+
: '';
|
|
61
|
+
|
|
62
|
+
const network = this.hederaKit.client.network;
|
|
63
|
+
const networkType: NetworkType = network.toString().includes('mainnet')
|
|
64
|
+
? 'mainnet'
|
|
65
|
+
: 'testnet';
|
|
66
|
+
|
|
67
|
+
const clientConfig: HederaClientConfig = {
|
|
68
|
+
accountId: operatorId,
|
|
69
|
+
privateKey: operatorPrivateKey,
|
|
70
|
+
network: networkType,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return await inscribe(input, clientConfig, options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Inscribe content using a DApp signer
|
|
78
|
+
*/
|
|
79
|
+
async inscribeWithSigner(
|
|
80
|
+
input: InscriptionInput,
|
|
81
|
+
signer: DAppSigner,
|
|
82
|
+
options: InscriptionOptions
|
|
83
|
+
): Promise<InscriptionResponse> {
|
|
84
|
+
return await inscribeWithSigner(input, signer as any, options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retrieve an existing inscription
|
|
89
|
+
*/
|
|
90
|
+
async retrieveInscription(
|
|
91
|
+
transactionId: string,
|
|
92
|
+
options: InscriptionOptions
|
|
93
|
+
): Promise<RetrievedInscriptionResult> {
|
|
94
|
+
const operatorId = this.hederaKit.signer.getAccountId().toString();
|
|
95
|
+
const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()
|
|
96
|
+
? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()
|
|
97
|
+
: '';
|
|
98
|
+
|
|
99
|
+
return await retrieveInscription(transactionId, {
|
|
100
|
+
...options,
|
|
101
|
+
accountId: operatorId,
|
|
102
|
+
privateKey: operatorPrivateKey,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Close the inscription SDK
|
|
108
|
+
*/
|
|
109
|
+
async close(): Promise<void> {
|
|
110
|
+
this.inscriptionSDK = undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * from './tools';
|
|
|
2
2
|
export * from './state';
|
|
3
3
|
export * from './init';
|
|
4
4
|
export * from './plugins';
|
|
5
|
-
export { HCS10Builder } from './builders';
|
|
5
|
+
export { HCS10Builder, HCS2Builder, InscriberBuilder } from './builders';
|
|
6
6
|
export type { ExecuteResult } from './builders';
|
|
7
7
|
export { HCS10Client } from './hcs10';
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { AIAgentCapability } from '@hashgraphonline/standards-sdk';
|
|
3
3
|
import { BaseHCS10QueryTool } from './base-hcs10-tools';
|
|
4
4
|
import { HCS10QueryToolParams } from './hcs10-tool-params';
|
|
5
|
+
import { NaturalLanguageMapper } from './natural-language-mapper';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A tool to search for registered HCS-10 agents using the configured registry.
|
|
@@ -14,10 +15,24 @@ const FindRegistrationsZodSchema = z.object({
|
|
|
14
15
|
'Optional: Filter registrations by a specific Hedera account ID (e.g., 0.0.12345).'
|
|
15
16
|
),
|
|
16
17
|
tags: z
|
|
17
|
-
.
|
|
18
|
+
.union([
|
|
19
|
+
z.array(z.nativeEnum(AIAgentCapability)),
|
|
20
|
+
z.array(z.string()),
|
|
21
|
+
z.string(),
|
|
22
|
+
])
|
|
18
23
|
.optional()
|
|
24
|
+
.transform((val) => {
|
|
25
|
+
if (!val) return undefined;
|
|
26
|
+
if (typeof val === 'string') {
|
|
27
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {
|
|
30
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
31
|
+
}
|
|
32
|
+
return val as AIAgentCapability[];
|
|
33
|
+
})
|
|
19
34
|
.describe(
|
|
20
|
-
'Optional: Filter
|
|
35
|
+
'Optional: Filter by capabilities/tags like "ai", "data", "analytics". Can be natural language terms or capability numbers.'
|
|
21
36
|
),
|
|
22
37
|
});
|
|
23
38
|
|
|
@@ -26,7 +41,7 @@ export class FindRegistrationsTool extends BaseHCS10QueryTool<
|
|
|
26
41
|
> {
|
|
27
42
|
name = 'find_registrations';
|
|
28
43
|
description =
|
|
29
|
-
'Searches the configured agent registry for HCS-10 agents. You can filter by account ID or tags. Returns basic registration info.';
|
|
44
|
+
'Searches the configured agent registry for HCS-10 agents. You can filter by account ID or tags/capabilities using natural language like "ai", "data processing", "analytics". Returns basic registration info.';
|
|
30
45
|
specificInputSchema = FindRegistrationsZodSchema;
|
|
31
46
|
constructor(params: HCS10QueryToolParams) {
|
|
32
47
|
super(params);
|
|
@@ -42,7 +57,7 @@ export class FindRegistrationsTool extends BaseHCS10QueryTool<
|
|
|
42
57
|
params.accountId = accountId;
|
|
43
58
|
}
|
|
44
59
|
if (tags) {
|
|
45
|
-
params.tags = tags;
|
|
60
|
+
params.tags = tags as number[];
|
|
46
61
|
}
|
|
47
62
|
await hcs10Builder.findRegistrations(params);
|
|
48
63
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { AIAgentCapability } from '@hashgraphonline/standards-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { BaseServiceBuilder } from 'hedera-agent-kit';
|
|
4
|
-
import {
|
|
4
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
import {
|
|
6
|
+
HCS10Builder,
|
|
7
|
+
RegisterAgentParams,
|
|
8
|
+
} from '../../builders/hcs10/hcs10-builder';
|
|
5
9
|
import { BaseHCS10TransactionTool } from './base-hcs10-tools';
|
|
6
10
|
import { HCS10TransactionToolParams } from './hcs10-tool-params';
|
|
11
|
+
import { RegisteredAgent } from '../../state/state-types';
|
|
12
|
+
import { NaturalLanguageMapper } from './natural-language-mapper';
|
|
7
13
|
|
|
8
14
|
const RegisterAgentZodSchema = z.object({
|
|
9
15
|
name: z
|
|
@@ -19,7 +25,17 @@ const RegisterAgentZodSchema = z.object({
|
|
|
19
25
|
alias: z
|
|
20
26
|
.string()
|
|
21
27
|
.optional()
|
|
22
|
-
.
|
|
28
|
+
.transform((val) => {
|
|
29
|
+
if (!val || val.toLowerCase().includes('random')) {
|
|
30
|
+
const timestamp = Date.now().toString(36);
|
|
31
|
+
const randomChars = Math.random().toString(36);
|
|
32
|
+
return `bot${timestamp}${randomChars}`;
|
|
33
|
+
}
|
|
34
|
+
return val;
|
|
35
|
+
})
|
|
36
|
+
.describe(
|
|
37
|
+
'Optional custom username/alias for the agent. Use "random" to generate a unique alias'
|
|
38
|
+
),
|
|
23
39
|
type: z
|
|
24
40
|
.enum(['autonomous', 'manual'])
|
|
25
41
|
.optional()
|
|
@@ -29,9 +45,37 @@ const RegisterAgentZodSchema = z.object({
|
|
|
29
45
|
.optional()
|
|
30
46
|
.describe('AI model identifier (default: agent-model-2024)'),
|
|
31
47
|
capabilities: z
|
|
32
|
-
.
|
|
48
|
+
.union([
|
|
49
|
+
z.array(z.nativeEnum(AIAgentCapability)),
|
|
50
|
+
z.array(z.string()),
|
|
51
|
+
z.string(),
|
|
52
|
+
])
|
|
33
53
|
.optional()
|
|
34
|
-
.
|
|
54
|
+
.transform((val) => {
|
|
55
|
+
if (!val) return undefined;
|
|
56
|
+
if (typeof val === 'string') {
|
|
57
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {
|
|
60
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
61
|
+
}
|
|
62
|
+
return val as AIAgentCapability[];
|
|
63
|
+
})
|
|
64
|
+
.describe('Agent capabilities - can be capability names (e.g. "ai", "data processing"), capability enum values, or array of either. Common values: "ai"/"text" (TEXT_GENERATION), "data" (DATA_INTEGRATION), "analytics" (TRANSACTION_ANALYTICS)'),
|
|
65
|
+
tags: z
|
|
66
|
+
.union([
|
|
67
|
+
z.array(z.string()),
|
|
68
|
+
z.string(),
|
|
69
|
+
])
|
|
70
|
+
.optional()
|
|
71
|
+
.transform((val) => {
|
|
72
|
+
if (!val) return undefined;
|
|
73
|
+
if (typeof val === 'string') {
|
|
74
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
75
|
+
}
|
|
76
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
77
|
+
})
|
|
78
|
+
.describe('Tags for the agent (alternative to capabilities) - e.g. "ai", "data", "analytics". Will be converted to appropriate capabilities.'),
|
|
35
79
|
creator: z.string().optional().describe('Creator attribution for the agent'),
|
|
36
80
|
socials: z
|
|
37
81
|
.record(
|
|
@@ -124,8 +168,9 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
124
168
|
> {
|
|
125
169
|
name = 'register_agent';
|
|
126
170
|
description =
|
|
127
|
-
'Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Note: This tool requires multiple transactions and cannot be used in returnBytes mode.';
|
|
171
|
+
'Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Supports natural language for capabilities/tags like "ai", "data processing", "analytics". Note: This tool requires multiple transactions and cannot be used in returnBytes mode. If alias is set to "random" or contains "random", a unique alias will be generated.';
|
|
128
172
|
specificInputSchema = RegisterAgentZodSchema;
|
|
173
|
+
private specificArgs: z.infer<typeof RegisterAgentZodSchema> | undefined;
|
|
129
174
|
|
|
130
175
|
constructor(params: HCS10TransactionToolParams) {
|
|
131
176
|
super(params);
|
|
@@ -138,7 +183,7 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
138
183
|
specificArgs: z.infer<typeof RegisterAgentZodSchema>
|
|
139
184
|
): Promise<void> {
|
|
140
185
|
const hcs10Builder = builder as HCS10Builder;
|
|
141
|
-
|
|
186
|
+
this.specificArgs = specificArgs;
|
|
142
187
|
const params: RegisterAgentParams = {
|
|
143
188
|
name: specificArgs.name,
|
|
144
189
|
};
|
|
@@ -148,6 +193,9 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
148
193
|
}
|
|
149
194
|
if (specificArgs.alias !== undefined) {
|
|
150
195
|
params.alias = specificArgs.alias;
|
|
196
|
+
} else {
|
|
197
|
+
const randomSuffix = Date.now().toString(36);
|
|
198
|
+
params.alias = `${specificArgs.name}${randomSuffix}`;
|
|
151
199
|
}
|
|
152
200
|
if (specificArgs.type !== undefined) {
|
|
153
201
|
params.type = specificArgs.type;
|
|
@@ -155,8 +203,11 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
155
203
|
if (specificArgs.model !== undefined) {
|
|
156
204
|
params.model = specificArgs.model;
|
|
157
205
|
}
|
|
158
|
-
|
|
159
|
-
|
|
206
|
+
// Handle both capabilities and tags (tags takes precedence if both provided)
|
|
207
|
+
if (specificArgs.tags !== undefined) {
|
|
208
|
+
params.capabilities = specificArgs.tags as AIAgentCapability[];
|
|
209
|
+
} else if (specificArgs.capabilities !== undefined) {
|
|
210
|
+
params.capabilities = specificArgs.capabilities as AIAgentCapability[];
|
|
160
211
|
}
|
|
161
212
|
if (specificArgs.creator !== undefined) {
|
|
162
213
|
params.creator = specificArgs.creator;
|
|
@@ -210,4 +261,91 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
210
261
|
|
|
211
262
|
await hcs10Builder.registerAgent(params);
|
|
212
263
|
}
|
|
213
|
-
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Override _call to intercept the result and save agent to state if needed
|
|
267
|
+
*/
|
|
268
|
+
protected override async _call(
|
|
269
|
+
args: z.infer<ReturnType<this['schema']>>,
|
|
270
|
+
runManager?: CallbackManagerForToolRun
|
|
271
|
+
): Promise<string> {
|
|
272
|
+
const result = await super._call(args, runManager);
|
|
273
|
+
|
|
274
|
+
const shouldSetAsCurrent = this.specificArgs?.setAsCurrent !== false;
|
|
275
|
+
|
|
276
|
+
if (this.specificArgs && shouldSetAsCurrent) {
|
|
277
|
+
try {
|
|
278
|
+
const parsed = JSON.parse(result);
|
|
279
|
+
if (parsed.rawResult) {
|
|
280
|
+
this._handleRegistrationResult(parsed.rawResult);
|
|
281
|
+
} else if (parsed.state || parsed.accountId || parsed.metadata) {
|
|
282
|
+
this._handleRegistrationResult(parsed);
|
|
283
|
+
}
|
|
284
|
+
} catch (e) {}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Extract agent data from registration result and save to state
|
|
292
|
+
*/
|
|
293
|
+
private _handleRegistrationResult(rawResult: any): void {
|
|
294
|
+
let accountId = rawResult.accountId || rawResult.metadata?.accountId;
|
|
295
|
+
|
|
296
|
+
if (!accountId && rawResult.state?.createdResources) {
|
|
297
|
+
const accountResource = rawResult.state.createdResources.find(
|
|
298
|
+
(r: string) => r.startsWith('account:')
|
|
299
|
+
);
|
|
300
|
+
if (accountResource) {
|
|
301
|
+
accountId = accountResource.split(':')[1];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const inboundTopicId =
|
|
306
|
+
rawResult.inboundTopicId ||
|
|
307
|
+
rawResult.metadata?.inboundTopicId ||
|
|
308
|
+
rawResult.state?.inboundTopicId;
|
|
309
|
+
|
|
310
|
+
const outboundTopicId =
|
|
311
|
+
rawResult.outboundTopicId ||
|
|
312
|
+
rawResult.metadata?.outboundTopicId ||
|
|
313
|
+
rawResult.state?.outboundTopicId;
|
|
314
|
+
|
|
315
|
+
const profileTopicId =
|
|
316
|
+
rawResult.profileTopicId ||
|
|
317
|
+
rawResult.metadata?.profileTopicId ||
|
|
318
|
+
rawResult.state?.profileTopicId;
|
|
319
|
+
|
|
320
|
+
const privateKey = rawResult.privateKey || rawResult.metadata?.privateKey;
|
|
321
|
+
|
|
322
|
+
if (accountId && inboundTopicId && outboundTopicId && this.specificArgs) {
|
|
323
|
+
const registeredAgent: RegisteredAgent = {
|
|
324
|
+
name: this.specificArgs.name,
|
|
325
|
+
accountId,
|
|
326
|
+
inboundTopicId,
|
|
327
|
+
outboundTopicId,
|
|
328
|
+
profileTopicId,
|
|
329
|
+
privateKey,
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const hcs10Builder = this.getServiceBuilder() as HCS10Builder;
|
|
333
|
+
const stateManager = hcs10Builder.getStateManager();
|
|
334
|
+
if (stateManager) {
|
|
335
|
+
stateManager.setCurrentAgent(registeredAgent);
|
|
336
|
+
|
|
337
|
+
if (stateManager.persistAgentData) {
|
|
338
|
+
const prefix =
|
|
339
|
+
this.specificArgs.persistence?.prefix ||
|
|
340
|
+
this.specificArgs.name.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
341
|
+
stateManager
|
|
342
|
+
.persistAgentData(registeredAgent, {
|
|
343
|
+
type: 'env-file',
|
|
344
|
+
prefix: prefix,
|
|
345
|
+
})
|
|
346
|
+
.catch(() => {});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
package/src/tools/hcs10/index.ts
CHANGED
|
@@ -10,4 +10,5 @@ export * from './ConnectionMonitorTool';
|
|
|
10
10
|
export * from './ManageConnectionRequestsTool';
|
|
11
11
|
export * from './AcceptConnectionRequestTool';
|
|
12
12
|
export * from './RetrieveProfileTool';
|
|
13
|
-
export * from './ListUnapprovedConnectionRequestsTool';
|
|
13
|
+
export * from './ListUnapprovedConnectionRequestsTool';
|
|
14
|
+
export * from './natural-language-mapper';
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { AIAgentCapability } from '@hashgraphonline/standards-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Maps natural language terms to AIAgentCapability enum values
|
|
5
|
+
*/
|
|
6
|
+
export class NaturalLanguageMapper {
|
|
7
|
+
private static readonly CAPABILITY_MAPPINGS: Record<string, AIAgentCapability[]> = {
|
|
8
|
+
// Common terms
|
|
9
|
+
'ai': [AIAgentCapability.TEXT_GENERATION],
|
|
10
|
+
'artificial intelligence': [AIAgentCapability.TEXT_GENERATION],
|
|
11
|
+
'chat': [AIAgentCapability.TEXT_GENERATION],
|
|
12
|
+
'conversation': [AIAgentCapability.TEXT_GENERATION],
|
|
13
|
+
'text': [AIAgentCapability.TEXT_GENERATION],
|
|
14
|
+
'text generation': [AIAgentCapability.TEXT_GENERATION],
|
|
15
|
+
|
|
16
|
+
// Image
|
|
17
|
+
'image': [AIAgentCapability.IMAGE_GENERATION],
|
|
18
|
+
'picture': [AIAgentCapability.IMAGE_GENERATION],
|
|
19
|
+
'visual': [AIAgentCapability.IMAGE_GENERATION],
|
|
20
|
+
'photo': [AIAgentCapability.IMAGE_GENERATION],
|
|
21
|
+
|
|
22
|
+
// Audio
|
|
23
|
+
'audio': [AIAgentCapability.AUDIO_GENERATION],
|
|
24
|
+
'sound': [AIAgentCapability.AUDIO_GENERATION],
|
|
25
|
+
'voice': [AIAgentCapability.AUDIO_GENERATION],
|
|
26
|
+
'speech': [AIAgentCapability.AUDIO_GENERATION],
|
|
27
|
+
|
|
28
|
+
// Video
|
|
29
|
+
'video': [AIAgentCapability.VIDEO_GENERATION],
|
|
30
|
+
'movie': [AIAgentCapability.VIDEO_GENERATION],
|
|
31
|
+
'animation': [AIAgentCapability.VIDEO_GENERATION],
|
|
32
|
+
|
|
33
|
+
// Code
|
|
34
|
+
'code': [AIAgentCapability.CODE_GENERATION],
|
|
35
|
+
'programming': [AIAgentCapability.CODE_GENERATION],
|
|
36
|
+
'development': [AIAgentCapability.CODE_GENERATION],
|
|
37
|
+
'coding': [AIAgentCapability.CODE_GENERATION],
|
|
38
|
+
|
|
39
|
+
// Translation
|
|
40
|
+
'translate': [AIAgentCapability.LANGUAGE_TRANSLATION],
|
|
41
|
+
'translation': [AIAgentCapability.LANGUAGE_TRANSLATION],
|
|
42
|
+
'language': [AIAgentCapability.LANGUAGE_TRANSLATION],
|
|
43
|
+
|
|
44
|
+
// Summarization
|
|
45
|
+
'summarize': [AIAgentCapability.SUMMARIZATION_EXTRACTION],
|
|
46
|
+
'summary': [AIAgentCapability.SUMMARIZATION_EXTRACTION],
|
|
47
|
+
'extract': [AIAgentCapability.SUMMARIZATION_EXTRACTION],
|
|
48
|
+
'extraction': [AIAgentCapability.SUMMARIZATION_EXTRACTION],
|
|
49
|
+
|
|
50
|
+
// Knowledge
|
|
51
|
+
'knowledge': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],
|
|
52
|
+
'search': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],
|
|
53
|
+
'retrieve': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],
|
|
54
|
+
'lookup': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],
|
|
55
|
+
|
|
56
|
+
// Data
|
|
57
|
+
'data': [AIAgentCapability.DATA_INTEGRATION],
|
|
58
|
+
'data processing': [AIAgentCapability.DATA_INTEGRATION],
|
|
59
|
+
'data integration': [AIAgentCapability.DATA_INTEGRATION],
|
|
60
|
+
'etl': [AIAgentCapability.DATA_INTEGRATION],
|
|
61
|
+
|
|
62
|
+
// Market
|
|
63
|
+
'market': [AIAgentCapability.MARKET_INTELLIGENCE],
|
|
64
|
+
'trading': [AIAgentCapability.MARKET_INTELLIGENCE],
|
|
65
|
+
'finance': [AIAgentCapability.MARKET_INTELLIGENCE],
|
|
66
|
+
'financial': [AIAgentCapability.MARKET_INTELLIGENCE],
|
|
67
|
+
|
|
68
|
+
// Analytics
|
|
69
|
+
'analytics': [AIAgentCapability.TRANSACTION_ANALYTICS],
|
|
70
|
+
'analysis': [AIAgentCapability.TRANSACTION_ANALYTICS],
|
|
71
|
+
'analyze': [AIAgentCapability.TRANSACTION_ANALYTICS],
|
|
72
|
+
'transactions': [AIAgentCapability.TRANSACTION_ANALYTICS],
|
|
73
|
+
|
|
74
|
+
// Smart Contract
|
|
75
|
+
'audit': [AIAgentCapability.SMART_CONTRACT_AUDIT],
|
|
76
|
+
'contract': [AIAgentCapability.SMART_CONTRACT_AUDIT],
|
|
77
|
+
'smart contract': [AIAgentCapability.SMART_CONTRACT_AUDIT],
|
|
78
|
+
|
|
79
|
+
// Governance
|
|
80
|
+
'governance': [AIAgentCapability.GOVERNANCE_FACILITATION],
|
|
81
|
+
'voting': [AIAgentCapability.GOVERNANCE_FACILITATION],
|
|
82
|
+
'dao': [AIAgentCapability.GOVERNANCE_FACILITATION],
|
|
83
|
+
|
|
84
|
+
// Security
|
|
85
|
+
'security': [AIAgentCapability.SECURITY_MONITORING],
|
|
86
|
+
'monitoring': [AIAgentCapability.SECURITY_MONITORING],
|
|
87
|
+
'threat': [AIAgentCapability.SECURITY_MONITORING],
|
|
88
|
+
|
|
89
|
+
// Compliance
|
|
90
|
+
'compliance': [AIAgentCapability.COMPLIANCE_ANALYSIS],
|
|
91
|
+
'regulatory': [AIAgentCapability.COMPLIANCE_ANALYSIS],
|
|
92
|
+
'regulation': [AIAgentCapability.COMPLIANCE_ANALYSIS],
|
|
93
|
+
|
|
94
|
+
// Fraud
|
|
95
|
+
'fraud': [AIAgentCapability.FRAUD_DETECTION],
|
|
96
|
+
'detection': [AIAgentCapability.FRAUD_DETECTION],
|
|
97
|
+
'anomaly': [AIAgentCapability.FRAUD_DETECTION],
|
|
98
|
+
|
|
99
|
+
// Multi-agent
|
|
100
|
+
'coordination': [AIAgentCapability.MULTI_AGENT_COORDINATION],
|
|
101
|
+
'multi-agent': [AIAgentCapability.MULTI_AGENT_COORDINATION],
|
|
102
|
+
'orchestration': [AIAgentCapability.MULTI_AGENT_COORDINATION],
|
|
103
|
+
|
|
104
|
+
// API
|
|
105
|
+
'api': [AIAgentCapability.API_INTEGRATION],
|
|
106
|
+
'integration': [AIAgentCapability.API_INTEGRATION],
|
|
107
|
+
'webhook': [AIAgentCapability.API_INTEGRATION],
|
|
108
|
+
|
|
109
|
+
// Workflow
|
|
110
|
+
'workflow': [AIAgentCapability.WORKFLOW_AUTOMATION],
|
|
111
|
+
'automation': [AIAgentCapability.WORKFLOW_AUTOMATION],
|
|
112
|
+
'process': [AIAgentCapability.WORKFLOW_AUTOMATION],
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Parse natural language text and extract capability values
|
|
117
|
+
*/
|
|
118
|
+
static parseCapabilities(text: string): AIAgentCapability[] {
|
|
119
|
+
if (!text) return [AIAgentCapability.TEXT_GENERATION];
|
|
120
|
+
|
|
121
|
+
const normalizedText = text.toLowerCase();
|
|
122
|
+
const capabilities = new Set<AIAgentCapability>();
|
|
123
|
+
|
|
124
|
+
// Check for exact matches first
|
|
125
|
+
for (const [term, caps] of Object.entries(this.CAPABILITY_MAPPINGS)) {
|
|
126
|
+
if (normalizedText.includes(term)) {
|
|
127
|
+
caps.forEach(cap => capabilities.add(cap));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Default to TEXT_GENERATION if no capabilities found
|
|
132
|
+
if (capabilities.size === 0) {
|
|
133
|
+
capabilities.add(AIAgentCapability.TEXT_GENERATION);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return Array.from(capabilities);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Parse tags/capabilities from various input formats
|
|
141
|
+
*/
|
|
142
|
+
static parseTagsOrCapabilities(input: any): AIAgentCapability[] {
|
|
143
|
+
// If already an array of numbers, return as is
|
|
144
|
+
if (Array.isArray(input) && input.every(item => typeof item === 'number')) {
|
|
145
|
+
return input;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// If array of strings, parse each
|
|
149
|
+
if (Array.isArray(input) && input.every(item => typeof item === 'string')) {
|
|
150
|
+
const capabilities = new Set<AIAgentCapability>();
|
|
151
|
+
input.forEach(term => {
|
|
152
|
+
this.parseCapabilities(term).forEach(cap => capabilities.add(cap));
|
|
153
|
+
});
|
|
154
|
+
return Array.from(capabilities);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// If single string, parse it
|
|
158
|
+
if (typeof input === 'string') {
|
|
159
|
+
return this.parseCapabilities(input);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Default
|
|
163
|
+
return [AIAgentCapability.TEXT_GENERATION];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Convert capability enum to human-readable name
|
|
168
|
+
*/
|
|
169
|
+
static getCapabilityName(capability: AIAgentCapability): string {
|
|
170
|
+
const names: Record<AIAgentCapability, string> = {
|
|
171
|
+
[AIAgentCapability.TEXT_GENERATION]: 'Text Generation',
|
|
172
|
+
[AIAgentCapability.IMAGE_GENERATION]: 'Image Generation',
|
|
173
|
+
[AIAgentCapability.AUDIO_GENERATION]: 'Audio Generation',
|
|
174
|
+
[AIAgentCapability.VIDEO_GENERATION]: 'Video Generation',
|
|
175
|
+
[AIAgentCapability.CODE_GENERATION]: 'Code Generation',
|
|
176
|
+
[AIAgentCapability.LANGUAGE_TRANSLATION]: 'Language Translation',
|
|
177
|
+
[AIAgentCapability.SUMMARIZATION_EXTRACTION]: 'Summarization & Extraction',
|
|
178
|
+
[AIAgentCapability.KNOWLEDGE_RETRIEVAL]: 'Knowledge Retrieval',
|
|
179
|
+
[AIAgentCapability.DATA_INTEGRATION]: 'Data Integration',
|
|
180
|
+
[AIAgentCapability.MARKET_INTELLIGENCE]: 'Market Intelligence',
|
|
181
|
+
[AIAgentCapability.TRANSACTION_ANALYTICS]: 'Transaction Analytics',
|
|
182
|
+
[AIAgentCapability.SMART_CONTRACT_AUDIT]: 'Smart Contract Audit',
|
|
183
|
+
[AIAgentCapability.GOVERNANCE_FACILITATION]: 'Governance Facilitation',
|
|
184
|
+
[AIAgentCapability.SECURITY_MONITORING]: 'Security Monitoring',
|
|
185
|
+
[AIAgentCapability.COMPLIANCE_ANALYSIS]: 'Compliance Analysis',
|
|
186
|
+
[AIAgentCapability.FRAUD_DETECTION]: 'Fraud Detection',
|
|
187
|
+
[AIAgentCapability.MULTI_AGENT_COORDINATION]: 'Multi-Agent Coordination',
|
|
188
|
+
[AIAgentCapability.API_INTEGRATION]: 'API Integration',
|
|
189
|
+
[AIAgentCapability.WORKFLOW_AUTOMATION]: 'Workflow Automation',
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return names[capability] || 'Unknown Capability';
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { HCS2RegistryType } from '@hashgraphonline/standards-sdk';
|
|
4
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Schema for creating an HCS-2 registry
|
|
8
|
+
*/
|
|
9
|
+
const createRegistrySchema = z.object({
|
|
10
|
+
registryType: z
|
|
11
|
+
.nativeEnum(HCS2RegistryType)
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Registry type: 0 for indexed, 1 for non-indexed (default: 0)'),
|
|
14
|
+
ttl: z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.positive()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Time to live in seconds (default: 86400)'),
|
|
20
|
+
adminKey: z
|
|
21
|
+
.union([z.string(), z.boolean()])
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Admin key: public key string or true to use operator key'),
|
|
24
|
+
submitKey: z
|
|
25
|
+
.union([z.string(), z.boolean()])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Submit key: public key string or true to use operator key'),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Tool for creating HCS-2 registries
|
|
32
|
+
*/
|
|
33
|
+
export class CreateRegistryTool extends BaseHCS2QueryTool<typeof createRegistrySchema> {
|
|
34
|
+
name = 'createHCS2Registry';
|
|
35
|
+
description = 'Create a new HCS-2 registry topic for storing decentralized data';
|
|
36
|
+
|
|
37
|
+
get specificInputSchema() {
|
|
38
|
+
return createRegistrySchema;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected async executeQuery(
|
|
42
|
+
params: z.infer<typeof createRegistrySchema>,
|
|
43
|
+
_runManager?: CallbackManagerForToolRun
|
|
44
|
+
): Promise<unknown> {
|
|
45
|
+
try {
|
|
46
|
+
const result = await this.hcs2Builder.createRegistry({
|
|
47
|
+
registryType: params.registryType,
|
|
48
|
+
ttl: params.ttl,
|
|
49
|
+
adminKey: params.adminKey,
|
|
50
|
+
submitKey: params.submitKey,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
throw new Error(result.error || 'Failed to create registry');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `Successfully created HCS-2 registry!\n\nTopic ID: ${result.topicId}\nRegistry Type: ${params.registryType === 1 ? 'Non-Indexed' : 'Indexed'}\nTTL: ${params.ttl || 86400} seconds\n\nYou can now register entries to this registry using the topic ID.`;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to create HCS-2 registry';
|
|
60
|
+
throw new Error(`Registry creation failed: ${errorMessage}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|