@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
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketDebugger = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("@ant-design/icons");
|
|
6
|
+
const antd_1 = require("antd");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const ThemeContext_1 = require("../contexts/ThemeContext");
|
|
9
|
+
const WebSocketDebugger = ({ wsProxyBase }) => {
|
|
10
|
+
const { isDark } = (0, ThemeContext_1.useThemeHook)();
|
|
11
|
+
const { token } = antd_1.theme.useToken();
|
|
12
|
+
const [wsUrl, setWsUrl] = (0, react_1.useState)(wsProxyBase);
|
|
13
|
+
const [status, setStatus] = (0, react_1.useState)("disconnected");
|
|
14
|
+
const [messages, setMessages] = (0, react_1.useState)([]);
|
|
15
|
+
const [inputValue, setInputValue] = (0, react_1.useState)("");
|
|
16
|
+
const [format, setFormat] = (0, react_1.useState)("text");
|
|
17
|
+
const wsRef = (0, react_1.useRef)(null);
|
|
18
|
+
const msgIdRef = (0, react_1.useRef)(0);
|
|
19
|
+
const messagesEndRef = (0, react_1.useRef)(null);
|
|
20
|
+
const scrollToBottom = (0, react_1.useCallback)(() => {
|
|
21
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
22
|
+
}, []);
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
scrollToBottom();
|
|
25
|
+
}, [messages, scrollToBottom]);
|
|
26
|
+
const addMessage = (0, react_1.useCallback)((direction, content, size) => {
|
|
27
|
+
const msg = {
|
|
28
|
+
id: `msg-${++msgIdRef.current}`,
|
|
29
|
+
direction,
|
|
30
|
+
content,
|
|
31
|
+
timestamp: Date.now(),
|
|
32
|
+
size,
|
|
33
|
+
};
|
|
34
|
+
setMessages((prev) => [...prev, msg]);
|
|
35
|
+
}, []);
|
|
36
|
+
const connect = (0, react_1.useCallback)(() => {
|
|
37
|
+
if (wsRef.current) {
|
|
38
|
+
wsRef.current.close();
|
|
39
|
+
}
|
|
40
|
+
setStatus("connecting");
|
|
41
|
+
addMessage("system", `Connecting to ${wsUrl} ...`);
|
|
42
|
+
try {
|
|
43
|
+
const ws = new WebSocket(wsUrl);
|
|
44
|
+
wsRef.current = ws;
|
|
45
|
+
ws.onopen = () => {
|
|
46
|
+
setStatus("connected");
|
|
47
|
+
addMessage("system", "Connected successfully");
|
|
48
|
+
};
|
|
49
|
+
ws.onmessage = (event) => {
|
|
50
|
+
const data = typeof event.data === "string" ? event.data : "[Binary Data]";
|
|
51
|
+
const size = typeof event.data === "string" ? new Blob([event.data]).size : undefined;
|
|
52
|
+
addMessage("received", data, size);
|
|
53
|
+
};
|
|
54
|
+
ws.onclose = (event) => {
|
|
55
|
+
setStatus("disconnected");
|
|
56
|
+
addMessage("system", `Connection closed (code: ${event.code}${event.reason ? `, reason: ${event.reason}` : ""})`);
|
|
57
|
+
wsRef.current = null;
|
|
58
|
+
};
|
|
59
|
+
ws.onerror = () => {
|
|
60
|
+
setStatus("error");
|
|
61
|
+
addMessage("system", "Connection error");
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
setStatus("error");
|
|
66
|
+
addMessage("system", `Failed to connect: ${err}`);
|
|
67
|
+
}
|
|
68
|
+
}, [wsUrl, addMessage]);
|
|
69
|
+
const disconnect = (0, react_1.useCallback)(() => {
|
|
70
|
+
if (wsRef.current) {
|
|
71
|
+
wsRef.current.close(1000, "User disconnected");
|
|
72
|
+
wsRef.current = null;
|
|
73
|
+
}
|
|
74
|
+
}, []);
|
|
75
|
+
const sendMessage = (0, react_1.useCallback)(() => {
|
|
76
|
+
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN || !inputValue.trim())
|
|
77
|
+
return;
|
|
78
|
+
let payload = inputValue;
|
|
79
|
+
if (format === "json") {
|
|
80
|
+
try {
|
|
81
|
+
payload = JSON.stringify(JSON.parse(inputValue), null, 0);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
addMessage("system", "Invalid JSON format");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
wsRef.current.send(payload);
|
|
89
|
+
addMessage("sent", payload, new Blob([payload]).size);
|
|
90
|
+
setInputValue("");
|
|
91
|
+
}, [inputValue, format, addMessage]);
|
|
92
|
+
const clearMessages = (0, react_1.useCallback)(() => {
|
|
93
|
+
setMessages([]);
|
|
94
|
+
}, []);
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
return () => {
|
|
97
|
+
wsRef.current?.close();
|
|
98
|
+
};
|
|
99
|
+
}, []);
|
|
100
|
+
const getStatusColor = () => {
|
|
101
|
+
switch (status) {
|
|
102
|
+
case "connected":
|
|
103
|
+
return token.colorSuccess;
|
|
104
|
+
case "connecting":
|
|
105
|
+
return token.colorWarning;
|
|
106
|
+
case "error":
|
|
107
|
+
return token.colorError;
|
|
108
|
+
default:
|
|
109
|
+
return token.colorTextDisabled;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const getStatusText = () => {
|
|
113
|
+
switch (status) {
|
|
114
|
+
case "connected":
|
|
115
|
+
return "Connected";
|
|
116
|
+
case "connecting":
|
|
117
|
+
return "Connecting...";
|
|
118
|
+
case "error":
|
|
119
|
+
return "Error";
|
|
120
|
+
default:
|
|
121
|
+
return "Disconnected";
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const getMessageStyle = (direction) => {
|
|
125
|
+
switch (direction) {
|
|
126
|
+
case "sent":
|
|
127
|
+
return {
|
|
128
|
+
background: isDark ? "#112a11" : "#f0fff0",
|
|
129
|
+
borderLeft: `3px solid ${token.colorSuccess}`,
|
|
130
|
+
};
|
|
131
|
+
case "received":
|
|
132
|
+
return {
|
|
133
|
+
background: isDark ? "#0d1b2a" : "#f0f5ff",
|
|
134
|
+
borderLeft: `3px solid ${token.colorPrimary}`,
|
|
135
|
+
};
|
|
136
|
+
case "system":
|
|
137
|
+
return {
|
|
138
|
+
background: isDark ? "#1f1f1f" : "#fafafa",
|
|
139
|
+
borderLeft: `3px solid ${token.colorTextDisabled}`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const formatTimestamp = (ts) => {
|
|
144
|
+
const d = new Date(ts);
|
|
145
|
+
return d.toLocaleTimeString("en-US", { hour12: false, fractionalSecondDigits: 3 });
|
|
146
|
+
};
|
|
147
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
148
|
+
display: "flex",
|
|
149
|
+
flexDirection: "column",
|
|
150
|
+
height: "100%",
|
|
151
|
+
background: token.colorBgContainer,
|
|
152
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
153
|
+
padding: "12px 16px",
|
|
154
|
+
borderBottom: `1px solid ${token.colorBorderSecondary}`,
|
|
155
|
+
display: "flex",
|
|
156
|
+
gap: 8,
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
flexShrink: 0,
|
|
159
|
+
}, children: [(0, jsx_runtime_1.jsx)(antd_1.Input, { value: wsUrl, onChange: (e) => setWsUrl(e.target.value), placeholder: "ws://localhost:PORT/path", disabled: status === "connected" || status === "connecting", style: { flex: 1 }, onPressEnter: () => {
|
|
160
|
+
if (status === "disconnected" || status === "error")
|
|
161
|
+
connect();
|
|
162
|
+
} }), status === "connected" || status === "connecting" ? ((0, jsx_runtime_1.jsx)(antd_1.Button, { icon: (0, jsx_runtime_1.jsx)(icons_1.DisconnectOutlined, {}), danger: true, onClick: disconnect, children: "Disconnect" })) : ((0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", icon: (0, jsx_runtime_1.jsx)(icons_1.ApiOutlined, {}), onClick: connect, children: "Connect" }))] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
163
|
+
padding: "6px 16px",
|
|
164
|
+
borderBottom: `1px solid ${token.colorBorderSecondary}`,
|
|
165
|
+
display: "flex",
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
justifyContent: "space-between",
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
flexShrink: 0,
|
|
170
|
+
}, children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, { size: 8, children: [(0, jsx_runtime_1.jsx)("span", { style: {
|
|
171
|
+
width: 8,
|
|
172
|
+
height: 8,
|
|
173
|
+
borderRadius: "50%",
|
|
174
|
+
background: getStatusColor(),
|
|
175
|
+
display: "inline-block",
|
|
176
|
+
} }), (0, jsx_runtime_1.jsx)("span", { style: { color: token.colorTextSecondary }, children: getStatusText() }), status === "connected" && ((0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "green", style: { margin: 0 }, children: "WS" }))] }), (0, jsx_runtime_1.jsxs)(antd_1.Space, { size: 8, children: [(0, jsx_runtime_1.jsxs)("span", { style: { color: token.colorTextQuaternary }, children: [messages.filter((m) => m.direction !== "system").length, " messages"] }), (0, jsx_runtime_1.jsx)(antd_1.Tooltip, { title: "Clear messages", children: (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "text", size: "small", icon: (0, jsx_runtime_1.jsx)(icons_1.CloseCircleOutlined, {}), onClick: clearMessages }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
177
|
+
flex: 1,
|
|
178
|
+
overflow: "auto",
|
|
179
|
+
padding: "8px 16px",
|
|
180
|
+
}, children: [messages.length === 0 ? ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
181
|
+
display: "flex",
|
|
182
|
+
alignItems: "center",
|
|
183
|
+
justifyContent: "center",
|
|
184
|
+
height: "100%",
|
|
185
|
+
color: token.colorTextQuaternary,
|
|
186
|
+
flexDirection: "column",
|
|
187
|
+
gap: 8,
|
|
188
|
+
}, children: [(0, jsx_runtime_1.jsx)(icons_1.ApiOutlined, { style: { fontSize: 32 } }), (0, jsx_runtime_1.jsx)("span", { children: "Enter a WebSocket URL and click Connect to start debugging" })] })) : (messages.map((msg) => ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
189
|
+
padding: "8px 12px",
|
|
190
|
+
marginBottom: 4,
|
|
191
|
+
borderRadius: 4,
|
|
192
|
+
fontFamily: "monospace",
|
|
193
|
+
fontSize: 13,
|
|
194
|
+
...getMessageStyle(msg.direction),
|
|
195
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
196
|
+
display: "flex",
|
|
197
|
+
justifyContent: "space-between",
|
|
198
|
+
marginBottom: 4,
|
|
199
|
+
fontSize: 11,
|
|
200
|
+
color: token.colorTextSecondary,
|
|
201
|
+
}, children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, { size: 6, children: [(0, jsx_runtime_1.jsx)("span", { children: msg.direction === "sent"
|
|
202
|
+
? "SENT"
|
|
203
|
+
: msg.direction === "received"
|
|
204
|
+
? "RECV"
|
|
205
|
+
: "SYS" }), msg.size !== undefined && (0, jsx_runtime_1.jsxs)("span", { children: [msg.size, " bytes"] })] }), (0, jsx_runtime_1.jsx)("span", { children: formatTimestamp(msg.timestamp) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
206
|
+
wordBreak: "break-all",
|
|
207
|
+
whiteSpace: "pre-wrap",
|
|
208
|
+
color: msg.direction === "system" ? token.colorTextSecondary : token.colorText,
|
|
209
|
+
}, children: msg.content })] }, msg.id)))), (0, jsx_runtime_1.jsx)("div", { ref: messagesEndRef })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
210
|
+
padding: "12px 16px",
|
|
211
|
+
borderTop: `1px solid ${token.colorBorderSecondary}`,
|
|
212
|
+
display: "flex",
|
|
213
|
+
gap: 8,
|
|
214
|
+
alignItems: "flex-end",
|
|
215
|
+
flexShrink: 0,
|
|
216
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 6 }, children: [(0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { size: "small", value: format, onChange: (e) => setFormat(e.target.value), optionType: "button", buttonStyle: "solid", options: [
|
|
217
|
+
{ label: "Text", value: "text" },
|
|
218
|
+
{ label: "JSON", value: "json" },
|
|
219
|
+
] }), (0, jsx_runtime_1.jsx)(antd_1.Input.TextArea, { value: inputValue, onChange: (e) => setInputValue(e.target.value), placeholder: format === "json" ? '{"key": "value"}' : "Type a message...", autoSize: { minRows: 1, maxRows: 4 }, disabled: status !== "connected", onPressEnter: (e) => {
|
|
220
|
+
if (!e.shiftKey) {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
sendMessage();
|
|
223
|
+
}
|
|
224
|
+
} })] }), (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", icon: (0, jsx_runtime_1.jsx)(icons_1.SendOutlined, {}), onClick: sendMessage, disabled: status !== "connected" || !inputValue.trim(), children: "Send" })] })] }));
|
|
225
|
+
};
|
|
226
|
+
exports.WebSocketDebugger = WebSocketDebugger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorx/agent-simulator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Development simulator for VectorX AI agents",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -24,14 +24,12 @@
|
|
|
24
24
|
"author": "",
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=20.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ant-design/icons": "^5.2.6",
|
|
31
31
|
"@ant-design/x": "^1.2.0",
|
|
32
32
|
"@types/form-data": "^2.5.2",
|
|
33
|
-
"@vectorx/ai-sdk": "1.0.0",
|
|
34
|
-
"@vectorx/functions-framework": "1.0.0",
|
|
35
33
|
"antd": "^5.0.0",
|
|
36
34
|
"antd-style": "^3.7.1",
|
|
37
35
|
"axios": "^1.11.0",
|
|
@@ -56,9 +54,14 @@
|
|
|
56
54
|
"react-dom": "^18.2.0",
|
|
57
55
|
"react-markdown": "^9.0.1",
|
|
58
56
|
"react-syntax-highlighter": "^15.5.0",
|
|
59
|
-
"reflect-metadata": "^0.2.1"
|
|
57
|
+
"reflect-metadata": "^0.2.1",
|
|
58
|
+
"ws": "^8.18.0",
|
|
59
|
+
"@vectorx/ai-sdk": "1.1.0",
|
|
60
|
+
"@vectorx/endpoints": "1.1.0",
|
|
61
|
+
"@vectorx/functions-framework": "1.1.0"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
64
|
+
"@types/ws": "^8.5.10",
|
|
62
65
|
"@types/cors": "^2.8.17",
|
|
63
66
|
"@types/express": "^4.17.21",
|
|
64
67
|
"@types/inversify": "^2.0.33",
|
|
@@ -88,6 +91,5 @@
|
|
|
88
91
|
"build": "npm run build:server && npm run build:client",
|
|
89
92
|
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
90
93
|
"fix": "eslint 'src/**/*.{ts,tsx}' --fix"
|
|
91
|
-
}
|
|
92
|
-
"readme": "# VectorX Agent Simulator\n\nVectorX Agent模拟器是一个开发工具,用于帮助开发和调试AI代理应用。它提供了一个简单的界面和调试环境,允许开发者在本地模拟API请求和响应。\n\n## 特性\n\n- 提供Web界面用于实时查看模拟器状态\n- 使用标准 Fetch API 直接连接Agent服务\n- 支持流式响应和普通 JSON 响应\n- 提供命令行工具,便于快速启动和配置\n\n## 安装\n\n```bash\n# 在项目根目录安装依赖\nnpm install\n\n# 构建模拟器\ncd packages/vectorx-agent-simulator\nnpm run build\n```\n\n## 实现方式\n\nVectorX Agent Simulator 使用标准的 Fetch API 直接连接Agent服务。\n\n这种实现方式具有以下优势:\n- 使用标准 Web API,无需额外依赖\n- 直接与Agent服务通信,无需模拟层\n- 支持流式响应,实时更新内容\n- 便于理解和扩展\n\n## 使用方法\n\n### 命令行\n\n使用以下命令启动模拟器:\n\n```bash\nagent -p 3001 --agent-server-url http://localhost:3000/v1/aiagent/agents/123\n```\n\n#### 命令行参数\n\n- `-p, --port <port>`: 模拟器HTTP服务端口 (默认: 3001)\n- `--agent-server-url <agentServerUrl>`: **[必填]** Agent服务器完整URL地址,例如: http://localhost:3000/v1/aiagent/agents/123\n- `-o, --open`: 启动后自动打开浏览器 (默认: true)\n\n#### 示例\n\n```bash\n# 基本使用\nagent --agent-server-url http://localhost:3000/v1/aiagent/agents/my-agent\n\n# 指定端口\nagent -p 8080 --agent-server-url http://localhost:3000/v1/aiagent/agents/my-agent\n\n# 不自动打开浏览器\nagent --agent-server-url http://localhost:3000/v1/aiagent/agents/my-agent --no-open\n```\n\n## 开发\n\n要在开发模式下运行模拟器:\n\n```bash\n# 监视文件变化并重新构建\nnpm run dev\n\n# 在另一个终端启动模拟器\nnode bin/agent.js --agent-server-url http://localhost:3000/v1/aiagent/agents/demo-agent\n```\n\n## 许可证\n\nISC "
|
|
94
|
+
}
|
|
93
95
|
}
|