@mseep/ai-tech-app-agent 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.env +24 -0
  2. package/.env.example +24 -0
  3. package/Jenkinsfile +210 -0
  4. package/MCP-SERVER-GUIDE.md +405 -0
  5. package/README.MD +450 -0
  6. package/dist/config/app.config.d.ts +65 -0
  7. package/dist/config/app.config.d.ts.map +1 -0
  8. package/dist/config/app.config.js +94 -0
  9. package/dist/config/app.config.js.map +1 -0
  10. package/dist/config/llm.config.d.ts +63 -0
  11. package/dist/config/llm.config.d.ts.map +1 -0
  12. package/dist/config/llm.config.js +158 -0
  13. package/dist/config/llm.config.js.map +1 -0
  14. package/dist/config/mcp.config.d.ts +175 -0
  15. package/dist/config/mcp.config.d.ts.map +1 -0
  16. package/dist/config/mcp.config.js +215 -0
  17. package/dist/config/mcp.config.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +175 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/llm/llamaClient.d.ts +14 -0
  23. package/dist/llm/llamaClient.d.ts.map +1 -0
  24. package/dist/llm/llamaClient.js +136 -0
  25. package/dist/llm/llamaClient.js.map +1 -0
  26. package/dist/mcp/mcpClient.d.ts +132 -0
  27. package/dist/mcp/mcpClient.d.ts.map +1 -0
  28. package/dist/mcp/mcpClient.js +784 -0
  29. package/dist/mcp/mcpClient.js.map +1 -0
  30. package/dist/models/testSpec.d.ts +78 -0
  31. package/dist/models/testSpec.d.ts.map +1 -0
  32. package/dist/models/testSpec.js +3 -0
  33. package/dist/models/testSpec.js.map +1 -0
  34. package/dist/orchestrator/aiTestRunner.d.ts +18 -0
  35. package/dist/orchestrator/aiTestRunner.d.ts.map +1 -0
  36. package/dist/orchestrator/aiTestRunner.js +247 -0
  37. package/dist/orchestrator/aiTestRunner.js.map +1 -0
  38. package/dist/utils/logger.d.ts +4 -0
  39. package/dist/utils/logger.d.ts.map +1 -0
  40. package/dist/utils/logger.js +49 -0
  41. package/dist/utils/logger.js.map +1 -0
  42. package/dist/utils/promptBuilder.d.ts +62 -0
  43. package/dist/utils/promptBuilder.d.ts.map +1 -0
  44. package/dist/utils/promptBuilder.js +333 -0
  45. package/dist/utils/promptBuilder.js.map +1 -0
  46. package/knowledge/app-knowledge.txt +100 -0
  47. package/logs/combined.log +486 -0
  48. package/logs/error.log +50 -0
  49. package/package.json +62 -0
  50. package/reports/screenshots/screenshot_1764535110518.png +0 -0
  51. package/reports/test-report.json +106 -0
  52. package/scripts/check-mcp-server.sh +100 -0
  53. package/scripts/extract-pom-knowledge.js +222 -0
  54. package/scripts/pre-test-setup.js +262 -0
  55. package/scripts/start-mcp-server.sh +76 -0
  56. package/src/config/app.config.ts +175 -0
  57. package/src/config/llm.config.ts +220 -0
  58. package/src/config/mcp.config.ts +291 -0
  59. package/src/index.ts +161 -0
  60. package/src/llm/llamaClient.ts +159 -0
  61. package/src/mcp/mcpClient.ts +878 -0
  62. package/src/models/testSpec.ts +85 -0
  63. package/src/orchestrator/aiTestRunner.ts +286 -0
  64. package/src/utils/logger.ts +59 -0
  65. package/src/utils/promptBuilder.ts +384 -0
  66. package/tests/nlp-specs/login-flow.yaml +31 -0
  67. package/tsconfig.json +31 -0
package/README.MD ADDED
@@ -0,0 +1,450 @@
1
+ # AI-Powered Mobile Test Automation with MCP
2
+
3
+ A cutting-edge test automation solution that uses **Model Context Protocol (MCP)**, **LLM (Llama 3.2:3b)**, and **Appium** to execute mobile tests from natural language specifications.
4
+
5
+ ## 🎯 Key Features
6
+
7
+ - **Natural Language Test Specs**: Write tests in YAML/JSON using plain English
8
+ - **No Traditional Locators**: AI determines the best element selectors automatically
9
+ - **Cross-Platform**: Works on both Android and iOS
10
+ - **Non-Interactive**: Fully automated execution in CI/CD pipelines
11
+ - **Reliability-First**: Semantic UI analysis prioritized over screenshot-based recognition
12
+ - **Free & Open Source**: Uses Llama 3.2:3b running locally via Ollama
13
+
14
+ ## 🏗️ Architecture
15
+
16
+ ```
17
+ Jenkins Pipeline
18
+
19
+ AI Test Runner (Orchestrator)
20
+
21
+ ┌──┴──┐
22
+ ↓ ↓
23
+ LLM MCP Server
24
+ (Llama) (Appium)
25
+ ↓ ↓
26
+ └──┬──┘
27
+
28
+ Appium Client
29
+
30
+ LambdaTest
31
+ (Devices)
32
+ ```
33
+
34
+ ## 📋 Prerequisites
35
+
36
+ ### macOS (Development)
37
+ - macOS 12.0 or later (M4 chip recommended)
38
+ - Homebrew installed
39
+ - Xcode Command Line Tools
40
+ - Node.js 18+ and npm
41
+ - VS Code (recommended)
42
+
43
+ ### Required Tools
44
+ - Ollama (for running Llama locally)
45
+ - Appium 2.x
46
+ - Git
47
+
48
+ ## 🚀 Quick Start
49
+
50
+ ### Step 1: Clone and Setup
51
+
52
+ ```bash
53
+ # Create project directory
54
+ mkdir ai-tech-app-agent
55
+ cd ai-tech-app-agent
56
+
57
+ # Initialize project (or use the artifacts provided)
58
+ npm init -y
59
+
60
+ # Install dependencies
61
+ npm install
62
+ ```
63
+
64
+ ### Step 2: Install Ollama and Llama
65
+
66
+ ```bash
67
+ # Install Ollama
68
+ brew install ollama
69
+
70
+ # Start Ollama server (keep this running)
71
+ ollama serve
72
+
73
+ # In another terminal, pull Llama model
74
+ ollama pull llama3.2:3b
75
+
76
+ # Verify installation
77
+ ollama list
78
+ ```
79
+
80
+ ### Step 3: Install Appium
81
+
82
+ ```bash
83
+ # Install Appium globally
84
+ npm install -g appium@next
85
+
86
+ # Install required drivers
87
+ appium driver install uiautomator2 # For Android
88
+ appium driver install xcuitest # For iOS
89
+
90
+ # Verify installation
91
+ appium --version
92
+ ```
93
+
94
+ ### Step 4: Configure Environment
95
+
96
+ Create `.env` file in project root:
97
+
98
+ ```bash
99
+ # LambdaTest Configuration
100
+ LAMBDATEST_USERNAME=your_username
101
+ LAMBDATEST_ACCESS_KEY=your_access_key
102
+ LAMBDATEST_GRID_URL=https://mobile-hub.lambdatest.com/wd/hub
103
+
104
+ # Ollama/LLM Configuration
105
+ OLLAMA_BASE_URL=http://localhost:11434
106
+ LLM_MODEL=llama3.2:3b
107
+ LLM_TEMPERATURE=0.1
108
+ LLM_MAX_TOKENS=2000
109
+
110
+ # MCP Configuration
111
+ MCP_SERVER_PORT=3000
112
+ APPIUM_SERVER_URL=http://localhost:4723
113
+
114
+ # Test Configuration
115
+ DEFAULT_TIMEOUT=30000
116
+ SCREENSHOT_ON_FAILURE=true
117
+ RETRY_FAILED_STEPS=true
118
+ MAX_RETRY_ATTEMPTS=2
119
+
120
+ # Logging
121
+ LOG_LEVEL=info
122
+ LOG_DIR=./logs
123
+ ```
124
+
125
+ ### Step 5: Build the Project
126
+
127
+ ```bash
128
+ # Compile TypeScript
129
+ npm run build
130
+
131
+ # Verify build
132
+ ls -la dist/
133
+ ```
134
+
135
+ ## 📝 Writing Test Specs
136
+
137
+ Create test specifications in `tests/nlp-specs/` directory:
138
+
139
+ ### Example: Login Flow (`login-flow.yaml`)
140
+
141
+ ```yaml
142
+ name: Technician App Login Flow
143
+ description: Test the complete login flow with OTP verification
144
+ platform: both
145
+
146
+ setup:
147
+ - step: Launch the app
148
+ timeout: 10000
149
+
150
+ steps:
151
+ - step: Login with mobile number "112233445"
152
+ expectedOutcome: OTP screen should appear
153
+ timeout: 5000
154
+
155
+ - step: Enter OTP "1111"
156
+ expectedOutcome: Home screen should load
157
+ timeout: 5000
158
+
159
+ - step: Enable location access
160
+ expectedOutcome: Location permission granted
161
+ timeout: 5000
162
+
163
+ teardown:
164
+ - step: Close the app
165
+ ```
166
+
167
+ ### Example: Job Search Flow (`job-search-flow.yaml`)
168
+
169
+ ```yaml
170
+ name: Job Search and Selection Flow
171
+ platform: both
172
+
173
+ setup:
174
+ - step: Launch the app
175
+ - step: Login with mobile number "112233445"
176
+ - step: Enter OTP "1111"
177
+
178
+ steps:
179
+ - step: Navigate to jobs tab
180
+ timeout: 5000
181
+
182
+ - step: Search for jobs near current location
183
+ timeout: 8000
184
+
185
+ - step: Select the first available job
186
+ timeout: 5000
187
+
188
+ - step: Verify job details are displayed
189
+ timeout: 3000
190
+
191
+ teardown:
192
+ - step: Return to home screen
193
+ ```
194
+
195
+ ## 🎮 Running Tests
196
+
197
+ ### Local Execution
198
+
199
+ ```bash
200
+ # Run all test specs in directory
201
+ npm run test
202
+
203
+ # Run single test spec
204
+ npm run test:single
205
+
206
+ # Or use the CLI directly
207
+ node dist/index.js run tests/nlp-specs/login-flow.yaml
208
+
209
+ # Run with app knowledge file
210
+ node dist/index.js run tests/nlp-specs/ \
211
+ --knowledge knowledge/app-knowledge.txt \
212
+ --output reports/test-report.json
213
+ ```
214
+
215
+ ### Validate Test Specs
216
+
217
+ ```bash
218
+ # Validate all specs
219
+ npm run validate
220
+
221
+ # Or specific directory
222
+ node dist/index.js validate tests/nlp-specs/
223
+ ```
224
+
225
+ ### Health Check
226
+
227
+ ```bash
228
+ # Check LLM and MCP status
229
+ npm run health
230
+ ```
231
+
232
+ ## 🔧 Integration with Existing Framework
233
+
234
+ To integrate with your existing Appium framework:
235
+
236
+ ### 1. Reuse Device Capabilities
237
+
238
+ ```typescript
239
+ // In your AI test runner, import existing caps
240
+ import { deviceCapsHelper } from '../../../dmg.qa.test.technician-app-3/helpers/deviceCapsHelper';
241
+
242
+ // Use your existing LambdaTest configuration
243
+ const caps = deviceCapsHelper.getCapabilities('android', 'Pixel 7');
244
+ ```
245
+
246
+ ### 2. Leverage Page Object Knowledge
247
+
248
+ Create an app knowledge file from your existing POMs:
249
+
250
+ ```bash
251
+ # Extract element info from your POMs
252
+ node scripts/extract-pom-knowledge.js \
253
+ --input ../dmg.qa.test.technician-app-3/pages \
254
+ --output knowledge/app-knowledge.txt
255
+ ```
256
+
257
+ ### 3. Hybrid Approach
258
+
259
+ Keep your existing framework as fallback:
260
+
261
+ ```typescript
262
+ // If AI fails, fall back to traditional POM
263
+ try {
264
+ await aiRunner.executeStep(step);
265
+ } catch (error) {
266
+ logger.warn('AI execution failed, using traditional POM');
267
+ await traditionalPomExecution(step);
268
+ }
269
+ ```
270
+
271
+ ## 📊 CI/CD Integration (Jenkins)
272
+
273
+ ### Prerequisites
274
+
275
+ 1. Create Kubernetes secrets for LambdaTest:
276
+
277
+ ```bash
278
+ kubectl create secret generic lambdatest-creds \
279
+ --from-literal=username=YOUR_USERNAME \
280
+ --from-literal=accessKey=YOUR_ACCESS_KEY
281
+ ```
282
+
283
+ 2. Deploy Ollama service in your cluster (optional):
284
+
285
+ ```yaml
286
+ apiVersion: v1
287
+ kind: Service
288
+ metadata:
289
+ name: ollama-service
290
+ spec:
291
+ ports:
292
+ - port: 11434
293
+ selector:
294
+ app: ollama
295
+ ```
296
+
297
+ ### Jenkins Pipeline
298
+
299
+ Use the provided `Jenkinsfile` which includes:
300
+ - Automatic pod provisioning with Node.js and Ollama
301
+ - Repository cloning
302
+ - Model downloading
303
+ - Test execution
304
+ - Report generation
305
+
306
+ ### Trigger Build
307
+
308
+ ```bash
309
+ # Via Jenkins UI or CLI
310
+ curl -X POST http://jenkins-url/job/ai-test-automation/build
311
+
312
+ # Or via webhook
313
+ git push origin main # If configured with GitHub webhook
314
+ ```
315
+
316
+ ## 📈 Understanding Test Results
317
+
318
+ Test reports are generated in JSON format:
319
+
320
+ ```json
321
+ {
322
+ "timestamp": "2025-01-15T10:30:00Z",
323
+ "summary": {
324
+ "total": 5,
325
+ "passed": 4,
326
+ "failed": 1,
327
+ "skipped": 0
328
+ },
329
+ "results": [
330
+ {
331
+ "specName": "Login Flow",
332
+ "status": "passed",
333
+ "duration": 45000,
334
+ "steps": [...]
335
+ }
336
+ ]
337
+ }
338
+ ```
339
+
340
+ ## 🐛 Troubleshooting
341
+
342
+ ### LLM Not Responding
343
+
344
+ ```bash
345
+ # Check if Ollama is running
346
+ ps aux | grep ollama
347
+
348
+ # Restart Ollama
349
+ pkill ollama
350
+ ollama serve
351
+
352
+ # Verify model
353
+ ollama list
354
+ ollama run llama3.2:3b "Hello"
355
+ ```
356
+
357
+ ### MCP Connection Issues
358
+
359
+ ```bash
360
+ # Check Appium is running
361
+ appium --version
362
+
363
+ # Start Appium manually
364
+ appium --allow-cors --log-level info
365
+
366
+ # Check MCP-Appium installation
367
+ npm list mcp-appium
368
+ ```
369
+
370
+ ### Test Execution Failures
371
+
372
+ ```bash
373
+ # Enable debug logging
374
+ export LOG_LEVEL=debug
375
+
376
+ # Check logs
377
+ tail -f logs/combined.log
378
+
379
+ # Verify device connectivity (LambdaTest)
380
+ curl -u "$LAMBDATEST_USERNAME:$LAMBDATEST_ACCESS_KEY" \
381
+ https://mobile-api.lambdatest.com/mobile-automation/api/v1/devices
382
+ ```
383
+
384
+ ### Actions Not Executing
385
+
386
+ 1. **Check UI Context**: Ensure page source is being captured correctly
387
+ 2. **Verify Selectors**: LLM-generated selectors might need tuning
388
+ 3. **Add App Knowledge**: Provide more context about your app's UI patterns
389
+ 4. **Increase Timeout**: Some actions might need more time
390
+ 5. **Check Element Visibility**: Elements might not be immediately available
391
+
392
+ ## 📚 Advanced Topics
393
+
394
+ ### Custom Action Types
395
+
396
+ Extend the action executor to support custom actions:
397
+
398
+ ```typescript
399
+ // In mcpClient.ts
400
+ async executeCustomAction(action: CustomAction): Promise<boolean> {
401
+ // Your custom logic
402
+ }
403
+ ```
404
+
405
+ ### Fine-tuning Prompts
406
+
407
+ Modify prompt templates in `llamaClient.ts` for better accuracy:
408
+
409
+ ```typescript
410
+ private buildPrompt(stepText: string, uiContext: string): string {
411
+ return `Enhanced prompt with more specific instructions...`;
412
+ }
413
+ ```
414
+
415
+ ### Screenshot-Based Recognition
416
+
417
+ For complex scenarios, enable screenshot analysis:
418
+
419
+ ```typescript
420
+ const uiContext = await mcpClient.getUIContext({
421
+ includeScreenshot: true,
422
+ screenshotAnalysis: 'vision-model'
423
+ });
424
+ ```
425
+
426
+ ## 🤝 Contributing
427
+
428
+ Contributions are welcome! Areas for improvement:
429
+
430
+ 1. Better XML parsing for UI elements
431
+ 2. Enhanced error recovery mechanisms
432
+ 3. Support for more complex gestures
433
+ 4. Integration with other LLM providers
434
+ 5. Performance optimizations
435
+
436
+ ## 📄 License
437
+
438
+ MIT License - feel free to use and modify
439
+
440
+ ## 🙋 Support
441
+
442
+ For issues and questions:
443
+ 1. Check the troubleshooting section
444
+ 2. Review logs in `logs/` directory
445
+ 3. Open an issue on GitHub
446
+ 4. Contact the team
447
+
448
+ ---
449
+
450
+ **Note**: This solution prioritizes reliability and maintainability over execution speed. Tests may run slightly slower than traditional scripts initially but provide significantly better maintainability and reduced flakiness.
@@ -0,0 +1,65 @@
1
+ export interface AppConfig {
2
+ env: string;
3
+ name: string;
4
+ version: string;
5
+ paths: {
6
+ root: string;
7
+ logs: string;
8
+ reports: string;
9
+ screenshots: string;
10
+ testSpecs: string;
11
+ knowledge: string;
12
+ };
13
+ execution: {
14
+ defaultTimeout: number;
15
+ maxRetryAttempts: number;
16
+ retryFailedSteps: boolean;
17
+ screenshotOnFailure: boolean;
18
+ continueOnFailure: boolean;
19
+ parallelExecution: boolean;
20
+ maxParallelTests: number;
21
+ };
22
+ interaction: {
23
+ implicitWait: number;
24
+ explicitWait: number;
25
+ actionDelay: number;
26
+ tapDuration: number;
27
+ swipeSpeed: number;
28
+ scrollPercentage: number;
29
+ };
30
+ reporting: {
31
+ format: 'json' | 'html' | 'allure';
32
+ includeScreenshots: boolean;
33
+ includeStepDetails: boolean;
34
+ includeTimestamps: boolean;
35
+ verboseLogging: boolean;
36
+ };
37
+ lambdatest: {
38
+ username: string;
39
+ accessKey: string;
40
+ gridUrl: string;
41
+ tunnel: boolean;
42
+ tunnelName?: string;
43
+ buildName: string;
44
+ projectName: string;
45
+ tags: string[];
46
+ network: boolean;
47
+ video: boolean;
48
+ console: boolean;
49
+ visual: boolean;
50
+ };
51
+ devices: {
52
+ android: {
53
+ defaultVersion: string;
54
+ defaultDevice: string;
55
+ };
56
+ ios: {
57
+ defaultVersion: string;
58
+ defaultDevice: string;
59
+ };
60
+ };
61
+ }
62
+ declare const appConfig: AppConfig;
63
+ export declare function validateAppConfig(): void;
64
+ export default appConfig;
65
+ //# sourceMappingURL=app.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.config.d.ts","sourceRoot":"","sources":["../../src/config/app.config.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAGhB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAGF,SAAS,EAAE;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;QAC7B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IAGF,WAAW,EAAE;QACX,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IAGF,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;QACnC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IAGF,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IAGF,OAAO,EAAE;QACP,OAAO,EAAE;YACP,cAAc,EAAE,MAAM,CAAC;YACvB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,GAAG,EAAE;YACH,cAAc,EAAE,MAAM,CAAC;YACvB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;CACH;AAED,QAAA,MAAM,SAAS,EAAE,SAkEhB,CAAC;AAGF,wBAAgB,iBAAiB,IAAI,IAAI,CAwBxC;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateAppConfig = validateAppConfig;
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ const path_1 = __importDefault(require("path"));
9
+ dotenv_1.default.config();
10
+ const appConfig = {
11
+ env: process.env.NODE_ENV || 'development',
12
+ name: process.env.APP_NAME || 'ai-tech-app-agent',
13
+ version: process.env.APP_VERSION || '1.0.0',
14
+ paths: {
15
+ root: process.cwd(),
16
+ logs: path_1.default.resolve(process.cwd(), process.env.LOG_DIR || './logs'),
17
+ reports: path_1.default.resolve(process.cwd(), process.env.REPORT_DIR || './reports'),
18
+ screenshots: path_1.default.resolve(process.cwd(), process.env.SCREENSHOT_DIR || './reports/screenshots'),
19
+ testSpecs: path_1.default.resolve(process.cwd(), process.env.TEST_SPEC_DIR || './tests/nlp-specs'),
20
+ knowledge: path_1.default.resolve(process.cwd(), process.env.KNOWLEDGE_DIR || './knowledge'),
21
+ },
22
+ execution: {
23
+ defaultTimeout: parseInt(process.env.DEFAULT_TIMEOUT || '30000'),
24
+ maxRetryAttempts: parseInt(process.env.MAX_RETRY_ATTEMPTS || '2'),
25
+ retryFailedSteps: process.env.RETRY_FAILED_STEPS === 'true',
26
+ screenshotOnFailure: process.env.SCREENSHOT_ON_FAILURE !== 'false',
27
+ continueOnFailure: process.env.CONTINUE_ON_FAILURE === 'true',
28
+ parallelExecution: process.env.PARALLEL_EXECUTION === 'true',
29
+ maxParallelTests: parseInt(process.env.MAX_PARALLEL_TESTS || '3'),
30
+ },
31
+ interaction: {
32
+ implicitWait: parseInt(process.env.IMPLICIT_WAIT || '5000'),
33
+ explicitWait: parseInt(process.env.EXPLICIT_WAIT || '10000'),
34
+ actionDelay: parseInt(process.env.ACTION_DELAY || '500'),
35
+ tapDuration: parseInt(process.env.TAP_DURATION || '100'),
36
+ swipeSpeed: parseInt(process.env.SWIPE_SPEED || '1000'),
37
+ scrollPercentage: parseFloat(process.env.SCROLL_PERCENTAGE || '0.75'),
38
+ },
39
+ reporting: {
40
+ format: process.env.REPORT_FORMAT || 'json',
41
+ includeScreenshots: process.env.INCLUDE_SCREENSHOTS !== 'false',
42
+ includeStepDetails: process.env.INCLUDE_STEP_DETAILS !== 'false',
43
+ includeTimestamps: process.env.INCLUDE_TIMESTAMPS !== 'false',
44
+ verboseLogging: process.env.VERBOSE_LOGGING === 'true',
45
+ },
46
+ lambdatest: {
47
+ username: process.env.LAMBDATEST_USERNAME || '',
48
+ accessKey: process.env.LAMBDATEST_ACCESS_KEY || '',
49
+ gridUrl: process.env.LAMBDATEST_GRID_URL || 'https://mobile-hub.lambdatest.com/wd/hub',
50
+ tunnel: process.env.LAMBDATEST_TUNNEL === 'true',
51
+ tunnelName: process.env.LAMBDATEST_TUNNEL_NAME,
52
+ buildName: process.env.LAMBDATEST_BUILD_NAME || `AI-Test-Build`,
53
+ projectName: process.env.LAMBDATEST_PROJECT_NAME || 'AI Mobile Test Automation',
54
+ tags: (process.env.LAMBDATEST_TAGS || 'ai,mcp,automation').split(','),
55
+ network: process.env.LAMBDATEST_NETWORK !== 'false',
56
+ video: process.env.LAMBDATEST_VIDEO !== 'false',
57
+ console: process.env.LAMBDATEST_CONSOLE !== 'false',
58
+ visual: process.env.LAMBDATEST_VISUAL !== 'false',
59
+ },
60
+ devices: {
61
+ android: {
62
+ defaultVersion: process.env.ANDROID_DEFAULT_VERSION || '13',
63
+ defaultDevice: process.env.ANDROID_DEFAULT_DEVICE || 'Pixel 7',
64
+ },
65
+ ios: {
66
+ defaultVersion: process.env.IOS_DEFAULT_VERSION || '16',
67
+ defaultDevice: process.env.IOS_DEFAULT_DEVICE || 'iPhone 14',
68
+ },
69
+ },
70
+ };
71
+ // Validation
72
+ function validateAppConfig() {
73
+ const errors = [];
74
+ // Check required LambdaTest credentials
75
+ if (!appConfig.lambdatest.username) {
76
+ errors.push('LAMBDATEST_USERNAME is required');
77
+ }
78
+ if (!appConfig.lambdatest.accessKey) {
79
+ errors.push('LAMBDATEST_ACCESS_KEY is required');
80
+ }
81
+ // Validate timeout values
82
+ if (appConfig.execution.defaultTimeout < 1000) {
83
+ errors.push('DEFAULT_TIMEOUT must be at least 1000ms');
84
+ }
85
+ // Validate retry attempts
86
+ if (appConfig.execution.maxRetryAttempts < 0 || appConfig.execution.maxRetryAttempts > 5) {
87
+ errors.push('MAX_RETRY_ATTEMPTS must be between 0 and 5');
88
+ }
89
+ if (errors.length > 0) {
90
+ throw new Error(`App configuration validation failed:\n${errors.join('\n')}`);
91
+ }
92
+ }
93
+ exports.default = appConfig;
94
+ //# sourceMappingURL=app.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.config.js","sourceRoot":"","sources":["../../src/config/app.config.ts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CAAiC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;IAED,0BAA0B;IAC1B,IAAI,SAAS,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;IACzD,CAAC;IAED,0BAA0B;IAC1B,IAAI,SAAS,CAAC,SAAS,CAAC,gBAAgB,GAAG,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,gBAAgB,GAAG,CAAC,EAAE,CAAC;QACzF,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,63 @@
1
+ export interface LLMConfig {
2
+ provider: 'ollama' | 'openai' | 'anthropic' | 'custom';
3
+ connection: {
4
+ baseUrl: string;
5
+ timeout: number;
6
+ retryAttempts: number;
7
+ retryDelay: number;
8
+ };
9
+ model: {
10
+ name: string;
11
+ temperature: number;
12
+ maxTokens: number;
13
+ topP: number;
14
+ topK: number;
15
+ frequencyPenalty: number;
16
+ presencePenalty: number;
17
+ };
18
+ prompt: {
19
+ systemMessage: string;
20
+ includeAppContext: boolean;
21
+ includeUIContext: boolean;
22
+ maxUIElements: number;
23
+ maxContextTokens: number;
24
+ includeReasoningInResponse: boolean;
25
+ strictJsonMode: boolean;
26
+ };
27
+ performance: {
28
+ cachingEnabled: boolean;
29
+ cacheTTL: number;
30
+ batchRequests: boolean;
31
+ maxBatchSize: number;
32
+ streamResponse: boolean;
33
+ };
34
+ fallback: {
35
+ enabled: boolean;
36
+ fallbackModel?: string;
37
+ maxFallbackAttempts: number;
38
+ };
39
+ }
40
+ declare const llmConfig: LLMConfig;
41
+ export declare const PromptTemplates: {
42
+ actionPlanning: string;
43
+ contextAnalysis: string;
44
+ errorRecovery: string;
45
+ assertionGeneration: string;
46
+ };
47
+ export declare function getPromptTemplate(type: keyof typeof PromptTemplates): string;
48
+ export declare function validateLLMConfig(): void;
49
+ export declare function getProviderConfig(provider: string): {
50
+ endpoint: string;
51
+ healthEndpoint: string;
52
+ format: string;
53
+ } | {
54
+ endpoint: string;
55
+ healthEndpoint: string;
56
+ format: string;
57
+ } | {
58
+ endpoint: string;
59
+ healthEndpoint: string;
60
+ format: string;
61
+ };
62
+ export default llmConfig;
63
+ //# sourceMappingURL=llm.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.config.d.ts","sourceRoot":"","sources":["../../src/config/llm.config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IAGvD,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAGF,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB,EAAE,MAAM,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IAGF,MAAM,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,OAAO,CAAC;QAC3B,gBAAgB,EAAE,OAAO,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC;QACtB,gBAA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