@loadmill/droid-cua 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 (34) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +227 -0
  3. package/bin/droid-cua +6 -0
  4. package/build/index.js +58 -0
  5. package/build/src/cli/app.js +115 -0
  6. package/build/src/cli/command-parser.js +57 -0
  7. package/build/src/cli/components/AgentStatus.js +21 -0
  8. package/build/src/cli/components/CommandSuggestions.js +33 -0
  9. package/build/src/cli/components/InputPanel.js +21 -0
  10. package/build/src/cli/components/OutputPanel.js +58 -0
  11. package/build/src/cli/components/StatusBar.js +22 -0
  12. package/build/src/cli/ink-shell.js +56 -0
  13. package/build/src/commands/create.js +42 -0
  14. package/build/src/commands/edit.js +61 -0
  15. package/build/src/commands/exit.js +20 -0
  16. package/build/src/commands/help.js +34 -0
  17. package/build/src/commands/index.js +49 -0
  18. package/build/src/commands/list.js +55 -0
  19. package/build/src/commands/run.js +112 -0
  20. package/build/src/commands/stop.js +32 -0
  21. package/build/src/commands/view.js +43 -0
  22. package/build/src/core/execution-engine.js +114 -0
  23. package/build/src/core/prompts.js +158 -0
  24. package/build/src/core/session.js +57 -0
  25. package/build/src/device/actions.js +81 -0
  26. package/build/src/device/assertions.js +75 -0
  27. package/build/src/device/connection.js +123 -0
  28. package/build/src/device/openai.js +124 -0
  29. package/build/src/modes/design-mode-ink.js +396 -0
  30. package/build/src/modes/design-mode.js +366 -0
  31. package/build/src/modes/execution-mode.js +165 -0
  32. package/build/src/test-store/test-manager.js +92 -0
  33. package/build/src/utils/logger.js +86 -0
  34. package/package.json +68 -0
@@ -0,0 +1,86 @@
1
+ import { appendFileSync, writeFileSync } from 'fs';
2
+ import { mkdir } from 'fs/promises';
3
+ import path from 'path';
4
+ /**
5
+ * Simple logger that writes to a file when debug mode is enabled
6
+ */
7
+ class Logger {
8
+ constructor() {
9
+ this.debugMode = false;
10
+ this.logFile = null;
11
+ }
12
+ /**
13
+ * Initialize debug logging to a file
14
+ * @param {boolean} enabled - Whether debug logging is enabled
15
+ */
16
+ async init(enabled = false) {
17
+ this.debugMode = enabled;
18
+ if (enabled) {
19
+ const logsDir = path.join(process.cwd(), 'logs');
20
+ await mkdir(logsDir, { recursive: true });
21
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
22
+ this.logFile = path.join(logsDir, `debug-${timestamp}.log`);
23
+ // Create/clear the log file
24
+ writeFileSync(this.logFile, `Debug log started at ${new Date().toISOString()}\n\n`);
25
+ console.log(`Debug logging enabled: ${this.logFile}`);
26
+ }
27
+ }
28
+ /**
29
+ * Log a debug message
30
+ * @param {string} message - The message to log
31
+ * @param {*} data - Optional data to log (will be JSON stringified)
32
+ */
33
+ debug(message, data = null) {
34
+ if (!this.debugMode || !this.logFile)
35
+ return;
36
+ const timestamp = new Date().toISOString();
37
+ let logEntry = `[${timestamp}] ${message}\n`;
38
+ if (data !== null) {
39
+ if (typeof data === 'object') {
40
+ logEntry += JSON.stringify(data, null, 2) + '\n';
41
+ }
42
+ else {
43
+ logEntry += String(data) + '\n';
44
+ }
45
+ }
46
+ logEntry += '\n';
47
+ try {
48
+ appendFileSync(this.logFile, logEntry);
49
+ }
50
+ catch (err) {
51
+ console.error('Failed to write to log file:', err.message);
52
+ }
53
+ }
54
+ /**
55
+ * Log an error
56
+ * @param {string} message - The error message
57
+ * @param {Error|*} error - The error object or data
58
+ */
59
+ error(message, error = null) {
60
+ if (!this.debugMode || !this.logFile)
61
+ return;
62
+ const timestamp = new Date().toISOString();
63
+ let logEntry = `[${timestamp}] ERROR: ${message}\n`;
64
+ if (error) {
65
+ if (error instanceof Error) {
66
+ logEntry += ` Message: ${error.message}\n`;
67
+ logEntry += ` Stack: ${error.stack}\n`;
68
+ }
69
+ else if (typeof error === 'object') {
70
+ logEntry += JSON.stringify(error, null, 2) + '\n';
71
+ }
72
+ else {
73
+ logEntry += String(error) + '\n';
74
+ }
75
+ }
76
+ logEntry += '\n';
77
+ try {
78
+ appendFileSync(this.logFile, logEntry);
79
+ }
80
+ catch (err) {
81
+ console.error('Failed to write to log file:', err.message);
82
+ }
83
+ }
84
+ }
85
+ // Global singleton instance
86
+ export const logger = new Logger();
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@loadmill/droid-cua",
3
+ "version": "1.0.0",
4
+ "description": "AI-powered Android testing agent using OpenAI's computer-use model and ADB",
5
+ "main": "build/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "droid-cua": "bin/droid-cua"
9
+ },
10
+ "files": [
11
+ "build/**/*",
12
+ "bin/**/*",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "start": "tsx index.js",
18
+ "build": "tsc",
19
+ "clean": "rm -rf build",
20
+ "prerelease": "npm run build",
21
+ "release:patch": "npm version patch && npm publish",
22
+ "postversion": "git push && git push --tags"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/loadmill/droid-cua.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/loadmill/droid-cua/issues"
30
+ },
31
+ "homepage": "https://github.com/loadmill/droid-cua",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "keywords": [
36
+ "openai",
37
+ "adb",
38
+ "android",
39
+ "automation",
40
+ "testing",
41
+ "ai",
42
+ "emulator",
43
+ "agent",
44
+ "cua",
45
+ "computer-use",
46
+ "mobile-testing",
47
+ "e2e"
48
+ ],
49
+ "author": "Loadmill",
50
+ "license": "UNLICENSED",
51
+ "dependencies": {
52
+ "dotenv": "^16.4.7",
53
+ "ink": "^4.4.1",
54
+ "ink-spinner": "^5.0.0",
55
+ "ink-text-input": "^5.0.1",
56
+ "minimist": "^1.2.8",
57
+ "openai": "^4.87.3",
58
+ "react": "^18.3.1",
59
+ "sharp": "^0.34.1"
60
+ },
61
+ "devDependencies": {
62
+ "tsx": "^4.21.0",
63
+ "typescript": "^5.7.3"
64
+ },
65
+ "engines": {
66
+ "node": ">=18.17.0"
67
+ }
68
+ }