@vectorx/agent-simulator 0.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.
Files changed (67) hide show
  1. package/README.md +76 -0
  2. package/bin/agent.js +55 -0
  3. package/lib/index.js +5 -0
  4. package/lib/simulator.js +224 -0
  5. package/lib/types.js +2 -0
  6. package/lib/utils.js +7 -0
  7. package/lib/webview-ui/Agent.js +16 -0
  8. package/lib/webview-ui/App.js +359 -0
  9. package/lib/webview-ui/ErrorBoundary.js +57 -0
  10. package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js +62 -0
  11. package/lib/webview-ui/components/KnowledgeBaseSearchResult.js +37 -0
  12. package/lib/webview-ui/components/MarkdownRenderer.js +27 -0
  13. package/lib/webview-ui/components/MessageRenderer.js +36 -0
  14. package/lib/webview-ui/components/ThinkingBlock.js +105 -0
  15. package/lib/webview-ui/components/ToolUseBlock.js +20 -0
  16. package/lib/webview-ui/components/ToolUseBlockHeader.js +48 -0
  17. package/lib/webview-ui/components/index.js +23 -0
  18. package/lib/webview-ui/constants.js +24 -0
  19. package/lib/webview-ui/contexts/ThemeContext.js +50 -0
  20. package/lib/webview-ui/hooks/useAgentStatus.js +96 -0
  21. package/lib/webview-ui/index.js +17 -0
  22. package/lib/webview-ui/services/agent-service.js +33 -0
  23. package/lib/webview-ui/services/logger-service.js +51 -0
  24. package/lib/webview-ui/styles/copilot.js +118 -0
  25. package/lib/webview-ui/styles/workarea.js +72 -0
  26. package/lib/webview-ui/types/index.js +2 -0
  27. package/lib/webview-ui/types.js +2 -0
  28. package/lib/webview-ui/widgets/BubbleComponents.js +114 -0
  29. package/lib/webview-ui/widgets/LogPanel.js +66 -0
  30. package/lib/webview-ui/widgets/SystemLogs.js +404 -0
  31. package/lib/webview-ui/widgets/ToolBar.js +109 -0
  32. package/lib/webview-ui/widgets/index.js +20 -0
  33. package/package.json +79 -0
  34. package/public/assets/index-j_rEEDWU.js +93 -0
  35. package/public/assets/main.js +580 -0
  36. package/public/assets/style.css +1 -0
  37. package/public/index.html +15 -0
  38. package/types/index.d.ts +3 -0
  39. package/types/simulator.d.ts +15 -0
  40. package/types/types.d.ts +6 -0
  41. package/types/utils.d.ts +1 -0
  42. package/types/webview-ui/Agent.d.ts +3 -0
  43. package/types/webview-ui/App.d.ts +3 -0
  44. package/types/webview-ui/ErrorBoundary.d.ts +18 -0
  45. package/types/webview-ui/components/KnowledgeBaseSearchBlock.d.ts +19 -0
  46. package/types/webview-ui/components/KnowledgeBaseSearchResult.d.ts +8 -0
  47. package/types/webview-ui/components/MarkdownRenderer.d.ts +6 -0
  48. package/types/webview-ui/components/MessageRenderer.d.ts +6 -0
  49. package/types/webview-ui/components/ThinkingBlock.d.ts +7 -0
  50. package/types/webview-ui/components/ToolUseBlock.d.ts +9 -0
  51. package/types/webview-ui/components/ToolUseBlockHeader.d.ts +9 -0
  52. package/types/webview-ui/components/index.d.ts +7 -0
  53. package/types/webview-ui/constants.d.ts +17 -0
  54. package/types/webview-ui/contexts/ThemeContext.d.ts +11 -0
  55. package/types/webview-ui/hooks/useAgentStatus.d.ts +11 -0
  56. package/types/webview-ui/index.d.ts +2 -0
  57. package/types/webview-ui/services/agent-service.d.ts +27 -0
  58. package/types/webview-ui/services/logger-service.d.ts +29 -0
  59. package/types/webview-ui/styles/copilot.d.ts +13 -0
  60. package/types/webview-ui/styles/workarea.d.ts +10 -0
  61. package/types/webview-ui/types/index.d.ts +20 -0
  62. package/types/webview-ui/types.d.ts +48 -0
  63. package/types/webview-ui/widgets/BubbleComponents.d.ts +12 -0
  64. package/types/webview-ui/widgets/LogPanel.d.ts +14 -0
  65. package/types/webview-ui/widgets/SystemLogs.d.ts +23 -0
  66. package/types/webview-ui/widgets/ToolBar.d.ts +13 -0
  67. package/types/webview-ui/widgets/index.d.ts +4 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ThinkingBlock = void 0;
37
+ const antd_1 = require("antd");
38
+ const antd_style_1 = require("antd-style");
39
+ const react_1 = __importStar(require("react"));
40
+ const useStyles = (0, antd_style_1.createStyles)(({ token, css }) => ({
41
+ thinkingContainer: css `
42
+ border: 1px solid ${token.colorBorder};
43
+ border-radius: 8px;
44
+ overflow: hidden;
45
+ background: ${token.colorBgElevated};
46
+ margin-bottom: 12px;
47
+ width: 100%;
48
+ `,
49
+ transparentCollapse: css `
50
+ background: transparent;
51
+ border: none;
52
+ `,
53
+ labelContainer: css `
54
+ display: flex;
55
+ align-items: center;
56
+ gap: 8px;
57
+ font-size: 13px;
58
+ font-weight: 500;
59
+ color: ${token.colorTextSecondary};
60
+ `,
61
+ contentContainer: css `
62
+ font-size: 12px;
63
+ line-height: 1.6;
64
+ color: ${token.colorTextSecondary};
65
+ `,
66
+ }));
67
+ const ThinkingBlock = ({ message }) => {
68
+ const { styles } = useStyles();
69
+ const [elapsedTime, setElapsedTime] = (0, react_1.useState)(0);
70
+ const intervalRef = (0, react_1.useRef)(null);
71
+ (0, react_1.useEffect)(() => {
72
+ if (message.isThinking && message.timestamp) {
73
+ const startTime = message.timestamp;
74
+ intervalRef.current = setInterval(() => {
75
+ const seconds = (Date.now() - startTime) / 1000;
76
+ setElapsedTime(seconds);
77
+ }, 50);
78
+ }
79
+ else {
80
+ if (intervalRef.current) {
81
+ clearInterval(intervalRef.current);
82
+ }
83
+ }
84
+ return () => {
85
+ if (intervalRef.current) {
86
+ clearInterval(intervalRef.current);
87
+ }
88
+ };
89
+ }, [message.isThinking, message.timestamp]);
90
+ const timeText = message.isThinking
91
+ ? `思考中... (用时 ${elapsedTime.toFixed(2)} 秒)`
92
+ : `已完成思考 (总用时 ${elapsedTime.toFixed(2)} 秒)`;
93
+ const collapseItems = [
94
+ {
95
+ key: "1",
96
+ label: (react_1.default.createElement("div", { className: styles.labelContainer },
97
+ react_1.default.createElement("span", null, message.isThinking ? "🤔" : "✅"),
98
+ timeText)),
99
+ children: react_1.default.createElement("div", { className: styles.contentContainer }, message.reasoningContent || "..."),
100
+ },
101
+ ];
102
+ return (react_1.default.createElement("div", { className: styles.thinkingContainer },
103
+ react_1.default.createElement(antd_1.Collapse, { items: collapseItems, size: "small", defaultActiveKey: ["1"], ghost: true, expandIconPosition: "end", className: styles.transparentCollapse })));
104
+ };
105
+ exports.ThinkingBlock = ThinkingBlock;
@@ -0,0 +1,20 @@
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.ToolUseBlock = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_2 = require("react");
9
+ const _1 = require(".");
10
+ const ToolUseBlock = ({ tool_name, tool_args, result, isResponse }) => {
11
+ const [isExpanded, setIsExpanded] = (0, react_2.useState)(true);
12
+ const headerText = isResponse ? `工具调用结果: ${tool_name}` : `工具调用: ${tool_name}`;
13
+ const content = isResponse ? result : tool_args;
14
+ return (react_1.default.createElement("div", { className: "tool-use-block" },
15
+ react_1.default.createElement(_1.ToolUseBlockHeader, { toolName: headerText, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded(!isExpanded) }),
16
+ isExpanded && (react_1.default.createElement("div", { className: "tool-use-body" },
17
+ react_1.default.createElement("pre", null,
18
+ react_1.default.createElement("code", null, JSON.stringify(content, null, 2)))))));
19
+ };
20
+ exports.ToolUseBlock = ToolUseBlock;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ToolUseBlockHeader = void 0;
18
+ const icons_1 = require("@ant-design/icons");
19
+ const antd_style_1 = require("antd-style");
20
+ const react_1 = __importDefault(require("react"));
21
+ const useStyles = (0, antd_style_1.createStyles)(({ token, css }) => ({
22
+ header: css `
23
+ display: flex;
24
+ align-items: center;
25
+ cursor: pointer;
26
+ user-select: none;
27
+ color: ${token.colorTextSecondary};
28
+ font-weight: 500;
29
+ font-size: 13px;
30
+ padding: 4px 8px;
31
+ border-radius: 4px;
32
+ &:hover {
33
+ background: ${token.colorBgLayout};
34
+ }
35
+ `,
36
+ icon: css `
37
+ margin-right: 6px;
38
+ `,
39
+ }));
40
+ const ToolUseBlockHeader = (_a) => {
41
+ var { toolName, isExpanded, onToggleExpand, icon, className } = _a, props = __rest(_a, ["toolName", "isExpanded", "onToggleExpand", "icon", "className"]);
42
+ const { styles, cx } = useStyles();
43
+ return (react_1.default.createElement("div", Object.assign({ className: cx(styles.header, className), onClick: onToggleExpand }, props),
44
+ isExpanded ? react_1.default.createElement(icons_1.CaretDownOutlined, { className: styles.icon }) : react_1.default.createElement(icons_1.CaretRightOutlined, { className: styles.icon }),
45
+ icon && react_1.default.createElement("span", { className: styles.icon }, icon),
46
+ toolName));
47
+ };
48
+ exports.ToolUseBlockHeader = ToolUseBlockHeader;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ThinkingBlock"), exports);
18
+ __exportStar(require("./KnowledgeBaseSearchBlock"), exports);
19
+ __exportStar(require("./ToolUseBlock"), exports);
20
+ __exportStar(require("./MarkdownRenderer"), exports);
21
+ __exportStar(require("./MessageRenderer"), exports);
22
+ __exportStar(require("./ToolUseBlockHeader"), exports);
23
+ __exportStar(require("./KnowledgeBaseSearchResult"), exports);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LOG_PANEL_HEIGHT = exports.AGENT_PLACEHOLDER = exports.MOCK_QUESTIONS = exports.MOCK_SUGGESTIONS = void 0;
4
+ exports.MOCK_SUGGESTIONS = [
5
+ { label: "写一篇关于AI的文章", value: "report" },
6
+ { label: "画一幅画", value: "draw" },
7
+ {
8
+ label: "检查一些知识",
9
+ value: "knowledge",
10
+ icon: "OpenAIFilled",
11
+ children: [
12
+ { label: "关于React", value: "react" },
13
+ { label: "关于Ant Design", value: "antd" },
14
+ ],
15
+ },
16
+ ];
17
+ exports.MOCK_QUESTIONS = [
18
+ "帮我写一篇关于AI的文章, 20字",
19
+ "帮我写一篇关于AI的文章",
20
+ "帮我写一篇关于广州的旅游攻略",
21
+ "帮我写一篇购物笔记",
22
+ ];
23
+ exports.AGENT_PLACEHOLDER = "Generating content, please wait...";
24
+ exports.LOG_PANEL_HEIGHT = 480;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useThemeHook = exports.ThemeProvider = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const ThemeContext = (0, react_1.createContext)(undefined);
39
+ const ThemeProvider = ({ children, isDark }) => {
40
+ return react_1.default.createElement(ThemeContext.Provider, { value: { isDark } }, children);
41
+ };
42
+ exports.ThemeProvider = ThemeProvider;
43
+ const useThemeHook = () => {
44
+ const context = (0, react_1.useContext)(ThemeContext);
45
+ if (context === undefined) {
46
+ throw new Error("useTheme must be used within a ThemeProvider");
47
+ }
48
+ return context;
49
+ };
50
+ exports.useThemeHook = useThemeHook;
@@ -0,0 +1,96 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useAgentStatus = void 0;
13
+ const react_1 = require("react");
14
+ const agent_service_1 = require("../services/agent-service");
15
+ const useAgentStatus = (pollInterval = 5000) => {
16
+ const [agentSimulatorInfo, setAgentSimulatorInfo] = (0, react_1.useState)();
17
+ const [debugStatus, setDebugStatus] = (0, react_1.useState)("connecting");
18
+ const [isConnecting, setIsConnecting] = (0, react_1.useState)(true);
19
+ const [error, setError] = (0, react_1.useState)(null);
20
+ const pollTimerRef = (0, react_1.useRef)(null);
21
+ const timeoutRef = (0, react_1.useRef)(null);
22
+ const fetchAgentInfo = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
23
+ try {
24
+ const info = yield agent_service_1.apiService.getAgentInfo();
25
+ setAgentSimulatorInfo(info);
26
+ setError(null);
27
+ }
28
+ catch (err) {
29
+ setError(err instanceof Error ? err.message : "获取 Agent 信息失败");
30
+ }
31
+ }), []);
32
+ const fetchAgentStatus = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
33
+ try {
34
+ const data = yield agent_service_1.apiService.getAgentStatus();
35
+ setDebugStatus(data.status === "normal" ? "normal" : "error");
36
+ setIsConnecting(false);
37
+ setError(null);
38
+ }
39
+ catch (err) {
40
+ setDebugStatus("error");
41
+ setIsConnecting(false);
42
+ setError(err instanceof Error ? err.message : "检查 Agent 状态失败");
43
+ }
44
+ }), []);
45
+ const startTimeout = (0, react_1.useCallback)(() => {
46
+ if (timeoutRef.current)
47
+ clearTimeout(timeoutRef.current);
48
+ timeoutRef.current = setTimeout(() => {
49
+ setDebugStatus("timeout");
50
+ setIsConnecting(false);
51
+ }, 10000);
52
+ }, []);
53
+ const clearTimeoutRef = (0, react_1.useCallback)(() => {
54
+ if (timeoutRef.current)
55
+ clearTimeout(timeoutRef.current);
56
+ timeoutRef.current = null;
57
+ }, []);
58
+ const startPolling = (0, react_1.useCallback)(() => {
59
+ if (pollTimerRef.current)
60
+ clearInterval(pollTimerRef.current);
61
+ pollTimerRef.current = setInterval(fetchAgentStatus, pollInterval);
62
+ }, [fetchAgentStatus, pollInterval]);
63
+ const stopPolling = (0, react_1.useCallback)(() => {
64
+ if (pollTimerRef.current)
65
+ clearInterval(pollTimerRef.current);
66
+ pollTimerRef.current = null;
67
+ }, []);
68
+ const retryConnection = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
69
+ setIsConnecting(true);
70
+ setDebugStatus("connecting");
71
+ setError(null);
72
+ startTimeout();
73
+ yield Promise.all([fetchAgentInfo(), fetchAgentStatus()]);
74
+ clearTimeoutRef();
75
+ }), [fetchAgentInfo, fetchAgentStatus, startTimeout, clearTimeoutRef]);
76
+ (0, react_1.useEffect)(() => {
77
+ setIsConnecting(true);
78
+ setDebugStatus("connecting");
79
+ setError(null);
80
+ startTimeout();
81
+ Promise.all([fetchAgentInfo(), fetchAgentStatus()]).then(clearTimeoutRef);
82
+ startPolling();
83
+ return () => {
84
+ stopPolling();
85
+ clearTimeoutRef();
86
+ };
87
+ }, [fetchAgentInfo, fetchAgentStatus, startPolling, stopPolling, startTimeout, clearTimeoutRef]);
88
+ return {
89
+ agentSimulatorInfo,
90
+ debugStatus,
91
+ isConnecting,
92
+ error,
93
+ retryConnection,
94
+ };
95
+ };
96
+ exports.useAgentStatus = useAgentStatus;
@@ -0,0 +1,17 @@
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.App = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const client_1 = __importDefault(require("react-dom/client"));
9
+ const App_1 = __importDefault(require("./App"));
10
+ require("./styles.css");
11
+ const rootElement = document.getElementById("root");
12
+ if (!rootElement)
13
+ throw new Error("Root element not found");
14
+ client_1.default.createRoot(rootElement).render(react_1.default.createElement(react_1.default.StrictMode, null,
15
+ react_1.default.createElement(App_1.default, null)));
16
+ var App_2 = require("./App");
17
+ Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(App_2).default; } });
@@ -0,0 +1,33 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.apiService = void 0;
13
+ class ApiService {
14
+ getAgentInfo() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const response = yield fetch(`/agentInfo/get`);
17
+ if (!response.ok) {
18
+ throw new Error(`获取 Agent 信息失败: ${response.status}`);
19
+ }
20
+ return response.json();
21
+ });
22
+ }
23
+ getAgentStatus() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const response = yield fetch(`/agentInfo/status`);
26
+ if (!response.ok) {
27
+ throw new Error(`获取 Agent 状态失败: ${response.status}`);
28
+ }
29
+ return response.json();
30
+ });
31
+ }
32
+ }
33
+ exports.apiService = new ApiService();
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LoggerService = exports.LogType = void 0;
13
+ var LogType;
14
+ (function (LogType) {
15
+ LogType["ACCESS"] = "ACCESS";
16
+ LogType["USERCODE"] = "USERCODE";
17
+ })(LogType || (exports.LogType = LogType = {}));
18
+ class LoggerService {
19
+ constructor(options) {
20
+ this.baseUrl = options.baseUrl;
21
+ }
22
+ getLogs(type) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const url = `${this.baseUrl}/@logs?type=${type}`;
26
+ const response = yield fetch(url);
27
+ if (!response.ok) {
28
+ throw new Error(`HTTP error! status: ${response.status}`);
29
+ }
30
+ const data = yield response.json();
31
+ return data;
32
+ }
33
+ catch (error) {
34
+ console.error("Failed to fetch logs:", error);
35
+ return {
36
+ success: false,
37
+ data: [],
38
+ error: error.message,
39
+ };
40
+ }
41
+ });
42
+ }
43
+ formatLogEntry(entry) {
44
+ const timestamp = new Date(entry["@timestamp"]).toLocaleString();
45
+ const level = entry.level.toUpperCase();
46
+ const message = entry.message;
47
+ const eventId = entry.eventId ? `[${entry.eventId}]` : "";
48
+ return `[${timestamp}] ${level} ${eventId} ${message}`;
49
+ }
50
+ }
51
+ exports.LoggerService = LoggerService;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCopilotStyle = void 0;
4
+ const antd_style_1 = require("antd-style");
5
+ exports.useCopilotStyle = (0, antd_style_1.createStyles)(({ token, css }) => {
6
+ return {
7
+ copilotChat: css `
8
+ width: 100%;
9
+ display: flex;
10
+ flex-direction: column;
11
+ background: ${token.colorBgContainer};
12
+ color: ${token.colorText};
13
+ `,
14
+ headerTitle: css `
15
+ font-weight: 600;
16
+ font-size: 15px;
17
+ `,
18
+ headerButton: css `
19
+ font-size: 18px;
20
+ `,
21
+ conversations: css `
22
+ width: 300px;
23
+ .ant-conversations-list {
24
+ padding-inline-start: 0;
25
+ }
26
+ `,
27
+ chatList: css `
28
+ overflow: auto;
29
+ padding-block: 16px;
30
+ flex: 1;
31
+ `,
32
+ chatWelcome: css `
33
+ margin-inline: 16px;
34
+ padding: 12px 16px;
35
+ border-radius: 12px;
36
+ margin-bottom: 16px;
37
+ `,
38
+ loadingMessage: css `
39
+ background-image: linear-gradient(90deg, #ff6b23 0%, #af3cb8 31%, #53b6ff 89%);
40
+ background-size: 100% 2px;
41
+ background-repeat: no-repeat;
42
+ background-position: bottom;
43
+ `,
44
+ chatSend: css `
45
+ padding: 12px;
46
+ `,
47
+ sendAction: css `
48
+ display: flex;
49
+ align-items: center;
50
+ margin-bottom: 12px;
51
+ gap: 8px;
52
+ `,
53
+ speechButton: css `
54
+ font-size: 18px;
55
+ color: ${token.colorText} !important;
56
+ `,
57
+ markdownContent: css `
58
+ .markdown-content {
59
+ will-change: contents;
60
+ contain: content;
61
+
62
+ /* 优化代码块样式 */
63
+ pre {
64
+ background: ${token.colorBgTextHover};
65
+ padding: 12px;
66
+ border-radius: 6px;
67
+ margin: 8px 0;
68
+ }
69
+
70
+ /* 优化列表样式 */
71
+ ul, ol {
72
+ padding-left: 20px;
73
+ margin: 8px 0;
74
+ }
75
+
76
+ /* 优化引用样式 */
77
+ blockquote {
78
+ border-left: 4px solid ${token.colorPrimary};
79
+ margin: 8px 0;
80
+ padding: 4px 12px;
81
+ background: ${token.colorBgTextHover};
82
+ }
83
+
84
+ /* 优化链接样式 */
85
+ a {
86
+ color: ${token.colorPrimary};
87
+ text-decoration: none;
88
+
89
+ &:hover {
90
+ text-decoration: underline;
91
+ }
92
+ }
93
+
94
+ /* 优化标题样式 */
95
+ h1, h2, h3, h4, h5, h6 {
96
+ margin: 16px 0 8px;
97
+ font-weight: 600;
98
+ }
99
+
100
+ /* 优化表格样式 */
101
+ table {
102
+ border-collapse: collapse;
103
+ width: 100%;
104
+ margin: 8px 0;
105
+
106
+ th, td {
107
+ border: 1px solid ${token.colorBorder};
108
+ padding: 8px;
109
+ }
110
+
111
+ th {
112
+ background: ${token.colorBgTextHover};
113
+ }
114
+ }
115
+ }
116
+ `,
117
+ };
118
+ });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWorkareaStyle = void 0;
4
+ const antd_style_1 = require("antd-style");
5
+ exports.useWorkareaStyle = (0, antd_style_1.createStyles)(({ token, css }) => {
6
+ return {
7
+ copilotWrapper: css `
8
+ max-width: 800px;
9
+ min-width: 300px;
10
+ width: 100%;
11
+ height: 100vh;
12
+ display: flex;
13
+ margin: 0 auto;
14
+ `,
15
+ workarea: css `
16
+ flex: 1;
17
+ background: ${token.colorBgLayout};
18
+ display: flex;
19
+ flex-direction: column;
20
+ `,
21
+ workareaHeader: css `
22
+ box-sizing: border-box;
23
+ height: 52px;
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: space-between;
27
+ padding: 0 48px 0 28px;
28
+ border-bottom: 1px solid ${token.colorBorder};
29
+ `,
30
+ headerTitle: css `
31
+ font-weight: 600;
32
+ font-size: 15px;
33
+ color: ${token.colorText};
34
+ display: flex;
35
+ align-items: center;
36
+ gap: 8px;
37
+ `,
38
+ headerButton: css `
39
+ background-image: linear-gradient(78deg, #8054f2 7%, #3895da 95%);
40
+ border-radius: 12px;
41
+ height: 24px;
42
+ width: 93px;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ color: ${token.colorBgContainer};
47
+ cursor: pointer;
48
+ font-size: 12px;
49
+ font-weight: 600;
50
+ transition: all 0.3s;
51
+ &:hover {
52
+ opacity: 0.8;
53
+ }
54
+ `,
55
+ workareaBody: css `
56
+ flex: 1;
57
+ padding: 16px;
58
+ background: ${token.colorBgContainer};
59
+ border-radius: 16px;
60
+ min-height: 0;
61
+ `,
62
+ bodyContent: css `
63
+ overflow: auto;
64
+ height: 100%;
65
+ padding-right: 10px;
66
+ `,
67
+ bodyText: css `
68
+ color: ${token.colorText};
69
+ padding: 8px;
70
+ `,
71
+ };
72
+ });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });