@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/index24.js
CHANGED
|
@@ -1,190 +1,340 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Logger
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
async updateConfig(config) {
|
|
49
|
-
const referenceConfig = {
|
|
50
|
-
sizeThresholdBytes: config.maxSize || 10240,
|
|
51
|
-
enableAutoCleanup: config.enableCompression || true,
|
|
52
|
-
...config
|
|
53
|
-
};
|
|
54
|
-
return await this.storage.updateConfig(referenceConfig);
|
|
55
|
-
}
|
|
56
|
-
async performCleanup() {
|
|
57
|
-
await this.storage.performCleanup();
|
|
58
|
-
}
|
|
59
|
-
async dispose() {
|
|
60
|
-
return Promise.resolve(this.storage.dispose());
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
class ContentResolver {
|
|
64
|
-
constructor(adapter) {
|
|
65
|
-
this.adapter = adapter;
|
|
66
|
-
}
|
|
67
|
-
async resolveReference(referenceId) {
|
|
68
|
-
return await this.adapter.resolveReference(referenceId);
|
|
69
|
-
}
|
|
70
|
-
shouldUseReference(content) {
|
|
71
|
-
return shouldUseReference(content);
|
|
72
|
-
}
|
|
73
|
-
extractReferenceId(input) {
|
|
74
|
-
return extractReferenceId(input);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
class ContentStoreManager {
|
|
78
|
-
constructor(maxMessageStorage = 1e3, referenceConfig, logger) {
|
|
79
|
-
this.isRegistered = false;
|
|
80
|
-
this.logger = logger || new Logger({ module: "ContentStoreManager" });
|
|
81
|
-
this.contentStorage = new ContentStorage(
|
|
82
|
-
maxMessageStorage,
|
|
83
|
-
referenceConfig
|
|
84
|
-
);
|
|
85
|
-
this.adapter = new ContentStorageAdapter(this.contentStorage);
|
|
86
|
-
this.resolver = new ContentResolver(this.adapter);
|
|
1
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
2
|
+
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
3
|
+
import { ENTITY_PATTERNS } from "./index44.js";
|
|
4
|
+
import "hedera-agent-kit";
|
|
5
|
+
import "@hashgraphonline/standards-agent-kit";
|
|
6
|
+
import "./index14.js";
|
|
7
|
+
import "./index38.js";
|
|
8
|
+
import "@langchain/core/tools";
|
|
9
|
+
import "zod";
|
|
10
|
+
import "@ethersphere/bee-js";
|
|
11
|
+
import "./index45.js";
|
|
12
|
+
import "./index46.js";
|
|
13
|
+
import "./index47.js";
|
|
14
|
+
import "./index48.js";
|
|
15
|
+
import "./index49.js";
|
|
16
|
+
import "./index50.js";
|
|
17
|
+
import "./index51.js";
|
|
18
|
+
import "./index52.js";
|
|
19
|
+
import "./index53.js";
|
|
20
|
+
import "./index54.js";
|
|
21
|
+
import "./index55.js";
|
|
22
|
+
import "./index56.js";
|
|
23
|
+
import "./index7.js";
|
|
24
|
+
import "langchain/agents";
|
|
25
|
+
import "zod-to-json-schema";
|
|
26
|
+
import "./index13.js";
|
|
27
|
+
import "@langchain/core/prompts";
|
|
28
|
+
import "@modelcontextprotocol/sdk/client/index.js";
|
|
29
|
+
import "@modelcontextprotocol/sdk/client/stdio.js";
|
|
30
|
+
import "./index19.js";
|
|
31
|
+
import "@langchain/core/messages";
|
|
32
|
+
import "./index20.js";
|
|
33
|
+
import "./index21.js";
|
|
34
|
+
import "./index22.js";
|
|
35
|
+
import "crypto";
|
|
36
|
+
import { EntityFormat } from "./index27.js";
|
|
37
|
+
import "./index29.js";
|
|
38
|
+
import "./index35.js";
|
|
39
|
+
class EntityResolver {
|
|
40
|
+
constructor(config) {
|
|
41
|
+
this.llm = new ChatOpenAI({
|
|
42
|
+
apiKey: config.apiKey,
|
|
43
|
+
modelName: config.modelName || "gpt-4o-mini",
|
|
44
|
+
temperature: 0
|
|
45
|
+
});
|
|
46
|
+
this.logger = new Logger({ module: "EntityResolver" });
|
|
87
47
|
}
|
|
88
48
|
/**
|
|
89
|
-
*
|
|
49
|
+
* Resolve entity references using LLM instead of regex
|
|
90
50
|
*/
|
|
91
|
-
async
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
51
|
+
async resolveReferences(message, entities) {
|
|
52
|
+
if (!entities || entities.length === 0) {
|
|
53
|
+
return message;
|
|
54
|
+
}
|
|
55
|
+
const byType = entities.reduce((acc, e) => {
|
|
56
|
+
if (!acc[e.entityType]) acc[e.entityType] = [];
|
|
57
|
+
acc[e.entityType].push(e);
|
|
58
|
+
return acc;
|
|
59
|
+
}, {});
|
|
60
|
+
try {
|
|
61
|
+
const stats = Object.fromEntries(
|
|
62
|
+
Object.entries(byType).map(([type, list]) => [
|
|
63
|
+
type,
|
|
64
|
+
{
|
|
65
|
+
count: list.length,
|
|
66
|
+
mostRecent: list[0]?.entityId
|
|
67
|
+
}
|
|
68
|
+
])
|
|
69
|
+
);
|
|
70
|
+
this.logger.info("resolveReferences: input summary", {
|
|
71
|
+
messagePreview: message.substring(0, 200),
|
|
72
|
+
entityStats: stats
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
let context = "Available entities in memory:\n";
|
|
77
|
+
for (const [type, list] of Object.entries(byType)) {
|
|
78
|
+
const recent = list[0];
|
|
79
|
+
context += `Most recent ${type}: "${recent.entityName}" = ${recent.entityId}
|
|
80
|
+
`;
|
|
81
|
+
if (list.length > 1) {
|
|
82
|
+
context += ` (${list.length - 1} other ${type}s in memory)
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
95
85
|
}
|
|
86
|
+
const prompt = `Task: Replace entity references with their IDs from memory. STRICT TYPE RULES:
|
|
87
|
+
|
|
88
|
+
- For phrases referring to "${ENTITY_PATTERNS.TOKEN_REFERENCE}" or actions that clearly require a token (create/mint/airdrop/associate/etc.), resolve to the most recent TOKEN entity ID (never a topic or account).
|
|
89
|
+
- For phrases referring to "${ENTITY_PATTERNS.TOPIC_REFERENCE}" or actions that clearly require a topic (inscribe/publish/consensus/etc.), resolve to the most recent TOPIC entity ID (never a token or account).
|
|
90
|
+
- Do not infer or invent entity IDs. Only use those present in the provided context.
|
|
91
|
+
|
|
92
|
+
${context}
|
|
93
|
+
|
|
94
|
+
User message: "${message}"
|
|
95
|
+
|
|
96
|
+
Instructions:
|
|
97
|
+
- If the user says "${ENTITY_PATTERNS.TOPIC_REFERENCE}" or "that topic" → replace with the most recent topic ID
|
|
98
|
+
- If the user says "${ENTITY_PATTERNS.TOKEN_REFERENCE}" or "that token" → replace with the most recent token ID (never a topic)
|
|
99
|
+
- If the user says "it" or "that" after an action verb → replace with the most recent entity ID
|
|
100
|
+
- Examples:
|
|
101
|
+
* "submit on ${ENTITY_PATTERNS.TOPIC_REFERENCE}" → "submit on 0.0.6543472"
|
|
102
|
+
* "airdrop ${ENTITY_PATTERNS.TOKEN_REFERENCE}" → "airdrop 0.0.123456"
|
|
103
|
+
* "send a message to it" → "send a message to 0.0.6543472"
|
|
104
|
+
|
|
105
|
+
Return ONLY the message with replacements made. Do not add any explanations.
|
|
106
|
+
Resolved message:`;
|
|
96
107
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
const response = await this.llm.invoke(prompt);
|
|
109
|
+
const resolved = response.content.trim();
|
|
110
|
+
const changed = resolved !== message;
|
|
111
|
+
try {
|
|
112
|
+
this.logger.info("resolveReferences: resolution result", {
|
|
113
|
+
changed,
|
|
114
|
+
hasEntityId: /\b0\.0\.\d+\b/.test(resolved),
|
|
115
|
+
resolvedPreview: resolved.substring(0, 200)
|
|
116
|
+
});
|
|
117
|
+
} catch {
|
|
103
118
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
this.resolver
|
|
107
|
-
);
|
|
108
|
-
} else {
|
|
109
|
-
this.logger.warn("ContentResolverRegistry.register is unavailable; skipping registration");
|
|
119
|
+
if (changed && resolved.includes("0.0.")) {
|
|
120
|
+
return resolved;
|
|
110
121
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
this.logger.error("Failed to initialize ContentStoreManager:", error);
|
|
117
|
-
throw error;
|
|
122
|
+
return message;
|
|
123
|
+
} catch {
|
|
124
|
+
return message;
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
/**
|
|
121
|
-
*
|
|
128
|
+
* Extract entities from agent response using receipt data (preferred) or LLM fallback
|
|
122
129
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
async extractEntities(response, userMessage) {
|
|
131
|
+
const receiptEntities = this.extractFromReceipt(response, userMessage);
|
|
132
|
+
if (receiptEntities.length > 0) {
|
|
133
|
+
return receiptEntities;
|
|
134
|
+
}
|
|
135
|
+
return this.extractWithLLM(response, userMessage);
|
|
125
136
|
}
|
|
126
137
|
/**
|
|
127
|
-
*
|
|
138
|
+
* Extract entities from transaction receipt data (primary method)
|
|
128
139
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
extractFromReceipt(response, userMessage) {
|
|
141
|
+
const entities = [];
|
|
142
|
+
let parsedResponse;
|
|
143
|
+
try {
|
|
144
|
+
parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
|
|
145
|
+
} catch {
|
|
146
|
+
parsedResponse = response;
|
|
147
|
+
}
|
|
148
|
+
if (!parsedResponse || parsedResponse.success === false) {
|
|
149
|
+
return entities;
|
|
150
|
+
}
|
|
151
|
+
const receipt = parsedResponse.receipt || parsedResponse.result?.receipt || parsedResponse.data?.receipt;
|
|
152
|
+
if (!receipt) {
|
|
153
|
+
return entities;
|
|
154
|
+
}
|
|
155
|
+
const entityName = this.extractNameFromMessage(userMessage);
|
|
156
|
+
const transactionId = parsedResponse.transactionId || parsedResponse.result?.transactionId || void 0;
|
|
157
|
+
const extractEntityId = (entityId) => {
|
|
158
|
+
if (typeof entityId === "string") {
|
|
159
|
+
return entityId;
|
|
160
|
+
}
|
|
161
|
+
if (entityId && typeof entityId === "object" && typeof entityId.toString === "function") {
|
|
162
|
+
if (entityId.toString !== Object.prototype.toString) {
|
|
163
|
+
return entityId.toString();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return String(entityId);
|
|
167
|
+
};
|
|
168
|
+
if (receipt.tokenId) {
|
|
169
|
+
const entity = {
|
|
170
|
+
id: extractEntityId(receipt.tokenId),
|
|
171
|
+
name: entityName,
|
|
172
|
+
type: EntityFormat.TOKEN_ID
|
|
173
|
+
};
|
|
174
|
+
if (transactionId) {
|
|
175
|
+
entity.transactionId = transactionId;
|
|
176
|
+
}
|
|
177
|
+
entities.push(entity);
|
|
178
|
+
}
|
|
179
|
+
if (receipt.topicId) {
|
|
180
|
+
const entity = {
|
|
181
|
+
id: extractEntityId(receipt.topicId),
|
|
182
|
+
name: entityName,
|
|
183
|
+
type: EntityFormat.TOPIC_ID
|
|
184
|
+
};
|
|
185
|
+
if (transactionId) {
|
|
186
|
+
entity.transactionId = transactionId;
|
|
187
|
+
}
|
|
188
|
+
entities.push(entity);
|
|
189
|
+
}
|
|
190
|
+
if (receipt.accountId) {
|
|
191
|
+
const entity = {
|
|
192
|
+
id: extractEntityId(receipt.accountId),
|
|
193
|
+
name: entityName,
|
|
194
|
+
type: EntityFormat.ACCOUNT_ID
|
|
195
|
+
};
|
|
196
|
+
if (transactionId) {
|
|
197
|
+
entity.transactionId = transactionId;
|
|
198
|
+
}
|
|
199
|
+
entities.push(entity);
|
|
200
|
+
}
|
|
201
|
+
if (receipt.contractId) {
|
|
202
|
+
const entity = {
|
|
203
|
+
id: extractEntityId(receipt.contractId),
|
|
204
|
+
name: entityName,
|
|
205
|
+
type: EntityFormat.CONTRACT_ID
|
|
206
|
+
};
|
|
207
|
+
if (transactionId) {
|
|
208
|
+
entity.transactionId = transactionId;
|
|
209
|
+
}
|
|
210
|
+
entities.push(entity);
|
|
211
|
+
}
|
|
212
|
+
if (receipt.fileId) {
|
|
213
|
+
const entity = {
|
|
214
|
+
id: extractEntityId(receipt.fileId),
|
|
215
|
+
name: entityName,
|
|
216
|
+
type: EntityFormat.FILE_ID
|
|
217
|
+
};
|
|
218
|
+
if (transactionId) {
|
|
219
|
+
entity.transactionId = transactionId;
|
|
220
|
+
}
|
|
221
|
+
entities.push(entity);
|
|
222
|
+
}
|
|
223
|
+
if (receipt.scheduleId) {
|
|
224
|
+
const entity = {
|
|
225
|
+
id: extractEntityId(receipt.scheduleId),
|
|
226
|
+
name: entityName,
|
|
227
|
+
type: EntityFormat.SCHEDULE_ID
|
|
228
|
+
};
|
|
229
|
+
if (transactionId) {
|
|
230
|
+
entity.transactionId = transactionId;
|
|
231
|
+
}
|
|
232
|
+
entities.push(entity);
|
|
233
|
+
}
|
|
234
|
+
return entities;
|
|
131
235
|
}
|
|
132
236
|
/**
|
|
133
|
-
*
|
|
237
|
+
* Extract entity name from user message
|
|
134
238
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
239
|
+
extractNameFromMessage(message) {
|
|
240
|
+
const quotedMatch = message.match(/"([^"]+)"/);
|
|
241
|
+
if (quotedMatch) return quotedMatch[1];
|
|
242
|
+
const calledMatch = message.match(/called\s+([A-Za-z0-9#\s_-]+?)(?:\s|$)/i);
|
|
243
|
+
if (calledMatch) return calledMatch[1].trim();
|
|
244
|
+
const forMatch = message.match(/for\s+([A-Za-z0-9#\s_-]+)/i);
|
|
245
|
+
if (forMatch) return forMatch[1].trim();
|
|
246
|
+
const namedMatch = message.match(
|
|
247
|
+
/(?:token|topic|account|contract)\s+([A-Za-z0-9#_-]+)/i
|
|
248
|
+
);
|
|
249
|
+
if (namedMatch) return namedMatch[1].trim();
|
|
250
|
+
if (message.includes("new account")) return "new account";
|
|
251
|
+
return "unnamed_entity";
|
|
137
252
|
}
|
|
138
253
|
/**
|
|
139
|
-
*
|
|
254
|
+
* Extract entities using LLM (fallback method)
|
|
140
255
|
*/
|
|
141
|
-
async
|
|
142
|
-
|
|
256
|
+
async extractWithLLM(response, userMessage) {
|
|
257
|
+
const text = typeof response === "string" ? response : JSON.stringify(response);
|
|
258
|
+
const prompt = `Analyze this agent response and extract ONLY newly created entities.
|
|
259
|
+
|
|
260
|
+
User asked: "${userMessage.substring(0, 200)}"
|
|
261
|
+
|
|
262
|
+
Agent response: ${text.substring(0, 3e3)}
|
|
263
|
+
|
|
264
|
+
CRITICAL: Only extract Hedera entity IDs in the format 0.0.XXXXX (shard.realm.number).
|
|
265
|
+
DO NOT extract:
|
|
266
|
+
- Token symbols (e.g., "FOREV", "USDC", "HBAR")
|
|
267
|
+
- Token names (e.g., "Forever", "My Token")
|
|
268
|
+
- Transaction IDs (format: 0.0.XXX@timestamp)
|
|
269
|
+
- Account aliases or mnemonics
|
|
270
|
+
|
|
271
|
+
Look for:
|
|
272
|
+
1. Success messages with entity IDs (e.g., "Successfully created topic 0.0.6543472")
|
|
273
|
+
2. Transaction confirmations that created new entities
|
|
274
|
+
3. Entity IDs that appear after words like "created", "new", "successfully"
|
|
275
|
+
|
|
276
|
+
DO NOT include:
|
|
277
|
+
- Token symbols or names (these are NOT entity IDs)
|
|
278
|
+
- Account IDs that already existed (like sender/receiver accounts)
|
|
279
|
+
- Entity IDs that were parameters to the operation
|
|
280
|
+
- Failed operations
|
|
281
|
+
- Anything that doesn't match the 0.0.XXXXX format
|
|
282
|
+
|
|
283
|
+
Return a JSON array of newly created entities:
|
|
284
|
+
[{"id": "0.0.XXX", "name": "descriptive_name", "type": "topic|token|account"}]
|
|
285
|
+
|
|
286
|
+
If no entities were created, return: []
|
|
287
|
+
|
|
288
|
+
JSON:`;
|
|
289
|
+
try {
|
|
290
|
+
const response2 = await this.llm.invoke(prompt);
|
|
291
|
+
const content = response2.content;
|
|
292
|
+
const match = content.match(/\[[\s\S]*?\]/);
|
|
293
|
+
if (match) {
|
|
294
|
+
const entities = JSON.parse(match[0]);
|
|
295
|
+
return entities;
|
|
296
|
+
}
|
|
297
|
+
} catch {
|
|
298
|
+
}
|
|
299
|
+
return [];
|
|
143
300
|
}
|
|
144
301
|
/**
|
|
145
|
-
*
|
|
302
|
+
* Validate that an entity matches the expected type
|
|
146
303
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
304
|
+
validateEntityType(entityId, expectedType, entities) {
|
|
305
|
+
const stored = entities.find((e) => e.entityId === entityId);
|
|
306
|
+
return !!stored && stored.entityType === expectedType;
|
|
149
307
|
}
|
|
150
308
|
/**
|
|
151
|
-
*
|
|
309
|
+
* Resolve entity references with type validation
|
|
152
310
|
*/
|
|
153
|
-
async
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return await this.contentStorage.storeContentIfLarge(
|
|
160
|
-
content,
|
|
161
|
-
storeMetadata
|
|
162
|
-
);
|
|
311
|
+
async resolveWithTypeValidation(query, entities, expectedType) {
|
|
312
|
+
await this.resolveReferences(query, entities);
|
|
313
|
+
if (!expectedType) {
|
|
314
|
+
return entities;
|
|
315
|
+
}
|
|
316
|
+
return entities.filter((entity) => entity.entityType === expectedType);
|
|
163
317
|
}
|
|
164
318
|
/**
|
|
165
|
-
*
|
|
319
|
+
* Get entities filtered by type
|
|
166
320
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.contentStorage.dispose();
|
|
170
|
-
if (ContentStoreService && typeof ContentStoreService.dispose === "function") {
|
|
171
|
-
ContentStoreService.dispose();
|
|
172
|
-
}
|
|
173
|
-
if (ContentResolverRegistry && typeof ContentResolverRegistry.unregister === "function") {
|
|
174
|
-
ContentResolverRegistry.unregister();
|
|
175
|
-
}
|
|
176
|
-
this.isRegistered = false;
|
|
177
|
-
this.logger.info("ContentStoreManager disposed and unregistered");
|
|
178
|
-
}
|
|
321
|
+
getEntitiesByType(entities, entityType) {
|
|
322
|
+
return entities.filter((entity) => entity.entityType === entityType);
|
|
179
323
|
}
|
|
180
324
|
/**
|
|
181
|
-
*
|
|
325
|
+
* Find the most recent entity of a specific type
|
|
182
326
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
327
|
+
getMostRecentEntityByType(entities, entityType) {
|
|
328
|
+
const filtered = entities.filter(
|
|
329
|
+
(entity) => entity.entityType === entityType
|
|
330
|
+
);
|
|
331
|
+
if (filtered.length === 0) return null;
|
|
332
|
+
return filtered.reduce(
|
|
333
|
+
(most, current) => current.createdAt > most.createdAt ? current : most
|
|
334
|
+
);
|
|
185
335
|
}
|
|
186
336
|
}
|
|
187
337
|
export {
|
|
188
|
-
|
|
338
|
+
EntityResolver
|
|
189
339
|
};
|
|
190
340
|
//# sourceMappingURL=index24.js.map
|
package/dist/esm/index24.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index24.js","sources":["../../src/services/content-store-manager.ts"],"sourcesContent":["import { ContentStorage } from '../memory/content-storage';\nimport {\n ContentStoreService,\n extractReferenceId,\n shouldUseReference,\n ContentResolverRegistry,\n type ContentStoreInterface,\n type ContentResolverInterface,\n type ReferenceResolutionResult,\n} from '@hashgraphonline/standards-sdk';\nimport type {\n ContentReference,\n ContentReferenceConfig,\n ContentReferenceStats,\n} from '../types/content-reference';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Content metadata interface for adapter compatibility\n */\ninterface AdapterContentMetadata {\n mimeType?: string;\n fileName?: string;\n sizeBytes?: number;\n [key: string]: unknown;\n}\n\n/**\n * Configuration interface for content storage\n */\ninterface ContentStoreConfig {\n maxSize?: number;\n enableCompression?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Adapter to make ContentStorage compatible with ContentStoreInterface\n */\nclass ContentStorageAdapter implements ContentStoreInterface {\n constructor(private storage: ContentStorage) {}\n\n async storeContent(\n content: Buffer,\n metadata: AdapterContentMetadata\n ): Promise<string> {\n const storeMetadata = {\n contentType: 'binary' as const,\n sizeBytes: content.length,\n source: 'system' as const,\n ...metadata,\n };\n const contentRef = await this.storage.storeContent(content, storeMetadata);\n return contentRef.referenceId;\n }\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n const result = await this.storage.resolveReference(referenceId);\n if (result.success && result.content) {\n const response: ReferenceResolutionResult = {\n content: result.content,\n };\n if (result.metadata) {\n response.metadata = {\n ...(result.metadata.mimeType !== undefined && {\n mimeType: result.metadata.mimeType,\n }),\n ...(result.metadata.fileName !== undefined && {\n fileName: result.metadata.fileName,\n }),\n originalSize: result.metadata.sizeBytes,\n };\n }\n return response;\n } else {\n throw new Error(result.error || 'Reference not found');\n }\n }\n\n async hasReference(referenceId: string): Promise<boolean> {\n return await this.storage.hasReference(referenceId);\n }\n\n async cleanupReference(referenceId: string): Promise<void> {\n await this.storage.cleanupReference(referenceId);\n }\n\n async getStats(): Promise<unknown> {\n return await this.storage.getStats();\n }\n\n async updateConfig(config: ContentStoreConfig): Promise<void> {\n const referenceConfig = {\n sizeThresholdBytes: config.maxSize || 10240,\n enableAutoCleanup: config.enableCompression || true,\n ...config,\n };\n return await this.storage.updateConfig(referenceConfig);\n }\n\n async performCleanup(): Promise<void> {\n await this.storage.performCleanup();\n }\n\n async dispose(): Promise<void> {\n return Promise.resolve(this.storage.dispose());\n }\n}\n\n/**\n * Content resolver implementation for dependency injection\n */\nclass ContentResolver implements ContentResolverInterface {\n constructor(private adapter: ContentStorageAdapter) {}\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n return await this.adapter.resolveReference(referenceId);\n }\n\n shouldUseReference(content: string | Buffer): boolean {\n return shouldUseReference(content);\n }\n\n extractReferenceId(input: string): string | null {\n return extractReferenceId(input);\n }\n}\n\n/**\n * Manages content store lifecycle and cross-package registration\n */\nexport class ContentStoreManager {\n private contentStorage: ContentStorage;\n private adapter: ContentStorageAdapter;\n private resolver: ContentResolver;\n private logger: Logger;\n protected isRegistered = false;\n\n constructor(\n maxMessageStorage: number = 1000,\n referenceConfig?: Partial<ContentReferenceConfig>,\n logger?: Logger\n ) {\n this.logger = logger || new Logger({ module: 'ContentStoreManager' });\n\n this.contentStorage = new ContentStorage(\n maxMessageStorage,\n referenceConfig\n );\n this.adapter = new ContentStorageAdapter(this.contentStorage);\n this.resolver = new ContentResolver(this.adapter);\n }\n\n /**\n * Initialize and register content storage for cross-package access\n */\n async initialize(): Promise<void> {\n if (this.isRegistered) {\n this.logger.warn('ContentStoreManager is already initialized');\n return;\n }\n\n try {\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { setInstance?: Function }).setInstance === 'function'\n ) {\n await (ContentStoreService as unknown as { setInstance: (adapter: unknown) => Promise<void> }).setInstance(\n this.adapter\n );\n } else {\n this.logger.warn('ContentStoreService.setInstance is unavailable; skipping registration');\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { register?: Function }).register === 'function'\n ) {\n (ContentResolverRegistry as unknown as { register: (resolver: unknown) => void }).register(\n this.resolver\n );\n } else {\n this.logger.warn('ContentResolverRegistry.register is unavailable; skipping registration');\n }\n this.isRegistered = true;\n this.logger.info(\n 'ContentStoreManager initialized and registered for cross-package access'\n );\n } catch (error) {\n this.logger.error('Failed to initialize ContentStoreManager:', error);\n throw error;\n }\n }\n\n /**\n * Get the underlying ContentStorage instance\n */\n getContentStorage(): ContentStorage {\n return this.contentStorage;\n }\n\n /**\n * Get storage statistics\n */\n async getStats(): Promise<ContentReferenceStats> {\n return await this.contentStorage.getStats();\n }\n\n /**\n * Update configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n return await this.contentStorage.updateConfig(config);\n }\n\n /**\n * Perform manual cleanup\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n return await this.contentStorage.performCleanup();\n }\n\n /**\n * Check if content should be stored as reference\n */\n shouldUseReference(content: Buffer | string): boolean {\n return this.contentStorage.shouldUseReference(content);\n }\n\n /**\n * Store content if it's large enough\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: AdapterContentMetadata\n ): Promise<ContentReference | null> {\n const storeMetadata = {\n source: 'system' as const,\n contentType: 'binary' as const,\n ...metadata,\n };\n return await this.contentStorage.storeContentIfLarge(\n content,\n storeMetadata\n );\n }\n\n /**\n * Cleanup and unregister\n */\n async dispose(): Promise<void> {\n if (this.isRegistered) {\n this.contentStorage.dispose();\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { dispose?: Function }).dispose === 'function'\n ) {\n (ContentStoreService as unknown as { dispose: () => void }).dispose();\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { unregister?: Function }).unregister === 'function'\n ) {\n (ContentResolverRegistry as unknown as { unregister: () => void }).unregister();\n }\n this.isRegistered = false;\n this.logger.info('ContentStoreManager disposed and unregistered');\n }\n }\n\n /**\n * Check if the manager is initialized\n */\n isInitialized(): boolean {\n return this.isRegistered;\n }\n}\n"],"names":[],"mappings":";;AAuCA,MAAM,sBAAuD;AAAA,EAC3D,YAAoB,SAAyB;AAAzB,SAAA,UAAA;AAAA,EAA0B;AAAA,EAE9C,MAAM,aACJ,SACA,UACiB;AACjB,UAAM,gBAAgB;AAAA,MACpB,aAAa;AAAA,MACb,WAAW,QAAQ;AAAA,MACnB,QAAQ;AAAA,MACR,GAAG;AAAA,IAAA;AAEL,UAAM,aAAa,MAAM,KAAK,QAAQ,aAAa,SAAS,aAAa;AACzE,WAAO,WAAW;AAAA,EACpB;AAAA,EAEA,MAAM,iBACJ,aACoC;AACpC,UAAM,SAAS,MAAM,KAAK,QAAQ,iBAAiB,WAAW;AAC9D,QAAI,OAAO,WAAW,OAAO,SAAS;AACpC,YAAM,WAAsC;AAAA,QAC1C,SAAS,OAAO;AAAA,MAAA;AAElB,UAAI,OAAO,UAAU;AACnB,iBAAS,WAAW;AAAA,UAClB,GAAI,OAAO,SAAS,aAAa,UAAa;AAAA,YAC5C,UAAU,OAAO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B,SAAmC;AACpD,WAAO,KAAK,eAAe,mBAAmB,OAAO;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,oBACJ,SACA,UACkC;AAClC,UAAM,gBAAgB;AAAA,MACpB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,GAAG;AAAA,IAAA;AAEL,WAAO,MAAM,KAAK,eAAe;AAAA,MAC/B;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC7B,QAAI,KAAK,cAAc;AACrB,WAAK,eAAe,QAAA;AACpB,UACE,uBACA,OAAQ,oBAA0D,YAAY,YAC9E;AACC,4BAA2D,QAAA;AAAA,MAC9D;AACA,UACE,2BACA,OAAQ,wBAAiE,eAAe,YACxF;AACC,gCAAkE,WAAA;AAAA,MACrE;AACA,WAAK,eAAe;AACpB,WAAK,OAAO,KAAK,+CAA+C;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
|
|
1
|
+
{"version":3,"file":"index24.js","sources":["../../src/services/entity-resolver.ts"],"sourcesContent":["import { ChatOpenAI } from '@langchain/openai';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { EntityAssociation } from '../memory/smart-memory-manager';\nimport { ENTITY_PATTERNS } from '../constants';\nimport { EntityFormat } from '..';\n\nexport interface EntityResolverConfig {\n apiKey: string;\n modelName?: string;\n}\n\ninterface EntityIdValue {\n toString(): string;\n}\n\ninterface TransactionReceipt {\n tokenId?: EntityIdValue | string;\n topicId?: EntityIdValue | string;\n accountId?: EntityIdValue | string;\n contractId?: EntityIdValue | string;\n fileId?: EntityIdValue | string;\n scheduleId?: EntityIdValue | string;\n}\n\ninterface TransactionResponse {\n success?: boolean;\n receipt?: TransactionReceipt;\n result?: {\n receipt?: TransactionReceipt;\n transactionId?: string;\n };\n data?: {\n receipt?: TransactionReceipt;\n };\n transactionId?: string;\n}\n\ninterface ExtractedEntity {\n id: string;\n name: string;\n type: EntityFormat;\n transactionId?: string;\n}\n\n/**\n * LLM-based entity resolver that replaces brittle regex patterns\n */\nexport class EntityResolver {\n private llm: ChatOpenAI;\n private logger: Logger;\n\n constructor(config: EntityResolverConfig) {\n this.llm = new ChatOpenAI({\n apiKey: config.apiKey,\n modelName: config.modelName || 'gpt-4o-mini',\n temperature: 0,\n });\n this.logger = new Logger({ module: 'EntityResolver' });\n }\n\n /**\n * Resolve entity references using LLM instead of regex\n */\n async resolveReferences(\n message: string,\n entities: EntityAssociation[]\n ): Promise<string> {\n if (!entities || entities.length === 0) {\n return message;\n }\n\n const byType = entities.reduce((acc, e) => {\n if (!acc[e.entityType]) acc[e.entityType] = [];\n acc[e.entityType].push(e);\n return acc;\n }, {} as Record<string, EntityAssociation[]>);\n\n try {\n const stats = Object.fromEntries(\n Object.entries(byType).map(([type, list]) => [\n type,\n {\n count: list.length,\n mostRecent: list[0]?.entityId,\n },\n ])\n );\n this.logger.info('resolveReferences: input summary', {\n messagePreview: message.substring(0, 200),\n entityStats: stats,\n });\n } catch {}\n\n let context = 'Available entities in memory:\\n';\n for (const [type, list] of Object.entries(byType)) {\n const recent = list[0];\n context += `Most recent ${type}: \"${recent.entityName}\" = ${recent.entityId}\\n`;\n if (list.length > 1) {\n context += ` (${list.length - 1} other ${type}s in memory)\\n`;\n }\n }\n\n const prompt = `Task: Replace entity references with their IDs from memory. STRICT TYPE RULES:\n\n- For phrases referring to \"${ENTITY_PATTERNS.TOKEN_REFERENCE}\" or actions that clearly require a token (create/mint/airdrop/associate/etc.), resolve to the most recent TOKEN entity ID (never a topic or account).\n- For phrases referring to \"${ENTITY_PATTERNS.TOPIC_REFERENCE}\" or actions that clearly require a topic (inscribe/publish/consensus/etc.), resolve to the most recent TOPIC entity ID (never a token or account).\n- Do not infer or invent entity IDs. Only use those present in the provided context.\n\n${context}\n\nUser message: \"${message}\"\n\nInstructions:\n- If the user says \"${ENTITY_PATTERNS.TOPIC_REFERENCE}\" or \"that topic\" → replace with the most recent topic ID\n- If the user says \"${ENTITY_PATTERNS.TOKEN_REFERENCE}\" or \"that token\" → replace with the most recent token ID (never a topic)\n- If the user says \"it\" or \"that\" after an action verb → replace with the most recent entity ID\n- Examples:\n * \"submit on ${ENTITY_PATTERNS.TOPIC_REFERENCE}\" → \"submit on 0.0.6543472\"\n * \"airdrop ${ENTITY_PATTERNS.TOKEN_REFERENCE}\" → \"airdrop 0.0.123456\"\n * \"send a message to it\" → \"send a message to 0.0.6543472\"\n\nReturn ONLY the message with replacements made. Do not add any explanations.\nResolved message:`;\n\n try {\n const response = await this.llm.invoke(prompt);\n const resolved = (response.content as string).trim();\n\n const changed = resolved !== message;\n try {\n this.logger.info('resolveReferences: resolution result', {\n changed,\n hasEntityId: /\\b0\\.0\\.\\d+\\b/.test(resolved),\n resolvedPreview: resolved.substring(0, 200),\n });\n } catch {}\n\n if (changed && resolved.includes('0.0.')) {\n return resolved;\n }\n\n return message;\n } catch {\n return message;\n }\n }\n\n /**\n * Extract entities from agent response using receipt data (preferred) or LLM fallback\n */\n async extractEntities(\n response: unknown,\n userMessage: string\n ): Promise<ExtractedEntity[]> {\n const receiptEntities = this.extractFromReceipt(response, userMessage);\n if (receiptEntities.length > 0) {\n return receiptEntities;\n }\n\n return this.extractWithLLM(response, userMessage);\n }\n\n /**\n * Extract entities from transaction receipt data (primary method)\n */\n private extractFromReceipt(\n response: unknown,\n userMessage: string\n ): ExtractedEntity[] {\n const entities: ExtractedEntity[] = [];\n\n let parsedResponse: TransactionResponse;\n try {\n parsedResponse =\n typeof response === 'string'\n ? JSON.parse(response)\n : (response as TransactionResponse);\n } catch {\n parsedResponse = response as TransactionResponse;\n }\n\n if (!parsedResponse || parsedResponse.success === false) {\n return entities;\n }\n\n const receipt =\n parsedResponse.receipt ||\n parsedResponse.result?.receipt ||\n parsedResponse.data?.receipt;\n\n if (!receipt) {\n return entities;\n }\n\n const entityName = this.extractNameFromMessage(userMessage);\n\n const transactionId =\n parsedResponse.transactionId ||\n parsedResponse.result?.transactionId ||\n undefined;\n\n const extractEntityId = (entityId: EntityIdValue | string): string => {\n if (typeof entityId === 'string') {\n return entityId;\n }\n if (\n entityId &&\n typeof entityId === 'object' &&\n typeof entityId.toString === 'function'\n ) {\n if (entityId.toString !== Object.prototype.toString) {\n return entityId.toString();\n }\n }\n return String(entityId);\n };\n\n if (receipt.tokenId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.tokenId),\n name: entityName,\n type: EntityFormat.TOKEN_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.topicId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.topicId),\n name: entityName,\n type: EntityFormat.TOPIC_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.accountId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.accountId),\n name: entityName,\n type: EntityFormat.ACCOUNT_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.contractId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.contractId),\n name: entityName,\n type: EntityFormat.CONTRACT_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.fileId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.fileId),\n name: entityName,\n type: EntityFormat.FILE_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.scheduleId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.scheduleId),\n name: entityName,\n type: EntityFormat.SCHEDULE_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n return entities;\n }\n\n /**\n * Extract entity name from user message\n */\n private extractNameFromMessage(message: string): string {\n const quotedMatch = message.match(/\"([^\"]+)\"/);\n if (quotedMatch) return quotedMatch[1];\n\n const calledMatch = message.match(/called\\s+([A-Za-z0-9#\\s_-]+?)(?:\\s|$)/i);\n if (calledMatch) return calledMatch[1].trim();\n\n const forMatch = message.match(/for\\s+([A-Za-z0-9#\\s_-]+)/i);\n if (forMatch) return forMatch[1].trim();\n\n const namedMatch = message.match(\n /(?:token|topic|account|contract)\\s+([A-Za-z0-9#_-]+)/i\n );\n if (namedMatch) return namedMatch[1].trim();\n\n if (message.includes('new account')) return 'new account';\n\n return 'unnamed_entity';\n }\n\n /**\n * Extract entities using LLM (fallback method)\n */\n private async extractWithLLM(\n response: unknown,\n userMessage: string\n ): Promise<ExtractedEntity[]> {\n const text =\n typeof response === 'string' ? response : JSON.stringify(response);\n\n const prompt = `Analyze this agent response and extract ONLY newly created entities.\n\nUser asked: \"${userMessage.substring(0, 200)}\"\n\nAgent response: ${text.substring(0, 3000)}\n\nCRITICAL: Only extract Hedera entity IDs in the format 0.0.XXXXX (shard.realm.number).\nDO NOT extract:\n- Token symbols (e.g., \"FOREV\", \"USDC\", \"HBAR\")\n- Token names (e.g., \"Forever\", \"My Token\")\n- Transaction IDs (format: 0.0.XXX@timestamp)\n- Account aliases or mnemonics\n\nLook for:\n1. Success messages with entity IDs (e.g., \"Successfully created topic 0.0.6543472\")\n2. Transaction confirmations that created new entities\n3. Entity IDs that appear after words like \"created\", \"new\", \"successfully\"\n\nDO NOT include:\n- Token symbols or names (these are NOT entity IDs)\n- Account IDs that already existed (like sender/receiver accounts)\n- Entity IDs that were parameters to the operation\n- Failed operations\n- Anything that doesn't match the 0.0.XXXXX format\n\nReturn a JSON array of newly created entities:\n[{\"id\": \"0.0.XXX\", \"name\": \"descriptive_name\", \"type\": \"topic|token|account\"}]\n\nIf no entities were created, return: []\n\nJSON:`;\n\n try {\n const response = await this.llm.invoke(prompt);\n const content = response.content as string;\n const match = content.match(/\\[[\\s\\S]*?\\]/);\n if (match) {\n const entities = JSON.parse(match[0]);\n return entities;\n }\n } catch {}\n return [];\n }\n\n /**\n * Validate that an entity matches the expected type\n */\n validateEntityType(\n entityId: string,\n expectedType: string,\n entities: EntityAssociation[]\n ): boolean {\n const stored = entities.find((e) => e.entityId === entityId);\n return !!stored && stored.entityType === expectedType;\n }\n\n /**\n * Resolve entity references with type validation\n */\n async resolveWithTypeValidation(\n query: string,\n entities: EntityAssociation[],\n expectedType?: string\n ): Promise<EntityAssociation[]> {\n await this.resolveReferences(query, entities);\n\n if (!expectedType) {\n return entities;\n }\n\n return entities.filter((entity) => entity.entityType === expectedType);\n }\n\n /**\n * Get entities filtered by type\n */\n getEntitiesByType(\n entities: EntityAssociation[],\n entityType: string\n ): EntityAssociation[] {\n return entities.filter((entity) => entity.entityType === entityType);\n }\n\n /**\n * Find the most recent entity of a specific type\n */\n getMostRecentEntityByType(\n entities: EntityAssociation[],\n entityType: string\n ): EntityAssociation | null {\n const filtered = entities.filter(\n (entity) => entity.entityType === entityType\n );\n if (filtered.length === 0) return null;\n\n return filtered.reduce((most, current) =>\n current.createdAt > most.createdAt ? current : most\n );\n }\n}\n"],"names":["response"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAM,eAAe;AAAA,EAI1B,YAAY,QAA8B;AACxC,SAAK,MAAM,IAAI,WAAW;AAAA,MACxB,QAAQ,OAAO;AAAA,MACf,WAAW,OAAO,aAAa;AAAA,MAC/B,aAAa;AAAA,IAAA,CACd;AACD,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,kBAAkB;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,kBACJ,SACA,UACiB;AACjB,QAAI,CAAC,YAAY,SAAS,WAAW,GAAG;AACtC,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM;AACzC,UAAI,CAAC,IAAI,EAAE,UAAU,EAAG,KAAI,EAAE,UAAU,IAAI,CAAA;AAC5C,UAAI,EAAE,UAAU,EAAE,KA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