@autotest/agent 0.0.5 → 0.0.7

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 (192) hide show
  1. package/README.md +10 -0
  2. package/dist/api/agent_api.d.ts +2 -2
  3. package/dist/autotest-cli.js +1 -397
  4. package/dist/common/config/config.yaml +5 -0
  5. package/dist/common/config/manager.d.ts +7 -7
  6. package/dist/common/config/types.d.ts +33 -1
  7. package/dist/common/dfx/index.d.ts +1 -1
  8. package/dist/common/image_helper.d.ts +2 -2
  9. package/dist/common/llm_cache/cache_transport.d.ts +1 -1
  10. package/dist/common/llm_cache/prompt_cache.d.ts +2 -2
  11. package/dist/common/utils.d.ts +5 -5
  12. package/dist/core/agent/layered_agent/agent_registry.d.ts +3 -1
  13. package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.d.ts +1 -1
  14. package/dist/core/agent/layered_agent/execute_agent/prompts.d.ts +1 -1
  15. package/dist/core/agent/report_analyzer_agent/prompt.d.ts +1 -1
  16. package/dist/core/agent/report_analyzer_agent/tools.d.ts +1 -1
  17. package/dist/core/agent/rewrite_agent/agent.d.ts +5 -5
  18. package/dist/core/agent/rewrite_agent/guardrails.d.ts +1 -1
  19. package/dist/core/agent/rewrite_agent/mapping.d.ts +1 -1
  20. package/dist/core/agent/rewrite_agent/parse.d.ts +1 -1
  21. package/dist/core/agent/rewrite_agent/types.d.ts +1 -1
  22. package/dist/core/agent/single_agent/agent.d.ts +2 -2
  23. package/dist/core/agent/single_agent/hook_manager.d.ts +1 -2
  24. package/dist/core/agent/single_agent/image_utils.d.ts +1 -2
  25. package/dist/core/agent/single_agent/scroll_search_agent.d.ts +5 -5
  26. package/dist/core/agent/single_agent/subagent_manager.d.ts +1 -2
  27. package/dist/core/agent/single_agent/tool_recorder_hook.d.ts +3 -3
  28. package/dist/core/device/device_protocol.d.ts +1 -1
  29. package/dist/core/device/hdc/device.d.ts +1 -1
  30. package/dist/core/device/index.d.ts +2 -2
  31. package/dist/core/knowledge/knowledge_manager.d.ts +1 -1
  32. package/dist/core/knowledge/vectordb.d.ts +1 -1
  33. package/dist/core/mcp/harmony_hdc_adapter.d.ts +1 -0
  34. package/dist/core/mcp/mcp_tools.d.ts +11 -2
  35. package/dist/core/mcp/verify_tool.d.ts +12 -0
  36. package/dist/core/memory/_utils.d.ts +1 -1
  37. package/dist/core/memory/index.d.ts +1 -1
  38. package/dist/core/memory/memory_manager.d.ts +1 -1
  39. package/dist/core/memory/replan_manager.d.ts +1 -1
  40. package/dist/core/memory/tool_player.d.ts +5 -5
  41. package/dist/core/memory/tool_player_popup.d.ts +1 -1
  42. package/dist/core/memory/tool_player_replan.d.ts +1 -1
  43. package/dist/core/memory/tool_player_xpath.d.ts +3 -3
  44. package/dist/core/prompt/prompt_loader.d.ts +1 -1
  45. package/dist/core/prompt/templates/single/single_v2.0.md +15 -0
  46. package/dist/core/skill/skill_manager.d.ts +2 -2
  47. package/dist/data_types/device.d.ts +1 -1
  48. package/dist/data_types/index.d.ts +1 -1
  49. package/dist/index.d.ts +5 -5
  50. package/dist/index.js +1 -164
  51. package/dist/loop/cli.d.ts +4 -4
  52. package/dist/loop/orchestrator.d.ts +6 -6
  53. package/dist/loop/result_writer.d.ts +1 -1
  54. package/dist/loop/types.d.ts +1 -1
  55. package/dist/tools/batch_runner.js +1 -745
  56. package/dist/tools/case_runner/report.d.ts +1 -1
  57. package/dist/tools/case_runner/runner.d.ts +3 -3
  58. package/dist/tools/case_runner/runner.js +1 -410
  59. package/dist/tools/config/config_tool.d.ts +6 -6
  60. package/dist/tools/config/config_tool.js +1 -339
  61. package/dist/tools/prompt_compare/compare_runner.d.ts +2 -2
  62. package/dist/tools/prompt_compare/compare_runner.js +1 -360
  63. package/package.json +2 -2
  64. package/dist/api/agent_api.js +0 -550
  65. package/dist/api/autotest_agent.js +0 -205
  66. package/dist/api/types.js +0 -11
  67. package/dist/common/case_manager.js +0 -91
  68. package/dist/common/collect_case.js +0 -128
  69. package/dist/common/common_errors.js +0 -66
  70. package/dist/common/config/config_validator.js +0 -28
  71. package/dist/common/config/manager.js +0 -257
  72. package/dist/common/config/output.js +0 -59
  73. package/dist/common/config/types.js +0 -184
  74. package/dist/common/dfx/client_factory.js +0 -62
  75. package/dist/common/dfx/context.js +0 -23
  76. package/dist/common/dfx/index.js +0 -15
  77. package/dist/common/dfx/recorder.js +0 -191
  78. package/dist/common/dfx/recording_fetch.js +0 -228
  79. package/dist/common/dfx/source.js +0 -13
  80. package/dist/common/image_cacher.js +0 -36
  81. package/dist/common/image_helper.js +0 -128
  82. package/dist/common/image_similarity.js +0 -171
  83. package/dist/common/llm_cache/cache_transport.js +0 -102
  84. package/dist/common/llm_cache/prompt_cache.js +0 -113
  85. package/dist/common/logger.js +0 -158
  86. package/dist/common/model/custom_model.js +0 -525
  87. package/dist/common/model/index.js +0 -5
  88. package/dist/common/path_utils.js +0 -88
  89. package/dist/common/result_parser.js +0 -49
  90. package/dist/common/usage/token_usage.js +0 -117
  91. package/dist/common/utils.js +0 -125
  92. package/dist/core/agent/layered_agent/ability_helper.js +0 -125
  93. package/dist/core/agent/layered_agent/agent.js +0 -37
  94. package/dist/core/agent/layered_agent/agent_registry.js +0 -75
  95. package/dist/core/agent/layered_agent/decision.js +0 -516
  96. package/dist/core/agent/layered_agent/execute_agent/action_handler.js +0 -155
  97. package/dist/core/agent/layered_agent/execute_agent/agent_factory.js +0 -41
  98. package/dist/core/agent/layered_agent/execute_agent/base_agent.js +0 -112
  99. package/dist/core/agent/layered_agent/execute_agent/general_agent.js +0 -207
  100. package/dist/core/agent/layered_agent/execute_agent/glm_agent.js +0 -241
  101. package/dist/core/agent/layered_agent/execute_agent/i18n.js +0 -34
  102. package/dist/core/agent/layered_agent/execute_agent/index.js +0 -67
  103. package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js +0 -316
  104. package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +0 -154
  105. package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +0 -243
  106. package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +0 -139
  107. package/dist/core/agent/layered_agent/execute_agent/parser/index.js +0 -9
  108. package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +0 -94
  109. package/dist/core/agent/layered_agent/execute_agent/prompts.js +0 -109
  110. package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js +0 -33
  111. package/dist/core/agent/layered_agent/execute_agent/utils.js +0 -52
  112. package/dist/core/agent/report_analyzer_agent/agent.js +0 -565
  113. package/dist/core/agent/report_analyzer_agent/config.js +0 -22
  114. package/dist/core/agent/report_analyzer_agent/data_loader.js +0 -255
  115. package/dist/core/agent/report_analyzer_agent/guardrails.js +0 -99
  116. package/dist/core/agent/report_analyzer_agent/hooks.js +0 -31
  117. package/dist/core/agent/report_analyzer_agent/index.js +0 -52
  118. package/dist/core/agent/report_analyzer_agent/key_steps_builder.js +0 -42
  119. package/dist/core/agent/report_analyzer_agent/mapping.js +0 -133
  120. package/dist/core/agent/report_analyzer_agent/parse.js +0 -375
  121. package/dist/core/agent/report_analyzer_agent/prompt.js +0 -300
  122. package/dist/core/agent/report_analyzer_agent/report_writer.js +0 -558
  123. package/dist/core/agent/report_analyzer_agent/tools.js +0 -150
  124. package/dist/core/agent/report_analyzer_agent/types.js +0 -274
  125. package/dist/core/agent/rewrite_agent/agent.js +0 -209
  126. package/dist/core/agent/rewrite_agent/guardrails.js +0 -95
  127. package/dist/core/agent/rewrite_agent/mapping.js +0 -56
  128. package/dist/core/agent/rewrite_agent/parse.js +0 -121
  129. package/dist/core/agent/rewrite_agent/types.js +0 -37
  130. package/dist/core/agent/single_agent/agent.js +0 -798
  131. package/dist/core/agent/single_agent/hook_manager.js +0 -60
  132. package/dist/core/agent/single_agent/hooks.js +0 -288
  133. package/dist/core/agent/single_agent/image_utils.js +0 -159
  134. package/dist/core/agent/single_agent/scroll_search_agent.js +0 -376
  135. package/dist/core/agent/single_agent/subagent_manager.js +0 -73
  136. package/dist/core/agent/single_agent/tool_recorder_hook.js +0 -42
  137. package/dist/core/agent/types.js +0 -2
  138. package/dist/core/agent/utils/message_builder.js +0 -138
  139. package/dist/core/device/device_protocol.js +0 -2
  140. package/dist/core/device/hdc/apps.js +0 -437
  141. package/dist/core/device/hdc/device.js +0 -219
  142. package/dist/core/device/hdc/index.js +0 -31
  143. package/dist/core/device/hdc/input.js +0 -74
  144. package/dist/core/device/hdc/screenshot.js +0 -171
  145. package/dist/core/device/index.js +0 -70
  146. package/dist/core/device/types.js +0 -2
  147. package/dist/core/knowledge/knowledge_manager.js +0 -70
  148. package/dist/core/knowledge/vectordb.js +0 -283
  149. package/dist/core/mcp/adapter_factory.js +0 -99
  150. package/dist/core/mcp/android_adapter.js +0 -286
  151. package/dist/core/mcp/base_adapter.js +0 -86
  152. package/dist/core/mcp/harmony_hdc_adapter.js +0 -782
  153. package/dist/core/mcp/ios_adapter.js +0 -286
  154. package/dist/core/mcp/local_tools.js +0 -41
  155. package/dist/core/mcp/mcp_tools.js +0 -410
  156. package/dist/core/mcp/types.js +0 -6
  157. package/dist/core/memory/_utils.js +0 -140
  158. package/dist/core/memory/compressed_session.js +0 -182
  159. package/dist/core/memory/context_compressor.js +0 -176
  160. package/dist/core/memory/index.js +0 -22
  161. package/dist/core/memory/memory_manager.js +0 -28
  162. package/dist/core/memory/reflector.js +0 -95
  163. package/dist/core/memory/replan_manager.js +0 -12
  164. package/dist/core/memory/session_factory.js +0 -29
  165. package/dist/core/memory/tool_player.js +0 -225
  166. package/dist/core/memory/tool_player_popup.js +0 -276
  167. package/dist/core/memory/tool_player_replan.js +0 -226
  168. package/dist/core/memory/tool_player_xpath.js +0 -139
  169. package/dist/core/memory/tool_recorder.js +0 -126
  170. package/dist/core/preprocessor/task_splitter.js +0 -112
  171. package/dist/core/prompt/prompt_loader.js +0 -315
  172. package/dist/core/skill/skill_manager.js +0 -302
  173. package/dist/data_types/action.js +0 -2
  174. package/dist/data_types/agent.js +0 -2
  175. package/dist/data_types/case.js +0 -57
  176. package/dist/data_types/device.js +0 -2
  177. package/dist/data_types/index.js +0 -11
  178. package/dist/data_types/report.js +0 -6
  179. package/dist/data_types/screen.js +0 -23
  180. package/dist/data_types/task.js +0 -2
  181. package/dist/loop/cli.js +0 -127
  182. package/dist/loop/orchestrator.js +0 -314
  183. package/dist/loop/result_writer.js +0 -260
  184. package/dist/loop/types.js +0 -82
  185. package/dist/mcp-server/server.js +0 -341
  186. package/dist/mcp-server/types.js +0 -224
  187. package/dist/reporter/batch_summary.js +0 -197
  188. package/dist/reporter/generator.js +0 -286
  189. package/dist/reporter/html_template/index.js +0 -524
  190. package/dist/reporter/json_report.js +0 -6
  191. package/dist/reporter/types.js +0 -45
  192. package/dist/tools/case_runner/report.js +0 -264
@@ -1,286 +0,0 @@
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.IOSMCPAdapter = void 0;
37
- const net = __importStar(require("net"));
38
- const path = __importStar(require("path"));
39
- const fs = __importStar(require("fs"));
40
- const os = __importStar(require("os"));
41
- const child_process_1 = require("child_process");
42
- const base_adapter_1 = require("./base_adapter");
43
- const common_errors_1 = require("../../common/common_errors");
44
- class IOSMCPAdapter extends base_adapter_1.MCPDeviceAdapterBase {
45
- platform = 'ios';
46
- devicectlPath;
47
- mcpProcess = null;
48
- mcpServerUrl = null;
49
- logFilePath = null;
50
- logStream = null;
51
- static MCP_SERVICE_PORT = 8712;
52
- static SCREENSHOT_TOOL_NAME = 'mobile_take_screenshot';
53
- static PRESS_BUTTON_TOOL = 'mobile_press_button';
54
- constructor(devicectlPath = 'devicectl', configManager) {
55
- super(configManager);
56
- this.devicectlPath = devicectlPath;
57
- }
58
- getDefaultServerUrl() {
59
- return `http://127.0.0.1:${IOSMCPAdapter.MCP_SERVICE_PORT}/mcp`;
60
- }
61
- getMcpServicePort() {
62
- return IOSMCPAdapter.MCP_SERVICE_PORT;
63
- }
64
- useSseTransport() {
65
- return true;
66
- }
67
- async startMcpService() {
68
- const config = this.configManager.getEffectiveConfig();
69
- const port = IOSMCPAdapter.MCP_SERVICE_PORT;
70
- await this.killProcessByPort(port);
71
- await new Promise((r) => setTimeout(r, 1000));
72
- const env = {
73
- ...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v != null)),
74
- };
75
- if (config.device.deviceSn) {
76
- env.DEVICE_ID = config.device.deviceSn;
77
- }
78
- const logDir = path.join(config.output.rootDir, 'log');
79
- fs.mkdirSync(logDir, { recursive: true });
80
- const timestamp = new Date().toISOString().replace(/[:.]/g, '').slice(0, 15);
81
- this.logFilePath = path.join(logDir, `mobile_mcp_ios_${timestamp}.log`);
82
- this.logStream = fs.createWriteStream(this.logFilePath, { flags: 'w' });
83
- const npxCmd = os.platform() === 'win32' ? 'npx.cmd' : 'npx';
84
- try {
85
- this.mcpProcess = (0, child_process_1.spawn)(npxCmd, ['-y', '@mobilenext/mobile-mcp@latest', '--listen', `0.0.0.0:${port}`], { env, cwd: process.cwd(), stdio: ['ignore', 'pipe', 'pipe'] });
86
- this.mcpProcess.stdout?.pipe(this.logStream);
87
- this.mcpProcess.stderr?.pipe(this.logStream);
88
- this.mcpProcess.on('error', (err) => {
89
- if (this.logFilePath) {
90
- fs.appendFileSync(this.logFilePath, `mobile_mcp process error: ${err.message}\n`);
91
- }
92
- });
93
- }
94
- catch (err) {
95
- this.closeLogStream();
96
- throw new common_errors_1.AgentError('MCP_SERVICE_TIMEOUT', `mobile-mcp start failed: ${err instanceof Error ? err.message : String(err)}`);
97
- }
98
- const serverUrl = this.getDefaultServerUrl();
99
- for (let attempt = 0; attempt < 20; attempt++) {
100
- await new Promise((r) => setTimeout(r, 1000));
101
- if (await this.isPortListening('127.0.0.1', port)) {
102
- return serverUrl;
103
- }
104
- }
105
- throw new common_errors_1.AgentError('MCP_SERVICE_TIMEOUT', `mobile-mcp service start timeout (20s), port ${port} not listening`);
106
- }
107
- async checkServiceHealth(serverUrl) {
108
- if (this.mcpProcess && this.mcpProcess.exitCode !== null) {
109
- return { isHealthy: false, status: 'notRunning' };
110
- }
111
- const portListening = await this.isPortListening('127.0.0.1', IOSMCPAdapter.MCP_SERVICE_PORT);
112
- if (!portListening) {
113
- return { isHealthy: false, status: 'notRunning' };
114
- }
115
- try {
116
- const response = await fetch(serverUrl, {
117
- method: 'POST',
118
- headers: { 'Content-Type': 'application/json', 'Accept': 'application/json, text/event-stream' },
119
- body: JSON.stringify({ jsonrpc: '2.0', method: 'ping', id: 1 }),
120
- signal: AbortSignal.timeout(5000),
121
- });
122
- if (response.ok) {
123
- return { isHealthy: true, status: 'healthy' };
124
- }
125
- return { isHealthy: false, status: 'error' };
126
- }
127
- catch {
128
- return { isHealthy: false, status: 'error' };
129
- }
130
- }
131
- async killProcessByPort(port) {
132
- const sys = os.platform();
133
- try {
134
- if (sys === 'win32') {
135
- const result = (0, child_process_1.execSync)('netstat -ano', { encoding: 'utf-8', timeout: 5000 });
136
- for (const line of result.split('\n')) {
137
- if (line.includes(`:${port}`) && line.includes('LISTENING')) {
138
- const parts = line.trim().split(/\s+/);
139
- const pid = parts[parts.length - 1];
140
- (0, child_process_1.execSync)(`taskkill /F /PID ${pid}`, { timeout: 5000 });
141
- return;
142
- }
143
- }
144
- }
145
- else {
146
- const result = (0, child_process_1.execSync)(`lsof -ti:${port}`, { encoding: 'utf-8', timeout: 5000 });
147
- if (result.trim()) {
148
- const pid = result.trim().split('\n')[0];
149
- (0, child_process_1.execSync)(`kill -9 ${pid}`, { timeout: 5000 });
150
- }
151
- }
152
- }
153
- catch {
154
- // port cleanup failed, not blocking main flow
155
- }
156
- }
157
- async callTool(toolName, args, timeout, retryOnFailure) {
158
- if (!this.connected) {
159
- throw new common_errors_1.AgentError('DEVICE_NOT_CONNECTED', 'Adapter not connected');
160
- }
161
- const config = this.configManager.getEffectiveConfig();
162
- const effectiveArgs = { ...(args ?? {}) };
163
- if (!effectiveArgs.device && config.device.deviceSn) {
164
- effectiveArgs.device = config.device.deviceSn;
165
- }
166
- const serverUrl = this.mcpServerUrl ?? this.getDefaultServerUrl();
167
- const effectiveTimeout = timeout ?? 60;
168
- const shouldRetry = retryOnFailure ?? true;
169
- try {
170
- const response = await fetch(serverUrl, {
171
- method: 'POST',
172
- headers: { 'Content-Type': 'application/json' },
173
- body: JSON.stringify({
174
- jsonrpc: '2.0',
175
- method: 'tools/call',
176
- id: Date.now(),
177
- params: { name: toolName, arguments: effectiveArgs },
178
- }),
179
- signal: this.getCallSignal(effectiveTimeout * 1000),
180
- });
181
- if (!response.ok) {
182
- throw new Error(`MCP tool call HTTP error: ${response.status}`);
183
- }
184
- const json = await response.json();
185
- if (json.error) {
186
- throw new Error(json.error.message);
187
- }
188
- return json.result;
189
- }
190
- catch (err) {
191
- if (!shouldRetry || this.isAborted()) {
192
- throw new common_errors_1.AgentError('MCP_SERVICE_TIMEOUT', err instanceof Error ? err.message : String(err));
193
- }
194
- try {
195
- await this.ensureServiceRunning(true);
196
- const retryUrl = this.getDefaultServerUrl();
197
- const retryResponse = await fetch(retryUrl, {
198
- method: 'POST',
199
- headers: { 'Content-Type': 'application/json' },
200
- body: JSON.stringify({
201
- jsonrpc: '2.0',
202
- method: 'tools/call',
203
- id: Date.now(),
204
- params: { name: toolName, arguments: effectiveArgs },
205
- }),
206
- signal: this.getCallSignal(effectiveTimeout * 1000),
207
- });
208
- const retryJson = await retryResponse.json();
209
- if (retryJson.error) {
210
- throw new Error(retryJson.error.message);
211
- }
212
- return retryJson.result;
213
- }
214
- catch (retryErr) {
215
- throw new common_errors_1.AgentError('MCP_SERVICE_TIMEOUT', `tool call failed and reconnect failed: ${retryErr instanceof Error ? retryErr.message : String(retryErr)}`);
216
- }
217
- }
218
- }
219
- async getScreenshot() {
220
- if (!this.connected) {
221
- throw new common_errors_1.AgentError('DEVICE_NOT_CONNECTED', 'Adapter not connected');
222
- }
223
- let base64Data = '';
224
- const result = await this.callTool(IOSMCPAdapter.SCREENSHOT_TOOL_NAME);
225
- if (result && typeof result === 'object') {
226
- const content = result.content;
227
- if (Array.isArray(content) && content.length > 0) {
228
- const item = content[0];
229
- if (item.data) {
230
- base64Data = item.data;
231
- }
232
- }
233
- }
234
- return {
235
- base64Data,
236
- layoutData: '',
237
- width: 1080,
238
- height: 1920,
239
- isSensitive: false,
240
- screenshotPath: null,
241
- };
242
- }
243
- async reset() {
244
- if (!this.connected) {
245
- throw new common_errors_1.AgentError('DEVICE_NOT_CONNECTED', 'Adapter not connected');
246
- }
247
- try {
248
- await this.callTool(IOSMCPAdapter.PRESS_BUTTON_TOOL, { button: 'HOME' }, 30, false);
249
- }
250
- catch {
251
- // timeout not treated as failure
252
- }
253
- }
254
- async connect() {
255
- await this.ensureServiceRunning();
256
- this.mcpServerUrl = this.getDefaultServerUrl();
257
- this.connected = true;
258
- }
259
- async disconnect() {
260
- await super.disconnect();
261
- this.mcpServerUrl = null;
262
- this.closeLogStream();
263
- if (this.mcpProcess) {
264
- this.mcpProcess.kill();
265
- this.mcpProcess = null;
266
- }
267
- this.logFilePath = null;
268
- }
269
- closeLogStream() {
270
- if (this.logStream) {
271
- this.logStream.end();
272
- this.logStream = null;
273
- }
274
- }
275
- async isPortListening(host, port) {
276
- return new Promise((resolve) => {
277
- const socket = new net.Socket();
278
- socket.setTimeout(2000);
279
- socket.on('connect', () => { socket.destroy(); resolve(true); });
280
- socket.on('error', () => { socket.destroy(); resolve(false); });
281
- socket.on('timeout', () => { socket.destroy(); resolve(false); });
282
- socket.connect(port, host);
283
- });
284
- }
285
- }
286
- exports.IOSMCPAdapter = IOSMCPAdapter;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- /**
3
- * Local helper tools executed directly (not via the MCP protocol).
4
- *
5
- * Current tools:
6
- * - wait: sleep for a number of seconds
7
- * - load_skill: load skill step content from the skill manager
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.wait = wait;
11
- exports.loadSkill = loadSkill;
12
- const logger_1 = require("../../common/logger");
13
- const skill_manager_1 = require("../skill/skill_manager");
14
- /**
15
- * Wait for the given number of seconds.
16
- * @param seconds Seconds to wait (e.g. 1, 2, 5).
17
- * @returns A message confirming the wait completed.
18
- */
19
- async function wait(seconds) {
20
- await sleep(seconds);
21
- logger_1.logger.debug(`[Tool] waited ${seconds} seconds`);
22
- return `Waited ${seconds} seconds`;
23
- }
24
- /**
25
- * Load the detailed steps for a named skill.
26
- * @param skillName The skill name to load.
27
- * @returns The skill content, or a not-found message.
28
- */
29
- async function loadSkill(skillName) {
30
- const skillManager = new skill_manager_1.SkillManager();
31
- const content = skillManager.getSkillContent(skillName);
32
- if (content) {
33
- logger_1.logger.debug(`[Tool] loaded skill '${skillName}'`);
34
- return content;
35
- }
36
- logger_1.logger.warn(`[Tool] skill '${skillName}' not found`);
37
- return `Skill '${skillName}' not found, please check the skill file exists`;
38
- }
39
- function sleep(seconds) {
40
- return new Promise((resolve) => setTimeout(resolve, Math.max(0, seconds) * 1000));
41
- }