rl-rockcli 0.0.8 → 0.0.10

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 (162) hide show
  1. package/commands/attach/basic-repl.js +212 -0
  2. package/commands/attach/cleanup-history.js +189 -0
  3. package/commands/attach/cleanup-manager.js +163 -0
  4. package/commands/attach/copy-ui/copyRepl.js +195 -0
  5. package/commands/attach/copy-ui/index.js +7 -0
  6. package/commands/attach/copy-ui/render/outputBlock.js +25 -0
  7. package/commands/attach/copy-ui/viewport/viewport.js +23 -0
  8. package/commands/attach/copy-ui/viewport/wheel.js +14 -0
  9. package/commands/attach/history-manager.js +507 -0
  10. package/commands/attach/history-session.js +48 -0
  11. package/commands/attach/ink-repl/InkREPL.js +1507 -0
  12. package/commands/attach/ink-repl/builtinCommands.js +1253 -0
  13. package/commands/attach/ink-repl/components/ConnectingScreen.js +76 -0
  14. package/commands/attach/ink-repl/components/Console.js +191 -0
  15. package/commands/attach/ink-repl/components/DetailView.js +148 -0
  16. package/commands/attach/ink-repl/components/DropdownMenu.js +86 -0
  17. package/commands/attach/ink-repl/components/InputArea.js +125 -0
  18. package/commands/attach/ink-repl/components/InputLine.js +18 -0
  19. package/commands/attach/ink-repl/components/OutputArea.js +22 -0
  20. package/commands/attach/ink-repl/components/OutputItem.js +96 -0
  21. package/commands/attach/ink-repl/components/ShellLayout.js +61 -0
  22. package/commands/attach/ink-repl/components/Spinner.js +79 -0
  23. package/commands/attach/ink-repl/components/StatusBar.js +106 -0
  24. package/commands/attach/ink-repl/components/WelcomeBanner.js +48 -0
  25. package/commands/attach/ink-repl/contexts/LayoutContext.js +12 -0
  26. package/commands/attach/ink-repl/contexts/ThemeContext.js +43 -0
  27. package/commands/attach/ink-repl/hooks/useFunctionKeys.js +70 -0
  28. package/commands/attach/ink-repl/hooks/useMouse.js +162 -0
  29. package/commands/attach/ink-repl/hooks/useResources.js +132 -0
  30. package/commands/attach/ink-repl/hooks/useSpinner.js +49 -0
  31. package/commands/attach/ink-repl/index.js +112 -0
  32. package/commands/attach/ink-repl/package.json +3 -0
  33. package/commands/attach/ink-repl/replState.js +947 -0
  34. package/commands/attach/ink-repl/shortcuts/defaultKeybindings.js +138 -0
  35. package/commands/attach/ink-repl/shortcuts/index.js +332 -0
  36. package/commands/attach/ink-repl/themes/defaultDark.js +18 -0
  37. package/commands/attach/ink-repl/themes/defaultLight.js +18 -0
  38. package/commands/attach/ink-repl/themes/index.js +4 -0
  39. package/commands/attach/ink-repl/themes/themeManager.js +45 -0
  40. package/commands/attach/ink-repl/themes/themeTokens.js +15 -0
  41. package/commands/attach/ink-repl/utils/atCompletion.js +346 -0
  42. package/commands/attach/ink-repl/utils/clipboard.js +50 -0
  43. package/commands/attach/ink-repl/utils/consoleLogger.js +81 -0
  44. package/commands/attach/ink-repl/utils/exitCodeHandler.js +49 -0
  45. package/commands/attach/ink-repl/utils/exitCodeTips.js +56 -0
  46. package/commands/attach/ink-repl/utils/formatTime.js +12 -0
  47. package/commands/attach/ink-repl/utils/outputSelection.js +120 -0
  48. package/commands/attach/ink-repl/utils/outputViewport.js +77 -0
  49. package/commands/attach/ink-repl/utils/paginatedFileLoading.js +76 -0
  50. package/commands/attach/ink-repl/utils/paramHint.js +60 -0
  51. package/commands/attach/ink-repl/utils/parseError.js +174 -0
  52. package/commands/attach/ink-repl/utils/pathCompletion.js +167 -0
  53. package/commands/attach/ink-repl/utils/remotePathSafety.js +56 -0
  54. package/commands/attach/ink-repl/utils/replSelection.js +205 -0
  55. package/commands/attach/ink-repl/utils/responseFormatter.js +127 -0
  56. package/commands/attach/ink-repl/utils/textWrap.js +117 -0
  57. package/commands/attach/ink-repl/utils/truncate.js +115 -0
  58. package/commands/attach/opentui-repl/App.tsx +891 -0
  59. package/commands/attach/opentui-repl/builtinCommands.ts +80 -0
  60. package/commands/attach/opentui-repl/components/ConfirmDialog.tsx +116 -0
  61. package/commands/attach/opentui-repl/components/ConnectingScreen.tsx +131 -0
  62. package/commands/attach/opentui-repl/components/Console.tsx +73 -0
  63. package/commands/attach/opentui-repl/components/DetailView.tsx +45 -0
  64. package/commands/attach/opentui-repl/components/DropdownMenu.tsx +130 -0
  65. package/commands/attach/opentui-repl/components/ExecutionStatus.tsx +66 -0
  66. package/commands/attach/opentui-repl/components/Header.tsx +24 -0
  67. package/commands/attach/opentui-repl/components/OutputArea.tsx +25 -0
  68. package/commands/attach/opentui-repl/components/OutputBlock.tsx +108 -0
  69. package/commands/attach/opentui-repl/components/PromptInput.tsx +109 -0
  70. package/commands/attach/opentui-repl/components/StatusBar.tsx +63 -0
  71. package/commands/attach/opentui-repl/components/Toast.tsx +65 -0
  72. package/commands/attach/opentui-repl/components/WelcomeBanner.tsx +41 -0
  73. package/commands/attach/opentui-repl/contexts/ReplContext.tsx +137 -0
  74. package/commands/attach/opentui-repl/contexts/SessionContext.tsx +32 -0
  75. package/commands/attach/opentui-repl/contexts/ThemeContext.tsx +70 -0
  76. package/commands/attach/opentui-repl/contexts/ToastContext.tsx +69 -0
  77. package/commands/attach/opentui-repl/contexts/toast-logic.js +71 -0
  78. package/commands/attach/opentui-repl/hooks/useResources.ts +102 -0
  79. package/commands/attach/opentui-repl/hooks/useSpinner.ts +46 -0
  80. package/commands/attach/opentui-repl/index.js +99 -0
  81. package/commands/attach/opentui-repl/keybindings.ts +39 -0
  82. package/commands/attach/opentui-repl/package.json +3 -0
  83. package/commands/attach/opentui-repl/render.tsx +72 -0
  84. package/commands/attach/opentui-repl/tsconfig.json +12 -0
  85. package/commands/attach/repl.js +791 -0
  86. package/commands/attach/sandbox-id-resolver.js +56 -0
  87. package/commands/attach/session-manager.js +307 -0
  88. package/commands/attach/ui-mode.js +146 -0
  89. package/commands/log/core/constants.js +237 -0
  90. package/commands/log/core/display.js +370 -0
  91. package/commands/log/core/search.js +330 -0
  92. package/commands/log/core/tail.js +216 -0
  93. package/commands/log/core/utils.js +424 -0
  94. package/commands/log.js +298 -0
  95. package/commands/sandbox/core/log-bridge.js +119 -0
  96. package/commands/sandbox/core/replay/analyzer.js +311 -0
  97. package/commands/sandbox/core/replay/batch-orchestrator.js +536 -0
  98. package/commands/sandbox/core/replay/batch-task.js +369 -0
  99. package/commands/sandbox/core/replay/concurrent-display.js +70 -0
  100. package/commands/sandbox/core/replay/concurrent-orchestrator.js +170 -0
  101. package/commands/sandbox/core/replay/data-source.js +86 -0
  102. package/commands/sandbox/core/replay/display.js +231 -0
  103. package/commands/sandbox/core/replay/executor.js +634 -0
  104. package/commands/sandbox/core/replay/history-fetcher.js +124 -0
  105. package/commands/sandbox/core/replay/index.js +338 -0
  106. package/commands/sandbox/core/replay/loghouse-data-source.js +177 -0
  107. package/commands/sandbox/core/replay/pid-mapping.js +26 -0
  108. package/commands/sandbox/core/replay/request.js +109 -0
  109. package/commands/sandbox/core/replay/worker.js +166 -0
  110. package/commands/sandbox/core/session.js +346 -0
  111. package/commands/sandbox/log-bridge.js +2 -0
  112. package/commands/sandbox/ray.js +2 -0
  113. package/commands/sandbox/replay/analyzer.js +311 -0
  114. package/commands/sandbox/replay/batch-orchestrator.js +536 -0
  115. package/commands/sandbox/replay/batch-task.js +369 -0
  116. package/commands/sandbox/replay/concurrent-display.js +70 -0
  117. package/commands/sandbox/replay/concurrent-orchestrator.js +170 -0
  118. package/commands/sandbox/replay/display.js +231 -0
  119. package/commands/sandbox/replay/executor.js +634 -0
  120. package/commands/sandbox/replay/history-fetcher.js +118 -0
  121. package/commands/sandbox/replay/index.js +338 -0
  122. package/commands/sandbox/replay/pid-mapping.js +26 -0
  123. package/commands/sandbox/replay/request.js +109 -0
  124. package/commands/sandbox/replay/worker.js +166 -0
  125. package/commands/sandbox/replay.js +2 -0
  126. package/commands/sandbox/session.js +2 -0
  127. package/commands/sandbox-original.js +1393 -0
  128. package/commands/sandbox.js +499 -0
  129. package/help/help.json +1071 -0
  130. package/help/middleware.js +71 -0
  131. package/help/renderer.js +800 -0
  132. package/index.js +5 -15
  133. package/lib/plugin-context.js +40 -0
  134. package/package.json +2 -2
  135. package/sdks/sandbox/core/client.js +845 -0
  136. package/sdks/sandbox/core/config.js +70 -0
  137. package/sdks/sandbox/core/types.js +74 -0
  138. package/sdks/sandbox/httpLogger.js +251 -0
  139. package/sdks/sandbox/index.js +9 -0
  140. package/utils/asciiArt.js +138 -0
  141. package/utils/bun-compat.js +59 -0
  142. package/utils/ciPipelines.js +138 -0
  143. package/utils/cli.js +17 -0
  144. package/utils/command-router.js +79 -0
  145. package/utils/configManager.js +503 -0
  146. package/utils/dependency-resolver.js +135 -0
  147. package/utils/eagleeye_traceid.js +151 -0
  148. package/utils/envDetector.js +78 -0
  149. package/utils/execution_logger.js +415 -0
  150. package/utils/featureManager.js +68 -0
  151. package/utils/firstTimeTip.js +44 -0
  152. package/utils/hook-manager.js +125 -0
  153. package/utils/http-logger.js +264 -0
  154. package/utils/i18n.js +139 -0
  155. package/utils/image-progress.js +159 -0
  156. package/utils/logger.js +154 -0
  157. package/utils/plugin-loader.js +124 -0
  158. package/utils/plugin-manager.js +348 -0
  159. package/utils/ray_cli_wrapper.js +746 -0
  160. package/utils/sandbox-client.js +419 -0
  161. package/utils/terminal.js +32 -0
  162. package/utils/tips.js +106 -0
@@ -0,0 +1,166 @@
1
+ const path = require('path');
2
+ const { SandboxClient, SandboxConfig } = require('../../../utils/sandbox-client');
3
+ const { ReplayExecutor } = require('./executor');
4
+ const { ReplayRequest, ReplayPlan } = require('./request');
5
+
6
+ /**
7
+ * 单个沙箱回放工作者
8
+ * 封装独立的 SandboxClient 和 ReplayExecutor
9
+ */
10
+ class ReplayWorker {
11
+ /**
12
+ * @param {number} workerId - 工作者 ID(1-based)
13
+ * @param {SandboxConfig} config - 沙箱配置
14
+ * @param {ReplayPlan} plan - 回放计划(会被深拷贝)
15
+ * @param {Object} options - 回放选项
16
+ * @param {string} options.timing - 时间控制
17
+ * @param {number} options.interval - 固定间隔
18
+ * @param {string} options.logFile - 日志文件基础路径
19
+ */
20
+ constructor(workerId, config, plan, options = {}) {
21
+ this.workerId = workerId;
22
+ this.config = config;
23
+ this.plan = this.deepClonePlan(plan);
24
+ this.options = options;
25
+
26
+ // 独立的沙箱客户端和执行器
27
+ this.client = null;
28
+ this.executor = null;
29
+
30
+ // 执行状态
31
+ this.status = 'pending'; // pending | running | completed | failed
32
+ this.error = null;
33
+ this.results = null;
34
+ this.startTime = null;
35
+ this.endTime = null;
36
+ }
37
+
38
+ /**
39
+ * 深拷贝回放计划
40
+ * 确保每个 worker 有独立的请求对象(requestBody 可能被修改)
41
+ * @param {ReplayPlan} plan
42
+ * @returns {ReplayPlan}
43
+ */
44
+ deepClonePlan(plan) {
45
+ const cloned = new ReplayPlan();
46
+ cloned.originalCount = plan.originalCount;
47
+ cloned.stats = { ...plan.stats };
48
+ cloned.pidAssociations = new Map(plan.pidAssociations);
49
+
50
+ // 深拷贝请求列表
51
+ cloned.requests = plan.requests.map(req => this.cloneRequest(req));
52
+ cloned.skippedRequests = plan.skippedRequests.map(req => this.cloneRequest(req));
53
+ cloned.mergedRequests = plan.mergedRequests.map(req => this.cloneRequest(req));
54
+
55
+ return cloned;
56
+ }
57
+
58
+ /**
59
+ * 深拷贝单个请求
60
+ * @param {ReplayRequest} req
61
+ * @returns {ReplayRequest}
62
+ */
63
+ cloneRequest(req) {
64
+ const cloned = new ReplayRequest({
65
+ method: req.method,
66
+ uri: req.uri,
67
+ requestBody: JSON.parse(JSON.stringify(req.requestBody || {})),
68
+ headers: JSON.parse(JSON.stringify(req.headers || {})),
69
+ responseTime: req.responseTime
70
+ }, req.index);
71
+
72
+ cloned.category = req.category;
73
+ cloned.action = req.action;
74
+ cloned.originalPid = req.originalPid;
75
+ cloned.skipReason = req.skipReason;
76
+
77
+ return cloned;
78
+ }
79
+
80
+ /**
81
+ * 获取 worker 专属的日志文件名
82
+ * @returns {string}
83
+ */
84
+ getLogFileName() {
85
+ const baseLogFile = this.options.logFile || 'replay.log';
86
+ const ext = path.extname(baseLogFile);
87
+ const base = path.basename(baseLogFile, ext);
88
+ const dir = path.dirname(baseLogFile);
89
+ return path.join(dir, `${base}-worker${this.workerId}${ext}`);
90
+ }
91
+
92
+ /**
93
+ * 执行回放
94
+ * @returns {Promise<WorkerResult>}
95
+ */
96
+ async execute() {
97
+ this.status = 'running';
98
+ this.startTime = Date.now();
99
+
100
+ try {
101
+ // 创建独立的 SandboxClient
102
+ this.client = new SandboxClient(this.config);
103
+
104
+ // 创建独立的 ReplayExecutor
105
+ this.executor = new ReplayExecutor(this.client, {
106
+ timing: this.options.timing,
107
+ interval: this.options.interval,
108
+ quiet: true, // 并发模式下强制静默,由 orchestrator 统一输出
109
+ logFile: this.getLogFileName(),
110
+ plan: this.plan,
111
+ workerId: this.workerId
112
+ });
113
+
114
+ // 执行回放
115
+ this.results = await this.executor.execute(this.plan);
116
+ this.status = 'completed';
117
+
118
+ } catch (error) {
119
+ this.status = 'failed';
120
+ this.error = error;
121
+ this.results = {
122
+ total: this.plan.requests.length,
123
+ success: 0,
124
+ failed: this.plan.requests.length,
125
+ skipped: 0
126
+ };
127
+ } finally {
128
+ this.endTime = Date.now();
129
+ }
130
+
131
+ return this.getWorkerResult();
132
+ }
133
+
134
+ /**
135
+ * 获取工作者执行结果
136
+ * @returns {WorkerResult}
137
+ */
138
+ getWorkerResult() {
139
+ return {
140
+ workerId: this.workerId,
141
+ status: this.status,
142
+ sandboxId: this.executor?.currentSandboxId || null,
143
+ results: this.results,
144
+ error: this.error?.message || null,
145
+ duration: this.endTime - this.startTime,
146
+ logFile: this.getLogFileName()
147
+ };
148
+ }
149
+
150
+ /**
151
+ * 获取当前进度
152
+ * @returns {Object}
153
+ */
154
+ getProgress() {
155
+ return {
156
+ workerId: this.workerId,
157
+ status: this.status,
158
+ sandboxId: this.executor?.currentSandboxId?.substring(0, 8) || null,
159
+ success: this.executor?.results?.success || 0,
160
+ failed: this.executor?.results?.failed || 0,
161
+ total: this.plan.requests.length
162
+ };
163
+ }
164
+ }
165
+
166
+ module.exports = { ReplayWorker };
@@ -0,0 +1,2 @@
1
+ // Core replay - re-export from new location
2
+ module.exports = require('./core/replay');
@@ -0,0 +1,2 @@
1
+ // Compatibility wrapper - delegates to core implementation
2
+ module.exports = require('./core/session');