@hashgraphonline/conversational-agent 0.2.216 → 0.2.218
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/cli/readme.md +181 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
- package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
- package/dist/cjs/plugins/community/swarm/config.d.ts +6 -0
- package/dist/cjs/plugins/community/swarm/constants.d.ts +8 -0
- package/dist/cjs/plugins/community/swarm/index.d.ts +2 -0
- package/dist/cjs/plugins/community/swarm/model.d.ts +23 -0
- package/dist/cjs/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
- package/dist/cjs/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
- package/dist/cjs/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
- package/dist/cjs/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
- package/dist/cjs/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
- package/dist/cjs/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
- package/dist/cjs/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
- package/dist/cjs/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
- package/dist/cjs/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
- package/dist/cjs/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
- package/dist/cjs/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
- package/dist/cjs/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
- package/dist/cjs/plugins/community/swarm/utils.d.ts +22 -0
- package/dist/cjs/plugins/index.d.ts +1 -0
- package/dist/esm/index.js +33 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index10.js +13 -677
- package/dist/esm/index10.js.map +1 -1
- package/dist/esm/index11.js +601 -234
- package/dist/esm/index11.js.map +1 -1
- package/dist/esm/index12.js +296 -136
- package/dist/esm/index12.js.map +1 -1
- package/dist/esm/index13.js +127 -235
- package/dist/esm/index13.js.map +1 -1
- package/dist/esm/index14.js +247 -84
- package/dist/esm/index14.js.map +1 -1
- package/dist/esm/index15.js +81 -159
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index16.js +155 -229
- package/dist/esm/index16.js.map +1 -1
- package/dist/esm/index17.js +238 -140
- package/dist/esm/index17.js.map +1 -1
- package/dist/esm/index18.js +139 -493
- package/dist/esm/index18.js.map +1 -1
- package/dist/esm/index19.js +479 -91
- package/dist/esm/index19.js.map +1 -1
- package/dist/esm/index20.js +88 -147
- package/dist/esm/index20.js.map +1 -1
- package/dist/esm/index21.js +127 -666
- package/dist/esm/index21.js.map +1 -1
- package/dist/esm/index22.js +698 -44
- package/dist/esm/index22.js.map +1 -1
- package/dist/esm/index23.js +45 -304
- package/dist/esm/index23.js.map +1 -1
- package/dist/esm/index24.js +303 -153
- package/dist/esm/index24.js.map +1 -1
- package/dist/esm/index25.js +150 -117
- package/dist/esm/index25.js.map +1 -1
- package/dist/esm/index26.js +154 -18
- package/dist/esm/index26.js.map +1 -1
- package/dist/esm/index27.js +18 -22
- package/dist/esm/index27.js.map +1 -1
- package/dist/esm/index28.js +15 -74
- package/dist/esm/index28.js.map +1 -1
- package/dist/esm/index29.js +70 -295
- package/dist/esm/index29.js.map +1 -1
- package/dist/esm/index30.js +279 -100
- package/dist/esm/index30.js.map +1 -1
- package/dist/esm/index31.js +86 -922
- package/dist/esm/index31.js.map +1 -1
- package/dist/esm/index32.js +904 -189
- package/dist/esm/index32.js.map +1 -1
- package/dist/esm/index33.js +185 -1169
- package/dist/esm/index33.js.map +1 -1
- package/dist/esm/index34.js +1218 -112
- package/dist/esm/index34.js.map +1 -1
- package/dist/esm/index35.js +111 -99
- package/dist/esm/index35.js.map +1 -1
- package/dist/esm/index36.js +113 -8
- package/dist/esm/index36.js.map +1 -1
- package/dist/esm/index37.js +8 -45
- package/dist/esm/index37.js.map +1 -1
- package/dist/esm/index38.js +41 -102
- package/dist/esm/index38.js.map +1 -1
- package/dist/esm/index39.js +96 -55
- package/dist/esm/index39.js.map +1 -1
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index40.js +58 -71
- package/dist/esm/index40.js.map +1 -1
- package/dist/esm/index41.js +79 -21
- package/dist/esm/index41.js.map +1 -1
- package/dist/esm/index42.js +21 -5
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index43.js +26 -11
- package/dist/esm/index43.js.map +1 -1
- package/dist/esm/index44.js +12 -322
- package/dist/esm/index44.js.map +1 -1
- package/dist/esm/index45.js +66 -173
- package/dist/esm/index45.js.map +1 -1
- package/dist/esm/index46.js +69 -24
- package/dist/esm/index46.js.map +1 -1
- package/dist/esm/index47.js +47 -88
- package/dist/esm/index47.js.map +1 -1
- package/dist/esm/index48.js +100 -7
- package/dist/esm/index48.js.map +1 -1
- package/dist/esm/index49.js +79 -0
- package/dist/esm/index49.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index50.js +75 -0
- package/dist/esm/index50.js.map +1 -0
- package/dist/esm/index51.js +124 -0
- package/dist/esm/index51.js.map +1 -0
- package/dist/esm/index52.js +58 -0
- package/dist/esm/index52.js.map +1 -0
- package/dist/esm/index53.js +83 -0
- package/dist/esm/index53.js.map +1 -0
- package/dist/esm/index54.js +100 -0
- package/dist/esm/index54.js.map +1 -0
- package/dist/esm/index55.js +118 -0
- package/dist/esm/index55.js.map +1 -0
- package/dist/esm/index56.js +108 -0
- package/dist/esm/index56.js.map +1 -0
- package/dist/esm/index57.js +8 -0
- package/dist/esm/index57.js.map +1 -0
- package/dist/esm/index58.js +325 -0
- package/dist/esm/index58.js.map +1 -0
- package/dist/esm/index59.js +187 -0
- package/dist/esm/index59.js.map +1 -0
- package/dist/esm/index6.js +132 -833
- package/dist/esm/index6.js.map +1 -1
- package/dist/esm/index60.js +10 -0
- package/dist/esm/index60.js.map +1 -0
- package/dist/esm/index61.js +98 -0
- package/dist/esm/index61.js.map +1 -0
- package/dist/esm/index62.js +131 -0
- package/dist/esm/index62.js.map +1 -0
- package/dist/esm/index63.js +19 -0
- package/dist/esm/index63.js.map +1 -0
- package/dist/esm/index7.js +826 -75
- package/dist/esm/index7.js.map +1 -1
- package/dist/esm/index8.js +91 -13
- package/dist/esm/index8.js.map +1 -1
- package/dist/esm/index9.js +13 -17
- package/dist/esm/index9.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
- package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
- package/dist/types/plugins/community/swarm/config.d.ts +6 -0
- package/dist/types/plugins/community/swarm/constants.d.ts +8 -0
- package/dist/types/plugins/community/swarm/index.d.ts +2 -0
- package/dist/types/plugins/community/swarm/model.d.ts +23 -0
- package/dist/types/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
- package/dist/types/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
- package/dist/types/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
- package/dist/types/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
- package/dist/types/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
- package/dist/types/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
- package/dist/types/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
- package/dist/types/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
- package/dist/types/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
- package/dist/types/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
- package/dist/types/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
- package/dist/types/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
- package/dist/types/plugins/community/swarm/utils.d.ts +22 -0
- package/dist/types/plugins/index.d.ts +1 -0
- package/package.json +37 -27
- package/src/index.ts +1 -0
- package/src/plugins/community/swarm/README.md +279 -0
- package/src/plugins/community/swarm/SwarmPlugin.ts +178 -0
- package/src/plugins/community/swarm/__tests__/SwarmPlugin.mocks.ts +105 -0
- package/src/plugins/community/swarm/__tests__/SwarmPlugin.test.ts +93 -0
- package/src/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.ts +152 -0
- package/src/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.ts +93 -0
- package/src/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.ts +163 -0
- package/src/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.ts +132 -0
- package/src/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.ts +83 -0
- package/src/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.ts +219 -0
- package/src/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.ts +169 -0
- package/src/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.ts +133 -0
- package/src/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.ts +67 -0
- package/src/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.ts +148 -0
- package/src/plugins/community/swarm/__tests__/tools/UploadDataTool.test.ts +125 -0
- package/src/plugins/community/swarm/__tests__/tools/UploadFileTool.test.ts +194 -0
- package/src/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.ts +118 -0
- package/src/plugins/community/swarm/config.ts +6 -0
- package/src/plugins/community/swarm/constants.ts +12 -0
- package/src/plugins/community/swarm/index.ts +2 -0
- package/src/plugins/community/swarm/model.ts +23 -0
- package/src/plugins/community/swarm/tools/CreatePostageStampTool.ts +137 -0
- package/src/plugins/community/swarm/tools/DownloadDataTool.ts +79 -0
- package/src/plugins/community/swarm/tools/DownloadFilesTool.ts +155 -0
- package/src/plugins/community/swarm/tools/ExtendPostageStampTool.ts +112 -0
- package/src/plugins/community/swarm/tools/GetPostageStampTool.ts +92 -0
- package/src/plugins/community/swarm/tools/ListPostageStampsTool.ts +124 -0
- package/src/plugins/community/swarm/tools/QueryUploadProgressTool.ts +109 -0
- package/src/plugins/community/swarm/tools/ReadFeedTool.ts +110 -0
- package/src/plugins/community/swarm/tools/UpdateFeedTool.ts +149 -0
- package/src/plugins/community/swarm/tools/UploadDataTool.ts +109 -0
- package/src/plugins/community/swarm/tools/UploadFileTool.ts +163 -0
- package/src/plugins/community/swarm/tools/UploadFolderTool.ts +150 -0
- package/src/plugins/community/swarm/utils.ts +172 -0
- package/src/plugins/index.ts +1 -0
- package/cli/dist/CLIApp.d.ts +0 -11
- package/cli/dist/CLIApp.d.ts.map +0 -1
- package/cli/dist/CLIApp.js +0 -128
- package/cli/dist/CLIApp.js.map +0 -1
- package/cli/dist/LocalConversationalAgent.d.ts +0 -37
- package/cli/dist/LocalConversationalAgent.js +0 -58
- package/cli/dist/app.d.ts +0 -18
- package/cli/dist/app.d.ts.map +0 -1
- package/cli/dist/app.js +0 -14
- package/cli/dist/app.js.map +0 -1
- package/cli/dist/cli.d.ts +0 -3
- package/cli/dist/cli.d.ts.map +0 -1
- package/cli/dist/cli.js +0 -87
- package/cli/dist/cli.js.map +0 -1
- package/cli/dist/components/AppContainer.d.ts +0 -16
- package/cli/dist/components/AppContainer.js +0 -24
- package/cli/dist/components/AppScreens.d.ts +0 -2
- package/cli/dist/components/AppScreens.js +0 -259
- package/cli/dist/components/ChatScreen.d.ts +0 -21
- package/cli/dist/components/ChatScreen.d.ts.map +0 -1
- package/cli/dist/components/ChatScreen.js +0 -40
- package/cli/dist/components/ChatScreen.js.map +0 -1
- package/cli/dist/components/DebugLoadingScreen.d.ts +0 -5
- package/cli/dist/components/DebugLoadingScreen.js +0 -31
- package/cli/dist/components/LoadingScreen.d.ts +0 -3
- package/cli/dist/components/LoadingScreen.d.ts.map +0 -1
- package/cli/dist/components/LoadingScreen.js +0 -17
- package/cli/dist/components/LoadingScreen.js.map +0 -1
- package/cli/dist/components/LoadingScreenDebug.d.ts +0 -5
- package/cli/dist/components/LoadingScreenDebug.js +0 -27
- package/cli/dist/components/MCPConfigScreen.d.ts +0 -28
- package/cli/dist/components/MCPConfigScreen.d.ts.map +0 -1
- package/cli/dist/components/MCPConfigScreen.js +0 -186
- package/cli/dist/components/MCPConfigScreen.js.map +0 -1
- package/cli/dist/components/ScreenRouter.d.ts +0 -13
- package/cli/dist/components/ScreenRouter.d.ts.map +0 -1
- package/cli/dist/components/ScreenRouter.js +0 -23
- package/cli/dist/components/ScreenRouter.js.map +0 -1
- package/cli/dist/components/SetupScreen.d.ts +0 -16
- package/cli/dist/components/SetupScreen.d.ts.map +0 -1
- package/cli/dist/components/SetupScreen.js +0 -67
- package/cli/dist/components/SetupScreen.js.map +0 -1
- package/cli/dist/components/SingleLoadingScreen.d.ts +0 -5
- package/cli/dist/components/SingleLoadingScreen.js +0 -27
- package/cli/dist/components/StatusBadge.d.ts +0 -10
- package/cli/dist/components/StatusBadge.d.ts.map +0 -1
- package/cli/dist/components/StatusBadge.js +0 -24
- package/cli/dist/components/StatusBadge.js.map +0 -1
- package/cli/dist/components/TerminalWindow.d.ts +0 -9
- package/cli/dist/components/TerminalWindow.d.ts.map +0 -1
- package/cli/dist/components/TerminalWindow.js +0 -19
- package/cli/dist/components/TerminalWindow.js.map +0 -1
- package/cli/dist/components/WelcomeScreen.d.ts +0 -12
- package/cli/dist/components/WelcomeScreen.d.ts.map +0 -1
- package/cli/dist/components/WelcomeScreen.js +0 -47
- package/cli/dist/components/WelcomeScreen.js.map +0 -1
- package/cli/dist/context/AppContext.d.ts +0 -68
- package/cli/dist/context/AppContext.js +0 -363
- package/cli/dist/headless-runner.d.ts +0 -17
- package/cli/dist/headless-runner.d.ts.map +0 -1
- package/cli/dist/headless-runner.js +0 -128
- package/cli/dist/headless-runner.js.map +0 -1
- package/cli/dist/hooks/useInitializeAgent.d.ts +0 -19
- package/cli/dist/hooks/useInitializeAgent.d.ts.map +0 -1
- package/cli/dist/hooks/useInitializeAgent.js +0 -29
- package/cli/dist/hooks/useInitializeAgent.js.map +0 -1
- package/cli/dist/hooks/useStableState.d.ts +0 -38
- package/cli/dist/hooks/useStableState.d.ts.map +0 -1
- package/cli/dist/hooks/useStableState.js +0 -69
- package/cli/dist/hooks/useStableState.js.map +0 -1
- package/cli/dist/managers/AgentManager.d.ts +0 -58
- package/cli/dist/managers/AgentManager.d.ts.map +0 -1
- package/cli/dist/managers/AgentManager.js +0 -121
- package/cli/dist/managers/AgentManager.js.map +0 -1
- package/cli/dist/managers/ConfigManager.d.ts +0 -54
- package/cli/dist/managers/ConfigManager.d.ts.map +0 -1
- package/cli/dist/managers/ConfigManager.js +0 -188
- package/cli/dist/managers/ConfigManager.js.map +0 -1
- package/cli/dist/types.d.ts +0 -52
- package/cli/dist/types.d.ts.map +0 -1
- package/cli/dist/types.js +0 -34
- package/cli/dist/types.js.map +0 -1
package/dist/esm/index44.js
CHANGED
|
@@ -1,325 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Register a tool with the registry
|
|
15
|
-
*/
|
|
16
|
-
registerTool(tool, options = {}) {
|
|
17
|
-
const capabilities = this.analyzeToolCapabilities(tool);
|
|
18
|
-
const metadata = {
|
|
19
|
-
name: tool.name,
|
|
20
|
-
version: "1.0.0",
|
|
21
|
-
category: options.metadata?.category || "core",
|
|
22
|
-
description: tool.description,
|
|
23
|
-
capabilities,
|
|
24
|
-
dependencies: [],
|
|
25
|
-
schema: tool.schema,
|
|
26
|
-
...options.metadata
|
|
27
|
-
};
|
|
28
|
-
try {
|
|
29
|
-
if (!metadata.entityResolutionPreferences) {
|
|
30
|
-
const schemaRecord = tool.schema;
|
|
31
|
-
const rawPrefs = schemaRecord && typeof schemaRecord === "object" && schemaRecord["_entityResolutionPreferences"];
|
|
32
|
-
if (rawPrefs && typeof rawPrefs === "object") {
|
|
33
|
-
metadata.entityResolutionPreferences = rawPrefs;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch {
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
const schemaRecord = tool.schema;
|
|
40
|
-
const schemaDef = schemaRecord && schemaRecord._def;
|
|
41
|
-
if (schemaDef?.typeName === "ZodObject") {
|
|
42
|
-
const shape = typeof schemaDef.shape === "function" ? schemaDef.shape?.() || {} : schemaDef.shape || {};
|
|
43
|
-
const metadataField = shape["metadata"];
|
|
44
|
-
const isStringArray = !!metadataField && metadataField._def?.typeName === "ZodArray" && metadataField._def?.type?._def?.typeName === "ZodString";
|
|
45
|
-
if (isStringArray && typeof tool.description === "string") {
|
|
46
|
-
if (!metadata.entityResolutionPreferences) {
|
|
47
|
-
metadata.entityResolutionPreferences = {
|
|
48
|
-
inscription: "hrl"
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const note = " NOTE: When referencing inscriptions or media, provide canonical Hashlink Resource Locators (e.g., hcs://<standard>/<topicId>) rather than external URLs or embedded JSON.";
|
|
52
|
-
if (!tool.description.includes("Hashlink Resource Locators")) {
|
|
53
|
-
tool.description = `${tool.description}${note}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
let finalTool = tool;
|
|
60
|
-
let wrapper;
|
|
61
|
-
if (this.shouldWrapTool(tool, capabilities, options)) {
|
|
62
|
-
wrapper = wrapToolWithFormValidation(
|
|
63
|
-
tool,
|
|
64
|
-
this.formGenerator,
|
|
65
|
-
{
|
|
66
|
-
requireAllFields: false,
|
|
67
|
-
skipFields: ["metaOptions"],
|
|
68
|
-
...options.wrapperConfig
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
finalTool = wrapper;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
if (metadata.entityResolutionPreferences) {
|
|
75
|
-
finalTool["entityResolutionPreferences"] = metadata.entityResolutionPreferences;
|
|
76
|
-
}
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
const entry = {
|
|
80
|
-
tool: finalTool,
|
|
81
|
-
metadata,
|
|
82
|
-
wrapper,
|
|
83
|
-
originalTool: tool,
|
|
84
|
-
options: {
|
|
85
|
-
priority: capabilities.priority,
|
|
86
|
-
capability: "basic",
|
|
87
|
-
// Default capability
|
|
88
|
-
enabled: true,
|
|
89
|
-
// All tools are enabled by default
|
|
90
|
-
namespace: metadata.category
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
this.tools.set(tool.name, entry);
|
|
94
|
-
try {
|
|
95
|
-
const metaFG = metadata.fieldGuidance;
|
|
96
|
-
if (metaFG) {
|
|
97
|
-
fieldGuidanceRegistry.registerToolConfiguration(metaFG);
|
|
98
|
-
}
|
|
99
|
-
const provider = metadata.fieldGuidanceProvider;
|
|
100
|
-
if (provider) {
|
|
101
|
-
const pattern = metaFG?.toolPattern ?? tool.name;
|
|
102
|
-
fieldGuidanceRegistry.registerToolProvider(pattern, provider, {
|
|
103
|
-
id: `${tool.name}:field-guidance-provider`,
|
|
104
|
-
priority: 0
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
} catch {
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get a tool by name
|
|
112
|
-
*/
|
|
113
|
-
getTool(name) {
|
|
114
|
-
return this.tools.get(name) || null;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get tools by capability
|
|
118
|
-
*/
|
|
119
|
-
getToolsByCapability(capability, value) {
|
|
120
|
-
const results = [];
|
|
121
|
-
for (const entry of this.tools.values()) {
|
|
122
|
-
if (value !== void 0) {
|
|
123
|
-
if (entry.metadata.capabilities[capability] === value) {
|
|
124
|
-
results.push(entry);
|
|
125
|
-
}
|
|
126
|
-
} else if (entry.metadata.capabilities[capability]) {
|
|
127
|
-
results.push(entry);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return results;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get tools by query
|
|
134
|
-
*/
|
|
135
|
-
getToolsByQuery(query) {
|
|
136
|
-
const results = [];
|
|
137
|
-
for (const entry of this.tools.values()) {
|
|
138
|
-
let matches = true;
|
|
139
|
-
if (query.name && entry.metadata.name !== query.name) {
|
|
140
|
-
matches = false;
|
|
141
|
-
}
|
|
142
|
-
if (query.category && entry.metadata.category !== query.category) {
|
|
143
|
-
matches = false;
|
|
144
|
-
}
|
|
145
|
-
if (query.capabilities) {
|
|
146
|
-
for (const [key, value] of Object.entries(query.capabilities)) {
|
|
147
|
-
if (entry.metadata.capabilities[key] !== value) {
|
|
148
|
-
matches = false;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (matches) {
|
|
154
|
-
results.push(entry);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return results;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Get all registered tools
|
|
161
|
-
*/
|
|
162
|
-
getAllTools() {
|
|
163
|
-
return Array.from(this.tools.values()).map((entry) => entry.tool);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Get all registry entries
|
|
167
|
-
*/
|
|
168
|
-
getAllRegistryEntries() {
|
|
169
|
-
return Array.from(this.tools.values());
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get all tool names
|
|
173
|
-
*/
|
|
174
|
-
getToolNames() {
|
|
175
|
-
return Array.from(this.tools.keys());
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get tools by priority
|
|
179
|
-
*/
|
|
180
|
-
getToolsByPriority(priority) {
|
|
181
|
-
return this.getToolsByCapability("priority", priority);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Get enabled tools (all tools are considered enabled by default)
|
|
185
|
-
*/
|
|
186
|
-
getEnabledTools() {
|
|
187
|
-
return this.getAllRegistryEntries();
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Get tools by namespace/category
|
|
191
|
-
*/
|
|
192
|
-
getToolsByNamespace(namespace) {
|
|
193
|
-
if (!namespace) {
|
|
194
|
-
return this.getAllRegistryEntries();
|
|
195
|
-
}
|
|
196
|
-
return this.getToolsByQuery({ category: namespace });
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Check if registry has capability
|
|
200
|
-
*/
|
|
201
|
-
hasCapability(capability) {
|
|
202
|
-
for (const entry of this.tools.values()) {
|
|
203
|
-
if (entry.metadata.capabilities[capability]) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Update tool options (metadata)
|
|
211
|
-
*/
|
|
212
|
-
updateToolOptions(name, options) {
|
|
213
|
-
const entry = this.tools.get(name);
|
|
214
|
-
if (!entry) {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
entry.metadata = { ...entry.metadata, ...options };
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Check if a tool is registered
|
|
222
|
-
*/
|
|
223
|
-
hasTool(name) {
|
|
224
|
-
return this.tools.has(name);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Unregister a tool
|
|
228
|
-
*/
|
|
229
|
-
unregisterTool(name) {
|
|
230
|
-
return this.tools.delete(name);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Clear all tools
|
|
234
|
-
*/
|
|
235
|
-
clear() {
|
|
236
|
-
this.tools.clear();
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Analyze tool capabilities
|
|
240
|
-
*/
|
|
241
|
-
analyzeToolCapabilities(tool) {
|
|
242
|
-
const implementsFormValidatable = isFormValidatable(tool);
|
|
243
|
-
const hasRenderConfig = this.hasRenderConfig(tool);
|
|
244
|
-
const isZodObjectLike = this.isZodObjectLike(tool.schema);
|
|
245
|
-
const supportsFormValidation = implementsFormValidatable || hasRenderConfig;
|
|
246
|
-
const requiresWrapper = supportsFormValidation && isZodObjectLike;
|
|
247
|
-
let priority = "medium";
|
|
248
|
-
let category = "core";
|
|
249
|
-
if (supportsFormValidation && requiresWrapper) {
|
|
250
|
-
priority = "critical";
|
|
251
|
-
} else if (supportsFormValidation) {
|
|
252
|
-
priority = "high";
|
|
253
|
-
} else if (tool.description?.toLowerCase().includes("query") || tool.description?.toLowerCase().includes("search")) {
|
|
254
|
-
priority = "low";
|
|
255
|
-
}
|
|
256
|
-
const toolAsAny = tool;
|
|
257
|
-
if (tool.constructor.name.includes("MCP") || toolAsAny.isMCPTool) {
|
|
258
|
-
category = "mcp";
|
|
259
|
-
} else if (toolAsAny.isExtension || tool.constructor.name.includes("Extension")) {
|
|
260
|
-
category = "extension";
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
supportsFormValidation,
|
|
264
|
-
requiresWrapper,
|
|
265
|
-
priority,
|
|
266
|
-
category
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Check if tool has render configuration
|
|
271
|
-
*/
|
|
272
|
-
hasRenderConfig(tool) {
|
|
273
|
-
const schema = tool.schema;
|
|
274
|
-
return !!(schema && schema._renderConfig);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Determine if tool should be wrapped
|
|
278
|
-
*/
|
|
279
|
-
shouldWrapTool(tool, capabilities, options) {
|
|
280
|
-
if (options.skipWrapper) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
if (options.forceWrapper) {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
return capabilities.requiresWrapper;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Check if schema is ZodObject-like
|
|
290
|
-
*/
|
|
291
|
-
isZodObjectLike(schema) {
|
|
292
|
-
if (!schema || typeof schema !== "object") {
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
const schemaRecord = schema;
|
|
296
|
-
const schemaDef = schemaRecord._def;
|
|
297
|
-
return schema instanceof z.ZodObject || schemaDef?.typeName === "ZodObject" || "shape" in schemaRecord && typeof schemaRecord.shape === "object";
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Get statistics about the registry
|
|
301
|
-
*/
|
|
302
|
-
getStatistics() {
|
|
303
|
-
const stats = {
|
|
304
|
-
totalTools: this.tools.size,
|
|
305
|
-
wrappedTools: 0,
|
|
306
|
-
unwrappedTools: 0,
|
|
307
|
-
categoryCounts: { core: 0, extension: 0, mcp: 0 },
|
|
308
|
-
priorityCounts: { low: 0, medium: 0, high: 0, critical: 0 }
|
|
309
|
-
};
|
|
310
|
-
for (const entry of this.tools.values()) {
|
|
311
|
-
if (entry.wrapper) {
|
|
312
|
-
stats.wrappedTools++;
|
|
313
|
-
} else {
|
|
314
|
-
stats.unwrappedTools++;
|
|
315
|
-
}
|
|
316
|
-
stats.categoryCounts[entry.metadata.category]++;
|
|
317
|
-
stats.priorityCounts[entry.metadata.capabilities.priority]++;
|
|
318
|
-
}
|
|
319
|
-
return stats;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
1
|
+
import { EntityFormat } from "./index27.js";
|
|
2
|
+
const ENTITY_PATTERNS = {
|
|
3
|
+
TOPIC_REFERENCE: "the topic",
|
|
4
|
+
TOKEN_REFERENCE: "the token"
|
|
5
|
+
};
|
|
6
|
+
({
|
|
7
|
+
TOPIC: EntityFormat.TOPIC_ID,
|
|
8
|
+
TOKEN: EntityFormat.TOKEN_ID,
|
|
9
|
+
ACCOUNT: EntityFormat.ACCOUNT_ID,
|
|
10
|
+
CONTRACT: EntityFormat.CONTRACT_ID
|
|
11
|
+
});
|
|
322
12
|
export {
|
|
323
|
-
|
|
13
|
+
ENTITY_PATTERNS
|
|
324
14
|
};
|
|
325
15
|
//# sourceMappingURL=index44.js.map
|
package/dist/esm/index44.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index44.js","sources":["../../src/core/tool-registry.ts"],"sourcesContent":["import { StructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport {\n FormValidatingToolWrapper,\n wrapToolWithFormValidation,\n} from '../langchain/form-validating-tool-wrapper';\nimport { FormGenerator } from '../forms/form-generator';\nimport {\n fieldGuidanceRegistry,\n} from '../forms/field-guidance-registry';\nimport type {\n ToolFieldConfiguration as FG_ToolFieldConfiguration,\n FieldGuidanceProvider as FG_FieldGuidanceProvider,\n} from '../forms/field-guidance-registry';\nimport { isFormValidatable } from '@hashgraphonline/standards-agent-kit';\n\n/**\n * Tool capabilities configuration for registry entries\n */\nexport interface ToolCapabilities {\n supportsFormValidation: boolean;\n requiresWrapper: boolean;\n priority: 'low' | 'medium' | 'high' | 'critical';\n category: 'core' | 'extension' | 'mcp';\n}\n\n/**\n * Entity resolution format preferences for tools\n */\nexport interface EntityResolutionPreferences {\n inscription?: 'hrl' | 'topicId' | 'metadata' | 'any';\n token?: 'tokenId' | 'address' | 'symbol' | 'any';\n nft?: 'serialNumber' | 'metadata' | 'hrl' | 'any';\n account?: 'accountId' | 'alias' | 'evmAddress' | 'any';\n}\n\n/**\n * Tool metadata for comprehensive tool information\n */\nexport interface ToolMetadata {\n name: string;\n version: string;\n category: ToolCapabilities['category'];\n description: string;\n capabilities: ToolCapabilities;\n dependencies: string[];\n schema: unknown;\n entityResolutionPreferences?: EntityResolutionPreferences;\n fieldGuidance?: FG_ToolFieldConfiguration;\n fieldGuidanceProvider?: FG_FieldGuidanceProvider;\n}\n\n/**\n * Registry entry containing tool instance and metadata\n */\nexport interface ToolRegistryEntry {\n tool: StructuredTool;\n metadata: ToolMetadata;\n wrapper?: FormValidatingToolWrapper<z.ZodObject<z.ZodRawShape>> | undefined;\n originalTool: StructuredTool;\n options?: {\n priority?: ToolCapabilities['priority'];\n capability?: string;\n enabled?: boolean;\n namespace?: string;\n };\n}\n\n/**\n * Options for tool registration\n */\nexport interface ToolRegistrationOptions {\n forceWrapper?: boolean;\n skipWrapper?: boolean;\n wrapperConfig?: {\n requireAllFields?: boolean;\n skipFields?: string[];\n };\n metadata?: Partial<ToolMetadata>;\n}\n\n/**\n * Query interface for finding tools\n */\nexport interface ToolQuery {\n name?: string;\n category?: ToolMetadata['category'];\n capabilities?: Partial<ToolCapabilities>;\n}\n\n/**\n * Centralized tool registry for managing tool lifecycle\n */\nexport class ToolRegistry {\n private tools = new Map<string, ToolRegistryEntry>();\n private formGenerator: FormGenerator;\n private logger: Logger;\n\n constructor(logger?: Logger) {\n this.formGenerator = new FormGenerator();\n this.logger = logger || new Logger({ module: 'ToolRegistry' });\n }\n\n /**\n * Register a tool with the registry\n */\n registerTool(\n tool: StructuredTool,\n options: ToolRegistrationOptions = {}\n ): void {\n const capabilities = this.analyzeToolCapabilities(tool);\n const metadata: ToolMetadata = {\n name: tool.name,\n version: '1.0.0',\n category: options.metadata?.category || 'core',\n description: tool.description,\n capabilities,\n dependencies: [],\n schema: tool.schema,\n ...options.metadata,\n };\n\n try {\n if (!metadata.entityResolutionPreferences) {\n const schemaRecord = tool.schema as unknown as Record<string, unknown>;\n const rawPrefs =\n schemaRecord &&\n typeof schemaRecord === 'object' &&\n (schemaRecord as Record<string, unknown>)[\n '_entityResolutionPreferences'\n ];\n if (rawPrefs && typeof rawPrefs === 'object') {\n metadata.entityResolutionPreferences = rawPrefs as unknown as EntityResolutionPreferences;\n }\n }\n } catch {\n }\n\n try {\n const schemaRecord = tool.schema as unknown as Record<string, unknown>;\n const schemaDef = (schemaRecord && (schemaRecord as Record<string, unknown>)._def) as\n | { typeName?: string; shape?: unknown }\n | undefined;\n if (schemaDef?.typeName === 'ZodObject') {\n const shape: Record<string, unknown> =\n typeof (schemaDef as { shape?: () => Record<string, unknown> }).shape === 'function'\n ? ((schemaDef as { shape: () => Record<string, unknown> }).shape?.() || {})\n : ((schemaDef as { shape?: Record<string, unknown> }).shape || {});\n\n const metadataField = shape['metadata'] as\n | { _def?: { typeName?: string; type?: { _def?: { typeName?: string } } } }\n | undefined;\n const isStringArray =\n !!metadataField &&\n metadataField._def?.typeName === 'ZodArray' &&\n metadataField._def?.type?._def?.typeName === 'ZodString';\n\n if (isStringArray && typeof tool.description === 'string') {\n if (!metadata.entityResolutionPreferences) {\n metadata.entityResolutionPreferences = {\n inscription: 'hrl',\n } as EntityResolutionPreferences;\n }\n const note =\n ' NOTE: When referencing inscriptions or media, provide canonical Hashlink Resource Locators (e.g., hcs://<standard>/<topicId>) rather than external URLs or embedded JSON.';\n if (!tool.description.includes('Hashlink Resource Locators')) {\n (tool as unknown as { description: string }).description = `${tool.description}${note}`;\n }\n }\n }\n } catch {}\n\n let finalTool: StructuredTool = tool;\n let wrapper:\n | FormValidatingToolWrapper<z.ZodObject<z.ZodRawShape>>\n | undefined;\n\n if (this.shouldWrapTool(tool, capabilities, options)) {\n wrapper = wrapToolWithFormValidation(\n tool as StructuredTool<z.ZodObject<z.ZodRawShape>>,\n this.formGenerator,\n {\n requireAllFields: false,\n skipFields: ['metaOptions'],\n ...options.wrapperConfig,\n }\n ) as FormValidatingToolWrapper<z.ZodObject<z.ZodRawShape>>;\n finalTool = wrapper as StructuredTool;\n }\n\n try {\n if (metadata.entityResolutionPreferences) {\n (finalTool as unknown as Record<string, unknown>)[\n 'entityResolutionPreferences'\n ] = metadata.entityResolutionPreferences;\n }\n } catch {\n }\n\n const entry: ToolRegistryEntry = {\n tool: finalTool,\n metadata,\n wrapper,\n originalTool: tool,\n options: {\n priority: capabilities.priority,\n capability: 'basic', // Default capability\n enabled: true, // All tools are enabled by default\n namespace: metadata.category,\n },\n };\n\n this.tools.set(tool.name, entry);\n\n try {\n const metaFG = metadata.fieldGuidance as FG_ToolFieldConfiguration | undefined;\n if (metaFG) {\n fieldGuidanceRegistry.registerToolConfiguration(metaFG);\n }\n const provider = metadata.fieldGuidanceProvider as FG_FieldGuidanceProvider | undefined;\n if (provider) {\n const pattern = metaFG?.toolPattern ?? tool.name;\n fieldGuidanceRegistry.registerToolProvider(pattern, provider, {\n id: `${tool.name}:field-guidance-provider`,\n priority: 0,\n });\n }\n } catch {}\n }\n\n /**\n * Get a tool by name\n */\n getTool(name: string): ToolRegistryEntry | null {\n return this.tools.get(name) || null;\n }\n\n /**\n * Get tools by capability\n */\n getToolsByCapability(\n capability: keyof ToolCapabilities,\n value?: unknown\n ): ToolRegistryEntry[] {\n const results: ToolRegistryEntry[] = [];\n\n for (const entry of this.tools.values()) {\n if (value !== undefined) {\n if (entry.metadata.capabilities[capability] === value) {\n results.push(entry);\n }\n } else if (entry.metadata.capabilities[capability]) {\n results.push(entry);\n }\n }\n\n return results;\n }\n\n /**\n * Get tools by query\n */\n getToolsByQuery(query: ToolQuery): ToolRegistryEntry[] {\n const results: ToolRegistryEntry[] = [];\n\n for (const entry of this.tools.values()) {\n let matches = true;\n\n if (query.name && entry.metadata.name !== query.name) {\n matches = false;\n }\n\n if (query.category && entry.metadata.category !== query.category) {\n matches = false;\n }\n\n if (query.capabilities) {\n for (const [key, value] of Object.entries(query.capabilities)) {\n if (\n entry.metadata.capabilities[key as keyof ToolCapabilities] !== value\n ) {\n matches = false;\n break;\n }\n }\n }\n\n if (matches) {\n results.push(entry);\n }\n }\n\n return results;\n }\n\n /**\n * Get all registered tools\n */\n getAllTools(): StructuredTool[] {\n return Array.from(this.tools.values()).map((entry) => entry.tool);\n }\n\n /**\n * Get all registry entries\n */\n getAllRegistryEntries(): ToolRegistryEntry[] {\n return Array.from(this.tools.values());\n }\n\n /**\n * Get all tool names\n */\n getToolNames(): string[] {\n return Array.from(this.tools.keys());\n }\n\n /**\n * Get tools by priority\n */\n getToolsByPriority(priority: ToolCapabilities['priority']): ToolRegistryEntry[] {\n return this.getToolsByCapability('priority', priority);\n }\n\n /**\n * Get enabled tools (all tools are considered enabled by default)\n */\n getEnabledTools(): ToolRegistryEntry[] {\n return this.getAllRegistryEntries();\n }\n\n /**\n * Get tools by namespace/category\n */\n getToolsByNamespace(namespace?: string): ToolRegistryEntry[] {\n if (!namespace) {\n return this.getAllRegistryEntries();\n }\n return this.getToolsByQuery({ category: namespace as ToolMetadata['category'] });\n }\n\n /**\n * Check if registry has capability\n */\n hasCapability(capability: keyof ToolCapabilities): boolean {\n for (const entry of this.tools.values()) {\n if (entry.metadata.capabilities[capability]) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Update tool options (metadata)\n */\n updateToolOptions(name: string, options: Partial<ToolMetadata>): boolean {\n const entry = this.tools.get(name);\n if (!entry) {\n return false;\n }\n\n entry.metadata = { ...entry.metadata, ...options };\n return true;\n }\n\n /**\n * Check if a tool is registered\n */\n hasTool(name: string): boolean {\n return this.tools.has(name);\n }\n\n /**\n * Unregister a tool\n */\n unregisterTool(name: string): boolean {\n return this.tools.delete(name);\n }\n\n /**\n * Clear all tools\n */\n clear(): void {\n this.tools.clear();\n }\n\n /**\n * Analyze tool capabilities\n */\n private analyzeToolCapabilities(tool: StructuredTool): ToolCapabilities {\n const implementsFormValidatable = isFormValidatable(tool);\n const hasRenderConfig = this.hasRenderConfig(tool);\n const isZodObjectLike = this.isZodObjectLike(tool.schema);\n\n const supportsFormValidation = implementsFormValidatable || hasRenderConfig;\n const requiresWrapper = supportsFormValidation && isZodObjectLike;\n\n let priority: ToolCapabilities['priority'] = 'medium';\n let category: ToolCapabilities['category'] = 'core';\n\n if (supportsFormValidation && requiresWrapper) {\n priority = 'critical';\n } else if (supportsFormValidation) {\n priority = 'high';\n } else if (\n tool.description?.toLowerCase().includes('query') ||\n tool.description?.toLowerCase().includes('search')\n ) {\n priority = 'low';\n }\n\n const toolAsAny = tool as unknown as Record<string, unknown>;\n if (tool.constructor.name.includes('MCP') || toolAsAny.isMCPTool) {\n category = 'mcp';\n } else if (\n toolAsAny.isExtension ||\n tool.constructor.name.includes('Extension')\n ) {\n category = 'extension';\n }\n\n return {\n supportsFormValidation,\n requiresWrapper,\n priority,\n category,\n };\n }\n\n /**\n * Check if tool has render configuration\n */\n private hasRenderConfig(tool: StructuredTool): boolean {\n const schema = tool.schema as Record<string, unknown>;\n return !!(schema && schema._renderConfig);\n }\n\n /**\n * Determine if tool should be wrapped\n */\n private shouldWrapTool(\n tool: StructuredTool,\n capabilities: ToolCapabilities,\n options: ToolRegistrationOptions\n ): boolean {\n if (options.skipWrapper) {\n return false;\n }\n\n if (options.forceWrapper) {\n return true;\n }\n\n return capabilities.requiresWrapper;\n }\n\n /**\n * Check if schema is ZodObject-like\n */\n private isZodObjectLike(schema: unknown): boolean {\n if (!schema || typeof schema !== 'object') {\n return false;\n }\n\n const schemaRecord = schema as Record<string, unknown>;\n const schemaDef = schemaRecord._def as Record<string, unknown> | undefined;\n\n return (\n schema instanceof z.ZodObject ||\n schemaDef?.typeName === 'ZodObject' ||\n ('shape' in schemaRecord && typeof schemaRecord.shape === 'object')\n );\n }\n\n /**\n * Get statistics about the registry\n */\n getStatistics(): {\n totalTools: number;\n wrappedTools: number;\n unwrappedTools: number;\n categoryCounts: Record<ToolCapabilities['category'], number>;\n priorityCounts: Record<ToolCapabilities['priority'], number>;\n } {\n const stats = {\n totalTools: this.tools.size,\n wrappedTools: 0,\n unwrappedTools: 0,\n categoryCounts: { core: 0, extension: 0, mcp: 0 } as Record<\n ToolCapabilities['category'],\n number\n >,\n priorityCounts: { low: 0, medium: 0, high: 0, critical: 0 } as Record<\n ToolCapabilities['priority'],\n number\n >,\n };\n\n for (const entry of this.tools.values()) {\n if (entry.wrapper) {\n stats.wrappedTools++;\n } else {\n stats.unwrappedTools++;\n }\n\n stats.categoryCounts[entry.metadata.category]++;\n stats.priorityCounts[entry.metadata.capabilities.priority]++;\n }\n\n return stats;\n }\n}\n"],"names":[],"mappings":";;;;;;AA8FO,MAAM,aAAa;AAAA,EAKxB,YAAY,QAAiB;AAJ7B,SAAQ,4BAAY,IAAA;AAKlB,SAAK,gBAAgB,IAAI,cAAA;AACzB,SAAK,SAAS,UAAU,IAAI,OAAO,EAAE,QAAQ,gBAAgB;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,aACE,MACA,UAAmC,IAC7B;AACN,UAAM,eAAe,KAAK,wBAAwB,IAAI;AACtD,UAAM,WAAyB;AAAA,MAC7B,MAAM,KAAK;AAAA,MACX,SAAS;AAAA,MACT,UAAU,QAAQ,UAAU,YAAY;AAAA,MACxC,aAAa,KAAK;AAAA,MAClB;AAAA,MACA,cAAc,CAAA;AAAA,MACd,QAAQ,KAAK;AAAA,MACb,GAAG,QAAQ;AAAA,IAAA;AAGb,QAAI;AACF,UAAI,CAAC,SAAS,6BAA6B;AACzC,cAAM,eAAe,KAAK;AAC1B,cAAM,WACJ,gBACA,OAAO,iBAAiB,YACvB,aACC,8BACF;AACF,YAAI,YAAY,OAAO,aAAa,UAAU;AAC5C,mBAAS,8BAA8B;AAAA,QACzC;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IACR;AAEA,QAAI;AACF,YAAM,eAAe,KAAK;AAC1B,YAAM,YAAa,gBAAiB,aAAyC;AAG7E,UAAI,WAAW,aAAa,aAAa;AACvC,cAAM,QACJ,OAAQ,UAAwD,UAAU,aACpE,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AM,eAAe;AACrB,UAAM,YAAY,aAAa;AAE/B,WACE,kBAAkB,EAAE,aACpB,WAAW,aAAa,eACvB,WAAW,gBAAgB,OAAO,aAAa,UAAU;AAAA,EAE9D;AAAA;AAAA;AAAA;AAAA,EAKA,gBAME;AACA,UAAM,QAAQ;AAAA,MACZ,YAAY,KAAK,MAAM;AAAA,MACvB,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,gBAAgB,EAAE,MAAM,GAAG,WAAW,GAAG,KAAK,EAAA;AAAA,MAI9C,gBAAgB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,EAAA;AAAA,IAAE;AAM5D,eAAW,SAAS,KAAK,MAAM,OAAA,GAAU;AACvC,UAAI,MAAM,SAAS;AACjB,cAAM;AAAA,MACR,OAAO;AACL,cAAM;AAAA,MACR;AAEA,YAAM,eAAe,MAAM,SAAS,QAAQ;AAC5C,YAAM,eAAe,MAAM,SAAS,aAAa,QAAQ;AAAA,IAC3D;AAEA,WAAO;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"index44.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}
|
package/dist/esm/index45.js
CHANGED
|
@@ -1,187 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { BaseHederaQueryTool } from "hedera-agent-kit";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { errorHasStatus, getBatchSummary, getResponseWithStructuredContent } from "./index62.js";
|
|
4
|
+
import { NOT_FOUND_STATUS, GATEWAY_STAMP_ERROR_MESSAGE } from "./index63.js";
|
|
5
|
+
const ListPostageStampsSchema = z.object({
|
|
6
|
+
leastUsed: z.boolean().optional(),
|
|
7
|
+
limit: z.number().optional(),
|
|
8
|
+
minUsage: z.number().optional(),
|
|
9
|
+
maxUsage: z.number().optional()
|
|
10
|
+
});
|
|
11
|
+
class ListPostageStampsTool extends BaseHederaQueryTool {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
const { bee, config, ...rest } = params;
|
|
14
|
+
super(rest);
|
|
15
|
+
this.name = "swarm-list-postage-stamps";
|
|
16
|
+
this.description = `
|
|
17
|
+
List the available postage stamps.
|
|
18
|
+
leastUsed: A boolean value that tells if stamps are sorted so least used comes first.
|
|
19
|
+
limit: Limit is the maximum number of returned stamps.
|
|
20
|
+
minUsage: Only list stamps with at least this usage percentage.
|
|
21
|
+
maxUsage: Only list stamps with at most this usage percentage.
|
|
22
|
+
`;
|
|
23
|
+
this.namespace = "swarm";
|
|
24
|
+
this.specificInputSchema = ListPostageStampsSchema;
|
|
25
|
+
this.bee = bee;
|
|
26
|
+
this.config = config;
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
async execute(toolName, input, sessionContext) {
|
|
14
|
-
const traceId = `trace-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
const startTime = Date.now();
|
|
16
|
-
const toolEntry = this.toolRegistry.getTool(toolName);
|
|
17
|
-
if (!toolEntry) {
|
|
18
|
-
throw new Error(`Tool not found in registry: ${toolName}`);
|
|
19
|
-
}
|
|
20
|
-
const context = {
|
|
21
|
-
toolName,
|
|
22
|
-
input,
|
|
23
|
-
session: sessionContext || this.buildDefaultSession(),
|
|
24
|
-
memory: this.memory,
|
|
25
|
-
traceId,
|
|
26
|
-
toolEntry
|
|
27
|
-
};
|
|
28
|
+
async executeQuery(input) {
|
|
29
|
+
const { leastUsed, limit, minUsage, maxUsage } = input;
|
|
30
|
+
let rawPostageBatches;
|
|
28
31
|
try {
|
|
29
|
-
|
|
30
|
-
if (shouldGenerateForm.requiresForm && shouldGenerateForm.formMessage) {
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
output: "Form generation required",
|
|
34
|
-
requiresForm: true,
|
|
35
|
-
formMessage: shouldGenerateForm.formMessage,
|
|
36
|
-
traceId,
|
|
37
|
-
executionTime: Date.now() - startTime
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const result = await this.executeToolDirect(context);
|
|
41
|
-
return {
|
|
42
|
-
success: true,
|
|
43
|
-
output: result,
|
|
44
|
-
traceId,
|
|
45
|
-
executionTime: Date.now() - startTime
|
|
46
|
-
};
|
|
32
|
+
rawPostageBatches = await this.bee.getPostageBatches();
|
|
47
33
|
} catch (error) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
let errorMessage = "Retrieval of postage batches failed.";
|
|
35
|
+
if (errorHasStatus(error, NOT_FOUND_STATUS)) {
|
|
36
|
+
errorMessage = GATEWAY_STAMP_ERROR_MESSAGE;
|
|
37
|
+
}
|
|
38
|
+
this.logger.error(
|
|
39
|
+
errorMessage,
|
|
40
|
+
error
|
|
53
41
|
);
|
|
42
|
+
throw new Error(errorMessage);
|
|
54
43
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const processedInput = await this.formEngine.processSubmission(
|
|
76
|
-
formSubmission
|
|
44
|
+
const batches = rawPostageBatches.map((batch) => ({
|
|
45
|
+
...batch,
|
|
46
|
+
batchID: batch.batchID.toHex()
|
|
47
|
+
}));
|
|
48
|
+
let filteredPostageBatches = batches.filter((batch) => {
|
|
49
|
+
if (!batch.usable) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const usagePercentage = batch.usage * 100;
|
|
53
|
+
if (minUsage !== void 0 && usagePercentage < minUsage) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (maxUsage !== void 0 && usagePercentage > maxUsage) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
});
|
|
61
|
+
if (Boolean(leastUsed) && filteredPostageBatches.length) {
|
|
62
|
+
filteredPostageBatches = filteredPostageBatches.sort(
|
|
63
|
+
(batch1, batch2) => batch1.usage - batch2.usage
|
|
77
64
|
);
|
|
78
|
-
return this.execute(toolName, processedInput, sessionContext);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
return {
|
|
81
|
-
success: false,
|
|
82
|
-
output: "Form submission processing failed",
|
|
83
|
-
error: error instanceof Error ? error.message : String(error),
|
|
84
|
-
traceId,
|
|
85
|
-
executionTime: Date.now() - startTime
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if form generation is required
|
|
91
|
-
*/
|
|
92
|
-
async checkFormGeneration(context) {
|
|
93
|
-
const inputRecord = context.input;
|
|
94
|
-
if (inputRecord?.__fromForm === true || inputRecord?.renderForm === false) {
|
|
95
|
-
return { requiresForm: false };
|
|
96
65
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
66
|
+
if (limit !== void 0 && limit < filteredPostageBatches.length) {
|
|
67
|
+
filteredPostageBatches = filteredPostageBatches.slice(0, limit);
|
|
99
68
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
if (formMessage) {
|
|
106
|
-
return { requiresForm: true, formMessage };
|
|
107
|
-
}
|
|
108
|
-
return { requiresForm: false };
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Execute tool directly
|
|
112
|
-
*/
|
|
113
|
-
async executeToolDirect(context) {
|
|
114
|
-
const { toolEntry, input } = context;
|
|
115
|
-
const parameters = input || {};
|
|
116
|
-
const mergedArgs = { ...parameters, renderForm: false };
|
|
117
|
-
if (toolEntry.wrapper) {
|
|
118
|
-
return this.executeWrappedTool(toolEntry, mergedArgs);
|
|
119
|
-
}
|
|
120
|
-
return await toolEntry.tool.call(mergedArgs);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Execute wrapped tool
|
|
124
|
-
*/
|
|
125
|
-
async executeWrappedTool(toolEntry, mergedArgs) {
|
|
126
|
-
const wrapper = toolEntry.wrapper;
|
|
127
|
-
if (!wrapper) {
|
|
128
|
-
throw new Error("Tool wrapper not found");
|
|
129
|
-
}
|
|
130
|
-
const wrapperAsAny = wrapper;
|
|
131
|
-
if (wrapperAsAny.executeOriginal) {
|
|
132
|
-
return await wrapperAsAny.executeOriginal(mergedArgs);
|
|
133
|
-
}
|
|
134
|
-
if (wrapperAsAny.originalTool?.call) {
|
|
135
|
-
return await wrapperAsAny.originalTool.call(mergedArgs);
|
|
136
|
-
}
|
|
137
|
-
return await toolEntry.originalTool.call(mergedArgs);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Handle execution error
|
|
141
|
-
*/
|
|
142
|
-
handleExecutionError(error, context, traceId, executionTime) {
|
|
143
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
-
if (error instanceof ZodError) {
|
|
145
|
-
return {
|
|
146
|
-
success: false,
|
|
147
|
-
output: "Validation error occurred",
|
|
148
|
-
error: errorMessage,
|
|
149
|
-
traceId,
|
|
150
|
-
executionTime
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
this.logger.error(`Tool execution failed: ${context.toolName}`, {
|
|
154
|
-
traceId,
|
|
155
|
-
error: errorMessage
|
|
156
|
-
});
|
|
157
|
-
return {
|
|
158
|
-
success: false,
|
|
159
|
-
output: "Tool execution failed",
|
|
160
|
-
error: errorMessage,
|
|
161
|
-
traceId,
|
|
162
|
-
executionTime
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Build default session context
|
|
167
|
-
*/
|
|
168
|
-
buildDefaultSession() {
|
|
169
|
-
return {
|
|
170
|
-
sessionId: `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
171
|
-
timestamp: Date.now()
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get statistics about the pipeline
|
|
176
|
-
*/
|
|
177
|
-
getStatistics() {
|
|
178
|
-
return {
|
|
179
|
-
totalMiddleware: 0,
|
|
180
|
-
registeredMiddleware: []
|
|
69
|
+
const computedPostageBatches = filteredPostageBatches.map((batch) => getBatchSummary(batch));
|
|
70
|
+
const content = {
|
|
71
|
+
raw: filteredPostageBatches,
|
|
72
|
+
summary: computedPostageBatches
|
|
181
73
|
};
|
|
74
|
+
return getResponseWithStructuredContent(content);
|
|
182
75
|
}
|
|
183
76
|
}
|
|
184
77
|
export {
|
|
185
|
-
|
|
78
|
+
ListPostageStampsTool
|
|
186
79
|
};
|
|
187
80
|
//# sourceMappingURL=index45.js.map
|