@hashgraphonline/conversational-agent 0.2.215 → 0.2.217
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 +4 -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 +280 -142
- package/dist/esm/index45.js.map +1 -1
- package/dist/esm/index46.js +181 -24
- package/dist/esm/index46.js.map +1 -1
- package/dist/esm/index48.js +67 -85
- package/dist/esm/index48.js.map +1 -1
- package/dist/esm/index49.js +75 -0
- package/dist/esm/index49.js.map +1 -0
- package/dist/esm/index5.js +2 -2
- package/dist/esm/index50.js +57 -0
- package/dist/esm/index50.js.map +1 -0
- package/dist/esm/index51.js +103 -0
- package/dist/esm/index51.js.map +1 -0
- package/dist/esm/index52.js +79 -0
- package/dist/esm/index52.js.map +1 -0
- package/dist/esm/index53.js +75 -0
- package/dist/esm/index53.js.map +1 -0
- package/dist/esm/index54.js +124 -0
- package/dist/esm/index54.js.map +1 -0
- package/dist/esm/index55.js +58 -0
- package/dist/esm/index55.js.map +1 -0
- package/dist/esm/index56.js +83 -0
- package/dist/esm/index56.js.map +1 -0
- package/dist/esm/index57.js +100 -0
- package/dist/esm/index57.js.map +1 -0
- package/dist/esm/index58.js +118 -0
- package/dist/esm/index58.js.map +1 -0
- package/dist/esm/index59.js +108 -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 +30 -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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseHederaQueryTool,
|
|
3
|
+
HederaAgentKit,
|
|
4
|
+
type GenericPluginContext,
|
|
5
|
+
} from "hedera-agent-kit";
|
|
6
|
+
import { Bee, CollectionUploadOptions } from "@ethersphere/bee-js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { promisify } from "util";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import {
|
|
11
|
+
errorHasStatus,
|
|
12
|
+
getErrorMessage,
|
|
13
|
+
getResponseWithStructuredContent,
|
|
14
|
+
getUploadPostageBatchId,
|
|
15
|
+
ToolResponse,
|
|
16
|
+
} from "../utils";
|
|
17
|
+
import { BAD_REQUEST_STATUS } from "../constants";
|
|
18
|
+
import { SwarmConfig } from "../config";
|
|
19
|
+
|
|
20
|
+
const UploadFolderSchema = z.object({
|
|
21
|
+
folderPath: z.string(),
|
|
22
|
+
redundancyLevel: z.number().optional(),
|
|
23
|
+
postageBatchId: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export class UploadFolderTool extends BaseHederaQueryTool<typeof UploadFolderSchema> {
|
|
27
|
+
name = "swarm-upload-folder";
|
|
28
|
+
description = `Upload a folder to Swarm.
|
|
29
|
+
folderPath: Path to the folder to upload.
|
|
30
|
+
redundancyLevel: Redundancy level for fault tolerance (higher values provide better fault tolerance but increase storage overhead). 0 - none, 1 - medium, 2 - strong, 3 - insane, 4 - paranoid.
|
|
31
|
+
postageBatchId: The postage stamp batch ID which will be used to perform the upload, if it is provided.`;
|
|
32
|
+
namespace = "swarm";
|
|
33
|
+
specificInputSchema = UploadFolderSchema;
|
|
34
|
+
bee: Bee;
|
|
35
|
+
config: SwarmConfig;
|
|
36
|
+
|
|
37
|
+
constructor(params: {
|
|
38
|
+
hederaKit: HederaAgentKit;
|
|
39
|
+
config: SwarmConfig;
|
|
40
|
+
logger?: GenericPluginContext['logger'];
|
|
41
|
+
bee: Bee;
|
|
42
|
+
}) {
|
|
43
|
+
const { bee, config, ...rest } = params;
|
|
44
|
+
super(rest);
|
|
45
|
+
this.bee = bee;
|
|
46
|
+
this.config = config;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected async executeQuery(
|
|
50
|
+
input: z.infer<typeof UploadFolderSchema>
|
|
51
|
+
): Promise<ToolResponse | string> {
|
|
52
|
+
const { folderPath, redundancyLevel: inputRedundancyLevel, postageBatchId: inputPostageBatchId } = input;
|
|
53
|
+
|
|
54
|
+
if (!folderPath) {
|
|
55
|
+
this.logger.error(
|
|
56
|
+
'Missing required parameter: folderPath.'
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
throw new Error('Missing required parameter: folderPath.');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Check if folder exists
|
|
63
|
+
const stats = await promisify(fs.stat)(folderPath);
|
|
64
|
+
if (!stats.isDirectory()) {
|
|
65
|
+
this.logger.error(
|
|
66
|
+
`Path is not a directory: ${folderPath}.`
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
throw new Error(`Path is not a directory: ${folderPath}.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let postageBatchId = "";
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
postageBatchId = await getUploadPostageBatchId(
|
|
76
|
+
inputPostageBatchId,
|
|
77
|
+
this.bee,
|
|
78
|
+
this.config,
|
|
79
|
+
);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
let errorMessage = 'Upload folder failed.';
|
|
82
|
+
if (error instanceof Error) {
|
|
83
|
+
errorMessage = error.message;
|
|
84
|
+
}
|
|
85
|
+
this.logger.error(errorMessage);
|
|
86
|
+
|
|
87
|
+
throw new Error(errorMessage);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const redundancyLevel = inputRedundancyLevel;
|
|
91
|
+
const options: CollectionUploadOptions = {};
|
|
92
|
+
|
|
93
|
+
if (redundancyLevel) {
|
|
94
|
+
options.redundancyLevel = redundancyLevel;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const deferred = true;
|
|
98
|
+
options.deferred = deferred;
|
|
99
|
+
let message = 'Folder successfully uploaded to Swarm';
|
|
100
|
+
|
|
101
|
+
let tagId: string | undefined = undefined;
|
|
102
|
+
|
|
103
|
+
if (deferred) {
|
|
104
|
+
try {
|
|
105
|
+
const tag = await this.bee.createTag();
|
|
106
|
+
tagId = tag.uid.toString();
|
|
107
|
+
options.tag = tag.uid;
|
|
108
|
+
message =
|
|
109
|
+
'Folder upload started in deferred mode. Use swarm-query-upload-progress to track progress.';
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.logger.error(
|
|
112
|
+
'Failed to create tag',
|
|
113
|
+
error
|
|
114
|
+
);
|
|
115
|
+
options.deferred = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let result;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
// Start the deferred upload
|
|
123
|
+
result = await this.bee.uploadFilesFromDirectory(
|
|
124
|
+
postageBatchId,
|
|
125
|
+
folderPath,
|
|
126
|
+
options
|
|
127
|
+
);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
let errorMessage = 'Unable to upload folder.';
|
|
130
|
+
|
|
131
|
+
if (errorHasStatus(error, BAD_REQUEST_STATUS)) {
|
|
132
|
+
errorMessage = getErrorMessage(error);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.logger.error(
|
|
136
|
+
errorMessage,
|
|
137
|
+
error
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
throw new Error(errorMessage);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return getResponseWithStructuredContent({
|
|
144
|
+
reference: result.reference.toString(),
|
|
145
|
+
url: this.bee.url + "/bzz/" + result.reference.toString(),
|
|
146
|
+
message,
|
|
147
|
+
tagId,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Bee, PostageBatch } from "@ethersphere/bee-js";
|
|
2
|
+
import { PostageBatchCurated, PostageBatchSummary } from "./model";
|
|
3
|
+
import { SwarmConfig } from "./config";
|
|
4
|
+
import { DEFAULT_GATEWAY_BATCH_ID, NOT_FOUND_STATUS } from "./constants";
|
|
5
|
+
|
|
6
|
+
export interface ToolResponse {
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
tools?: { [x: string]: unknown; name: string /* other properties */ };
|
|
9
|
+
_meta?: { [x: string]: unknown };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function hexToBytes(hex: string): Uint8Array {
|
|
13
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
14
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
15
|
+
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
16
|
+
}
|
|
17
|
+
return bytes;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getBatchSummary = (
|
|
21
|
+
batch: PostageBatch | PostageBatchCurated
|
|
22
|
+
): PostageBatchSummary => ({
|
|
23
|
+
stampID:
|
|
24
|
+
typeof batch.batchID === "string" ? batch.batchID : batch.batchID.toHex(),
|
|
25
|
+
usage: batch.usageText,
|
|
26
|
+
capacity: `${batch.remainingSize.toFormattedString()} remaining out of ${batch.size.toFormattedString()}`,
|
|
27
|
+
immutable: batch.immutableFlag,
|
|
28
|
+
ttl: `${batch.duration.represent()} (${batch.duration
|
|
29
|
+
.toEndDate()
|
|
30
|
+
.toDateString()})`,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const getResponseWithStructuredContent = <T>(data: T): ToolResponse => ({
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: JSON.stringify(data, null, 2),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
structuredContent: data,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const errorHasStatus = (error: unknown, status: number) => {
|
|
44
|
+
if (typeof error === "object" && error !== null && "status" in error) {
|
|
45
|
+
return error.status === status;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getErrorMessage = (error: unknown) => {
|
|
52
|
+
if (
|
|
53
|
+
typeof error === "object" &&
|
|
54
|
+
error !== null &&
|
|
55
|
+
"responseBody" in error &&
|
|
56
|
+
typeof error.responseBody === "object" &&
|
|
57
|
+
error.responseBody !== null &&
|
|
58
|
+
"message" in error.responseBody
|
|
59
|
+
) {
|
|
60
|
+
return error.responseBody.message as string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return "";
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const runWithTimeout = async <T>(
|
|
67
|
+
asyncAction: Promise<T>,
|
|
68
|
+
timeout: number
|
|
69
|
+
): Promise<[unknown, boolean]> => {
|
|
70
|
+
let hasTimedOut = false;
|
|
71
|
+
|
|
72
|
+
const timeoutPromise = new Promise((resolve) =>
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
hasTimedOut = true;
|
|
75
|
+
resolve(true);
|
|
76
|
+
}, timeout)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const response = await Promise.race([asyncAction, timeoutPromise]);
|
|
80
|
+
|
|
81
|
+
return [response, hasTimedOut];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const getUploadPostageBatchId = async (
|
|
85
|
+
argsPostageBatchId: string | undefined,
|
|
86
|
+
bee: Bee,
|
|
87
|
+
config: SwarmConfig,
|
|
88
|
+
): Promise<string> => {
|
|
89
|
+
let postageBatchId = argsPostageBatchId;
|
|
90
|
+
const autoAssignStamp = config.autoAssignStamp ?? true;
|
|
91
|
+
let maxRemainingSize = 0;
|
|
92
|
+
|
|
93
|
+
if (!postageBatchId && !autoAssignStamp) {
|
|
94
|
+
throw new Error('No postageBatchId was provided. Please repeat the prompt and also specify the usable postage batch id.');
|
|
95
|
+
} else if (!postageBatchId) {
|
|
96
|
+
try {
|
|
97
|
+
const rawPostageBatches = await bee.getPostageBatches();
|
|
98
|
+
|
|
99
|
+
rawPostageBatches.forEach((batch) => {
|
|
100
|
+
if (!batch.usable) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const remainingSize = batch.remainingSize.toBytes();
|
|
105
|
+
|
|
106
|
+
if (remainingSize > maxRemainingSize) {
|
|
107
|
+
maxRemainingSize = remainingSize;
|
|
108
|
+
postageBatchId = batch.batchID.toHex();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (errorHasStatus(error, NOT_FOUND_STATUS)) {
|
|
113
|
+
postageBatchId = DEFAULT_GATEWAY_BATCH_ID;
|
|
114
|
+
} else {
|
|
115
|
+
throw new Error('Retrieval of postage batches failed.');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!postageBatchId) {
|
|
121
|
+
throw new Error('There is no usable postage batch with capacity.');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return postageBatchId!;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const dateUnits: Record<string, number | undefined> = {
|
|
128
|
+
ms: 1,
|
|
129
|
+
milli: 1,
|
|
130
|
+
millis: 1,
|
|
131
|
+
millisecond: 1,
|
|
132
|
+
milliseconds: 1,
|
|
133
|
+
s: 1000,
|
|
134
|
+
sec: 1000,
|
|
135
|
+
second: 1000,
|
|
136
|
+
seconds: 1000,
|
|
137
|
+
m: 60_000,
|
|
138
|
+
min: 60_000,
|
|
139
|
+
minute: 60_000,
|
|
140
|
+
minutes: 60_000,
|
|
141
|
+
h: 3_600_000,
|
|
142
|
+
hour: 3_600_000,
|
|
143
|
+
hours: 3_600_000,
|
|
144
|
+
d: 86_400_000,
|
|
145
|
+
day: 86_400_000,
|
|
146
|
+
days: 86_400_000,
|
|
147
|
+
w: 604_800_000,
|
|
148
|
+
week: 604_800_000,
|
|
149
|
+
weeks: 604_800_000,
|
|
150
|
+
month: 2_592_000_000,
|
|
151
|
+
months: 2_592_000_000,
|
|
152
|
+
y: 31_536_000_000,
|
|
153
|
+
year: 31_536_000_000,
|
|
154
|
+
years: 31_536_000_000,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// From bee.js
|
|
158
|
+
export function makeDate(numberWithUnit: string): number {
|
|
159
|
+
const number = parseFloat(numberWithUnit);
|
|
160
|
+
if (isNaN(number)) {
|
|
161
|
+
throw Error("makeDate got NaN for input");
|
|
162
|
+
}
|
|
163
|
+
const unit = numberWithUnit
|
|
164
|
+
.replace(/^-?[0-9.]+/, "")
|
|
165
|
+
.trim()
|
|
166
|
+
.toLowerCase();
|
|
167
|
+
const multiplier = dateUnits[unit];
|
|
168
|
+
if (!multiplier) {
|
|
169
|
+
throw Error(`Unknown unit: "${unit}"`);
|
|
170
|
+
}
|
|
171
|
+
return number * multiplier;
|
|
172
|
+
}
|
package/src/plugins/index.ts
CHANGED
package/cli/dist/CLIApp.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Network } from './types';
|
|
3
|
-
interface Props {
|
|
4
|
-
accountId?: string;
|
|
5
|
-
privateKey?: string;
|
|
6
|
-
network?: Network;
|
|
7
|
-
openAIApiKey?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const CLIApp: React.FC<Props>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=CLIApp.d.ts.map
|
package/cli/dist/CLIApp.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CLIApp.d.ts","sourceRoot":"","sources":["../src/CLIApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EAA4B,KAAK,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhE,UAAU,KAAK;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiKlC,CAAC"}
|
package/cli/dist/CLIApp.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
import { useApp } from 'ink';
|
|
3
|
-
import { ScreenRouter } from './components/ScreenRouter';
|
|
4
|
-
import { ConfigManager } from './managers/ConfigManager';
|
|
5
|
-
import { AgentManager } from './managers/AgentManager';
|
|
6
|
-
import { useStableState } from './hooks/useStableState';
|
|
7
|
-
import { useInitializeAgent } from './hooks/useInitializeAgent';
|
|
8
|
-
export const CLIApp = props => {
|
|
9
|
-
const { exit } = useApp();
|
|
10
|
-
const configManager = useMemo(() => ConfigManager.getInstance(), []);
|
|
11
|
-
const agentManager = useMemo(() => AgentManager.getInstance(), []);
|
|
12
|
-
const initialConfig = useMemo(() => configManager.getConfig(props), [
|
|
13
|
-
configManager,
|
|
14
|
-
props.accountId,
|
|
15
|
-
props.privateKey,
|
|
16
|
-
props.network,
|
|
17
|
-
props.openAIApiKey,
|
|
18
|
-
]);
|
|
19
|
-
const initialMcpServers = useMemo(() => configManager.getMCPServers(), [configManager]);
|
|
20
|
-
const { state, actions } = useStableState(initialMcpServers);
|
|
21
|
-
const [currentConfig, setCurrentConfig] = useState(initialConfig);
|
|
22
|
-
const initializeAgent = useInitializeAgent({
|
|
23
|
-
configManager,
|
|
24
|
-
agentManager,
|
|
25
|
-
actions,
|
|
26
|
-
});
|
|
27
|
-
const handleInitializeAgent = useCallback(() => {
|
|
28
|
-
initializeAgent(currentConfig, state.mcpConfig);
|
|
29
|
-
}, [initializeAgent, currentConfig, state.mcpConfig]);
|
|
30
|
-
const sendMessage = useCallback(async (message) => {
|
|
31
|
-
if (!message.trim())
|
|
32
|
-
return;
|
|
33
|
-
const userMessage = {
|
|
34
|
-
role: 'user',
|
|
35
|
-
content: message,
|
|
36
|
-
timestamp: new Date(),
|
|
37
|
-
};
|
|
38
|
-
actions.addMessages([userMessage]);
|
|
39
|
-
actions.setInput('');
|
|
40
|
-
actions.setLoading(true);
|
|
41
|
-
try {
|
|
42
|
-
const chatHistory = state.messages
|
|
43
|
-
.filter((m) => m.role !== 'system')
|
|
44
|
-
.map((m) => ({
|
|
45
|
-
type: m.role === 'user' ? 'human' : 'ai',
|
|
46
|
-
content: m.content,
|
|
47
|
-
}));
|
|
48
|
-
const response = await agentManager.sendMessage(message, chatHistory);
|
|
49
|
-
const assistantMessage = {
|
|
50
|
-
role: 'assistant',
|
|
51
|
-
content: response.message ||
|
|
52
|
-
response.output ||
|
|
53
|
-
response.error ||
|
|
54
|
-
'No response received',
|
|
55
|
-
timestamp: new Date(),
|
|
56
|
-
};
|
|
57
|
-
const newMessages = [assistantMessage];
|
|
58
|
-
if (response.transactionId) {
|
|
59
|
-
newMessages.push({
|
|
60
|
-
role: 'system',
|
|
61
|
-
content: `Transaction ID: ${response.transactionId}`,
|
|
62
|
-
timestamp: new Date(),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (response.scheduleId) {
|
|
66
|
-
newMessages.push({
|
|
67
|
-
role: 'system',
|
|
68
|
-
content: `Schedule ID: ${response.scheduleId}`,
|
|
69
|
-
timestamp: new Date(),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (response.notes && response.notes.length > 0) {
|
|
73
|
-
response.notes.forEach((note) => {
|
|
74
|
-
newMessages.push({
|
|
75
|
-
role: 'system',
|
|
76
|
-
content: note,
|
|
77
|
-
timestamp: new Date(),
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
actions.addMessages(newMessages);
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
actions.addMessages([
|
|
85
|
-
{
|
|
86
|
-
role: 'system',
|
|
87
|
-
content: `Error: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
88
|
-
timestamp: new Date(),
|
|
89
|
-
},
|
|
90
|
-
]);
|
|
91
|
-
}
|
|
92
|
-
finally {
|
|
93
|
-
actions.setLoading(false);
|
|
94
|
-
}
|
|
95
|
-
}, [agentManager, state.messages, actions]);
|
|
96
|
-
const updateConfig = (field, value) => {
|
|
97
|
-
const updated = { ...currentConfig, [field]: value };
|
|
98
|
-
setCurrentConfig(updated);
|
|
99
|
-
};
|
|
100
|
-
const saveMCPConfig = () => {
|
|
101
|
-
const servers = [];
|
|
102
|
-
if (state.mcpConfig.enableFilesystem) {
|
|
103
|
-
const filesystemServer = {
|
|
104
|
-
name: 'filesystem',
|
|
105
|
-
command: 'npx',
|
|
106
|
-
args: [
|
|
107
|
-
'-y',
|
|
108
|
-
'@modelcontextprotocol/server-filesystem',
|
|
109
|
-
state.mcpConfig.filesystemPath,
|
|
110
|
-
],
|
|
111
|
-
transport: 'stdio',
|
|
112
|
-
autoConnect: true,
|
|
113
|
-
};
|
|
114
|
-
servers.push(filesystemServer);
|
|
115
|
-
}
|
|
116
|
-
servers.push(...state.mcpConfig.customServers);
|
|
117
|
-
configManager.saveMCPConfig(servers);
|
|
118
|
-
};
|
|
119
|
-
const stableHandlers = useMemo(() => ({
|
|
120
|
-
initializeAgent: handleInitializeAgent,
|
|
121
|
-
sendMessage,
|
|
122
|
-
updateConfig,
|
|
123
|
-
saveMCPConfig,
|
|
124
|
-
getMCPConfigPath: () => configManager.getMCPConfigPathForDisplay(),
|
|
125
|
-
}), [handleInitializeAgent, sendMessage]);
|
|
126
|
-
return (React.createElement(ScreenRouter, { state: state, currentConfig: currentConfig, actions: actions, stableHandlers: stableHandlers, exit: exit }));
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=CLIApp.js.map
|
package/cli/dist/CLIApp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CLIApp.js","sourceRoot":"","sources":["../src/CLIApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD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-
* This avoids complex dependencies while providing the core functionality
|
|
4
|
-
*
|
|
5
|
-
* For local development, this allows the CLI to work without needing to publish
|
|
6
|
-
* the main package, while still providing a functional demo of the interface.
|
|
7
|
-
*/
|
|
8
|
-
export interface ConversationalAgentOptions {
|
|
9
|
-
accountId: string;
|
|
10
|
-
privateKey: string;
|
|
11
|
-
network: 'testnet' | 'mainnet';
|
|
12
|
-
openAIApiKey: string;
|
|
13
|
-
openAIModelName?: string;
|
|
14
|
-
plugins?: any[];
|
|
15
|
-
verbose?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface AgentResponse {
|
|
18
|
-
message?: string;
|
|
19
|
-
output?: string;
|
|
20
|
-
error?: string;
|
|
21
|
-
transactionId?: string;
|
|
22
|
-
scheduleId?: string;
|
|
23
|
-
notes?: string[];
|
|
24
|
-
}
|
|
25
|
-
export declare class ConversationalAgent {
|
|
26
|
-
private config;
|
|
27
|
-
private initialized;
|
|
28
|
-
constructor(config: ConversationalAgentOptions);
|
|
29
|
-
initialize(): Promise<void>;
|
|
30
|
-
processMessage(message: string, _chatHistory?: Array<{
|
|
31
|
-
type: 'human' | 'ai';
|
|
32
|
-
content: string;
|
|
33
|
-
}>): Promise<AgentResponse>;
|
|
34
|
-
}
|
|
35
|
-
export declare class OpenConvAIPlugin {
|
|
36
|
-
constructor();
|
|
37
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal ConversationalAgent implementation for CLI use
|
|
3
|
-
* This avoids complex dependencies while providing the core functionality
|
|
4
|
-
*
|
|
5
|
-
* For local development, this allows the CLI to work without needing to publish
|
|
6
|
-
* the main package, while still providing a functional demo of the interface.
|
|
7
|
-
*/
|
|
8
|
-
export class ConversationalAgent {
|
|
9
|
-
constructor(config) {
|
|
10
|
-
Object.defineProperty(this, "config", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: void 0
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "initialized", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: false
|
|
21
|
-
});
|
|
22
|
-
this.config = config;
|
|
23
|
-
}
|
|
24
|
-
async initialize() {
|
|
25
|
-
if (!this.config.accountId || !this.config.privateKey || !this.config.openAIApiKey) {
|
|
26
|
-
throw new Error('Missing required configuration: accountId, privateKey, or openAIApiKey');
|
|
27
|
-
}
|
|
28
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
29
|
-
this.initialized = true;
|
|
30
|
-
}
|
|
31
|
-
async processMessage(message, _chatHistory) {
|
|
32
|
-
if (!this.initialized) {
|
|
33
|
-
throw new Error('Agent not initialized. Call initialize() first.');
|
|
34
|
-
}
|
|
35
|
-
const responses = [
|
|
36
|
-
"I'm a demo version of the Conversational Agent. In the full version, I would help you interact with the Hedera network.",
|
|
37
|
-
"This CLI demonstrates the interface for the Hashgraph Online Conversational Agent. Full functionality requires the complete implementation.",
|
|
38
|
-
"I understand you want to use Hedera network features. The production version would process this request using real network calls.",
|
|
39
|
-
"Demo mode: Your message has been received. The full agent would analyze this and execute appropriate Hedera operations.",
|
|
40
|
-
"This is a placeholder response. The actual Conversational Agent would provide real Hedera network functionality."
|
|
41
|
-
];
|
|
42
|
-
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
|
|
43
|
-
return {
|
|
44
|
-
message: randomResponse,
|
|
45
|
-
output: `Demo response for: ${message}`,
|
|
46
|
-
notes: [
|
|
47
|
-
`Connected to ${this.config.network}`,
|
|
48
|
-
`Using account ${this.config.accountId}`,
|
|
49
|
-
`Model: ${this.config.openAIModelName || 'gpt-4o-mini'}`,
|
|
50
|
-
'Running in CLI demo mode'
|
|
51
|
-
]
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export class OpenConvAIPlugin {
|
|
56
|
-
constructor() {
|
|
57
|
-
}
|
|
58
|
-
}
|
package/cli/dist/app.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Network } from './types';
|
|
3
|
-
type Props = {
|
|
4
|
-
accountId?: string;
|
|
5
|
-
privateKey?: string;
|
|
6
|
-
network?: Network;
|
|
7
|
-
openAIApiKey?: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Main App component for the Hashgraph Online Conversational Agent CLI
|
|
11
|
-
* @param accountId - Hedera account ID
|
|
12
|
-
* @param privateKey - Hedera private key
|
|
13
|
-
* @param network - Network to connect to (testnet or mainnet)
|
|
14
|
-
* @param openAIApiKey - OpenAI API key for the conversational agent
|
|
15
|
-
*/
|
|
16
|
-
export default function App({ accountId, privateKey, network, openAIApiKey, }: Props): React.JSX.Element;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=app.d.ts.map
|
package/cli/dist/app.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC,KAAK,KAAK,GAAG;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,OAAmB,EACnB,YAAY,GACZ,EAAE,KAAK,qBASP"}
|
package/cli/dist/app.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CLIApp } from './CLIApp';
|
|
3
|
-
process.setMaxListeners(20);
|
|
4
|
-
/**
|
|
5
|
-
* Main App component for the Hashgraph Online Conversational Agent CLI
|
|
6
|
-
* @param accountId - Hedera account ID
|
|
7
|
-
* @param privateKey - Hedera private key
|
|
8
|
-
* @param network - Network to connect to (testnet or mainnet)
|
|
9
|
-
* @param openAIApiKey - OpenAI API key for the conversational agent
|
|
10
|
-
*/
|
|
11
|
-
export default function App({ accountId, privateKey, network = 'testnet', openAIApiKey, }) {
|
|
12
|
-
return (React.createElement(CLIApp, { accountId: accountId, privateKey: privateKey, network: network, openAIApiKey: openAIApiKey }));
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=app.js.map
|
package/cli/dist/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAUhC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAC3B,SAAS,EACT,UAAU,EACV,OAAO,GAAG,SAAS,EACnB,YAAY,GACL;IACP,OAAO,CACN,oBAAC,MAAM,IACN,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,GACzB,CACF,CAAC;AACH,CAAC"}
|
package/cli/dist/cli.d.ts
DELETED
package/cli/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":""}
|