@vectorx/agent-simulator 0.1.3 → 0.4.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 (302) hide show
  1. package/lib/app.d.ts +43 -0
  2. package/lib/app.d.ts.map +1 -0
  3. package/lib/app.js +96 -0
  4. package/lib/app.js.map +1 -0
  5. package/lib/config/api.config.d.ts +2 -0
  6. package/lib/config/api.config.d.ts.map +1 -0
  7. package/lib/config/api.config.js +13 -0
  8. package/lib/config/api.config.js.map +1 -0
  9. package/lib/config/app.config.d.ts +22 -0
  10. package/lib/config/app.config.d.ts.map +1 -0
  11. package/lib/config/app.config.js +18 -0
  12. package/lib/config/app.config.js.map +1 -0
  13. package/lib/config/upload.config.d.ts +6 -0
  14. package/lib/config/upload.config.d.ts.map +1 -0
  15. package/lib/config/upload.config.js +10 -0
  16. package/lib/config/upload.config.js.map +1 -0
  17. package/lib/container/container.d.ts +6 -0
  18. package/lib/container/container.d.ts.map +1 -0
  19. package/lib/container/container.js +34 -0
  20. package/lib/container/container.js.map +1 -0
  21. package/lib/container/identifiers.d.ts +14 -0
  22. package/lib/container/identifiers.d.ts.map +1 -0
  23. package/lib/container/identifiers.js +20 -0
  24. package/lib/container/identifiers.js.map +1 -0
  25. package/lib/container/index.d.ts +4 -0
  26. package/lib/container/index.d.ts.map +1 -0
  27. package/lib/container/index.js +20 -0
  28. package/lib/container/index.js.map +1 -0
  29. package/lib/container/types.d.ts +41 -0
  30. package/lib/container/types.d.ts.map +1 -0
  31. package/lib/{types.js → container/types.js} +1 -0
  32. package/lib/container/types.js.map +1 -0
  33. package/lib/controllers/agent.controller.d.ts +15 -0
  34. package/lib/controllers/agent.controller.d.ts.map +1 -0
  35. package/lib/controllers/agent.controller.js +59 -0
  36. package/lib/controllers/agent.controller.js.map +1 -0
  37. package/lib/controllers/auth.controller.d.ts +23 -0
  38. package/lib/controllers/auth.controller.d.ts.map +1 -0
  39. package/lib/controllers/auth.controller.js +132 -0
  40. package/lib/controllers/auth.controller.js.map +1 -0
  41. package/lib/controllers/simulator.controller.d.ts +11 -0
  42. package/lib/controllers/simulator.controller.d.ts.map +1 -0
  43. package/lib/controllers/simulator.controller.js +44 -0
  44. package/lib/controllers/simulator.controller.js.map +1 -0
  45. package/lib/controllers/upload.controller.d.ts +8 -0
  46. package/lib/controllers/upload.controller.d.ts.map +1 -0
  47. package/lib/controllers/upload.controller.js +44 -0
  48. package/lib/controllers/upload.controller.js.map +1 -0
  49. package/lib/index.d.ts +7 -0
  50. package/lib/index.d.ts.map +1 -0
  51. package/lib/index.js +15 -2
  52. package/lib/index.js.map +1 -0
  53. package/lib/middleware/cors.middleware.d.ts +7 -0
  54. package/lib/middleware/cors.middleware.d.ts.map +1 -0
  55. package/lib/middleware/cors.middleware.js +14 -0
  56. package/lib/middleware/cors.middleware.js.map +1 -0
  57. package/lib/middleware/error.middleware.d.ts +8 -0
  58. package/lib/middleware/error.middleware.d.ts.map +1 -0
  59. package/lib/middleware/error.middleware.js +33 -0
  60. package/lib/middleware/error.middleware.js.map +1 -0
  61. package/lib/middleware/proxy.middleware.d.ts +3 -0
  62. package/lib/middleware/proxy.middleware.d.ts.map +1 -0
  63. package/lib/middleware/proxy.middleware.js +21 -0
  64. package/lib/middleware/proxy.middleware.js.map +1 -0
  65. package/lib/routes/agent.d.ts +3 -0
  66. package/lib/routes/agent.d.ts.map +1 -0
  67. package/lib/routes/agent.js +16 -0
  68. package/lib/routes/agent.js.map +1 -0
  69. package/lib/routes/auth.d.ts +3 -0
  70. package/lib/routes/auth.d.ts.map +1 -0
  71. package/lib/routes/auth.js +20 -0
  72. package/lib/routes/auth.js.map +1 -0
  73. package/lib/routes/index.d.ts +3 -0
  74. package/lib/routes/index.d.ts.map +1 -0
  75. package/lib/routes/index.js +19 -0
  76. package/lib/routes/index.js.map +1 -0
  77. package/lib/routes/simulator.d.ts +3 -0
  78. package/lib/routes/simulator.d.ts.map +1 -0
  79. package/lib/routes/simulator.js +14 -0
  80. package/lib/routes/simulator.js.map +1 -0
  81. package/lib/routes/upload.d.ts +3 -0
  82. package/lib/routes/upload.d.ts.map +1 -0
  83. package/lib/routes/upload.js +13 -0
  84. package/lib/routes/upload.js.map +1 -0
  85. package/{types/webview-ui/services/agent-service.d.ts → lib/services/agent.service.d.ts} +15 -3
  86. package/lib/services/agent.service.d.ts.map +1 -0
  87. package/lib/services/agent.service.js +116 -0
  88. package/lib/services/agent.service.js.map +1 -0
  89. package/lib/services/auth.service.d.ts +55 -0
  90. package/lib/services/auth.service.d.ts.map +1 -0
  91. package/lib/services/auth.service.js +124 -0
  92. package/lib/services/auth.service.js.map +1 -0
  93. package/lib/services/simulator.service.d.ts +23 -0
  94. package/lib/services/simulator.service.d.ts.map +1 -0
  95. package/lib/services/simulator.service.js +49 -0
  96. package/lib/services/simulator.service.js.map +1 -0
  97. package/lib/services/upload.service.d.ts +32 -0
  98. package/lib/services/upload.service.d.ts.map +1 -0
  99. package/lib/services/upload.service.js +61 -0
  100. package/lib/services/upload.service.js.map +1 -0
  101. package/lib/simulator.d.ts +27 -0
  102. package/lib/simulator.d.ts.map +1 -0
  103. package/lib/simulator.js +42 -187
  104. package/lib/simulator.js.map +1 -0
  105. package/lib/utils/logger.d.ts +8 -0
  106. package/lib/utils/logger.d.ts.map +1 -0
  107. package/lib/utils/logger.js +28 -0
  108. package/lib/utils/logger.js.map +1 -0
  109. package/lib/utils/request.d.ts +11 -0
  110. package/lib/utils/request.d.ts.map +1 -0
  111. package/lib/utils/request.js +36 -0
  112. package/lib/utils/request.js.map +1 -0
  113. package/lib/utils/url-parser.d.ts +14 -0
  114. package/lib/utils/url-parser.d.ts.map +1 -0
  115. package/lib/utils/url-parser.js +25 -0
  116. package/lib/utils/url-parser.js.map +1 -0
  117. package/lib/utils.d.ts +6 -0
  118. package/lib/utils.d.ts.map +1 -0
  119. package/lib/utils.js +5 -0
  120. package/lib/utils.js.map +1 -0
  121. package/{types → lib}/webview-ui/Agent.d.ts +2 -0
  122. package/lib/webview-ui/Agent.d.ts.map +1 -0
  123. package/lib/webview-ui/Agent.js +8 -0
  124. package/lib/webview-ui/Agent.js.map +1 -0
  125. package/lib/webview-ui/App.d.ts +3 -0
  126. package/lib/webview-ui/App.d.ts.map +1 -0
  127. package/lib/webview-ui/App.js +392 -181
  128. package/lib/webview-ui/App.js.map +1 -0
  129. package/{types → lib}/webview-ui/ErrorBoundary.d.ts +2 -1
  130. package/lib/webview-ui/ErrorBoundary.d.ts.map +1 -0
  131. package/lib/webview-ui/ErrorBoundary.js +15 -18
  132. package/lib/webview-ui/ErrorBoundary.js.map +1 -0
  133. package/lib/webview-ui/components/AsyncTaskBlock.d.ts +13 -0
  134. package/lib/webview-ui/components/AsyncTaskBlock.d.ts.map +1 -0
  135. package/lib/webview-ui/components/AsyncTaskBlock.js +179 -0
  136. package/lib/webview-ui/components/AsyncTaskBlock.js.map +1 -0
  137. package/lib/webview-ui/components/AuthIndicator.d.ts +3 -0
  138. package/lib/webview-ui/components/AuthIndicator.d.ts.map +1 -0
  139. package/lib/webview-ui/components/AuthIndicator.js +17 -0
  140. package/lib/webview-ui/components/AuthIndicator.js.map +1 -0
  141. package/lib/webview-ui/components/ErrorCard.d.ts +11 -0
  142. package/lib/webview-ui/components/ErrorCard.d.ts.map +1 -0
  143. package/lib/webview-ui/components/ErrorCard.js +50 -0
  144. package/lib/webview-ui/components/ErrorCard.js.map +1 -0
  145. package/{types → lib}/webview-ui/components/KnowledgeBaseSearchBlock.d.ts +1 -0
  146. package/lib/webview-ui/components/KnowledgeBaseSearchBlock.d.ts.map +1 -0
  147. package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js +7 -24
  148. package/lib/webview-ui/components/KnowledgeBaseSearchBlock.js.map +1 -0
  149. package/{types → lib}/webview-ui/components/KnowledgeBaseSearchResult.d.ts +1 -0
  150. package/lib/webview-ui/components/KnowledgeBaseSearchResult.d.ts.map +1 -0
  151. package/lib/webview-ui/components/KnowledgeBaseSearchResult.js +3 -9
  152. package/lib/webview-ui/components/KnowledgeBaseSearchResult.js.map +1 -0
  153. package/{types → lib}/webview-ui/components/MarkdownRenderer.d.ts +1 -0
  154. package/lib/webview-ui/components/MarkdownRenderer.d.ts.map +1 -0
  155. package/lib/webview-ui/components/MarkdownRenderer.js +6 -5
  156. package/lib/webview-ui/components/MarkdownRenderer.js.map +1 -0
  157. package/{types → lib}/webview-ui/components/MessageRenderer.d.ts +1 -0
  158. package/lib/webview-ui/components/MessageRenderer.d.ts.map +1 -0
  159. package/lib/webview-ui/components/MessageRenderer.js +22 -25
  160. package/lib/webview-ui/components/MessageRenderer.js.map +1 -0
  161. package/lib/webview-ui/components/MultimodalFileRenderer.d.ts +20 -0
  162. package/lib/webview-ui/components/MultimodalFileRenderer.d.ts.map +1 -0
  163. package/lib/webview-ui/components/MultimodalFileRenderer.js +169 -0
  164. package/lib/webview-ui/components/MultimodalFileRenderer.js.map +1 -0
  165. package/{types → lib}/webview-ui/components/ThinkingBlock.d.ts +1 -0
  166. package/lib/webview-ui/components/ThinkingBlock.d.ts.map +1 -0
  167. package/lib/webview-ui/components/ThinkingBlock.js +11 -41
  168. package/lib/webview-ui/components/ThinkingBlock.js.map +1 -0
  169. package/{types → lib}/webview-ui/components/ToolUseBlock.d.ts +1 -0
  170. package/lib/webview-ui/components/ToolUseBlock.d.ts.map +1 -0
  171. package/lib/webview-ui/components/ToolUseBlock.js +5 -11
  172. package/lib/webview-ui/components/ToolUseBlock.js.map +1 -0
  173. package/{types → lib}/webview-ui/components/ToolUseBlockHeader.d.ts +1 -0
  174. package/lib/webview-ui/components/ToolUseBlockHeader.d.ts.map +1 -0
  175. package/lib/webview-ui/components/ToolUseBlockHeader.js +4 -21
  176. package/lib/webview-ui/components/ToolUseBlockHeader.js.map +1 -0
  177. package/lib/webview-ui/components/UploadPreview.d.ts +6 -0
  178. package/lib/webview-ui/components/UploadPreview.d.ts.map +1 -0
  179. package/lib/webview-ui/components/UploadPreview.js +12 -0
  180. package/lib/webview-ui/components/UploadPreview.js.map +1 -0
  181. package/lib/webview-ui/components/WelcomeModule.d.ts +10 -0
  182. package/lib/webview-ui/components/WelcomeModule.d.ts.map +1 -0
  183. package/lib/webview-ui/components/WelcomeModule.js +161 -0
  184. package/lib/webview-ui/components/WelcomeModule.js.map +1 -0
  185. package/{types → lib}/webview-ui/components/index.d.ts +7 -0
  186. package/lib/webview-ui/components/index.d.ts.map +1 -0
  187. package/lib/webview-ui/components/index.js +7 -0
  188. package/lib/webview-ui/components/index.js.map +1 -0
  189. package/lib/webview-ui/config/cos-config.d.ts +41 -0
  190. package/lib/webview-ui/config/cos-config.d.ts.map +1 -0
  191. package/lib/webview-ui/config/cos-config.js +83 -0
  192. package/lib/webview-ui/config/cos-config.js.map +1 -0
  193. package/lib/webview-ui/config/http-config.d.ts +8 -0
  194. package/lib/webview-ui/config/http-config.d.ts.map +1 -0
  195. package/lib/webview-ui/config/http-config.js +36 -0
  196. package/lib/webview-ui/config/http-config.js.map +1 -0
  197. package/{types → lib}/webview-ui/constants.d.ts +1 -0
  198. package/lib/webview-ui/constants.d.ts.map +1 -0
  199. package/lib/webview-ui/constants.js +1 -0
  200. package/lib/webview-ui/constants.js.map +1 -0
  201. package/lib/webview-ui/contexts/AgentContext.d.ts +13 -0
  202. package/lib/webview-ui/contexts/AgentContext.d.ts.map +1 -0
  203. package/lib/webview-ui/contexts/AgentContext.js +19 -0
  204. package/lib/webview-ui/contexts/AgentContext.js.map +1 -0
  205. package/lib/webview-ui/contexts/AuthContext.d.ts +17 -0
  206. package/lib/webview-ui/contexts/AuthContext.d.ts.map +1 -0
  207. package/lib/webview-ui/contexts/AuthContext.js +79 -0
  208. package/lib/webview-ui/contexts/AuthContext.js.map +1 -0
  209. package/{types → lib}/webview-ui/contexts/ThemeContext.d.ts +1 -0
  210. package/lib/webview-ui/contexts/ThemeContext.d.ts.map +1 -0
  211. package/lib/webview-ui/contexts/ThemeContext.js +6 -35
  212. package/lib/webview-ui/contexts/ThemeContext.js.map +1 -0
  213. package/{types → lib}/webview-ui/hooks/useAgentStatus.d.ts +5 -0
  214. package/lib/webview-ui/hooks/useAgentStatus.d.ts.map +1 -0
  215. package/lib/webview-ui/hooks/useAgentStatus.js +39 -19
  216. package/lib/webview-ui/hooks/useAgentStatus.js.map +1 -0
  217. package/lib/webview-ui/hooks/useUploader.d.ts +19 -0
  218. package/lib/webview-ui/hooks/useUploader.d.ts.map +1 -0
  219. package/lib/webview-ui/hooks/useUploader.js +132 -0
  220. package/lib/webview-ui/hooks/useUploader.js.map +1 -0
  221. package/lib/webview-ui/hooks/useUserAvatar.d.ts +28 -0
  222. package/lib/webview-ui/hooks/useUserAvatar.d.ts.map +1 -0
  223. package/lib/webview-ui/hooks/useUserAvatar.js +74 -0
  224. package/lib/webview-ui/hooks/useUserAvatar.js.map +1 -0
  225. package/{types → lib}/webview-ui/index.d.ts +1 -0
  226. package/lib/webview-ui/index.d.ts.map +1 -0
  227. package/lib/webview-ui/index.js +4 -3
  228. package/lib/webview-ui/index.js.map +1 -0
  229. package/lib/webview-ui/services/agent-service.d.ts +106 -0
  230. package/lib/webview-ui/services/agent-service.d.ts.map +1 -0
  231. package/lib/webview-ui/services/agent-service.js +52 -25
  232. package/lib/webview-ui/services/agent-service.js.map +1 -0
  233. package/lib/webview-ui/services/index.d.ts +3 -0
  234. package/lib/webview-ui/services/index.d.ts.map +1 -0
  235. package/lib/webview-ui/services/index.js +19 -0
  236. package/lib/webview-ui/services/index.js.map +1 -0
  237. package/{types → lib}/webview-ui/services/logger-service.d.ts +18 -1
  238. package/lib/webview-ui/services/logger-service.d.ts.map +1 -0
  239. package/lib/webview-ui/services/logger-service.js +45 -27
  240. package/lib/webview-ui/services/logger-service.js.map +1 -0
  241. package/{types → lib}/webview-ui/styles/copilot.d.ts +1 -0
  242. package/lib/webview-ui/styles/copilot.d.ts.map +1 -0
  243. package/lib/webview-ui/styles/copilot.js +1 -0
  244. package/lib/webview-ui/styles/copilot.js.map +1 -0
  245. package/{types → lib}/webview-ui/styles/workarea.d.ts +1 -0
  246. package/lib/webview-ui/styles/workarea.d.ts.map +1 -0
  247. package/lib/webview-ui/styles/workarea.js +1 -0
  248. package/lib/webview-ui/styles/workarea.js.map +1 -0
  249. package/{types → lib}/webview-ui/types.d.ts +15 -1
  250. package/lib/webview-ui/types.d.ts.map +1 -0
  251. package/lib/webview-ui/types.js +1 -0
  252. package/lib/webview-ui/types.js.map +1 -0
  253. package/lib/webview-ui/utils/cos.d.ts +65 -0
  254. package/lib/webview-ui/utils/cos.d.ts.map +1 -0
  255. package/lib/webview-ui/utils/cos.js +113 -0
  256. package/lib/webview-ui/utils/cos.js.map +1 -0
  257. package/lib/webview-ui/utils/http-client.d.ts +44 -0
  258. package/lib/webview-ui/utils/http-client.d.ts.map +1 -0
  259. package/lib/webview-ui/utils/http-client.js +101 -0
  260. package/lib/webview-ui/utils/http-client.js.map +1 -0
  261. package/lib/webview-ui/utils/stream-text-handler.d.ts +4 -0
  262. package/lib/webview-ui/utils/stream-text-handler.d.ts.map +1 -0
  263. package/lib/webview-ui/utils/stream-text-handler.js +42 -0
  264. package/lib/webview-ui/utils/stream-text-handler.js.map +1 -0
  265. package/lib/webview-ui/utils/upload.d.ts +8 -0
  266. package/lib/webview-ui/utils/upload.d.ts.map +1 -0
  267. package/lib/webview-ui/utils/upload.js +22 -0
  268. package/lib/webview-ui/utils/upload.js.map +1 -0
  269. package/{types → lib}/webview-ui/widgets/BubbleComponents.d.ts +1 -5
  270. package/lib/webview-ui/widgets/BubbleComponents.d.ts.map +1 -0
  271. package/lib/webview-ui/widgets/BubbleComponents.js +17 -69
  272. package/lib/webview-ui/widgets/BubbleComponents.js.map +1 -0
  273. package/lib/webview-ui/widgets/ChatInput.d.ts +24 -0
  274. package/lib/webview-ui/widgets/ChatInput.d.ts.map +1 -0
  275. package/lib/webview-ui/widgets/ChatInput.js +113 -0
  276. package/lib/webview-ui/widgets/ChatInput.js.map +1 -0
  277. package/{types → lib}/webview-ui/widgets/LogPanel.d.ts +1 -0
  278. package/lib/webview-ui/widgets/LogPanel.d.ts.map +1 -0
  279. package/lib/webview-ui/widgets/LogPanel.js +37 -44
  280. package/lib/webview-ui/widgets/LogPanel.js.map +1 -0
  281. package/{types → lib}/webview-ui/widgets/SystemLogs.d.ts +7 -0
  282. package/lib/webview-ui/widgets/SystemLogs.d.ts.map +1 -0
  283. package/lib/webview-ui/widgets/SystemLogs.js +243 -187
  284. package/lib/webview-ui/widgets/SystemLogs.js.map +1 -0
  285. package/{types → lib}/webview-ui/widgets/ToolBar.d.ts +5 -0
  286. package/lib/webview-ui/widgets/ToolBar.d.ts.map +1 -0
  287. package/lib/webview-ui/widgets/ToolBar.js +49 -68
  288. package/lib/webview-ui/widgets/ToolBar.js.map +1 -0
  289. package/{types → lib}/webview-ui/widgets/index.d.ts +4 -2
  290. package/lib/webview-ui/widgets/index.d.ts.map +1 -0
  291. package/lib/webview-ui/widgets/index.js +4 -2
  292. package/lib/webview-ui/widgets/index.js.map +1 -0
  293. package/package.json +13 -4
  294. package/public/assets/main.js +141 -118
  295. package/public/assets/style.css +1 -1
  296. package/lib/webview-ui/types/index.js +0 -2
  297. package/types/index.d.ts +0 -3
  298. package/types/simulator.d.ts +0 -15
  299. package/types/types.d.ts +0 -6
  300. package/types/utils.d.ts +0 -1
  301. package/types/webview-ui/App.d.ts +0 -3
  302. package/types/webview-ui/types/index.d.ts +0 -20
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AgentService = void 0;
19
+ const inversify_1 = require("inversify");
20
+ const node_fetch_1 = __importDefault(require("node-fetch"));
21
+ const container_1 = require("../container");
22
+ const url_parser_1 = require("../utils/url-parser");
23
+ let AgentService = class AgentService {
24
+ constructor(context) {
25
+ this.parsedServerUrl = (0, url_parser_1.parseAgentServerUrl)(context.agentServerUrl);
26
+ }
27
+ /**
28
+ * 获取Agent信息
29
+ */
30
+ async getAgentInfo() {
31
+ const healthUrl = `${this.parsedServerUrl.fullUrl}/info`;
32
+ const response = await (0, node_fetch_1.default)(healthUrl);
33
+ if (!response.ok) {
34
+ throw new Error(`无法连接到后端服务: ${response.status} ${response.statusText}`);
35
+ }
36
+ const resData = await response.json();
37
+ if (resData.code !== 0) {
38
+ throw new Error(`后端服务返回错误: ${resData.message || "未知错误"}`);
39
+ }
40
+ const { agent_info } = resData.data;
41
+ if (!agent_info) {
42
+ throw new Error("后端服务返回的数据中缺少 agent_info 字段");
43
+ }
44
+ return this.transformToAgentSimulatorInfo(agent_info);
45
+ }
46
+ /**
47
+ * 获取Agent状态
48
+ */
49
+ async getAgentStatus() {
50
+ try {
51
+ // 调用后端服务的 /health 接口检查状态
52
+ const healthUrl = `${this.parsedServerUrl.fullUrl}/health`;
53
+ const response = await (0, node_fetch_1.default)(healthUrl);
54
+ if (response.ok) {
55
+ const healthData = await response.json();
56
+ return {
57
+ status: "normal",
58
+ health: healthData,
59
+ timestamp: Date.now(),
60
+ agentServerUrl: this.parsedServerUrl.fullUrl,
61
+ parsedUrl: {
62
+ hostname: this.parsedServerUrl.hostname,
63
+ port: this.parsedServerUrl.port,
64
+ baseUrl: this.parsedServerUrl.baseUrl,
65
+ },
66
+ };
67
+ }
68
+ else {
69
+ return {
70
+ status: "error",
71
+ message: `后端服务响应异常: ${response.status}`,
72
+ timestamp: Date.now(),
73
+ agentServerUrl: this.parsedServerUrl.fullUrl,
74
+ parsedUrl: {
75
+ hostname: this.parsedServerUrl.hostname,
76
+ port: this.parsedServerUrl.port,
77
+ baseUrl: this.parsedServerUrl.baseUrl,
78
+ },
79
+ };
80
+ }
81
+ }
82
+ catch (error) {
83
+ return {
84
+ status: "error",
85
+ message: `无法连接到后端服务: ${error instanceof Error ? error.message : "未知错误"}`,
86
+ timestamp: Date.now(),
87
+ agentServerUrl: this.parsedServerUrl.fullUrl,
88
+ parsedUrl: {
89
+ hostname: this.parsedServerUrl.hostname,
90
+ port: this.parsedServerUrl.port,
91
+ baseUrl: this.parsedServerUrl.baseUrl,
92
+ },
93
+ };
94
+ }
95
+ }
96
+ /**
97
+ * 转换后端数据为AgentSimulatorInfo格式
98
+ */
99
+ transformToAgentSimulatorInfo(agentInfo) {
100
+ return {
101
+ agentInfo: {
102
+ agent_icon: agentInfo.agent_icon,
103
+ agent_id: agentInfo.agent_id,
104
+ agent_name: agentInfo.agent_name,
105
+ },
106
+ agentServerUrl: this.parsedServerUrl.fullUrl,
107
+ };
108
+ }
109
+ };
110
+ exports.AgentService = AgentService;
111
+ exports.AgentService = AgentService = __decorate([
112
+ (0, inversify_1.injectable)(),
113
+ __param(0, (0, inversify_1.inject)(container_1.APP_CONTEXT)),
114
+ __metadata("design:paramtypes", [Object])
115
+ ], AgentService);
116
+ //# sourceMappingURL=agent.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.service.js","sourceRoot":"","sources":["../../src/services/agent.service.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,55 @@
1
+ import type { IAuthService } from "../container/types";
2
+ /**
3
+ * 认证相关类型定义
4
+ */
5
+ export interface LoginInfo {
6
+ secret_id: string;
7
+ cli_token: string;
8
+ create_at: number;
9
+ expire_in_sec: number;
10
+ }
11
+ export interface CheckStatusRequest {
12
+ secret_id: string;
13
+ nonce: string;
14
+ cli_token: string;
15
+ }
16
+ export interface CheckStatusResponse {
17
+ code: number;
18
+ msg: string;
19
+ data: LoginInfo;
20
+ }
21
+ export interface AuthStatus {
22
+ isLoggedIn: boolean;
23
+ loginInfo: LoginInfo | null;
24
+ expireTime?: string;
25
+ isExpired: boolean;
26
+ }
27
+ /**
28
+ * 获取 cli 登录信息
29
+ */
30
+ export declare class AuthService implements IAuthService {
31
+ private readonly configDir;
32
+ private readonly configFile;
33
+ constructor();
34
+ /**
35
+ * 检查是否已登录
36
+ */
37
+ hasLogin(): boolean;
38
+ /**
39
+ * 获取登录信息
40
+ */
41
+ getLoginInfo(): Promise<LoginInfo | null>;
42
+ /**
43
+ * 获取认证状态
44
+ */
45
+ getAuthStatus(): Promise<AuthStatus>;
46
+ /**
47
+ * 检查登录状态(调用下游服务)
48
+ */
49
+ check(params: {
50
+ secret_id: string;
51
+ nonce: string;
52
+ cli_token: string;
53
+ }): Promise<any>;
54
+ }
55
+ //# sourceMappingURL=auth.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD;;GAEG;AAEH,MAAM,WAAW,SAAS;IAExB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAEjC,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AACD;;GAEG;AACH,qBACa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;;IAOpC;;OAEG;IACI,QAAQ,IAAI,OAAO;IAI1B;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAsB/C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAsB1C;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAQ3F"}
@@ -0,0 +1,124 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.AuthService = void 0;
46
+ const fs = __importStar(require("fs"));
47
+ const os = __importStar(require("os"));
48
+ const path = __importStar(require("path"));
49
+ const inversify_1 = require("inversify");
50
+ /**
51
+ * 获取 cli 登录信息
52
+ */
53
+ let AuthService = class AuthService {
54
+ constructor() {
55
+ this.configDir = path.join(os.homedir(), ".rcb");
56
+ this.configFile = path.join(this.configDir, "config.json");
57
+ }
58
+ /**
59
+ * 检查是否已登录
60
+ */
61
+ hasLogin() {
62
+ return fs.existsSync(this.configFile) && fs.statSync(this.configFile).isFile();
63
+ }
64
+ /**
65
+ * 获取登录信息
66
+ */
67
+ async getLoginInfo() {
68
+ try {
69
+ if (!fs.existsSync(this.configFile)) {
70
+ return null;
71
+ }
72
+ const content = fs.readFileSync(this.configFile, "utf-8");
73
+ const loginInfo = JSON.parse(content);
74
+ // 检查是否过期
75
+ const expireTime = new Date(loginInfo.create_at + loginInfo.expire_in_sec * 1000);
76
+ if (expireTime < new Date()) {
77
+ console.error("登录信息已过期,请重新登录");
78
+ return null;
79
+ }
80
+ return loginInfo;
81
+ }
82
+ catch (error) {
83
+ return null;
84
+ }
85
+ }
86
+ /**
87
+ * 获取认证状态
88
+ */
89
+ async getAuthStatus() {
90
+ const loginInfo = await this.getLoginInfo();
91
+ if (!loginInfo) {
92
+ return {
93
+ isLoggedIn: false,
94
+ loginInfo: null,
95
+ isExpired: false,
96
+ };
97
+ }
98
+ const expireTime = new Date(loginInfo.create_at + loginInfo.expire_in_sec * 1000);
99
+ const isExpired = expireTime < new Date();
100
+ return {
101
+ isLoggedIn: true,
102
+ loginInfo,
103
+ expireTime: expireTime.toLocaleString("zh-CN"),
104
+ isExpired,
105
+ };
106
+ }
107
+ /**
108
+ * 检查登录状态(调用下游服务)
109
+ */
110
+ async check(params) {
111
+ // 这里可以调用下游服务进行验证
112
+ // 暂时返回模拟数据
113
+ return {
114
+ isValid: true,
115
+ message: "验证成功",
116
+ };
117
+ }
118
+ };
119
+ exports.AuthService = AuthService;
120
+ exports.AuthService = AuthService = __decorate([
121
+ (0, inversify_1.injectable)(),
122
+ __metadata("design:paramtypes", [])
123
+ ], AuthService);
124
+ //# sourceMappingURL=auth.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,yCAAuC;AAsCvC;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAItB;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC;IACjF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC;YACH,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACpC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC1D,MAAM,SAAS,GAAc,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAEjD,SAAS;YACT,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;YAClF,IAAI,UAAU,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;gBAC5B,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa;QACjB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;gBACL,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,KAAK;aACjB,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;QAClF,MAAM,SAAS,GAAG,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QAE1C,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,SAAS;YACT,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9C,SAAS;SACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,MAA+D;QACzE,iBAAiB;QACjB,WAAW;QACX,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;CACF,CAAA;AA7EY,kCAAW;sBAAX,WAAW;IADvB,IAAA,sBAAU,GAAE;;GACA,WAAW,CA6EvB"}
@@ -0,0 +1,23 @@
1
+ import type { ISimulatorService } from "../container/types";
2
+ export interface SimulatorStatus {
3
+ status: "running" | "stopped";
4
+ port: number;
5
+ agentServerUrl: string;
6
+ agentStatus: "normal" | "stopped" | "error";
7
+ timestamp: number;
8
+ }
9
+ export declare class SimulatorService implements ISimulatorService {
10
+ private port;
11
+ private agentServerUrl;
12
+ private agentStatus;
13
+ constructor(context: any);
14
+ /**
15
+ * 获取模拟器状态
16
+ */
17
+ getSimulatorStatus(): SimulatorStatus;
18
+ /**
19
+ * 更新Agent状态
20
+ */
21
+ updateAgentStatus(status: "normal" | "stopped" | "error"): void;
22
+ }
23
+ //# sourceMappingURL=simulator.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator.service.d.ts","sourceRoot":"","sources":["../../src/services/simulator.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBACa,gBAAiB,YAAW,iBAAiB;IACxD,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,WAAW,CAAiC;gBAEnB,OAAO,EAAE,GAAG;IAM7C;;OAEG;IACH,kBAAkB,IAAI,eAAe;IAUrC;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI;CAGhE"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SimulatorService = void 0;
16
+ const inversify_1 = require("inversify");
17
+ const container_1 = require("../container");
18
+ let SimulatorService = class SimulatorService {
19
+ constructor(context) {
20
+ this.port = context.config.port;
21
+ this.agentServerUrl = context.agentServerUrl;
22
+ this.agentStatus = "normal";
23
+ }
24
+ /**
25
+ * 获取模拟器状态
26
+ */
27
+ getSimulatorStatus() {
28
+ return {
29
+ status: "running",
30
+ port: this.port,
31
+ agentServerUrl: this.agentServerUrl,
32
+ agentStatus: this.agentStatus,
33
+ timestamp: Date.now(),
34
+ };
35
+ }
36
+ /**
37
+ * 更新Agent状态
38
+ */
39
+ updateAgentStatus(status) {
40
+ this.agentStatus = status;
41
+ }
42
+ };
43
+ exports.SimulatorService = SimulatorService;
44
+ exports.SimulatorService = SimulatorService = __decorate([
45
+ (0, inversify_1.injectable)(),
46
+ __param(0, (0, inversify_1.inject)(container_1.APP_CONTEXT)),
47
+ __metadata("design:paramtypes", [Object])
48
+ ], SimulatorService);
49
+ //# sourceMappingURL=simulator.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator.service.js","sourceRoot":"","sources":["../../src/services/simulator.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+C;AAC/C,4CAA2C;AAYpC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAK3B,YAAiC,OAAY;QAC3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,MAAsC;QACtD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;IAC5B,CAAC;CACF,CAAA;AA9BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;IAME,WAAA,IAAA,kBAAM,EAAC,uBAAW,CAAC,CAAA;;GALrB,gBAAgB,CA8B5B"}
@@ -0,0 +1,32 @@
1
+ import type { IAuthService, IUploadService } from "../container/types";
2
+ export interface UploadTempPermit {
3
+ secretId?: string;
4
+ secretKey?: string;
5
+ token: string;
6
+ uploadAddr: string;
7
+ expireTime: number;
8
+ qos: number;
9
+ cloudType: number;
10
+ bucket: string;
11
+ region: string;
12
+ fileIds: string[];
13
+ masterCloudId: number;
14
+ uploadId: number;
15
+ cdnDomain?: string;
16
+ }
17
+ export interface TokenResponse {
18
+ uploadLimitPolicy?: {
19
+ fileTypes?: string[];
20
+ maxSize?: number;
21
+ };
22
+ uploadTempPermits: UploadTempPermit[];
23
+ }
24
+ export declare class UploadService implements IUploadService {
25
+ private readonly authService;
26
+ constructor(authService: IAuthService);
27
+ getToken(params: {
28
+ bizName: string;
29
+ scene: string;
30
+ }): Promise<TokenResponse>;
31
+ }
32
+ //# sourceMappingURL=upload.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.service.d.ts","sourceRoot":"","sources":["../../src/services/upload.service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,iBAAiB,CAAC,EAAE;QAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC;AAID,qBACa,aAAc,YAAW,cAAc;IACG,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,YAAY;IAEzF,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;CAgCnF"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UploadService = void 0;
16
+ const inversify_1 = require("inversify");
17
+ const api_config_1 = require("../config/api.config");
18
+ const identifiers_1 = require("../container/identifiers");
19
+ const request_1 = require("../utils/request");
20
+ // baseUrl 与请求已抽离到统一配置与工具
21
+ let UploadService = class UploadService {
22
+ constructor(authService) {
23
+ this.authService = authService;
24
+ }
25
+ async getToken(params) {
26
+ const loginInfo = await this.authService.getLoginInfo();
27
+ if (!loginInfo) {
28
+ throw new Error("未登录,请先登录");
29
+ }
30
+ const url = `${(0, api_config_1.getBaseUrl)()}/api/eros/mp/red/code/agent_pkg/upload/permit`;
31
+ // 罗通新开发
32
+ // const url = `${getBaseUrl()}/api/eros/mp/red/code/upload/common_permit`;
33
+ // const url = `${getBaseUrl()}/mp/red/mp/apps/upload/permit`;
34
+ const res = await request_1.request.fetch({
35
+ url,
36
+ method: "GET",
37
+ headers: { "Content-Type": "application/json" },
38
+ data: {
39
+ params: {
40
+ secret_id: loginInfo.secret_id,
41
+ cli_token: loginInfo.cli_token,
42
+ biz_name: params.bizName,
43
+ scene: params.scene,
44
+ file_count: 1,
45
+ version: 1,
46
+ },
47
+ },
48
+ });
49
+ if (res.ok && res.data?.code === 0) {
50
+ return res.data.data;
51
+ }
52
+ throw new Error(res.data?.msg || res.data?.message || `获取上传Token失败: ${res.status}`);
53
+ }
54
+ };
55
+ exports.UploadService = UploadService;
56
+ exports.UploadService = UploadService = __decorate([
57
+ (0, inversify_1.injectable)(),
58
+ __param(0, (0, inversify_1.inject)(identifiers_1.SERVICE_IDENTIFIERS.AuthService)),
59
+ __metadata("design:paramtypes", [Object])
60
+ ], UploadService);
61
+ //# sourceMappingURL=upload.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.service.js","sourceRoot":"","sources":["../../src/services/upload.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+C;AAC/C,qDAAkD;AAClD,0DAA+D;AAE/D,8CAA2C;AAyB3C,yBAAyB;AAGlB,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAAsE,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IAAG,CAAC;IAEnG,KAAK,CAAC,QAAQ,CAAC,MAA0C;QACvD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;QACxD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,IAAA,uBAAU,GAAE,+CAA+C,CAAC;QAC3E,QAAQ;QACR,2EAA2E;QAC3E,8DAA8D;QAC9D,MAAM,GAAG,GAAG,MAAM,iBAAO,CAAC,KAAK,CAAC;YAC9B,GAAG;YACH,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE;gBACJ,MAAM,EAAE;oBACN,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,QAAQ,EAAE,MAAM,CAAC,OAAO;oBACxB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,UAAU,EAAE,CAAC;oBACb,OAAO,EAAE,CAAC;iBACX;aACF;SACF,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,IAAI,CAAC,IAAqB,CAAC;QACxC,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACtF,CAAC;CACF,CAAA;AAnCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,GAAE;IAEE,WAAA,IAAA,kBAAM,EAAC,iCAAmB,CAAC,WAAW,CAAC,CAAA;;GADzC,aAAa,CAmCzB"}
@@ -0,0 +1,27 @@
1
+ export interface SimulatorOptions {
2
+ port: number;
3
+ agentServerUrl: string;
4
+ open?: boolean;
5
+ }
6
+ /**
7
+ * Agent模拟器实现
8
+ */
9
+ export declare class AgentSimulator {
10
+ private app;
11
+ private server;
12
+ options: SimulatorOptions;
13
+ /**
14
+ * 创建模拟器实例
15
+ * @param options 模拟器配置选项
16
+ */
17
+ constructor(options: SimulatorOptions);
18
+ /**
19
+ * 配置并启动模拟器
20
+ */
21
+ start(): Promise<void>;
22
+ /**
23
+ * 停止模拟器
24
+ */
25
+ stop(): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=simulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../src/simulator.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA4B;IACnC,OAAO,EAAE,gBAAgB,CAAC;IAEjC;;;OAGG;gBACS,OAAO,EAAE,gBAAgB;IAarC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBtB"}