@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/index18.js
CHANGED
|
@@ -1,512 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Add a message to the active memory window
|
|
28
|
-
* Automatically handles pruning and storage of displaced messages
|
|
29
|
-
* @param message - Message to add
|
|
30
|
-
*/
|
|
31
|
-
addMessage(message) {
|
|
32
|
-
const result = this.memoryWindow.addMessage(message);
|
|
33
|
-
if (result.prunedMessages.length > 0) {
|
|
34
|
-
this._contentStorage.storeMessages(result.prunedMessages);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get all active messages from the memory window
|
|
39
|
-
* @returns Array of active messages in chronological order
|
|
40
|
-
*/
|
|
41
|
-
getMessages() {
|
|
42
|
-
return this.memoryWindow.getMessages();
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Clear active memory window
|
|
46
|
-
* @param clearStorage - Whether to also clear the content storage (default: false)
|
|
47
|
-
*/
|
|
48
|
-
clear(clearStorage = false) {
|
|
49
|
-
this.memoryWindow.clear();
|
|
50
|
-
if (clearStorage) {
|
|
51
|
-
this._contentStorage.clear();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Set the system prompt for the memory window
|
|
56
|
-
* @param systemPrompt - System prompt text
|
|
57
|
-
*/
|
|
58
|
-
setSystemPrompt(systemPrompt) {
|
|
59
|
-
this.memoryWindow.setSystemPrompt(systemPrompt);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the current system prompt
|
|
63
|
-
* @returns Current system prompt text
|
|
64
|
-
*/
|
|
65
|
-
getSystemPrompt() {
|
|
66
|
-
return this.memoryWindow.getSystemPrompt();
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Search through stored message history
|
|
70
|
-
* @param query - Search term or pattern
|
|
71
|
-
* @param options - Search configuration
|
|
72
|
-
* @returns Array of matching messages from history
|
|
73
|
-
*/
|
|
74
|
-
searchHistory(query, options = {}) {
|
|
75
|
-
return this._contentStorage.searchMessages(query, options);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get recent messages from storage history
|
|
79
|
-
* @param count - Number of recent messages to retrieve
|
|
80
|
-
* @returns Array of recent messages from storage
|
|
81
|
-
*/
|
|
82
|
-
getRecentHistory(count) {
|
|
83
|
-
return this._contentStorage.getRecentMessages(count);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Check if a message can be added without exceeding limits
|
|
87
|
-
* @param message - Message to test
|
|
88
|
-
* @returns True if message can be added
|
|
89
|
-
*/
|
|
90
|
-
canAddMessage(message) {
|
|
91
|
-
return this.memoryWindow.canAddMessage(message);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get statistics about the active memory window
|
|
95
|
-
* @returns Memory usage statistics
|
|
96
|
-
*/
|
|
97
|
-
getMemoryStats() {
|
|
98
|
-
const windowStats = this.memoryWindow.getStats();
|
|
99
|
-
return {
|
|
100
|
-
totalActiveMessages: windowStats.totalMessages,
|
|
101
|
-
currentTokenCount: windowStats.currentTokens,
|
|
102
|
-
maxTokens: windowStats.maxTokens,
|
|
103
|
-
remainingCapacity: windowStats.remainingCapacity,
|
|
104
|
-
systemPromptTokens: windowStats.systemPromptTokens,
|
|
105
|
-
usagePercentage: windowStats.usagePercentage
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get statistics about the content storage
|
|
110
|
-
* @returns Storage usage statistics
|
|
111
|
-
*/
|
|
112
|
-
getStorageStats() {
|
|
113
|
-
return this._contentStorage.getStorageStats();
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Get combined statistics for both active memory and storage
|
|
117
|
-
* @returns Combined memory and storage statistics
|
|
118
|
-
*/
|
|
119
|
-
getOverallStats() {
|
|
120
|
-
const memoryStats = this.getMemoryStats();
|
|
121
|
-
const storageStats = this.getStorageStats();
|
|
122
|
-
return {
|
|
123
|
-
activeMemory: memoryStats,
|
|
124
|
-
storage: storageStats,
|
|
125
|
-
totalMessagesManaged: memoryStats.totalActiveMessages + storageStats.totalMessages,
|
|
126
|
-
activeMemoryUtilization: memoryStats.usagePercentage,
|
|
127
|
-
storageUtilization: storageStats.usagePercentage
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Update the configuration and apply changes
|
|
132
|
-
* @param newConfig - New configuration options
|
|
133
|
-
*/
|
|
134
|
-
updateConfig(newConfig) {
|
|
135
|
-
this.config = { ...this.config, ...newConfig };
|
|
136
|
-
if (newConfig.maxTokens !== void 0 || newConfig.reserveTokens !== void 0) {
|
|
137
|
-
this.memoryWindow.updateLimits(
|
|
138
|
-
this.config.maxTokens,
|
|
139
|
-
this.config.reserveTokens
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
if (newConfig.storageLimit !== void 0) {
|
|
143
|
-
this._contentStorage.updateStorageLimit(this.config.storageLimit);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get current configuration
|
|
148
|
-
* @returns Current configuration settings
|
|
149
|
-
*/
|
|
150
|
-
getConfig() {
|
|
151
|
-
return { ...this.config };
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get messages from storage within a time range
|
|
155
|
-
* @param startTime - Start of time range
|
|
156
|
-
* @param endTime - End of time range
|
|
157
|
-
* @returns Messages within the specified time range
|
|
158
|
-
*/
|
|
159
|
-
getHistoryFromTimeRange(startTime, endTime) {
|
|
160
|
-
return this._contentStorage.getMessagesFromTimeRange(startTime, endTime);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Get messages from storage by message type
|
|
164
|
-
* @param messageType - Type of messages to retrieve ('human', 'ai', 'system', etc.)
|
|
165
|
-
* @param limit - Maximum number of messages to return
|
|
166
|
-
* @returns Messages of the specified type
|
|
167
|
-
*/
|
|
168
|
-
getHistoryByType(messageType, limit) {
|
|
169
|
-
return this._contentStorage.getMessagesByType(messageType, limit);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get recent messages from storage within the last N minutes
|
|
173
|
-
* @param minutes - Number of minutes to look back
|
|
174
|
-
* @returns Messages from the last N minutes
|
|
175
|
-
*/
|
|
176
|
-
getRecentHistoryByTime(minutes) {
|
|
177
|
-
return this._contentStorage.getRecentMessagesByTime(minutes);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Export the current state for persistence or analysis
|
|
181
|
-
* @returns Serializable representation of memory state
|
|
182
|
-
*/
|
|
183
|
-
exportState() {
|
|
184
|
-
return {
|
|
185
|
-
config: this.config,
|
|
186
|
-
activeMessages: this.memoryWindow.getMessages().map((msg) => ({
|
|
187
|
-
content: msg.content,
|
|
188
|
-
type: msg._getType()
|
|
189
|
-
})),
|
|
190
|
-
systemPrompt: this.memoryWindow.getSystemPrompt(),
|
|
191
|
-
memoryStats: this.getMemoryStats(),
|
|
192
|
-
storageStats: this.getStorageStats(),
|
|
193
|
-
storedMessages: this._contentStorage.exportMessages()
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get a summary of conversation context for external use
|
|
198
|
-
* Useful for providing context to other systems or for logging
|
|
199
|
-
* @param includeStoredContext - Whether to include recent stored messages
|
|
200
|
-
* @returns Context summary object
|
|
201
|
-
*/
|
|
202
|
-
getContextSummary(includeStoredContext = false) {
|
|
203
|
-
const activeMessages = this.getMessages();
|
|
204
|
-
const summary = {
|
|
205
|
-
activeMessageCount: activeMessages.length,
|
|
206
|
-
systemPrompt: this.getSystemPrompt(),
|
|
207
|
-
recentMessages: activeMessages.slice(-5),
|
|
208
|
-
memoryUtilization: this.getMemoryStats().usagePercentage,
|
|
209
|
-
hasStoredHistory: this.getStorageStats().totalMessages > 0
|
|
210
|
-
};
|
|
211
|
-
if (includeStoredContext) {
|
|
212
|
-
return {
|
|
213
|
-
...summary,
|
|
214
|
-
recentStoredMessages: this.getRecentHistory(10),
|
|
215
|
-
storageStats: this.getStorageStats()
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return summary;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Perform maintenance operations
|
|
222
|
-
* Optimizes storage and cleans up resources
|
|
223
|
-
*/
|
|
224
|
-
performMaintenance() {
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Store an entity association for later resolution
|
|
228
|
-
* @param entityId - The blockchain entity ID
|
|
229
|
-
* @param entityName - User-provided or derived friendly name
|
|
230
|
-
* @param entityType - Type of entity (token, account, topic, etc.)
|
|
231
|
-
* @param transactionId - Optional transaction ID that created this entity
|
|
232
|
-
*/
|
|
233
|
-
storeEntityAssociation(entityId, entityName, entityType, transactionId, sessionId) {
|
|
234
|
-
try {
|
|
235
|
-
if (!entityId || typeof entityId !== "string" || entityId.trim().length === 0) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (!entityName || typeof entityName !== "string" || entityName.trim().length === 0) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (!entityType || typeof entityType !== "string" || entityType.trim().length === 0) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const sanitizedEntityId = entityId.trim();
|
|
245
|
-
const sanitizedEntityName = entityName.trim().substring(0, 100);
|
|
246
|
-
const sanitizedEntityType = this.normalizeEntityType(entityType);
|
|
247
|
-
let usageHint = "";
|
|
248
|
-
if (sanitizedEntityType === "tokenid") {
|
|
249
|
-
usageHint = "Use this as tokenId for HTS operations";
|
|
250
|
-
} else if (sanitizedEntityType === "topicid") {
|
|
251
|
-
usageHint = "Can be used for HCS operations, HRLs for minting with the format hcs://1/<topicId>, etc.";
|
|
252
|
-
} else if (sanitizedEntityType === "accountid") {
|
|
253
|
-
usageHint = "Can be used for account based operations";
|
|
254
|
-
}
|
|
255
|
-
const association = {
|
|
256
|
-
entityId: sanitizedEntityId,
|
|
257
|
-
entityName: sanitizedEntityName,
|
|
258
|
-
entityType: sanitizedEntityType,
|
|
259
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
260
|
-
isEntityAssociation: true,
|
|
261
|
-
...usageHint ? { usage: usageHint } : {},
|
|
262
|
-
...sanitizedEntityType === "topicId" ? { hrl: `hcs://1/${sanitizedEntityId}` } : {},
|
|
263
|
-
...transactionId !== void 0 && transactionId !== null && transactionId.trim() !== "" ? { transactionId: transactionId.trim() } : {},
|
|
264
|
-
...sessionId && sessionId.trim() !== "" ? { sessionId: sessionId.trim() } : {}
|
|
265
|
-
};
|
|
266
|
-
const content = JSON.stringify(association);
|
|
267
|
-
const entityMessage = {
|
|
268
|
-
_getType: () => "system",
|
|
269
|
-
content,
|
|
270
|
-
id: `entity_${sanitizedEntityId}_${Date.now()}`,
|
|
271
|
-
name: "entity_association",
|
|
272
|
-
additional_kwargs: {
|
|
273
|
-
entityId: sanitizedEntityId,
|
|
274
|
-
entityName: sanitizedEntityName,
|
|
275
|
-
entityType: sanitizedEntityType,
|
|
276
|
-
isEntityAssociation: true,
|
|
277
|
-
...sessionId && sessionId.trim() !== "" ? { sessionId: sessionId.trim() } : {}
|
|
278
|
-
}
|
|
279
|
-
};
|
|
1
|
+
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { shouldUseReference, ContentStoreService } from "@hashgraphonline/standards-sdk";
|
|
4
|
+
function convertMCPToolToLangChain(tool, mcpManager, serverConfig) {
|
|
5
|
+
const zodSchema = jsonSchemaToZod(tool.inputSchema);
|
|
6
|
+
const sanitizedName = `${tool.serverName}_${tool.name}`.replace(
|
|
7
|
+
/[^a-zA-Z0-9_]/g,
|
|
8
|
+
"_"
|
|
9
|
+
);
|
|
10
|
+
let description = tool.description || `MCP tool ${tool.name} from ${tool.serverName}`;
|
|
11
|
+
if (serverConfig?.toolDescriptions?.[tool.name]) {
|
|
12
|
+
description = `${description}
|
|
13
|
+
|
|
14
|
+
${serverConfig.toolDescriptions[tool.name]}`;
|
|
15
|
+
}
|
|
16
|
+
if (serverConfig?.additionalContext) {
|
|
17
|
+
description = `${description}
|
|
18
|
+
|
|
19
|
+
Context: ${serverConfig.additionalContext}`;
|
|
20
|
+
}
|
|
21
|
+
return new DynamicStructuredTool({
|
|
22
|
+
name: sanitizedName,
|
|
23
|
+
description,
|
|
24
|
+
schema: zodSchema,
|
|
25
|
+
func: async (input) => {
|
|
280
26
|
try {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const raw = (input || "").trim();
|
|
299
|
-
if (raw.length === 0) {
|
|
300
|
-
return "";
|
|
301
|
-
}
|
|
302
|
-
const key = raw.replace(/[^a-z]/gi, "").toLowerCase();
|
|
303
|
-
const REGISTRY = {
|
|
304
|
-
topic: "topicId",
|
|
305
|
-
topicid: "topicId",
|
|
306
|
-
token: "tokenId",
|
|
307
|
-
tokenid: "tokenId",
|
|
308
|
-
account: "accountId",
|
|
309
|
-
accountid: "accountId",
|
|
310
|
-
contract: "contractId",
|
|
311
|
-
contractid: "contractId",
|
|
312
|
-
file: "fileId",
|
|
313
|
-
fileid: "fileId",
|
|
314
|
-
schedule: "scheduleId",
|
|
315
|
-
scheduleid: "scheduleId"
|
|
316
|
-
};
|
|
317
|
-
if (Object.prototype.hasOwnProperty.call(REGISTRY, key)) {
|
|
318
|
-
return REGISTRY[key];
|
|
319
|
-
}
|
|
320
|
-
if (/^[a-z]+Id$/.test(raw)) {
|
|
321
|
-
return raw;
|
|
322
|
-
}
|
|
323
|
-
return raw;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Resolve entity references from natural language queries
|
|
327
|
-
* @param query - Search query (entity name or natural language reference)
|
|
328
|
-
* @param options - Resolution options for filtering and fuzzy matching
|
|
329
|
-
* @returns Array of matching entity associations
|
|
330
|
-
*/
|
|
331
|
-
resolveEntityReference(query, options = {}) {
|
|
332
|
-
try {
|
|
333
|
-
if (!query || typeof query !== "string") {
|
|
334
|
-
return [];
|
|
335
|
-
}
|
|
336
|
-
const sanitizedQuery = query.trim();
|
|
337
|
-
if (sanitizedQuery.length === 0) {
|
|
338
|
-
return [];
|
|
339
|
-
}
|
|
340
|
-
if (sanitizedQuery.length > 200) {
|
|
341
|
-
}
|
|
342
|
-
const { entityType, limit = 10, fuzzyMatch = true } = options;
|
|
343
|
-
const safeLimit = Math.max(1, Math.min(limit || 10, 100));
|
|
344
|
-
const isEntityIdQuery = /^0\.0\.\d+$/.test(sanitizedQuery);
|
|
345
|
-
const searchResults = this._contentStorage.searchMessages(
|
|
346
|
-
sanitizedQuery.substring(0, 200),
|
|
347
|
-
{
|
|
348
|
-
caseSensitive: false,
|
|
349
|
-
limit: safeLimit * 2
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
const associations = [];
|
|
353
|
-
for (const message of searchResults) {
|
|
354
|
-
try {
|
|
355
|
-
const content = message.content;
|
|
356
|
-
if (content.includes(IS_ENTITY_ASSOCIATION_FLAG) || content.includes("entityId")) {
|
|
357
|
-
const parsed = JSON.parse(content);
|
|
358
|
-
if (parsed.entityId && parsed.entityName && parsed.entityType) {
|
|
359
|
-
if (entityType && parsed.entityType !== entityType) {
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
if (isEntityIdQuery) {
|
|
363
|
-
if (parsed.entityId !== sanitizedQuery) {
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
associations.push(parsed);
|
|
368
|
-
}
|
|
27
|
+
const result = await mcpManager.executeTool(
|
|
28
|
+
tool.serverName,
|
|
29
|
+
tool.name,
|
|
30
|
+
input
|
|
31
|
+
);
|
|
32
|
+
let responseText = "";
|
|
33
|
+
if (typeof result === "string") {
|
|
34
|
+
responseText = result;
|
|
35
|
+
} else if (result && typeof result === "object" && "content" in result) {
|
|
36
|
+
const content = result.content;
|
|
37
|
+
if (Array.isArray(content)) {
|
|
38
|
+
const textParts = content.filter(
|
|
39
|
+
(item) => typeof item === "object" && item !== null && "type" in item && item.type === "text" && "text" in item
|
|
40
|
+
).map((item) => item.text);
|
|
41
|
+
responseText = textParts.join("\n");
|
|
42
|
+
} else {
|
|
43
|
+
responseText = JSON.stringify(content);
|
|
369
44
|
}
|
|
370
|
-
}
|
|
371
|
-
|
|
45
|
+
} else {
|
|
46
|
+
responseText = JSON.stringify(result);
|
|
372
47
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
entityType || ""
|
|
380
|
-
].filter(Boolean);
|
|
381
|
-
for (const fuzzyQuery of fuzzyQueries) {
|
|
382
|
-
if (fuzzyQuery === query.toLowerCase()) continue;
|
|
383
|
-
const fuzzyResults = this._contentStorage.searchMessages(fuzzyQuery, {
|
|
384
|
-
caseSensitive: false,
|
|
385
|
-
limit
|
|
386
|
-
});
|
|
387
|
-
for (const message of fuzzyResults) {
|
|
48
|
+
const responseBuffer = Buffer.from(responseText, "utf8");
|
|
49
|
+
const MCP_REFERENCE_THRESHOLD = 10 * 1024;
|
|
50
|
+
const shouldStoreMCPContent = responseBuffer.length > MCP_REFERENCE_THRESHOLD;
|
|
51
|
+
if (shouldStoreMCPContent || shouldUseReference(responseBuffer)) {
|
|
52
|
+
const contentStore = ContentStoreService.getInstance();
|
|
53
|
+
if (contentStore) {
|
|
388
54
|
try {
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
associations.push(parsed);
|
|
55
|
+
const referenceId = await contentStore.storeContent(
|
|
56
|
+
responseBuffer,
|
|
57
|
+
{
|
|
58
|
+
contentType: "text",
|
|
59
|
+
source: "mcp",
|
|
60
|
+
mcpToolName: `${tool.serverName}_${tool.name}`,
|
|
61
|
+
originalSize: responseBuffer.length
|
|
397
62
|
}
|
|
398
|
-
|
|
63
|
+
);
|
|
64
|
+
return `content-ref:${referenceId}`;
|
|
399
65
|
} catch {
|
|
400
|
-
continue;
|
|
401
66
|
}
|
|
402
67
|
}
|
|
403
68
|
}
|
|
69
|
+
return responseText;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
72
|
+
return `Error executing MCP tool ${tool.name}: ${errorMessage}`;
|
|
404
73
|
}
|
|
405
|
-
const uniqueAssociations = associations.filter(
|
|
406
|
-
(assoc, index, arr) => arr.findIndex((a) => a.entityId === assoc.entityId) === index
|
|
407
|
-
).sort(
|
|
408
|
-
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
409
|
-
);
|
|
410
|
-
const results = uniqueAssociations.slice(0, safeLimit);
|
|
411
|
-
return results;
|
|
412
|
-
} catch (error) {
|
|
413
|
-
this.logger.error("Failed to resolve entity reference", {
|
|
414
|
-
query,
|
|
415
|
-
options,
|
|
416
|
-
error: error instanceof Error ? error.message : String(error)
|
|
417
|
-
});
|
|
418
|
-
return [];
|
|
419
74
|
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function jsonSchemaToZod(schema) {
|
|
78
|
+
if (!schema || typeof schema !== "object") {
|
|
79
|
+
return z.object({});
|
|
80
|
+
}
|
|
81
|
+
const schemaObj = schema;
|
|
82
|
+
if (schemaObj.type && schemaObj.type !== "object") {
|
|
83
|
+
return convertType(schemaObj);
|
|
84
|
+
}
|
|
85
|
+
if (!schemaObj.properties || typeof schemaObj.properties !== "object") {
|
|
86
|
+
return z.object({});
|
|
87
|
+
}
|
|
88
|
+
const shape = {};
|
|
89
|
+
for (const [key, value] of Object.entries(schemaObj.properties)) {
|
|
90
|
+
let zodType = convertType(value);
|
|
91
|
+
const isRequired = Array.isArray(schemaObj.required) && schemaObj.required.includes(key);
|
|
92
|
+
if (!isRequired) {
|
|
93
|
+
zodType = zodType.optional();
|
|
94
|
+
}
|
|
95
|
+
shape[key] = zodType;
|
|
96
|
+
}
|
|
97
|
+
return z.object(shape);
|
|
98
|
+
}
|
|
99
|
+
function convertType(schema) {
|
|
100
|
+
if (!schema || typeof schema !== "object" || !("type" in schema)) {
|
|
101
|
+
return z.unknown();
|
|
102
|
+
}
|
|
103
|
+
const schemaObj = schema;
|
|
104
|
+
let zodType;
|
|
105
|
+
switch (schemaObj.type) {
|
|
106
|
+
case "string":
|
|
107
|
+
zodType = z.string();
|
|
108
|
+
if (schemaObj.enum && Array.isArray(schemaObj.enum)) {
|
|
109
|
+
zodType = z.enum(schemaObj.enum);
|
|
432
110
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
});
|
|
439
|
-
const associations = [];
|
|
440
|
-
for (const message of searchResults) {
|
|
441
|
-
try {
|
|
442
|
-
const content = message.content;
|
|
443
|
-
if (content.includes(IS_ENTITY_ASSOCIATION_FLAG)) {
|
|
444
|
-
const parsed = JSON.parse(content);
|
|
445
|
-
if (parsed.entityId && parsed.entityName && parsed.entityType) {
|
|
446
|
-
if (filterCanonical && parsed.entityType !== filterCanonical) {
|
|
447
|
-
continue;
|
|
448
|
-
}
|
|
449
|
-
if (parsed.createdAt && typeof parsed.createdAt === "string") {
|
|
450
|
-
parsed.createdAt = new Date(parsed.createdAt);
|
|
451
|
-
}
|
|
452
|
-
associations.push(parsed);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
} catch (parseError) {
|
|
456
|
-
this.logger.warn("Failed to parse entity association from message", {
|
|
457
|
-
messageContent: typeof message.content === "string" ? message.content.substring(0, 100) : "non-string",
|
|
458
|
-
error: parseError instanceof Error ? parseError.message : String(parseError)
|
|
459
|
-
});
|
|
460
|
-
continue;
|
|
461
|
-
}
|
|
111
|
+
break;
|
|
112
|
+
case "number":
|
|
113
|
+
zodType = z.number();
|
|
114
|
+
if ("minimum" in schemaObj && typeof schemaObj.minimum === "number") {
|
|
115
|
+
zodType = zodType.min(schemaObj.minimum);
|
|
462
116
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
for (const assoc of associations) {
|
|
466
|
-
const existing = mergedById.get(assoc.entityId);
|
|
467
|
-
if (!existing) {
|
|
468
|
-
mergedById.set(assoc.entityId, assoc);
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
const existingTime = getTime(existing.createdAt);
|
|
472
|
-
const currentTime = getTime(assoc.createdAt);
|
|
473
|
-
const preferCurrent = currentTime > existingTime || !!assoc.transactionId && !existing.transactionId;
|
|
474
|
-
if (preferCurrent) {
|
|
475
|
-
mergedById.set(assoc.entityId, {
|
|
476
|
-
...existing,
|
|
477
|
-
...assoc
|
|
478
|
-
});
|
|
479
|
-
}
|
|
117
|
+
if ("maximum" in schemaObj && typeof schemaObj.maximum === "number") {
|
|
118
|
+
zodType = zodType.max(schemaObj.maximum);
|
|
480
119
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
120
|
+
break;
|
|
121
|
+
case "integer":
|
|
122
|
+
zodType = z.number().int();
|
|
123
|
+
if ("minimum" in schemaObj && typeof schemaObj.minimum === "number") {
|
|
124
|
+
zodType = zodType.min(schemaObj.minimum);
|
|
125
|
+
}
|
|
126
|
+
if ("maximum" in schemaObj && typeof schemaObj.maximum === "number") {
|
|
127
|
+
zodType = zodType.max(schemaObj.maximum);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "boolean":
|
|
131
|
+
zodType = z.boolean();
|
|
132
|
+
break;
|
|
133
|
+
case "array":
|
|
134
|
+
if (schemaObj.items) {
|
|
135
|
+
zodType = z.array(convertType(schemaObj.items));
|
|
136
|
+
} else {
|
|
137
|
+
zodType = z.array(z.unknown());
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case "object":
|
|
141
|
+
if ("properties" in schemaObj) {
|
|
142
|
+
zodType = jsonSchemaToZod(schemaObj);
|
|
143
|
+
} else {
|
|
144
|
+
zodType = z.object({}).passthrough();
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
zodType = z.unknown();
|
|
492
149
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
*/
|
|
496
|
-
dispose() {
|
|
497
|
-
this.memoryWindow.dispose();
|
|
498
|
-
this._contentStorage.dispose();
|
|
499
|
-
this.tokenCounter.dispose();
|
|
150
|
+
if ("description" in schemaObj && typeof schemaObj.description === "string") {
|
|
151
|
+
zodType = zodType.describe(schemaObj.description);
|
|
500
152
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
maxTokens: 8e3,
|
|
504
|
-
reserveTokens: 1e3,
|
|
505
|
-
modelName: "gpt-4o",
|
|
506
|
-
storageLimit: 1e3
|
|
507
|
-
};
|
|
508
|
-
let SmartMemoryManager = _SmartMemoryManager;
|
|
153
|
+
return zodType;
|
|
154
|
+
}
|
|
509
155
|
export {
|
|
510
|
-
|
|
156
|
+
convertMCPToolToLangChain
|
|
511
157
|
};
|
|
512
158
|
//# sourceMappingURL=index18.js.map
|