rl-rockcli 0.0.6 → 0.0.8

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 (74) hide show
  1. package/index.js +51 -20
  2. package/package.json +2 -2
  3. package/commands/log/core/constants.js +0 -237
  4. package/commands/log/core/display.js +0 -370
  5. package/commands/log/core/search.js +0 -330
  6. package/commands/log/core/tail.js +0 -216
  7. package/commands/log/core/utils.js +0 -424
  8. package/commands/log.js +0 -298
  9. package/commands/sandbox/core/log-bridge.js +0 -119
  10. package/commands/sandbox/core/replay/analyzer.js +0 -311
  11. package/commands/sandbox/core/replay/batch-orchestrator.js +0 -536
  12. package/commands/sandbox/core/replay/batch-task.js +0 -369
  13. package/commands/sandbox/core/replay/concurrent-display.js +0 -70
  14. package/commands/sandbox/core/replay/concurrent-orchestrator.js +0 -170
  15. package/commands/sandbox/core/replay/data-source.js +0 -86
  16. package/commands/sandbox/core/replay/display.js +0 -231
  17. package/commands/sandbox/core/replay/executor.js +0 -634
  18. package/commands/sandbox/core/replay/history-fetcher.js +0 -124
  19. package/commands/sandbox/core/replay/index.js +0 -338
  20. package/commands/sandbox/core/replay/loghouse-data-source.js +0 -177
  21. package/commands/sandbox/core/replay/pid-mapping.js +0 -26
  22. package/commands/sandbox/core/replay/request.js +0 -109
  23. package/commands/sandbox/core/replay/worker.js +0 -166
  24. package/commands/sandbox/core/session.js +0 -346
  25. package/commands/sandbox/log-bridge.js +0 -2
  26. package/commands/sandbox/ray.js +0 -2
  27. package/commands/sandbox/replay/analyzer.js +0 -311
  28. package/commands/sandbox/replay/batch-orchestrator.js +0 -536
  29. package/commands/sandbox/replay/batch-task.js +0 -369
  30. package/commands/sandbox/replay/concurrent-display.js +0 -70
  31. package/commands/sandbox/replay/concurrent-orchestrator.js +0 -170
  32. package/commands/sandbox/replay/display.js +0 -231
  33. package/commands/sandbox/replay/executor.js +0 -634
  34. package/commands/sandbox/replay/history-fetcher.js +0 -118
  35. package/commands/sandbox/replay/index.js +0 -338
  36. package/commands/sandbox/replay/pid-mapping.js +0 -26
  37. package/commands/sandbox/replay/request.js +0 -109
  38. package/commands/sandbox/replay/worker.js +0 -166
  39. package/commands/sandbox/replay.js +0 -2
  40. package/commands/sandbox/session.js +0 -2
  41. package/commands/sandbox-original.js +0 -1393
  42. package/commands/sandbox.js +0 -499
  43. package/help/help.json +0 -1071
  44. package/help/middleware.js +0 -71
  45. package/help/renderer.js +0 -800
  46. package/lib/plugin-context.js +0 -40
  47. package/sdks/sandbox/core/client.js +0 -845
  48. package/sdks/sandbox/core/config.js +0 -70
  49. package/sdks/sandbox/core/types.js +0 -74
  50. package/sdks/sandbox/httpLogger.js +0 -251
  51. package/sdks/sandbox/index.js +0 -9
  52. package/utils/asciiArt.js +0 -138
  53. package/utils/bun-compat.js +0 -59
  54. package/utils/ciPipelines.js +0 -138
  55. package/utils/cli.js +0 -17
  56. package/utils/command-router.js +0 -79
  57. package/utils/configManager.js +0 -503
  58. package/utils/dependency-resolver.js +0 -135
  59. package/utils/eagleeye_traceid.js +0 -151
  60. package/utils/envDetector.js +0 -78
  61. package/utils/execution_logger.js +0 -415
  62. package/utils/featureManager.js +0 -68
  63. package/utils/firstTimeTip.js +0 -44
  64. package/utils/hook-manager.js +0 -125
  65. package/utils/http-logger.js +0 -264
  66. package/utils/i18n.js +0 -139
  67. package/utils/image-progress.js +0 -159
  68. package/utils/logger.js +0 -154
  69. package/utils/plugin-loader.js +0 -124
  70. package/utils/plugin-manager.js +0 -348
  71. package/utils/ray_cli_wrapper.js +0 -746
  72. package/utils/sandbox-client.js +0 -419
  73. package/utils/terminal.js +0 -32
  74. package/utils/tips.js +0 -106
@@ -1,311 +0,0 @@
1
- const {
2
- RequestCategory,
3
- RequestAction,
4
- ReplayRequest,
5
- ReplayPlan
6
- } = require('./request');
7
-
8
- /**
9
- * 请求分析器
10
- * 负责对请求进行分类和优化
11
- */
12
- class RequestAnalyzer {
13
- /**
14
- * @param {Object} options
15
- * @param {string} options.mode - 回放模式: 'full' | 'smart' | 'minimal'
16
- * @param {string[]} options.filters - 自定义过滤规则
17
- * @param {boolean} options.executeStop - 是否执行 stop 请求
18
- */
19
- constructor(options = {}) {
20
- this.mode = options.mode || 'smart';
21
- this.filters = options.filters || [];
22
- this.executeStop = options.executeStop || false;
23
- }
24
-
25
- /**
26
- * 分析请求列表,生成回放计划
27
- * @param {Object[]} rawRequests - 原始请求列表
28
- * @returns {ReplayPlan}
29
- */
30
- analyze(rawRequests) {
31
- const plan = new ReplayPlan();
32
- plan.originalCount = rawRequests.length;
33
-
34
- if (rawRequests.length === 0) {
35
- return plan;
36
- }
37
-
38
- // 第一遍:分类
39
- const classified = rawRequests.map((raw, index) => this.classify(raw, index));
40
-
41
- // 第二遍:根据模式决定动作
42
- const actioned = this.assignActions(classified);
43
-
44
- // 第三遍:应用自定义过滤器和 stop 处理
45
- const filtered = this.applyFilters(actioned);
46
-
47
- // 分配到计划中
48
- for (const req of filtered) {
49
- this.updateStats(plan.stats, req);
50
-
51
- if (req.action === RequestAction.SKIP) {
52
- plan.skippedRequests.push(req);
53
- } else if (req.action === RequestAction.MERGE) {
54
- plan.mergedRequests.push(req);
55
- } else {
56
- plan.requests.push(req);
57
- }
58
- }
59
-
60
- return plan;
61
- }
62
-
63
- /**
64
- * 分类单个请求
65
- * @param {Object} raw - 原始请求对象
66
- * @param {number} index - 请求索引
67
- * @returns {ReplayRequest}
68
- */
69
- classify(raw, index) {
70
- const req = new ReplayRequest(raw, index);
71
- const uri = req.uri || '';
72
- const command = req.getCommand();
73
-
74
- // 按 URI 分类
75
- if (uri.includes('start_async')) {
76
- req.category = RequestCategory.STARTUP;
77
- } else if (uri.includes('get_status')) {
78
- req.category = RequestCategory.STARTUP_POLLING;
79
- } else if (uri.includes('create_session') || uri.includes('close_session')) {
80
- req.category = RequestCategory.SESSION;
81
- } else if (uri.includes('upload')) {
82
- req.category = RequestCategory.UPLOAD;
83
- } else if (uri.includes('/stop')) {
84
- req.category = RequestCategory.STOP;
85
- } else if (uri.includes('run_in_session')) {
86
- // 按命令内容进一步分类
87
- if (this.isNohupCommand(command)) {
88
- req.category = RequestCategory.NOHUP_COMMAND;
89
- } else if (this.isProcessCheck(command)) {
90
- req.category = RequestCategory.PROCESS_CHECK;
91
- } else if (this.isLogQuery(command)) {
92
- req.category = RequestCategory.LOG_QUERY;
93
- } else {
94
- req.category = RequestCategory.OTHER;
95
- }
96
- } else {
97
- req.category = RequestCategory.OTHER;
98
- }
99
-
100
- return req;
101
- }
102
-
103
- /**
104
- * 根据模式分配动作
105
- * @param {ReplayRequest[]} requests
106
- * @returns {ReplayRequest[]}
107
- */
108
- assignActions(requests) {
109
- switch (this.mode) {
110
- case 'full':
111
- return this.assignFullModeActions(requests);
112
- case 'smart':
113
- return this.assignSmartModeActions(requests);
114
- case 'minimal':
115
- return this.assignMinimalModeActions(requests);
116
- default:
117
- return this.assignSmartModeActions(requests);
118
- }
119
- }
120
-
121
- /**
122
- * Full 模式:保留所有请求,跳过进程检测
123
- * @param {ReplayRequest[]} requests
124
- * @returns {ReplayRequest[]}
125
- */
126
- assignFullModeActions(requests) {
127
- return requests.map(req => {
128
- switch (req.category) {
129
- case RequestCategory.NOHUP_COMMAND:
130
- req.action = RequestAction.EXECUTE_WITH_PROCESS_WAIT;
131
- break;
132
- case RequestCategory.PROCESS_CHECK:
133
- // 跳过所有 kill -0,由 nohup 执行后自动等待进程结束
134
- req.action = RequestAction.SKIP;
135
- req.skipReason = 'Process check (handled by automatic process wait)';
136
- break;
137
- default:
138
- req.action = RequestAction.EXECUTE;
139
- }
140
- return req;
141
- });
142
- }
143
-
144
- /**
145
- * Smart 模式:跳过启动轮询,跳过进程检测(由 nohup 自动等待)
146
- * @param {ReplayRequest[]} requests
147
- * @returns {ReplayRequest[]}
148
- */
149
- assignSmartModeActions(requests) {
150
- let afterStartup = false;
151
-
152
- for (const req of requests) {
153
- switch (req.category) {
154
- case RequestCategory.STARTUP:
155
- afterStartup = true;
156
- req.action = RequestAction.EXECUTE;
157
- break;
158
-
159
- case RequestCategory.STARTUP_POLLING:
160
- if (afterStartup) {
161
- req.action = RequestAction.SKIP;
162
- req.skipReason = 'Startup polling (replaced by built-in wait)';
163
- } else {
164
- req.action = RequestAction.EXECUTE;
165
- }
166
- break;
167
-
168
- case RequestCategory.SESSION:
169
- afterStartup = false;
170
- req.action = RequestAction.EXECUTE;
171
- break;
172
-
173
- case RequestCategory.NOHUP_COMMAND:
174
- req.action = RequestAction.EXECUTE_WITH_PROCESS_WAIT;
175
- break;
176
-
177
- case RequestCategory.PROCESS_CHECK:
178
- // 跳过所有 kill -0,由 nohup 执行后自动等待进程结束
179
- req.action = RequestAction.SKIP;
180
- req.skipReason = 'Process check (handled by automatic process wait)';
181
- break;
182
-
183
- case RequestCategory.LOG_QUERY:
184
- req.action = RequestAction.EXECUTE;
185
- break;
186
-
187
- case RequestCategory.OTHER:
188
- req.action = RequestAction.EXECUTE;
189
- break;
190
-
191
- default:
192
- req.action = RequestAction.EXECUTE;
193
- }
194
- }
195
-
196
- return requests;
197
- }
198
-
199
- /**
200
- * Minimal 模式:只保留关键操作
201
- * @param {ReplayRequest[]} requests
202
- * @returns {ReplayRequest[]}
203
- */
204
- assignMinimalModeActions(requests) {
205
- return requests.map(req => {
206
- switch (req.category) {
207
- case RequestCategory.STARTUP:
208
- req.action = RequestAction.EXECUTE;
209
- break;
210
-
211
- case RequestCategory.SESSION:
212
- req.action = RequestAction.EXECUTE;
213
- break;
214
-
215
- case RequestCategory.NOHUP_COMMAND:
216
- req.action = RequestAction.EXECUTE_WITH_PROCESS_WAIT;
217
- break;
218
-
219
- case RequestCategory.UPLOAD:
220
- req.action = RequestAction.EXECUTE;
221
- break;
222
-
223
- case RequestCategory.STARTUP_POLLING:
224
- req.action = RequestAction.SKIP;
225
- req.skipReason = 'Startup polling (minimal mode)';
226
- break;
227
-
228
- case RequestCategory.PROCESS_CHECK:
229
- req.action = RequestAction.SKIP;
230
- req.skipReason = 'Process check (minimal mode)';
231
- break;
232
-
233
- case RequestCategory.LOG_QUERY:
234
- req.action = RequestAction.SKIP;
235
- req.skipReason = 'Log query (minimal mode)';
236
- break;
237
-
238
- case RequestCategory.OTHER:
239
- // 保留非轮询类命令
240
- req.action = RequestAction.EXECUTE;
241
- break;
242
-
243
- default:
244
- req.action = RequestAction.EXECUTE;
245
- }
246
- return req;
247
- });
248
- }
249
-
250
- /**
251
- * 应用自定义过滤器和 stop 处理
252
- * @param {ReplayRequest[]} requests
253
- * @returns {ReplayRequest[]}
254
- */
255
- applyFilters(requests) {
256
- return requests.map(req => {
257
- // 处理 stop 请求
258
- if (req.category === RequestCategory.STOP) {
259
- if (!this.executeStop) {
260
- req.action = RequestAction.SKIP;
261
- req.skipReason = 'Stop request (use --stop to execute)';
262
- }
263
- return req;
264
- }
265
-
266
- // 应用自定义过滤器
267
- if (this.filters.length > 0 && req.action !== RequestAction.SKIP) {
268
- for (const filter of this.filters) {
269
- if (req.uri.includes(filter) ||
270
- req.getCommand().includes(filter)) {
271
- req.action = RequestAction.SKIP;
272
- req.skipReason = `Custom filter: "${filter}"`;
273
- break;
274
- }
275
- }
276
- }
277
-
278
- return req;
279
- });
280
- }
281
-
282
- // 辅助方法
283
- isNohupCommand(command) {
284
- return /^nohup\s+/.test(command) && /&/.test(command);
285
- }
286
-
287
- isProcessCheck(command) {
288
- return /^kill\s+-0\s+\d+$/.test(command);
289
- }
290
-
291
- isLogQuery(command) {
292
- return /^head\s+-c\s+\d+\s+/.test(command) ||
293
- /^tail\s+/.test(command);
294
- }
295
-
296
- updateStats(stats, req) {
297
- switch (req.category) {
298
- case RequestCategory.STARTUP: stats.startup++; break;
299
- case RequestCategory.STARTUP_POLLING: stats.startupPolling++; break;
300
- case RequestCategory.SESSION: stats.session++; break;
301
- case RequestCategory.NOHUP_COMMAND: stats.nohupCommand++; break;
302
- case RequestCategory.PROCESS_CHECK: stats.processCheck++; break;
303
- case RequestCategory.LOG_QUERY: stats.logQuery++; break;
304
- case RequestCategory.UPLOAD: stats.upload++; break;
305
- case RequestCategory.STOP: stats.stop++; break;
306
- case RequestCategory.OTHER: stats.other++; break;
307
- }
308
- }
309
- }
310
-
311
- module.exports = { RequestAnalyzer };