@vectorx/agent-simulator 1.0.0 → 1.1.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 +1 -1
- package/lib/app.js +4 -4
- package/lib/config/api.config.d.ts +0 -1
- package/lib/config/api.config.js +3 -2
- package/lib/config/app.config.d.ts +2 -1
- package/lib/config/app.config.js +0 -1
- package/lib/config/upload.config.d.ts +0 -1
- package/lib/config/upload.config.js +0 -1
- package/lib/container/container.d.ts +0 -1
- package/lib/container/container.js +4 -2
- package/lib/container/identifiers.d.ts +0 -1
- package/lib/container/identifiers.js +0 -1
- package/lib/container/index.d.ts +0 -1
- package/lib/container/index.js +0 -1
- package/lib/container/types.d.ts +9 -1
- package/lib/container/types.js +0 -1
- package/lib/controllers/agent.controller.d.ts +6 -3
- package/lib/controllers/agent.controller.js +17 -3
- package/lib/controllers/auth.controller.d.ts +4 -5
- package/lib/controllers/auth.controller.js +3 -4
- package/lib/controllers/simulator.controller.d.ts +2 -3
- package/lib/controllers/simulator.controller.js +1 -2
- package/lib/controllers/upload.controller.d.ts +1 -2
- package/lib/controllers/upload.controller.js +5 -2
- package/lib/index.d.ts +1 -2
- package/lib/index.js +0 -1
- package/lib/middleware/cors.middleware.d.ts +0 -1
- package/lib/middleware/cors.middleware.js +0 -1
- package/lib/middleware/error.middleware.d.ts +3 -4
- package/lib/middleware/error.middleware.js +2 -3
- package/lib/middleware/proxy.middleware.d.ts +1 -2
- package/lib/middleware/proxy.middleware.js +0 -1
- package/lib/middleware/upload.middleware.d.ts +0 -1
- package/lib/middleware/upload.middleware.js +0 -1
- package/lib/routes/agent.d.ts +0 -1
- package/lib/routes/agent.js +2 -1
- package/lib/routes/auth.d.ts +0 -1
- package/lib/routes/auth.js +0 -1
- package/lib/routes/index.d.ts +0 -1
- package/lib/routes/index.js +0 -1
- package/lib/routes/simulator.d.ts +0 -1
- package/lib/routes/simulator.js +0 -1
- package/lib/routes/upload.d.ts +0 -1
- package/lib/routes/upload.js +0 -1
- package/lib/services/agent.service.d.ts +15 -2
- package/lib/services/agent.service.js +34 -8
- package/lib/services/auth.service.d.ts +1 -2
- package/lib/services/auth.service.js +5 -6
- package/lib/services/simulator.service.d.ts +0 -1
- package/lib/services/simulator.service.js +0 -1
- package/lib/services/upload.service.d.ts +0 -1
- package/lib/services/upload.service.js +0 -1
- package/lib/simulator.d.ts +11 -1
- package/lib/simulator.js +90 -6
- package/lib/utils/env-helper.d.ts +0 -1
- package/lib/utils/env-helper.js +0 -1
- package/lib/utils/logger.d.ts +0 -1
- package/lib/utils/logger.js +0 -1
- package/lib/utils/request.d.ts +0 -1
- package/lib/utils/request.js +6 -2
- package/lib/utils/url-parser.d.ts +0 -1
- package/lib/utils/url-parser.js +1 -2
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +0 -1
- package/lib/webview-ui/Agent.d.ts +0 -1
- package/lib/webview-ui/Agent.js +0 -1
- package/lib/webview-ui/App.d.ts +0 -1
- package/lib/webview-ui/App.js +176 -34
- package/lib/webview-ui/ErrorBoundary.d.ts +0 -1
- package/lib/webview-ui/ErrorBoundary.js +0 -1
- package/lib/webview-ui/components/AsyncTaskBlock.d.ts +1 -2
- package/lib/webview-ui/components/AsyncTaskBlock.js +16 -5
- package/lib/webview-ui/components/AuthIndicator.d.ts +1 -2
- package/lib/webview-ui/components/AuthIndicator.js +0 -1
- package/lib/webview-ui/components/ErrorCard.d.ts +1 -2
- package/lib/webview-ui/components/ErrorCard.js +7 -5
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.d.ts +1 -2
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js +4 -3
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.d.ts +1 -2
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.js +1 -2
- package/lib/webview-ui/components/MarkdownRenderer.d.ts +1 -2
- package/lib/webview-ui/components/MarkdownRenderer.js +3 -8
- package/lib/webview-ui/components/MessageRenderer.d.ts +1 -2
- package/lib/webview-ui/components/MessageRenderer.js +48 -5
- package/lib/webview-ui/components/MultimodalFileRenderer.d.ts +2 -2
- package/lib/webview-ui/components/MultimodalFileRenderer.js +97 -40
- package/lib/webview-ui/components/ThinkingBlock.d.ts +2 -3
- package/lib/webview-ui/components/ThinkingBlock.js +0 -1
- package/lib/webview-ui/components/ToolUseBlock.d.ts +1 -2
- package/lib/webview-ui/components/ToolUseBlock.js +1 -2
- package/lib/webview-ui/components/ToolUseBlockHeader.d.ts +1 -2
- package/lib/webview-ui/components/ToolUseBlockHeader.js +1 -2
- package/lib/webview-ui/components/UploadPreview.d.ts +1 -2
- package/lib/webview-ui/components/UploadPreview.js +0 -1
- package/lib/webview-ui/components/WelcomeModule.d.ts +0 -1
- package/lib/webview-ui/components/WelcomeModule.js +46 -16
- package/lib/webview-ui/components/index.d.ts +0 -1
- package/lib/webview-ui/components/index.js +0 -1
- package/lib/webview-ui/config/cos-config.d.ts +0 -1
- package/lib/webview-ui/config/cos-config.js +0 -1
- package/lib/webview-ui/config/http-config.d.ts +0 -1
- package/lib/webview-ui/config/http-config.js +0 -1
- package/lib/webview-ui/constants.d.ts +0 -1
- package/lib/webview-ui/constants.js +0 -1
- package/lib/webview-ui/contexts/AgentContext.d.ts +1 -2
- package/lib/webview-ui/contexts/AgentContext.js +0 -1
- package/lib/webview-ui/contexts/AuthContext.d.ts +2 -2
- package/lib/webview-ui/contexts/AuthContext.js +0 -1
- package/lib/webview-ui/contexts/ThemeContext.d.ts +2 -2
- package/lib/webview-ui/contexts/ThemeContext.js +0 -1
- package/lib/webview-ui/hooks/useAgentStatus.d.ts +4 -2
- package/lib/webview-ui/hooks/useAgentStatus.js +31 -5
- package/lib/webview-ui/hooks/useUploader.d.ts +0 -1
- package/lib/webview-ui/hooks/useUploader.js +5 -2
- package/lib/webview-ui/hooks/useUserAvatar.d.ts +0 -1
- package/lib/webview-ui/hooks/useUserAvatar.js +0 -1
- package/lib/webview-ui/index.d.ts +1 -1
- package/lib/webview-ui/index.js +1 -1
- package/lib/webview-ui/services/agent-service.d.ts +14 -1
- package/lib/webview-ui/services/agent-service.js +7 -1
- package/lib/webview-ui/services/index.d.ts +0 -1
- package/lib/webview-ui/services/index.js +0 -1
- package/lib/webview-ui/services/logger-service.d.ts +0 -1
- package/lib/webview-ui/services/logger-service.js +0 -1
- package/lib/webview-ui/styles/copilot.d.ts +0 -1
- package/lib/webview-ui/styles/copilot.js +80 -22
- package/lib/webview-ui/styles/workarea.d.ts +0 -1
- package/lib/webview-ui/styles/workarea.js +7 -2
- package/lib/webview-ui/types.d.ts +11 -2
- package/lib/webview-ui/types.js +0 -1
- package/lib/webview-ui/utils/cos.d.ts +0 -1
- package/lib/webview-ui/utils/cos.js +4 -3
- package/lib/webview-ui/utils/env-helper.d.ts +6 -1
- package/lib/webview-ui/utils/env-helper.js +16 -2
- package/lib/webview-ui/utils/http-client.d.ts +1 -2
- package/lib/webview-ui/utils/http-client.js +0 -1
- package/lib/webview-ui/utils/markdownHighlight.d.ts +3 -0
- package/lib/webview-ui/utils/markdownHighlight.js +75 -0
- package/lib/webview-ui/utils/stream-text-handler.d.ts +0 -1
- package/lib/webview-ui/utils/stream-text-handler.js +6 -3
- package/lib/webview-ui/utils/upload.d.ts +0 -1
- package/lib/webview-ui/utils/upload.js +5 -2
- package/lib/webview-ui/widgets/BubbleComponents.d.ts +1 -2
- package/lib/webview-ui/widgets/BubbleComponents.js +1 -2
- package/lib/webview-ui/widgets/ChatInput.d.ts +1 -2
- package/lib/webview-ui/widgets/ChatInput.js +63 -90
- package/lib/webview-ui/widgets/LogPanel.d.ts +2 -3
- package/lib/webview-ui/widgets/LogPanel.js +5 -2
- package/lib/webview-ui/widgets/SystemLogs.d.ts +1 -2
- package/lib/webview-ui/widgets/SystemLogs.js +26 -9
- package/lib/webview-ui/widgets/ToolBar.d.ts +4 -3
- package/lib/webview-ui/widgets/ToolBar.js +6 -4
- package/lib/webview-ui/widgets/WebSocketDebugger.d.ts +6 -0
- package/lib/webview-ui/widgets/WebSocketDebugger.js +226 -0
- package/lib/webview-ui/widgets/index.d.ts +0 -1
- package/lib/webview-ui/widgets/index.js +0 -1
- package/package.json +9 -7
- package/public/assets/main.js +193 -166
- package/public/assets/style.css +1 -1
- package/lib/app.d.ts.map +0 -1
- package/lib/app.js.map +0 -1
- package/lib/config/api.config.d.ts.map +0 -1
- package/lib/config/api.config.js.map +0 -1
- package/lib/config/app.config.d.ts.map +0 -1
- package/lib/config/app.config.js.map +0 -1
- package/lib/config/upload.config.d.ts.map +0 -1
- package/lib/config/upload.config.js.map +0 -1
- package/lib/container/container.d.ts.map +0 -1
- package/lib/container/container.js.map +0 -1
- package/lib/container/identifiers.d.ts.map +0 -1
- package/lib/container/identifiers.js.map +0 -1
- package/lib/container/index.d.ts.map +0 -1
- package/lib/container/index.js.map +0 -1
- package/lib/container/types.d.ts.map +0 -1
- package/lib/container/types.js.map +0 -1
- package/lib/controllers/agent.controller.d.ts.map +0 -1
- package/lib/controllers/agent.controller.js.map +0 -1
- package/lib/controllers/auth.controller.d.ts.map +0 -1
- package/lib/controllers/auth.controller.js.map +0 -1
- package/lib/controllers/simulator.controller.d.ts.map +0 -1
- package/lib/controllers/simulator.controller.js.map +0 -1
- package/lib/controllers/upload.controller.d.ts.map +0 -1
- package/lib/controllers/upload.controller.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middleware/cors.middleware.d.ts.map +0 -1
- package/lib/middleware/cors.middleware.js.map +0 -1
- package/lib/middleware/error.middleware.d.ts.map +0 -1
- package/lib/middleware/error.middleware.js.map +0 -1
- package/lib/middleware/proxy.middleware.d.ts.map +0 -1
- package/lib/middleware/proxy.middleware.js.map +0 -1
- package/lib/middleware/upload.middleware.d.ts.map +0 -1
- package/lib/middleware/upload.middleware.js.map +0 -1
- package/lib/routes/agent.d.ts.map +0 -1
- package/lib/routes/agent.js.map +0 -1
- package/lib/routes/auth.d.ts.map +0 -1
- package/lib/routes/auth.js.map +0 -1
- package/lib/routes/index.d.ts.map +0 -1
- package/lib/routes/index.js.map +0 -1
- package/lib/routes/simulator.d.ts.map +0 -1
- package/lib/routes/simulator.js.map +0 -1
- package/lib/routes/upload.d.ts.map +0 -1
- package/lib/routes/upload.js.map +0 -1
- package/lib/services/agent.service.d.ts.map +0 -1
- package/lib/services/agent.service.js.map +0 -1
- package/lib/services/auth.service.d.ts.map +0 -1
- package/lib/services/auth.service.js.map +0 -1
- package/lib/services/simulator.service.d.ts.map +0 -1
- package/lib/services/simulator.service.js.map +0 -1
- package/lib/services/upload.service.d.ts.map +0 -1
- package/lib/services/upload.service.js.map +0 -1
- package/lib/simulator.d.ts.map +0 -1
- package/lib/simulator.js.map +0 -1
- package/lib/utils/env-helper.d.ts.map +0 -1
- package/lib/utils/env-helper.js.map +0 -1
- package/lib/utils/logger.d.ts.map +0 -1
- package/lib/utils/logger.js.map +0 -1
- package/lib/utils/request.d.ts.map +0 -1
- package/lib/utils/request.js.map +0 -1
- package/lib/utils/url-parser.d.ts.map +0 -1
- package/lib/utils/url-parser.js.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/webview-ui/Agent.d.ts.map +0 -1
- package/lib/webview-ui/Agent.js.map +0 -1
- package/lib/webview-ui/App.d.ts.map +0 -1
- package/lib/webview-ui/App.js.map +0 -1
- package/lib/webview-ui/ErrorBoundary.d.ts.map +0 -1
- package/lib/webview-ui/ErrorBoundary.js.map +0 -1
- package/lib/webview-ui/components/AsyncTaskBlock.d.ts.map +0 -1
- package/lib/webview-ui/components/AsyncTaskBlock.js.map +0 -1
- package/lib/webview-ui/components/AuthIndicator.d.ts.map +0 -1
- package/lib/webview-ui/components/AuthIndicator.js.map +0 -1
- package/lib/webview-ui/components/ErrorCard.d.ts.map +0 -1
- package/lib/webview-ui/components/ErrorCard.js.map +0 -1
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.d.ts.map +0 -1
- package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js.map +0 -1
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.d.ts.map +0 -1
- package/lib/webview-ui/components/KnowledgeBaseSearchResult.js.map +0 -1
- package/lib/webview-ui/components/MarkdownRenderer.d.ts.map +0 -1
- package/lib/webview-ui/components/MarkdownRenderer.js.map +0 -1
- package/lib/webview-ui/components/MessageRenderer.d.ts.map +0 -1
- package/lib/webview-ui/components/MessageRenderer.js.map +0 -1
- package/lib/webview-ui/components/MultimodalFileRenderer.d.ts.map +0 -1
- package/lib/webview-ui/components/MultimodalFileRenderer.js.map +0 -1
- package/lib/webview-ui/components/ThinkingBlock.d.ts.map +0 -1
- package/lib/webview-ui/components/ThinkingBlock.js.map +0 -1
- package/lib/webview-ui/components/ToolUseBlock.d.ts.map +0 -1
- package/lib/webview-ui/components/ToolUseBlock.js.map +0 -1
- package/lib/webview-ui/components/ToolUseBlockHeader.d.ts.map +0 -1
- package/lib/webview-ui/components/ToolUseBlockHeader.js.map +0 -1
- package/lib/webview-ui/components/UploadPreview.d.ts.map +0 -1
- package/lib/webview-ui/components/UploadPreview.js.map +0 -1
- package/lib/webview-ui/components/WelcomeModule.d.ts.map +0 -1
- package/lib/webview-ui/components/WelcomeModule.js.map +0 -1
- package/lib/webview-ui/components/index.d.ts.map +0 -1
- package/lib/webview-ui/components/index.js.map +0 -1
- package/lib/webview-ui/config/cos-config.d.ts.map +0 -1
- package/lib/webview-ui/config/cos-config.js.map +0 -1
- package/lib/webview-ui/config/http-config.d.ts.map +0 -1
- package/lib/webview-ui/config/http-config.js.map +0 -1
- package/lib/webview-ui/constants.d.ts.map +0 -1
- package/lib/webview-ui/constants.js.map +0 -1
- package/lib/webview-ui/contexts/AgentContext.d.ts.map +0 -1
- package/lib/webview-ui/contexts/AgentContext.js.map +0 -1
- package/lib/webview-ui/contexts/AuthContext.d.ts.map +0 -1
- package/lib/webview-ui/contexts/AuthContext.js.map +0 -1
- package/lib/webview-ui/contexts/ThemeContext.d.ts.map +0 -1
- package/lib/webview-ui/contexts/ThemeContext.js.map +0 -1
- package/lib/webview-ui/hooks/useAgentStatus.d.ts.map +0 -1
- package/lib/webview-ui/hooks/useAgentStatus.js.map +0 -1
- package/lib/webview-ui/hooks/useUploader.d.ts.map +0 -1
- package/lib/webview-ui/hooks/useUploader.js.map +0 -1
- package/lib/webview-ui/hooks/useUserAvatar.d.ts.map +0 -1
- package/lib/webview-ui/hooks/useUserAvatar.js.map +0 -1
- package/lib/webview-ui/index.d.ts.map +0 -1
- package/lib/webview-ui/index.js.map +0 -1
- package/lib/webview-ui/services/agent-service.d.ts.map +0 -1
- package/lib/webview-ui/services/agent-service.js.map +0 -1
- package/lib/webview-ui/services/index.d.ts.map +0 -1
- package/lib/webview-ui/services/index.js.map +0 -1
- package/lib/webview-ui/services/logger-service.d.ts.map +0 -1
- package/lib/webview-ui/services/logger-service.js.map +0 -1
- package/lib/webview-ui/styles/copilot.d.ts.map +0 -1
- package/lib/webview-ui/styles/copilot.js.map +0 -1
- package/lib/webview-ui/styles/workarea.d.ts.map +0 -1
- package/lib/webview-ui/styles/workarea.js.map +0 -1
- package/lib/webview-ui/types.d.ts.map +0 -1
- package/lib/webview-ui/types.js.map +0 -1
- package/lib/webview-ui/utils/cos.d.ts.map +0 -1
- package/lib/webview-ui/utils/cos.js.map +0 -1
- package/lib/webview-ui/utils/env-helper.d.ts.map +0 -1
- package/lib/webview-ui/utils/env-helper.js.map +0 -1
- package/lib/webview-ui/utils/http-client.d.ts.map +0 -1
- package/lib/webview-ui/utils/http-client.js.map +0 -1
- package/lib/webview-ui/utils/stream-text-handler.d.ts.map +0 -1
- package/lib/webview-ui/utils/stream-text-handler.js.map +0 -1
- package/lib/webview-ui/utils/upload.d.ts.map +0 -1
- package/lib/webview-ui/utils/upload.js.map +0 -1
- package/lib/webview-ui/widgets/BubbleComponents.d.ts.map +0 -1
- package/lib/webview-ui/widgets/BubbleComponents.js.map +0 -1
- package/lib/webview-ui/widgets/ChatInput.d.ts.map +0 -1
- package/lib/webview-ui/widgets/ChatInput.js.map +0 -1
- package/lib/webview-ui/widgets/LogPanel.d.ts.map +0 -1
- package/lib/webview-ui/widgets/LogPanel.js.map +0 -1
- package/lib/webview-ui/widgets/SystemLogs.d.ts.map +0 -1
- package/lib/webview-ui/widgets/SystemLogs.js.map +0 -1
- package/lib/webview-ui/widgets/ToolBar.d.ts.map +0 -1
- package/lib/webview-ui/widgets/ToolBar.js.map +0 -1
- package/lib/webview-ui/widgets/index.d.ts.map +0 -1
- package/lib/webview-ui/widgets/index.js.map +0 -1
|
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.AgentService = void 0;
|
|
19
|
+
const endpoints_1 = require("@vectorx/endpoints");
|
|
19
20
|
const form_data_1 = __importDefault(require("form-data"));
|
|
20
21
|
const inversify_1 = require("inversify");
|
|
21
22
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
@@ -24,23 +25,30 @@ const url_parser_1 = require("../utils/url-parser");
|
|
|
24
25
|
let AgentService = class AgentService {
|
|
25
26
|
constructor(context) {
|
|
26
27
|
this.parsedServerUrl = (0, url_parser_1.parseAgentServerUrl)(context.agentServerUrl);
|
|
28
|
+
this.agentId = context.agentId;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
|
-
* 获取Agent
|
|
31
|
+
* 获取 Agent 信息。
|
|
32
|
+
* 直接请求 agentbase `/agent/info`,不经过开发者 Agent Server(rcb-ff),
|
|
33
|
+
* 避免开发者代码异常导致获取失败。
|
|
30
34
|
*/
|
|
31
35
|
async getAgentInfo() {
|
|
32
|
-
const
|
|
33
|
-
const response = await (0, node_fetch_1.default)(
|
|
36
|
+
const agentInfoUrl = `${(0, endpoints_1.getAgentbaseBaseUrl)()}/agent/info`;
|
|
37
|
+
const response = await (0, node_fetch_1.default)(agentInfoUrl, {
|
|
38
|
+
headers: {
|
|
39
|
+
...(this.agentId ? { "agent-id": this.agentId } : {}),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
34
42
|
if (!response.ok) {
|
|
35
|
-
throw new Error(
|
|
43
|
+
throw new Error(`agentbase 响应异常: ${response.status} ${response.statusText}`);
|
|
36
44
|
}
|
|
37
45
|
const resData = await response.json();
|
|
38
46
|
if (resData.code !== 0) {
|
|
39
|
-
throw new Error(
|
|
47
|
+
throw new Error(`agentbase 返回错误: ${resData.message || "未知错误"}`);
|
|
40
48
|
}
|
|
41
49
|
const { agent_info } = resData.data;
|
|
42
50
|
if (!agent_info) {
|
|
43
|
-
throw new Error("
|
|
51
|
+
throw new Error("agentbase 返回数据异常:缺少 agent_info 字段");
|
|
44
52
|
}
|
|
45
53
|
return this.transformToAgentSimulatorInfo(agent_info);
|
|
46
54
|
}
|
|
@@ -53,7 +61,10 @@ let AgentService = class AgentService {
|
|
|
53
61
|
const healthUrl = `${this.parsedServerUrl.fullUrl}/health`;
|
|
54
62
|
const response = await (0, node_fetch_1.default)(healthUrl);
|
|
55
63
|
if (response.ok) {
|
|
56
|
-
const
|
|
64
|
+
const contentType = response.headers.get("content-type");
|
|
65
|
+
const healthData = contentType?.includes("application/json") && response.status !== 204
|
|
66
|
+
? await response.json()
|
|
67
|
+
: null;
|
|
57
68
|
return {
|
|
58
69
|
status: "normal",
|
|
59
70
|
health: healthData,
|
|
@@ -94,6 +105,22 @@ let AgentService = class AgentService {
|
|
|
94
105
|
};
|
|
95
106
|
}
|
|
96
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 获取函数能力元数据(用于检测函数是否支持 WebSocket 等特性)
|
|
110
|
+
*/
|
|
111
|
+
async getFunctionMeta() {
|
|
112
|
+
try {
|
|
113
|
+
const metaUrl = `${this.parsedServerUrl.baseUrl}/@meta`;
|
|
114
|
+
const response = await (0, node_fetch_1.default)(metaUrl);
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
return { functions: [] };
|
|
117
|
+
}
|
|
118
|
+
return (await response.json());
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return { functions: [] };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
97
124
|
/**
|
|
98
125
|
* 上传文件到云函数
|
|
99
126
|
* 使用 multipart/form-data 格式传输,对齐 OpenAI 文件上传标准
|
|
@@ -144,4 +171,3 @@ exports.AgentService = AgentService = __decorate([
|
|
|
144
171
|
__param(0, (0, inversify_1.inject)(container_1.APP_CONTEXT)),
|
|
145
172
|
__metadata("design:paramtypes", [Object])
|
|
146
173
|
], AgentService);
|
|
147
|
-
//# sourceMappingURL=agent.service.js.map
|
|
@@ -46,10 +46,9 @@ export declare class AuthService implements IAuthService {
|
|
|
46
46
|
/**
|
|
47
47
|
* 检查登录状态(调用下游服务)
|
|
48
48
|
*/
|
|
49
|
-
check(
|
|
49
|
+
check(_params: {
|
|
50
50
|
secret_id: string;
|
|
51
51
|
nonce: string;
|
|
52
52
|
cli_token: string;
|
|
53
53
|
}): Promise<any>;
|
|
54
54
|
}
|
|
55
|
-
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -43,9 +43,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.AuthService = void 0;
|
|
46
|
-
const fs = __importStar(require("fs"));
|
|
47
|
-
const os = __importStar(require("os"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const os = __importStar(require("node:os"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
49
|
const inversify_1 = require("inversify");
|
|
50
50
|
const env_helper_1 = require("../utils/env-helper");
|
|
51
51
|
/**
|
|
@@ -88,7 +88,7 @@ let AuthService = class AuthService {
|
|
|
88
88
|
}
|
|
89
89
|
return loginInfo;
|
|
90
90
|
}
|
|
91
|
-
catch (
|
|
91
|
+
catch (_error) {
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -124,7 +124,7 @@ let AuthService = class AuthService {
|
|
|
124
124
|
/**
|
|
125
125
|
* 检查登录状态(调用下游服务)
|
|
126
126
|
*/
|
|
127
|
-
async check(
|
|
127
|
+
async check(_params) {
|
|
128
128
|
// 这里可以调用下游服务进行验证
|
|
129
129
|
// 暂时返回模拟数据
|
|
130
130
|
return {
|
|
@@ -138,4 +138,3 @@ exports.AuthService = AuthService = __decorate([
|
|
|
138
138
|
(0, inversify_1.injectable)(),
|
|
139
139
|
__metadata("design:paramtypes", [])
|
|
140
140
|
], AuthService);
|
|
141
|
-
//# sourceMappingURL=auth.service.js.map
|
package/lib/simulator.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export interface SimulatorOptions {
|
|
|
2
2
|
port: number;
|
|
3
3
|
agentServerUrl: string;
|
|
4
4
|
open?: boolean;
|
|
5
|
+
/** 静默模式:不输出启动日志(用于 useIde 等场景由调用方统一输出) */
|
|
6
|
+
quiet?: boolean;
|
|
7
|
+
/** Agent ID(来自 project.config.json),用于直接向 agentbase 查询 Agent 信息 */
|
|
8
|
+
agentId?: string;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
11
|
* Agent模拟器实现
|
|
@@ -19,9 +23,15 @@ export declare class AgentSimulator {
|
|
|
19
23
|
* 配置并启动模拟器
|
|
20
24
|
*/
|
|
21
25
|
start(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 设置 WebSocket 代理:将 /ws-proxy/* 请求透传到 rcb-ff
|
|
28
|
+
*
|
|
29
|
+
* 实现策略:先完成浏览器侧握手,再连接上游 rcb-ff。
|
|
30
|
+
* 上游连接成功前,客户端消息暂存在队列中,连接就绪后逐条发出。
|
|
31
|
+
*/
|
|
32
|
+
private setupWebSocketProxy;
|
|
22
33
|
/**
|
|
23
34
|
* 停止模拟器
|
|
24
35
|
*/
|
|
25
36
|
stop(): Promise<void>;
|
|
26
37
|
}
|
|
27
|
-
//# sourceMappingURL=simulator.d.ts.map
|
package/lib/simulator.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AgentSimulator = void 0;
|
|
4
|
+
const ws_1 = require("ws");
|
|
4
5
|
const app_1 = require("./app");
|
|
5
6
|
const logger_1 = require("./utils/logger");
|
|
7
|
+
const url_parser_1 = require("./utils/url-parser");
|
|
6
8
|
/**
|
|
7
9
|
* Agent模拟器实现
|
|
8
10
|
*/
|
|
@@ -21,6 +23,7 @@ class AgentSimulator {
|
|
|
21
23
|
port: options.port,
|
|
22
24
|
agentServerUrl: options.agentServerUrl,
|
|
23
25
|
open: options.open,
|
|
26
|
+
agentId: options.agentId,
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
@@ -32,7 +35,9 @@ class AgentSimulator {
|
|
|
32
35
|
// 启动服务器
|
|
33
36
|
return new Promise((resolve) => {
|
|
34
37
|
this.server = expressApp.listen(config.port, () => {
|
|
35
|
-
|
|
38
|
+
this.setupWebSocketProxy();
|
|
39
|
+
if (!this.options.quiet) {
|
|
40
|
+
logger_1.Logger.success(`
|
|
36
41
|
┌────────────────────────────────────────────────────┐
|
|
37
42
|
│ │
|
|
38
43
|
│ 🚀 Agent模拟器已启动! │
|
|
@@ -41,15 +46,95 @@ class AgentSimulator {
|
|
|
41
46
|
│ 🔄 Agent服务: ${config.agentServerUrl} │
|
|
42
47
|
│ │
|
|
43
48
|
└────────────────────────────────────────────────────┘
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
`);
|
|
50
|
+
// 自动打开浏览器提示
|
|
51
|
+
if (config.open) {
|
|
52
|
+
logger_1.Logger.warning(`请手动在浏览器中打开: ${logger_1.Logger.info(`http://localhost:${config.port}`)}`);
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
55
|
resolve();
|
|
50
56
|
});
|
|
51
57
|
});
|
|
52
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* 设置 WebSocket 代理:将 /ws-proxy/* 请求透传到 rcb-ff
|
|
61
|
+
*
|
|
62
|
+
* 实现策略:先完成浏览器侧握手,再连接上游 rcb-ff。
|
|
63
|
+
* 上游连接成功前,客户端消息暂存在队列中,连接就绪后逐条发出。
|
|
64
|
+
*/
|
|
65
|
+
setupWebSocketProxy() {
|
|
66
|
+
if (!this.server)
|
|
67
|
+
return;
|
|
68
|
+
const parsed = (0, url_parser_1.parseAgentServerUrl)(this.options.agentServerUrl);
|
|
69
|
+
const rcbWsBase = `ws://${parsed.hostname}:${parsed.port}`;
|
|
70
|
+
const proxyWss = new ws_1.WebSocketServer({ noServer: true });
|
|
71
|
+
this.server.on("upgrade", (req, socket, head) => {
|
|
72
|
+
if (!req.url?.startsWith("/ws-proxy/"))
|
|
73
|
+
return;
|
|
74
|
+
const targetPath = req.url.replace("/ws-proxy", "");
|
|
75
|
+
const targetUrl = `${rcbWsBase}${targetPath}`;
|
|
76
|
+
proxyWss.handleUpgrade(req, socket, head, (clientWs) => {
|
|
77
|
+
const pendingMessages = [];
|
|
78
|
+
let upstreamReady = false;
|
|
79
|
+
const upstream = new ws_1.WebSocket(targetUrl, {
|
|
80
|
+
headers: { origin: req.headers.origin || "" },
|
|
81
|
+
});
|
|
82
|
+
upstream.on("open", () => {
|
|
83
|
+
upstreamReady = true;
|
|
84
|
+
console.log(`[ws-proxy] upstream connected to ${targetUrl}`);
|
|
85
|
+
for (const msg of pendingMessages) {
|
|
86
|
+
upstream.send(msg.data, { binary: msg.isBinary });
|
|
87
|
+
}
|
|
88
|
+
pendingMessages.length = 0;
|
|
89
|
+
});
|
|
90
|
+
upstream.on("message", (data, isBinary) => {
|
|
91
|
+
console.log(`[ws-proxy] upstream->client: ${String(Buffer.isBuffer(data) ? data.toString() : data).slice(0, 100)}`);
|
|
92
|
+
if (clientWs.readyState === ws_1.WebSocket.OPEN) {
|
|
93
|
+
clientWs.send(data, { binary: isBinary });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
clientWs.on("message", (data, isBinary) => {
|
|
97
|
+
console.log(`[ws-proxy] client->upstream: ready=${upstreamReady} state=${upstream.readyState} data=${String(Buffer.isBuffer(data) ? data.toString() : data).slice(0, 100)}`);
|
|
98
|
+
if (upstreamReady && upstream.readyState === ws_1.WebSocket.OPEN) {
|
|
99
|
+
upstream.send(data, { binary: isBinary });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
pendingMessages.push({ data, isBinary });
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const safeClose = (ws, code, reason) => {
|
|
106
|
+
try {
|
|
107
|
+
if (ws.readyState === ws_1.WebSocket.OPEN) {
|
|
108
|
+
const safeCode = code && code >= 1000 && code <= 4999 ? code : 1000;
|
|
109
|
+
ws.close(safeCode, reason || "");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
try {
|
|
114
|
+
ws.terminate();
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
/* ignore */
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
upstream.on("close", (code, reason) => {
|
|
122
|
+
safeClose(clientWs, code, reason?.toString());
|
|
123
|
+
});
|
|
124
|
+
clientWs.on("close", (code, reason) => {
|
|
125
|
+
safeClose(upstream, code, reason?.toString());
|
|
126
|
+
});
|
|
127
|
+
upstream.on("error", (err) => {
|
|
128
|
+
console.error(`[ws-proxy] upstream error:`, err?.message || err);
|
|
129
|
+
safeClose(clientWs, 1011, "upstream error");
|
|
130
|
+
});
|
|
131
|
+
clientWs.on("error", (err) => {
|
|
132
|
+
console.error(`[ws-proxy] client error:`, err?.message || err);
|
|
133
|
+
safeClose(upstream, 1011, "client error");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
53
138
|
/**
|
|
54
139
|
* 停止模拟器
|
|
55
140
|
*/
|
|
@@ -76,4 +161,3 @@ class AgentSimulator {
|
|
|
76
161
|
}
|
|
77
162
|
}
|
|
78
163
|
exports.AgentSimulator = AgentSimulator;
|
|
79
|
-
//# sourceMappingURL=simulator.js.map
|
package/lib/utils/env-helper.js
CHANGED
package/lib/utils/logger.d.ts
CHANGED
package/lib/utils/logger.js
CHANGED
package/lib/utils/request.d.ts
CHANGED
package/lib/utils/request.js
CHANGED
|
@@ -28,9 +28,13 @@ exports.request = {
|
|
|
28
28
|
body = JSON.stringify(data);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const res = await (0, node_fetch_1.default)(finalUrl, {
|
|
31
|
+
const res = await (0, node_fetch_1.default)(finalUrl, {
|
|
32
|
+
method,
|
|
33
|
+
headers: finalHeaders,
|
|
34
|
+
body: body,
|
|
35
|
+
timeout: 1000 * 20,
|
|
36
|
+
});
|
|
32
37
|
const json = await res.json().catch(() => ({}));
|
|
33
38
|
return { status: res.status, ok: res.ok, data: json };
|
|
34
39
|
},
|
|
35
40
|
};
|
|
36
|
-
//# sourceMappingURL=request.js.map
|
package/lib/utils/url-parser.js
CHANGED
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -2,4 +2,3 @@ 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
4
|
export declare function getQueryTasksUri(agentSimulatorInfo: AgentSimulatorInfo, taskId?: string): string;
|
|
5
|
-
//# sourceMappingURL=Agent.d.ts.map
|
package/lib/webview-ui/Agent.js
CHANGED
package/lib/webview-ui/App.d.ts
CHANGED