@hashgraphonline/standards-agent-kit 0.2.101 → 0.2.103
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/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 +10 -4
- 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/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.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 +302 -184
- 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 +10 -4
- 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/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 +10 -4
- 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 +33 -31
- 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 +37 -5
- 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
|
@@ -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
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { BaseHCS10TransactionTool } from './base-hcs10-tools';
|
|
10
10
|
import { HCS10TransactionToolParams } from './hcs10-tool-params';
|
|
11
11
|
import { RegisteredAgent } from '../../state/state-types';
|
|
12
|
+
import { NaturalLanguageMapper } from './natural-language-mapper';
|
|
12
13
|
|
|
13
14
|
const RegisterAgentZodSchema = z.object({
|
|
14
15
|
name: z
|
|
@@ -44,9 +45,37 @@ const RegisterAgentZodSchema = z.object({
|
|
|
44
45
|
.optional()
|
|
45
46
|
.describe('AI model identifier (default: agent-model-2024)'),
|
|
46
47
|
capabilities: z
|
|
47
|
-
.
|
|
48
|
+
.union([
|
|
49
|
+
z.array(z.nativeEnum(AIAgentCapability)),
|
|
50
|
+
z.array(z.string()),
|
|
51
|
+
z.string(),
|
|
52
|
+
])
|
|
53
|
+
.optional()
|
|
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
|
+
])
|
|
48
70
|
.optional()
|
|
49
|
-
.
|
|
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.'),
|
|
50
79
|
creator: z.string().optional().describe('Creator attribution for the agent'),
|
|
51
80
|
socials: z
|
|
52
81
|
.record(
|
|
@@ -139,7 +168,7 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
139
168
|
> {
|
|
140
169
|
name = 'register_agent';
|
|
141
170
|
description =
|
|
142
|
-
'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. If alias is set to "random" or contains "random", a unique alias will be generated.';
|
|
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.';
|
|
143
172
|
specificInputSchema = RegisterAgentZodSchema;
|
|
144
173
|
private specificArgs: z.infer<typeof RegisterAgentZodSchema> | undefined;
|
|
145
174
|
|
|
@@ -174,8 +203,11 @@ export class RegisterAgentTool extends BaseHCS10TransactionTool<
|
|
|
174
203
|
if (specificArgs.model !== undefined) {
|
|
175
204
|
params.model = specificArgs.model;
|
|
176
205
|
}
|
|
177
|
-
|
|
178
|
-
|
|
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[];
|
|
179
211
|
}
|
|
180
212
|
if (specificArgs.creator !== undefined) {
|
|
181
213
|
params.creator = specificArgs.creator;
|
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
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for deleting an entry from HCS-2
|
|
7
|
+
*/
|
|
8
|
+
const deleteEntrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID (must be indexed)'),
|
|
13
|
+
uid: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('The unique ID of the entry to delete'),
|
|
16
|
+
memo: z
|
|
17
|
+
.string()
|
|
18
|
+
.max(500)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional memo (max 500 characters)'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tool for deleting entries from HCS-2 registries
|
|
26
|
+
*/
|
|
27
|
+
export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema> {
|
|
28
|
+
name = 'deleteHCS2Entry';
|
|
29
|
+
description = 'Delete an entry from an indexed HCS-2 registry';
|
|
30
|
+
|
|
31
|
+
get specificInputSchema() {
|
|
32
|
+
return deleteEntrySchema;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async executeQuery(
|
|
36
|
+
params: z.infer<typeof deleteEntrySchema>,
|
|
37
|
+
_runManager?: CallbackManagerForToolRun
|
|
38
|
+
): Promise<unknown> {
|
|
39
|
+
try {
|
|
40
|
+
const result = await this.hcs2Builder.deleteEntry(
|
|
41
|
+
params.registryTopicId,
|
|
42
|
+
{
|
|
43
|
+
uid: params.uid,
|
|
44
|
+
memo: params.memo,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
throw new Error(result.error || 'Failed to delete entry');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `Successfully deleted entry from HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nUID: ${params.uid}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been removed from the registry.`;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to delete entry';
|
|
55
|
+
throw new Error(`Entry deletion failed: ${errorMessage}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for migrating an HCS-2 registry
|
|
7
|
+
*/
|
|
8
|
+
const migrateRegistrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The current HCS-2 registry topic ID'),
|
|
13
|
+
targetTopicId: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
16
|
+
.describe('The new topic ID to migrate to'),
|
|
17
|
+
metadata: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional metadata URI for migration details'),
|
|
21
|
+
memo: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(500)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Optional memo (max 500 characters)'),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Tool for migrating HCS-2 registries
|
|
31
|
+
*/
|
|
32
|
+
export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistrySchema> {
|
|
33
|
+
name = 'migrateHCS2Registry';
|
|
34
|
+
description = 'Migrate an HCS-2 registry to a new topic';
|
|
35
|
+
|
|
36
|
+
get specificInputSchema() {
|
|
37
|
+
return migrateRegistrySchema;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected async executeQuery(
|
|
41
|
+
params: z.infer<typeof migrateRegistrySchema>,
|
|
42
|
+
_runManager?: CallbackManagerForToolRun
|
|
43
|
+
): Promise<unknown> {
|
|
44
|
+
try {
|
|
45
|
+
const result = await this.hcs2Builder.migrateRegistry(
|
|
46
|
+
params.registryTopicId,
|
|
47
|
+
{
|
|
48
|
+
targetTopicId: params.targetTopicId,
|
|
49
|
+
metadata: params.metadata,
|
|
50
|
+
memo: params.memo,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
throw new Error(result.error || 'Failed to migrate registry');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return `Successfully migrated HCS-2 registry!\n\nFrom Registry Topic: ${params.registryTopicId}\nTo Target Topic: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe registry has been migrated to the new topic.`;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to migrate registry';
|
|
61
|
+
throw new Error(`Registry migration failed: ${errorMessage}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for querying HCS-2 registry
|
|
7
|
+
*/
|
|
8
|
+
const queryRegistrySchema = z.object({
|
|
9
|
+
topicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID to query'),
|
|
13
|
+
limit: z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.positive()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Maximum number of entries to return'),
|
|
19
|
+
order: z
|
|
20
|
+
.enum(['asc', 'desc'])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Order of results (ascending or descending)'),
|
|
23
|
+
skip: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(0)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Number of entries to skip'),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Tool for querying HCS-2 registries
|
|
34
|
+
*/
|
|
35
|
+
export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySchema> {
|
|
36
|
+
name = 'queryHCS2Registry';
|
|
37
|
+
description = 'Query entries from an HCS-2 registry';
|
|
38
|
+
|
|
39
|
+
get specificInputSchema() {
|
|
40
|
+
return queryRegistrySchema;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected async executeQuery(
|
|
44
|
+
params: z.infer<typeof queryRegistrySchema>,
|
|
45
|
+
_runManager?: CallbackManagerForToolRun
|
|
46
|
+
): Promise<unknown> {
|
|
47
|
+
const registry = await this.hcs2Builder.getRegistry(params.topicId, {
|
|
48
|
+
limit: params.limit,
|
|
49
|
+
order: params.order,
|
|
50
|
+
skip: params.skip,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
topicId: registry.topicId,
|
|
55
|
+
registryType: registry.registryType === 0 ? 'indexed' : 'non-indexed',
|
|
56
|
+
ttl: registry.ttl,
|
|
57
|
+
totalEntries: registry.entries.length,
|
|
58
|
+
entries: registry.entries.map(entry => ({
|
|
59
|
+
sequence: entry.sequence,
|
|
60
|
+
timestamp: entry.timestamp,
|
|
61
|
+
payer: entry.payer,
|
|
62
|
+
operation: entry.message.op,
|
|
63
|
+
targetTopicId: entry.message.t_id,
|
|
64
|
+
uid: entry.message.uid,
|
|
65
|
+
metadata: entry.message.metadata,
|
|
66
|
+
memo: entry.message.m,
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for registering an entry in HCS-2
|
|
7
|
+
*/
|
|
8
|
+
const registerEntrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID (e.g., 0.0.123456)'),
|
|
13
|
+
targetTopicId: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
16
|
+
.describe('The target topic ID to register (e.g., 0.0.123456)'),
|
|
17
|
+
metadata: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional metadata URI (HIP-412 format)'),
|
|
21
|
+
memo: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(500)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Optional memo (max 500 characters)'),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Tool for registering entries in HCS-2 registries
|
|
30
|
+
*/
|
|
31
|
+
export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySchema> {
|
|
32
|
+
name = 'registerHCS2Entry';
|
|
33
|
+
description = 'Register a new entry in an HCS-2 registry';
|
|
34
|
+
|
|
35
|
+
get specificInputSchema() {
|
|
36
|
+
return registerEntrySchema;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async executeQuery(
|
|
40
|
+
params: z.infer<typeof registerEntrySchema>,
|
|
41
|
+
_runManager?: CallbackManagerForToolRun
|
|
42
|
+
): Promise<unknown> {
|
|
43
|
+
try {
|
|
44
|
+
const result = await this.hcs2Builder.registerEntry(
|
|
45
|
+
params.registryTopicId,
|
|
46
|
+
{
|
|
47
|
+
targetTopicId: params.targetTopicId,
|
|
48
|
+
metadata: params.metadata,
|
|
49
|
+
memo: params.memo,
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
throw new Error(result.error || 'Failed to register entry');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `Successfully registered entry in HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nTarget Topic ID: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been added to the registry.`;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to register entry';
|
|
60
|
+
throw new Error(`Entry registration failed: ${errorMessage}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|