@vectorx/agent-simulator 0.1.3 → 0.3.0
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/lib/app.d.ts +43 -0
- package/lib/app.d.ts.map +1 -0
- package/lib/app.js +96 -0
- package/lib/app.js.map +1 -0
- package/lib/config/api.config.d.ts +2 -0
- package/lib/config/api.config.d.ts.map +1 -0
- package/lib/config/api.config.js +13 -0
- package/lib/config/api.config.js.map +1 -0
- package/lib/config/app.config.d.ts +22 -0
- package/lib/config/app.config.d.ts.map +1 -0
- package/lib/config/app.config.js +18 -0
- package/lib/config/app.config.js.map +1 -0
- package/lib/config/upload.config.d.ts +6 -0
- package/lib/config/upload.config.d.ts.map +1 -0
- package/lib/config/upload.config.js +10 -0
- package/lib/config/upload.config.js.map +1 -0
- package/lib/container/container.d.ts +6 -0
- package/lib/container/container.d.ts.map +1 -0
- package/lib/container/container.js +34 -0
- package/lib/container/container.js.map +1 -0
- package/lib/container/identifiers.d.ts +14 -0
- package/lib/container/identifiers.d.ts.map +1 -0
- package/lib/container/identifiers.js +20 -0
- package/lib/container/identifiers.js.map +1 -0
- package/lib/container/index.d.ts +4 -0
- package/lib/container/index.d.ts.map +1 -0
- package/lib/container/index.js +20 -0
- package/lib/container/index.js.map +1 -0
- package/lib/container/types.d.ts +41 -0
- package/lib/container/types.d.ts.map +1 -0
- package/lib/{types.js → container/types.js} +1 -0
- package/lib/container/types.js.map +1 -0
- package/lib/controllers/agent.controller.d.ts +15 -0
- package/lib/controllers/agent.controller.d.ts.map +1 -0
- package/lib/controllers/agent.controller.js +59 -0
- package/lib/controllers/agent.controller.js.map +1 -0
- package/lib/controllers/auth.controller.d.ts +23 -0
- package/lib/controllers/auth.controller.d.ts.map +1 -0
- package/lib/controllers/auth.controller.js +132 -0
- package/lib/controllers/auth.controller.js.map +1 -0
- package/lib/controllers/simulator.controller.d.ts +11 -0
- package/lib/controllers/simulator.controller.d.ts.map +1 -0
- package/lib/controllers/simulator.controller.js +44 -0
- package/lib/controllers/simulator.controller.js.map +1 -0
- package/lib/controllers/upload.controller.d.ts +8 -0
- package/lib/controllers/upload.controller.d.ts.map +1 -0
- package/lib/controllers/upload.controller.js +44 -0
- package/lib/controllers/upload.controller.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -0
- package/lib/middleware/cors.middleware.d.ts +7 -0
- package/lib/middleware/cors.middleware.d.ts.map +1 -0
- package/lib/middleware/cors.middleware.js +14 -0
- package/lib/middleware/cors.middleware.js.map +1 -0
- package/lib/middleware/error.middleware.d.ts +8 -0
- package/lib/middleware/error.middleware.d.ts.map +1 -0
- package/lib/middleware/error.middleware.js +33 -0
- package/lib/middleware/error.middleware.js.map +1 -0
- package/lib/middleware/proxy.middleware.d.ts +3 -0
- package/lib/middleware/proxy.middleware.d.ts.map +1 -0
- package/lib/middleware/proxy.middleware.js +21 -0
- package/lib/middleware/proxy.middleware.js.map +1 -0
- package/lib/routes/agent.d.ts +3 -0
- package/lib/routes/agent.d.ts.map +1 -0
- package/lib/routes/agent.js +16 -0
- package/lib/routes/agent.js.map +1 -0
- package/lib/routes/auth.d.ts +3 -0
- package/lib/routes/auth.d.ts.map +1 -0
- package/lib/routes/auth.js +20 -0
- package/lib/routes/auth.js.map +1 -0
- package/lib/routes/index.d.ts +3 -0
- package/lib/routes/index.d.ts.map +1 -0
- package/lib/routes/index.js +19 -0
- package/lib/routes/index.js.map +1 -0
- package/lib/routes/simulator.d.ts +3 -0
- package/lib/routes/simulator.d.ts.map +1 -0
- package/lib/routes/simulator.js +14 -0
- package/lib/routes/simulator.js.map +1 -0
- package/lib/routes/upload.d.ts +3 -0
- package/lib/routes/upload.d.ts.map +1 -0
- package/lib/routes/upload.js +13 -0
- package/lib/routes/upload.js.map +1 -0
- package/{types/webview-ui/services/agent-service.d.ts → lib/services/agent.service.d.ts} +15 -3
- package/lib/services/agent.service.d.ts.map +1 -0
- package/lib/services/agent.service.js +116 -0
- package/lib/services/agent.service.js.map +1 -0
- package/lib/services/auth.service.d.ts +55 -0
- package/lib/services/auth.service.d.ts.map +1 -0
- package/lib/services/auth.service.js +124 -0
- package/lib/services/auth.service.js.map +1 -0
- package/lib/services/simulator.service.d.ts +23 -0
- package/lib/services/simulator.service.d.ts.map +1 -0
- package/lib/services/simulator.service.js +49 -0
- package/lib/services/simulator.service.js.map +1 -0
- package/lib/services/upload.service.d.ts +32 -0
- package/lib/services/upload.service.d.ts.map +1 -0
- package/lib/services/upload.service.js +61 -0
- package/lib/services/upload.service.js.map +1 -0
- package/lib/simulator.d.ts +27 -0
- package/lib/simulator.d.ts.map +1 -0
- package/lib/simulator.js +42 -187
- package/lib/simulator.js.map +1 -0
- package/lib/utils/logger.d.ts +8 -0
- package/lib/utils/logger.d.ts.map +1 -0
- package/lib/utils/logger.js +28 -0
- package/lib/utils/logger.js.map +1 -0
- package/lib/utils/request.d.ts +11 -0
- package/lib/utils/request.d.ts.map +1 -0
- package/lib/utils/request.js +36 -0
- package/lib/utils/request.js.map +1 -0
- package/lib/utils/url-parser.d.ts +14 -0
- package/lib/utils/url-parser.d.ts.map +1 -0
- package/lib/utils/url-parser.js +25 -0
- package/lib/utils/url-parser.js.map +1 -0
- package/lib/utils.d.ts +6 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +5 -0
- package/lib/utils.js.map +1 -0
- package/{types → lib}/webview-ui/Agent.d.ts +2 -0
- package/lib/webview-ui/Agent.d.ts.map +1 -0
- package/lib/webview-ui/Agent.js +8 -0
- package/lib/webview-ui/Agent.js.map +1 -0
- package/lib/webview-ui/App.d.ts +3 -0
- package/lib/webview-ui/App.d.ts.map +1 -0
- package/lib/webview-ui/App.js +362 -181
- package/lib/webview-ui/App.js.map +1 -0
- package/{types → lib}/webview-ui/ErrorBoundary.d.ts +2 -1
- package/lib/webview-ui/ErrorBoundary.d.ts.map +1 -0
- package/lib/webview-ui/ErrorBoundary.js +15 -18
- package/lib/webview-ui/ErrorBoundary.js.map +1 -0
- package/lib/webview-ui/components/AsyncTaskBlock.d.ts +13 -0
- package/lib/webview-ui/components/AsyncTaskBlock.d.ts.map +1 -0
- package/lib/webview-ui/components/AsyncTaskBlock.js +179 -0
- package/lib/webview-ui/components/AsyncTaskBlock.js.map +1 -0
- package/lib/webview-ui/components/AuthIndicator.d.ts +3 -0
- package/lib/webview-ui/components/AuthIndicator.d.ts.map +1 -0
- package/lib/webview-ui/components/AuthIndicator.js +17 -0
- package/lib/webview-ui/components/AuthIndicator.js.map +1 -0
- package/lib/webview-ui/components/ErrorCard.d.ts +11 -0
- package/lib/webview-ui/components/ErrorCard.d.ts.map +1 -0
- package/lib/webview-ui/components/ErrorCard.js +50 -0
- package/lib/webview-ui/components/ErrorCard.js.map +1 -0
- package/{types → lib}/webview-ui/components/KnowledgeBaseSearchBlock.d.ts +1 -0
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.d.ts.map +1 -0
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js +7 -24
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js.map +1 -0
- package/{types → lib}/webview-ui/components/KnowledgeBaseSearchResult.d.ts +1 -0
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.d.ts.map +1 -0
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.js +3 -9
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.js.map +1 -0
- package/{types → lib}/webview-ui/components/MarkdownRenderer.d.ts +1 -0
- package/lib/webview-ui/components/MarkdownRenderer.d.ts.map +1 -0
- package/lib/webview-ui/components/MarkdownRenderer.js +6 -5
- package/lib/webview-ui/components/MarkdownRenderer.js.map +1 -0
- package/{types → lib}/webview-ui/components/MessageRenderer.d.ts +1 -0
- package/lib/webview-ui/components/MessageRenderer.d.ts.map +1 -0
- package/lib/webview-ui/components/MessageRenderer.js +22 -25
- package/lib/webview-ui/components/MessageRenderer.js.map +1 -0
- package/lib/webview-ui/components/MultimodalFileRenderer.d.ts +20 -0
- package/lib/webview-ui/components/MultimodalFileRenderer.d.ts.map +1 -0
- package/lib/webview-ui/components/MultimodalFileRenderer.js +143 -0
- package/lib/webview-ui/components/MultimodalFileRenderer.js.map +1 -0
- package/{types → lib}/webview-ui/components/ThinkingBlock.d.ts +1 -0
- package/lib/webview-ui/components/ThinkingBlock.d.ts.map +1 -0
- package/lib/webview-ui/components/ThinkingBlock.js +11 -41
- package/lib/webview-ui/components/ThinkingBlock.js.map +1 -0
- package/{types → lib}/webview-ui/components/ToolUseBlock.d.ts +1 -0
- package/lib/webview-ui/components/ToolUseBlock.d.ts.map +1 -0
- package/lib/webview-ui/components/ToolUseBlock.js +5 -11
- package/lib/webview-ui/components/ToolUseBlock.js.map +1 -0
- package/{types → lib}/webview-ui/components/ToolUseBlockHeader.d.ts +1 -0
- package/lib/webview-ui/components/ToolUseBlockHeader.d.ts.map +1 -0
- package/lib/webview-ui/components/ToolUseBlockHeader.js +4 -21
- package/lib/webview-ui/components/ToolUseBlockHeader.js.map +1 -0
- package/lib/webview-ui/components/UploadPreview.d.ts +6 -0
- package/lib/webview-ui/components/UploadPreview.d.ts.map +1 -0
- package/lib/webview-ui/components/UploadPreview.js +12 -0
- package/lib/webview-ui/components/UploadPreview.js.map +1 -0
- package/lib/webview-ui/components/WelcomeModule.d.ts +10 -0
- package/lib/webview-ui/components/WelcomeModule.d.ts.map +1 -0
- package/lib/webview-ui/components/WelcomeModule.js +161 -0
- package/lib/webview-ui/components/WelcomeModule.js.map +1 -0
- package/{types → lib}/webview-ui/components/index.d.ts +7 -0
- package/lib/webview-ui/components/index.d.ts.map +1 -0
- package/lib/webview-ui/components/index.js +7 -0
- package/lib/webview-ui/components/index.js.map +1 -0
- package/lib/webview-ui/config/cos-config.d.ts +41 -0
- package/lib/webview-ui/config/cos-config.d.ts.map +1 -0
- package/lib/webview-ui/config/cos-config.js +83 -0
- package/lib/webview-ui/config/cos-config.js.map +1 -0
- package/lib/webview-ui/config/http-config.d.ts +8 -0
- package/lib/webview-ui/config/http-config.d.ts.map +1 -0
- package/lib/webview-ui/config/http-config.js +36 -0
- package/lib/webview-ui/config/http-config.js.map +1 -0
- package/{types → lib}/webview-ui/constants.d.ts +1 -0
- package/lib/webview-ui/constants.d.ts.map +1 -0
- package/lib/webview-ui/constants.js +1 -0
- package/lib/webview-ui/constants.js.map +1 -0
- package/lib/webview-ui/contexts/AgentContext.d.ts +13 -0
- package/lib/webview-ui/contexts/AgentContext.d.ts.map +1 -0
- package/lib/webview-ui/contexts/AgentContext.js +19 -0
- package/lib/webview-ui/contexts/AgentContext.js.map +1 -0
- package/lib/webview-ui/contexts/AuthContext.d.ts +17 -0
- package/lib/webview-ui/contexts/AuthContext.d.ts.map +1 -0
- package/lib/webview-ui/contexts/AuthContext.js +79 -0
- package/lib/webview-ui/contexts/AuthContext.js.map +1 -0
- package/{types → lib}/webview-ui/contexts/ThemeContext.d.ts +1 -0
- package/lib/webview-ui/contexts/ThemeContext.d.ts.map +1 -0
- package/lib/webview-ui/contexts/ThemeContext.js +6 -35
- package/lib/webview-ui/contexts/ThemeContext.js.map +1 -0
- package/{types → lib}/webview-ui/hooks/useAgentStatus.d.ts +5 -0
- package/lib/webview-ui/hooks/useAgentStatus.d.ts.map +1 -0
- package/lib/webview-ui/hooks/useAgentStatus.js +39 -19
- package/lib/webview-ui/hooks/useAgentStatus.js.map +1 -0
- package/lib/webview-ui/hooks/useUploader.d.ts +19 -0
- package/lib/webview-ui/hooks/useUploader.d.ts.map +1 -0
- package/lib/webview-ui/hooks/useUploader.js +132 -0
- package/lib/webview-ui/hooks/useUploader.js.map +1 -0
- package/lib/webview-ui/hooks/useUserAvatar.d.ts +28 -0
- package/lib/webview-ui/hooks/useUserAvatar.d.ts.map +1 -0
- package/lib/webview-ui/hooks/useUserAvatar.js +74 -0
- package/lib/webview-ui/hooks/useUserAvatar.js.map +1 -0
- package/{types → lib}/webview-ui/index.d.ts +1 -0
- package/lib/webview-ui/index.d.ts.map +1 -0
- package/lib/webview-ui/index.js +4 -3
- package/lib/webview-ui/index.js.map +1 -0
- package/lib/webview-ui/services/agent-service.d.ts +106 -0
- package/lib/webview-ui/services/agent-service.d.ts.map +1 -0
- package/lib/webview-ui/services/agent-service.js +52 -25
- package/lib/webview-ui/services/agent-service.js.map +1 -0
- package/lib/webview-ui/services/index.d.ts +3 -0
- package/lib/webview-ui/services/index.d.ts.map +1 -0
- package/lib/webview-ui/services/index.js +19 -0
- package/lib/webview-ui/services/index.js.map +1 -0
- package/{types → lib}/webview-ui/services/logger-service.d.ts +18 -1
- package/lib/webview-ui/services/logger-service.d.ts.map +1 -0
- package/lib/webview-ui/services/logger-service.js +45 -27
- package/lib/webview-ui/services/logger-service.js.map +1 -0
- package/{types → lib}/webview-ui/styles/copilot.d.ts +1 -0
- package/lib/webview-ui/styles/copilot.d.ts.map +1 -0
- package/lib/webview-ui/styles/copilot.js +1 -0
- package/lib/webview-ui/styles/copilot.js.map +1 -0
- package/{types → lib}/webview-ui/styles/workarea.d.ts +1 -0
- package/lib/webview-ui/styles/workarea.d.ts.map +1 -0
- package/lib/webview-ui/styles/workarea.js +1 -0
- package/lib/webview-ui/styles/workarea.js.map +1 -0
- package/{types → lib}/webview-ui/types.d.ts +15 -1
- package/lib/webview-ui/types.d.ts.map +1 -0
- package/lib/webview-ui/types.js +1 -0
- package/lib/webview-ui/types.js.map +1 -0
- package/lib/webview-ui/utils/cos.d.ts +65 -0
- package/lib/webview-ui/utils/cos.d.ts.map +1 -0
- package/lib/webview-ui/utils/cos.js +113 -0
- package/lib/webview-ui/utils/cos.js.map +1 -0
- package/lib/webview-ui/utils/http-client.d.ts +44 -0
- package/lib/webview-ui/utils/http-client.d.ts.map +1 -0
- package/lib/webview-ui/utils/http-client.js +101 -0
- package/lib/webview-ui/utils/http-client.js.map +1 -0
- package/lib/webview-ui/utils/stream-text-handler.d.ts +4 -0
- package/lib/webview-ui/utils/stream-text-handler.d.ts.map +1 -0
- package/lib/webview-ui/utils/stream-text-handler.js +42 -0
- package/lib/webview-ui/utils/stream-text-handler.js.map +1 -0
- package/lib/webview-ui/utils/upload.d.ts +8 -0
- package/lib/webview-ui/utils/upload.d.ts.map +1 -0
- package/lib/webview-ui/utils/upload.js +22 -0
- package/lib/webview-ui/utils/upload.js.map +1 -0
- package/{types → lib}/webview-ui/widgets/BubbleComponents.d.ts +1 -5
- package/lib/webview-ui/widgets/BubbleComponents.d.ts.map +1 -0
- package/lib/webview-ui/widgets/BubbleComponents.js +17 -69
- package/lib/webview-ui/widgets/BubbleComponents.js.map +1 -0
- package/lib/webview-ui/widgets/ChatInput.d.ts +24 -0
- package/lib/webview-ui/widgets/ChatInput.d.ts.map +1 -0
- package/lib/webview-ui/widgets/ChatInput.js +113 -0
- package/lib/webview-ui/widgets/ChatInput.js.map +1 -0
- package/{types → lib}/webview-ui/widgets/LogPanel.d.ts +1 -0
- package/lib/webview-ui/widgets/LogPanel.d.ts.map +1 -0
- package/lib/webview-ui/widgets/LogPanel.js +37 -44
- package/lib/webview-ui/widgets/LogPanel.js.map +1 -0
- package/{types → lib}/webview-ui/widgets/SystemLogs.d.ts +7 -0
- package/lib/webview-ui/widgets/SystemLogs.d.ts.map +1 -0
- package/lib/webview-ui/widgets/SystemLogs.js +243 -187
- package/lib/webview-ui/widgets/SystemLogs.js.map +1 -0
- package/{types → lib}/webview-ui/widgets/ToolBar.d.ts +5 -0
- package/lib/webview-ui/widgets/ToolBar.d.ts.map +1 -0
- package/lib/webview-ui/widgets/ToolBar.js +49 -68
- package/lib/webview-ui/widgets/ToolBar.js.map +1 -0
- package/{types → lib}/webview-ui/widgets/index.d.ts +4 -2
- package/lib/webview-ui/widgets/index.d.ts.map +1 -0
- package/lib/webview-ui/widgets/index.js +4 -2
- package/lib/webview-ui/widgets/index.js.map +1 -0
- package/package.json +13 -4
- package/public/assets/main.js +141 -118
- package/public/assets/style.css +1 -1
- package/lib/webview-ui/types/index.js +0 -2
- package/types/index.d.ts +0 -3
- package/types/simulator.d.ts +0 -15
- package/types/types.d.ts +0 -6
- package/types/utils.d.ts +0 -1
- package/types/webview-ui/App.d.ts +0 -3
- package/types/webview-ui/types/index.d.ts +0 -20
package/lib/simulator.js
CHANGED
|
@@ -1,76 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.AgentSimulator = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
22
|
-
function parseAgentServerUrl(url) {
|
|
23
|
-
try {
|
|
24
|
-
const urlObj = new URL(url);
|
|
25
|
-
return {
|
|
26
|
-
protocol: urlObj.protocol,
|
|
27
|
-
hostname: urlObj.hostname,
|
|
28
|
-
port: urlObj.port || (urlObj.protocol === "https:" ? "443" : "80"),
|
|
29
|
-
pathname: urlObj.pathname,
|
|
30
|
-
baseUrl: `${urlObj.protocol}//${urlObj.hostname}${urlObj.port ? ":" + urlObj.port : ""}`,
|
|
31
|
-
fullUrl: url,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
throw new Error(`无效的 Agent Server URL: ${url}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
4
|
+
const app_1 = require("./app");
|
|
5
|
+
const logger_1 = require("./utils/logger");
|
|
6
|
+
/**
|
|
7
|
+
* Agent模拟器实现
|
|
8
|
+
*/
|
|
38
9
|
class AgentSimulator {
|
|
10
|
+
/**
|
|
11
|
+
* 创建模拟器实例
|
|
12
|
+
* @param options 模拟器配置选项
|
|
13
|
+
*/
|
|
39
14
|
constructor(options) {
|
|
40
15
|
this.server = null;
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
16
|
+
this.options = {
|
|
17
|
+
open: true,
|
|
18
|
+
...options,
|
|
19
|
+
};
|
|
20
|
+
this.app = new app_1.App({
|
|
21
|
+
port: options.port,
|
|
22
|
+
agentServerUrl: options.agentServerUrl,
|
|
23
|
+
open: options.open,
|
|
24
|
+
});
|
|
45
25
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log(chalk_1.default.green(`
|
|
26
|
+
/**
|
|
27
|
+
* 配置并启动模拟器
|
|
28
|
+
*/
|
|
29
|
+
async start() {
|
|
30
|
+
const config = this.app.getConfig();
|
|
31
|
+
const expressApp = this.app.getApp();
|
|
32
|
+
// 启动服务器
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
this.server = expressApp.listen(config.port, () => {
|
|
35
|
+
logger_1.Logger.success(`
|
|
57
36
|
┌────────────────────────────────────────────────────┐
|
|
58
37
|
│ │
|
|
59
38
|
│ 🚀 Agent模拟器已启动! │
|
|
60
39
|
│ │
|
|
61
|
-
│ 📡 模拟器地址: ${
|
|
62
|
-
│ 🔄 Agent服务: ${
|
|
40
|
+
│ 📡 模拟器地址: ${`http://localhost:${config.port}`} │
|
|
41
|
+
│ 🔄 Agent服务: ${config.agentServerUrl} │
|
|
63
42
|
│ │
|
|
64
43
|
└────────────────────────────────────────────────────┘
|
|
65
|
-
`)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
`);
|
|
45
|
+
// 自动打开浏览器提示
|
|
46
|
+
if (config.open) {
|
|
47
|
+
logger_1.Logger.warning(`请手动在浏览器中打开: ${logger_1.Logger.info(`http://localhost:${config.port}`)}`);
|
|
48
|
+
}
|
|
49
|
+
resolve();
|
|
71
50
|
});
|
|
72
51
|
});
|
|
73
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* 停止模拟器
|
|
55
|
+
*/
|
|
74
56
|
stop() {
|
|
75
57
|
return new Promise((resolve, reject) => {
|
|
76
58
|
if (this.server) {
|
|
@@ -78,9 +60,10 @@ class AgentSimulator {
|
|
|
78
60
|
if (err) {
|
|
79
61
|
return reject(err);
|
|
80
62
|
}
|
|
81
|
-
|
|
63
|
+
logger_1.Logger.warning("模拟器已停止");
|
|
82
64
|
resolve();
|
|
83
65
|
});
|
|
66
|
+
// 关闭所有连接
|
|
84
67
|
this.server.closeAllConnections();
|
|
85
68
|
setTimeout(() => {
|
|
86
69
|
resolve();
|
|
@@ -91,134 +74,6 @@ class AgentSimulator {
|
|
|
91
74
|
}
|
|
92
75
|
});
|
|
93
76
|
}
|
|
94
|
-
setupProxy() {
|
|
95
|
-
const proxyOptions = {
|
|
96
|
-
target: this.parsedServerUrl.baseUrl,
|
|
97
|
-
changeOrigin: true,
|
|
98
|
-
pathRewrite: {
|
|
99
|
-
"^/api": "",
|
|
100
|
-
},
|
|
101
|
-
logLevel: "silent",
|
|
102
|
-
};
|
|
103
|
-
this.app.use("/api", (req, res, next) => {
|
|
104
|
-
if (req.path === "/sse" || req.path === "/chat" || req.path === "/control" || req.path === "/restart") {
|
|
105
|
-
return next();
|
|
106
|
-
}
|
|
107
|
-
return (0, http_proxy_middleware_1.createProxyMiddleware)(proxyOptions)(req, res, next);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
setupRoutes() {
|
|
111
|
-
this.app.get("/agentInfo/get", (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
try {
|
|
113
|
-
const agentSimulatorInfo = yield this.getAgentSimulatorInfo();
|
|
114
|
-
res.json(agentSimulatorInfo);
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error("获取Agent信息失败:", error);
|
|
118
|
-
res.status(500).json({
|
|
119
|
-
error: error instanceof Error ? error.message : `获取Agent信息失败: ${error}`,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}));
|
|
123
|
-
this.app.get("/agentInfo/status", (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
try {
|
|
125
|
-
const healthUrl = `${this.parsedServerUrl.fullUrl}/health`;
|
|
126
|
-
const response = yield (0, node_fetch_1.default)(healthUrl);
|
|
127
|
-
if (response.ok) {
|
|
128
|
-
const healthData = yield response.json();
|
|
129
|
-
this.agentStatus = "normal";
|
|
130
|
-
res.json({
|
|
131
|
-
status: "normal",
|
|
132
|
-
health: healthData,
|
|
133
|
-
timestamp: Date.now(),
|
|
134
|
-
agentServerUrl: this.options.agentServerUrl,
|
|
135
|
-
parsedUrl: {
|
|
136
|
-
hostname: this.parsedServerUrl.hostname,
|
|
137
|
-
port: this.parsedServerUrl.port,
|
|
138
|
-
baseUrl: this.parsedServerUrl.baseUrl,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.agentStatus = "error";
|
|
144
|
-
res.json({
|
|
145
|
-
status: "error",
|
|
146
|
-
message: `后端服务响应异常: ${response.status}`,
|
|
147
|
-
timestamp: Date.now(),
|
|
148
|
-
agentServerUrl: this.options.agentServerUrl,
|
|
149
|
-
parsedUrl: {
|
|
150
|
-
hostname: this.parsedServerUrl.hostname,
|
|
151
|
-
port: this.parsedServerUrl.port,
|
|
152
|
-
baseUrl: this.parsedServerUrl.baseUrl,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
this.agentStatus = "error";
|
|
159
|
-
res.json({
|
|
160
|
-
status: "error",
|
|
161
|
-
message: `无法连接到后端服务: ${error.message}`,
|
|
162
|
-
timestamp: Date.now(),
|
|
163
|
-
agentServerUrl: this.options.agentServerUrl,
|
|
164
|
-
parsedUrl: {
|
|
165
|
-
hostname: this.parsedServerUrl.hostname,
|
|
166
|
-
port: this.parsedServerUrl.port,
|
|
167
|
-
baseUrl: this.parsedServerUrl.baseUrl,
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}));
|
|
172
|
-
this.app.get("/simulator/status", (req, res) => {
|
|
173
|
-
res.json({
|
|
174
|
-
status: "running",
|
|
175
|
-
port: this.options.port,
|
|
176
|
-
agentServerUrl: this.options.agentServerUrl,
|
|
177
|
-
agentStatus: this.agentStatus,
|
|
178
|
-
parsedUrl: {
|
|
179
|
-
hostname: this.parsedServerUrl.hostname,
|
|
180
|
-
port: this.parsedServerUrl.port,
|
|
181
|
-
baseUrl: this.parsedServerUrl.baseUrl,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
this.app.get("*", (req, res, next) => {
|
|
186
|
-
if (req.path.startsWith("/api") || req.path.startsWith("/simulator")) {
|
|
187
|
-
return next();
|
|
188
|
-
}
|
|
189
|
-
res.sendFile(path_1.default.resolve(__dirname, "../public/index.html"));
|
|
190
|
-
});
|
|
191
|
-
this.app.use((req, res) => {
|
|
192
|
-
res.status(404).json({ error: "未找到请求路径" });
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
getAgentSimulatorInfo() {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
const healthUrl = `${this.parsedServerUrl.fullUrl}/info`;
|
|
198
|
-
const response = yield (0, node_fetch_1.default)(healthUrl);
|
|
199
|
-
if (!response.ok) {
|
|
200
|
-
throw new Error(`无法连接到后端服务: ${response.status} ${response.statusText}`);
|
|
201
|
-
}
|
|
202
|
-
const resData = yield response.json();
|
|
203
|
-
if (resData.code !== 0) {
|
|
204
|
-
throw new Error(`后端服务返回错误: ${resData.message || "未知错误"}`);
|
|
205
|
-
}
|
|
206
|
-
const { agent_info } = resData.data;
|
|
207
|
-
if (!agent_info) {
|
|
208
|
-
throw new Error("后端服务返回的数据中缺少 agent_info 字段");
|
|
209
|
-
}
|
|
210
|
-
return this.transformToAgentSimulatorInfo(agent_info);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
transformToAgentSimulatorInfo(agentInfo) {
|
|
214
|
-
return {
|
|
215
|
-
agentInfo: {
|
|
216
|
-
agent_icon: agentInfo.agent_icon,
|
|
217
|
-
agent_id: agentInfo.agent_id,
|
|
218
|
-
agent_name: agentInfo.agent_name,
|
|
219
|
-
},
|
|
220
|
-
agentServerUrl: this.options.agentServerUrl,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
77
|
}
|
|
224
78
|
exports.AgentSimulator = AgentSimulator;
|
|
79
|
+
//# sourceMappingURL=simulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulator.js","sourceRoot":"","sources":["../src/simulator.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAC5B,2CAAwC;AAOxC;;GAEG;AACH,MAAa,cAAc;IAKzB;;;OAGG;IACH,YAAY,OAAyB;QAP7B,WAAM,GAAuB,IAAI,CAAC;QAQxC,IAAI,CAAC,OAAO,GAAG;YACb,IAAI,EAAE,IAAI;YACV,GAAG,OAAO;SACX,CAAC;QAEF,IAAI,CAAC,GAAG,GAAG,IAAI,SAAG,CAAC;YACjB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAErC,QAAQ;QACR,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;gBAChD,eAAM,CAAC,OAAO,CAAC;;;;;eAKR,oBAAoB,MAAM,CAAC,IAAI,EAAE;iBAC/B,MAAM,CAAC,cAAc;;;SAG7B,CAAC,CAAC;gBAEH,YAAY;gBACZ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;oBAChB,eAAM,CAAC,OAAO,CAAC,eAAe,eAAM,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;gBAClF,CAAC;gBAED,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAW,EAAE,EAAE;oBAChC,IAAI,GAAG,EAAE,CAAC;wBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;oBACrB,CAAC;oBACD,eAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACzB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;gBACH,SAAS;gBACT,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;gBAClC,UAAU,CAAC,GAAG,EAAE;oBACd,OAAO,EAAE,CAAC;gBACZ,CAAC,EAAE,IAAI,CAAC,CAAC;YACX,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5ED,wCA4EC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
static info(message: string, data?: any): void;
|
|
3
|
+
static success(message: string, data?: any): void;
|
|
4
|
+
static warning(message: string, data?: any): void;
|
|
5
|
+
static error(message: string, error?: any): void;
|
|
6
|
+
static debug(message: string, data?: any): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IACjB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAI9C,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIjD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIjD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAIhD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;CAKhD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
class Logger {
|
|
9
|
+
static info(message, data) {
|
|
10
|
+
console.log(chalk_1.default.blue(`[INFO] ${message}`), data ? data : "");
|
|
11
|
+
}
|
|
12
|
+
static success(message, data) {
|
|
13
|
+
console.log(chalk_1.default.green(`[SUCCESS] ${message}`), data ? data : "");
|
|
14
|
+
}
|
|
15
|
+
static warning(message, data) {
|
|
16
|
+
console.log(chalk_1.default.yellow(`[WARNING] ${message}`), data ? data : "");
|
|
17
|
+
}
|
|
18
|
+
static error(message, error) {
|
|
19
|
+
console.error(chalk_1.default.red(`[ERROR] ${message}`), error ? error : "");
|
|
20
|
+
}
|
|
21
|
+
static debug(message, data) {
|
|
22
|
+
if (process.env.NODE_ENV === "development") {
|
|
23
|
+
console.log(chalk_1.default.gray(`[DEBUG] ${message}`), data ? data : "");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Logger = Logger;
|
|
28
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,MAAa,MAAM;IACjB,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,IAAU;QACrC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,IAAU;QACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,aAAa,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,IAAU;QACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,aAAa,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe,EAAE,KAAW;QACvC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,WAAW,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe,EAAE,IAAU;QACtC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,WAAW,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF;AAtBD,wBAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,OAAO;mBACG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;CA4BnE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.request = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
exports.request = {
|
|
9
|
+
async fetch(options) {
|
|
10
|
+
const { url, method = "GET", headers = {}, data } = options;
|
|
11
|
+
let finalUrl = url;
|
|
12
|
+
let body;
|
|
13
|
+
const finalHeaders = {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
...headers,
|
|
16
|
+
};
|
|
17
|
+
if (method.toUpperCase() === "GET") {
|
|
18
|
+
if (data && typeof data === "object") {
|
|
19
|
+
const urlObj = new URL(url);
|
|
20
|
+
if (data.params && typeof data.params === "object") {
|
|
21
|
+
Object.entries(data.params).forEach(([k, v]) => urlObj.searchParams.set(k, String(v)));
|
|
22
|
+
}
|
|
23
|
+
finalUrl = urlObj.toString();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (data && typeof data === "object") {
|
|
28
|
+
body = JSON.stringify(data);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const res = await (0, node_fetch_1.default)(finalUrl, { method, headers: finalHeaders, body: body, timeout: 1000 * 20 });
|
|
32
|
+
const json = await res.json().catch(() => ({}));
|
|
33
|
+
return { status: res.status, ok: res.ok, data: json };
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AAQtB,QAAA,OAAO,GAAG;IACrB,KAAK,CAAC,KAAK,CAAC,OAAuC;QACjD,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAE5D,IAAI,QAAQ,GAAG,GAAG,CAAC;QACnB,IAAI,IAA0B,CAAC;QAC/B,MAAM,YAAY,GAA2B;YAC3C,cAAc,EAAE,kBAAkB;YAClC,GAAG,OAAO;SACX,CAAC;QAEF,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;YACnC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5B,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;oBACnD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzF,CAAC;gBACD,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC/B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,IAAW,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;QAChH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 解析 Agent Server URL
|
|
3
|
+
* @param url 完整的 Agent Server URL
|
|
4
|
+
* @returns 解析后的信息
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseAgentServerUrl(url: string): {
|
|
7
|
+
protocol: string;
|
|
8
|
+
hostname: string;
|
|
9
|
+
port: string;
|
|
10
|
+
pathname: string;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
fullUrl: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=url-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-parser.d.ts","sourceRoot":"","sources":["../../src/utils/url-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM;;;;;;;EAc9C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAgentServerUrl = parseAgentServerUrl;
|
|
4
|
+
/**
|
|
5
|
+
* 解析 Agent Server URL
|
|
6
|
+
* @param url 完整的 Agent Server URL
|
|
7
|
+
* @returns 解析后的信息
|
|
8
|
+
*/
|
|
9
|
+
function parseAgentServerUrl(url) {
|
|
10
|
+
try {
|
|
11
|
+
const urlObj = new URL(url);
|
|
12
|
+
return {
|
|
13
|
+
protocol: urlObj.protocol,
|
|
14
|
+
hostname: urlObj.hostname,
|
|
15
|
+
port: urlObj.port || (urlObj.protocol === "https:" ? "443" : "80"),
|
|
16
|
+
pathname: urlObj.pathname,
|
|
17
|
+
baseUrl: `${urlObj.protocol}//${urlObj.hostname}${urlObj.port ? ":" + urlObj.port : ""}`,
|
|
18
|
+
fullUrl: url,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw new Error(`无效的 Agent Server URL: ${url}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=url-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-parser.js","sourceRoot":"","sources":["../../src/utils/url-parser.ts"],"names":[],"mappings":";;AAKA,kDAcC;AAnBD;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YAClE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACxF,OAAO,EAAE,GAAG;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC"}
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateId = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 生成唯一ID
|
|
6
|
+
* @returns 唯一ID字符串
|
|
7
|
+
*/
|
|
4
8
|
const generateId = () => {
|
|
5
9
|
return Date.now() + "-" + Math.random().toString(36).substr(2, 9);
|
|
6
10
|
};
|
|
7
11
|
exports.generateId = generateId;
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,UAAU,GAAG,GAAW,EAAE;IACrC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { AgentSimulatorInfo } from "./services/agent-service";
|
|
2
2
|
export declare function getSendMessageUri(agentSimulatorInfo: AgentSimulatorInfo): string;
|
|
3
3
|
export declare function getHealthUri(agentSimulatorInfo: AgentSimulatorInfo): string;
|
|
4
|
+
export declare function getQueryTasksUri(agentSimulatorInfo: AgentSimulatorInfo, taskId?: string): string;
|
|
5
|
+
//# sourceMappingURL=Agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../src/webview-ui/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,wBAAgB,iBAAiB,CAAC,kBAAkB,EAAE,kBAAkB,UAKvE;AAED,wBAAgB,YAAY,CAAC,kBAAkB,EAAE,kBAAkB,UAKlE;AAED,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM,UAKvF"}
|
package/lib/webview-ui/Agent.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSendMessageUri = getSendMessageUri;
|
|
4
4
|
exports.getHealthUri = getHealthUri;
|
|
5
|
+
exports.getQueryTasksUri = getQueryTasksUri;
|
|
5
6
|
function getSendMessageUri(agentSimulatorInfo) {
|
|
6
7
|
if (!agentSimulatorInfo) {
|
|
7
8
|
throw new Error("agentSimulatorInfo is not set");
|
|
@@ -14,3 +15,10 @@ function getHealthUri(agentSimulatorInfo) {
|
|
|
14
15
|
}
|
|
15
16
|
return `${agentSimulatorInfo.agentServerUrl}/health`;
|
|
16
17
|
}
|
|
18
|
+
function getQueryTasksUri(agentSimulatorInfo, taskId) {
|
|
19
|
+
if (!agentSimulatorInfo) {
|
|
20
|
+
throw new Error("agentSimulatorInfo is not set");
|
|
21
|
+
}
|
|
22
|
+
return `${agentSimulatorInfo.agentServerUrl}/query-tasks${taskId ? `/${taskId}` : ""}`;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent.js","sourceRoot":"","sources":["../../src/webview-ui/Agent.ts"],"names":[],"mappings":";;AAEA,8CAKC;AAED,oCAKC;AAED,4CAKC;AAnBD,SAAgB,iBAAiB,CAAC,kBAAsC;IACtE,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,kBAAkB,CAAC,cAAc,eAAe,CAAC;AAC7D,CAAC;AAED,SAAgB,YAAY,CAAC,kBAAsC;IACjE,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,kBAAkB,CAAC,cAAc,SAAS,CAAC;AACvD,CAAC;AAED,SAAgB,gBAAgB,CAAC,kBAAsC,EAAE,MAAe;IACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,kBAAkB,CAAC,cAAc,eAAe,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/webview-ui/App.tsx"],"names":[],"mappings":"AA0oBA,QAAA,MAAM,gBAAgB,+CAqCrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|