testdriverai 7.2.24 → 7.2.25
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.
- package/agent/lib/commander.js +6 -5
- package/package.json +1 -1
- package/sdk-log-formatter.js +8 -8
- package/sdk.js +22 -22
package/agent/lib/commander.js
CHANGED
|
@@ -109,11 +109,12 @@ commands:
|
|
|
109
109
|
break;
|
|
110
110
|
case "hover-text":
|
|
111
111
|
emitter.emit(events.log.log, generator.jsonToManual(object));
|
|
112
|
-
response = await commands["hover-text"](
|
|
113
|
-
object.
|
|
114
|
-
object.
|
|
115
|
-
object.
|
|
116
|
-
|
|
112
|
+
response = await commands["hover-text"]({
|
|
113
|
+
text: object.text,
|
|
114
|
+
description: object.description,
|
|
115
|
+
action: object.action,
|
|
116
|
+
timeout: object.timeout,
|
|
117
|
+
});
|
|
117
118
|
break;
|
|
118
119
|
case "hover-image":
|
|
119
120
|
emitter.emit(events.log.log, generator.jsonToManual(object));
|
package/package.json
CHANGED
package/sdk-log-formatter.js
CHANGED
|
@@ -880,27 +880,27 @@ class SDKLogFormatter {
|
|
|
880
880
|
}
|
|
881
881
|
|
|
882
882
|
/**
|
|
883
|
-
* Format
|
|
883
|
+
* Format ai() start message - provides visual scope boundary
|
|
884
884
|
* @param {string} task - The task being executed
|
|
885
|
-
* @returns {string} Formatted
|
|
885
|
+
* @returns {string} Formatted ai start message
|
|
886
886
|
*/
|
|
887
|
-
|
|
887
|
+
formatAIStart(task) {
|
|
888
888
|
const parts = [];
|
|
889
889
|
this.addTimestamp(parts);
|
|
890
890
|
parts.push(this.getPrefix("action"));
|
|
891
|
-
parts.push(chalk.bold.cyan("
|
|
891
|
+
parts.push(chalk.bold.cyan("AI"));
|
|
892
892
|
parts.push(chalk.cyan(`"${task}"`));
|
|
893
893
|
return parts.join(" ");
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
/**
|
|
897
|
-
* Format
|
|
897
|
+
* Format ai() completion message - provides visual scope boundary
|
|
898
898
|
* @param {number} durationMs - Duration in milliseconds
|
|
899
|
-
* @param {boolean} success - Whether the
|
|
899
|
+
* @param {boolean} success - Whether the ai completed successfully
|
|
900
900
|
* @param {string} [error] - Error message if failed
|
|
901
|
-
* @returns {string} Formatted
|
|
901
|
+
* @returns {string} Formatted ai complete message
|
|
902
902
|
*/
|
|
903
|
-
|
|
903
|
+
formatAIComplete(durationMs, success, error = null) {
|
|
904
904
|
const parts = [];
|
|
905
905
|
this.addTimestamp(parts);
|
|
906
906
|
parts.push(this.getResultPrefix());
|
package/sdk.js
CHANGED
|
@@ -264,10 +264,10 @@ class ElementNotFoundError extends Error {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
|
-
* Custom error class for
|
|
267
|
+
* Custom error class for ai() failures
|
|
268
268
|
* Includes task execution details and retry information
|
|
269
269
|
*/
|
|
270
|
-
class
|
|
270
|
+
class AIError extends Error {
|
|
271
271
|
/**
|
|
272
272
|
* @param {string} message - Error message
|
|
273
273
|
* @param {Object} details - Additional details about the failure
|
|
@@ -279,7 +279,7 @@ class ActError extends Error {
|
|
|
279
279
|
*/
|
|
280
280
|
constructor(message, details = {}) {
|
|
281
281
|
super(message);
|
|
282
|
-
this.name = "
|
|
282
|
+
this.name = "AIError";
|
|
283
283
|
this.task = details.task;
|
|
284
284
|
this.tries = details.tries;
|
|
285
285
|
this.maxTries = details.maxTries;
|
|
@@ -289,11 +289,11 @@ class ActError extends Error {
|
|
|
289
289
|
|
|
290
290
|
// Capture stack trace
|
|
291
291
|
if (Error.captureStackTrace) {
|
|
292
|
-
Error.captureStackTrace(this,
|
|
292
|
+
Error.captureStackTrace(this, AIError);
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
// Enhance error message with execution details
|
|
296
|
-
this.message += `\n\n===
|
|
296
|
+
this.message += `\n\n=== AI Execution Details ===`;
|
|
297
297
|
this.message += `\nTask: "${this.task}"`;
|
|
298
298
|
this.message += `\nTries: ${this.tries}/${this.maxTries}`;
|
|
299
299
|
this.message += `\nDuration: ${this.duration}ms`;
|
|
@@ -1397,7 +1397,7 @@ class TestDriverSDK {
|
|
|
1397
1397
|
? `New-Item -ItemType File -Path "${logPath}" -Force | Out-Null`
|
|
1398
1398
|
: `touch ${logPath}`;
|
|
1399
1399
|
|
|
1400
|
-
await this.exec(shell, createLogCmd,
|
|
1400
|
+
await this.exec(shell, createLogCmd, 60000, true);
|
|
1401
1401
|
|
|
1402
1402
|
const urlObj = new URL(url);
|
|
1403
1403
|
const domain = urlObj.hostname;
|
|
@@ -1428,7 +1428,7 @@ class TestDriverSDK {
|
|
|
1428
1428
|
? `New-Item -ItemType Directory -Path "${defaultProfileDir}" -Force | Out-Null`
|
|
1429
1429
|
: `mkdir -p "${defaultProfileDir}"`;
|
|
1430
1430
|
|
|
1431
|
-
await this.exec(shell, createDirCmd,
|
|
1431
|
+
await this.exec(shell, createDirCmd, 60000, true);
|
|
1432
1432
|
|
|
1433
1433
|
// Write Chrome preferences
|
|
1434
1434
|
const chromePrefs = {
|
|
@@ -1465,7 +1465,7 @@ class TestDriverSDK {
|
|
|
1465
1465
|
? `[System.IO.File]::WriteAllText("${prefsPath}", '${JSON.stringify(chromePrefs).replace(/'/g, "''")}')`
|
|
1466
1466
|
: `cat > "${prefsPath}" << 'EOF'\n${prefsJson}\nEOF`;
|
|
1467
1467
|
|
|
1468
|
-
await this.exec(shell, writePrefCmd,
|
|
1468
|
+
await this.exec(shell, writePrefCmd, 60000, true);
|
|
1469
1469
|
|
|
1470
1470
|
// Build Chrome launch command
|
|
1471
1471
|
const chromeArgs = [];
|
|
@@ -1569,7 +1569,7 @@ class TestDriverSDK {
|
|
|
1569
1569
|
const mkdirCmd = this.os === 'windows'
|
|
1570
1570
|
? `New-Item -ItemType Directory -Path "${extensionDir}" -Force | Out-Null`
|
|
1571
1571
|
: `mkdir -p "${extensionDir}"`;
|
|
1572
|
-
await this.exec(shell, mkdirCmd,
|
|
1572
|
+
await this.exec(shell, mkdirCmd, 60000, true);
|
|
1573
1573
|
|
|
1574
1574
|
// Download CRX from Chrome Web Store
|
|
1575
1575
|
// The CRX download URL format for Chrome Web Store
|
|
@@ -1675,7 +1675,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
1675
1675
|
? `New-Item -ItemType File -Path "${logPath}" -Force | Out-Null`
|
|
1676
1676
|
: `touch ${logPath}`;
|
|
1677
1677
|
|
|
1678
|
-
await this.exec(shell, createLogCmd,
|
|
1678
|
+
await this.exec(shell, createLogCmd, 60000, true);
|
|
1679
1679
|
await this._dashcam.addFileLog(logPath, "TestDriver Log");
|
|
1680
1680
|
}
|
|
1681
1681
|
|
|
@@ -1698,7 +1698,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
1698
1698
|
? `New-Item -ItemType Directory -Path "${defaultProfileDir}" -Force | Out-Null`
|
|
1699
1699
|
: `mkdir -p "${defaultProfileDir}"`;
|
|
1700
1700
|
|
|
1701
|
-
await this.exec(shell, createDirCmd,
|
|
1701
|
+
await this.exec(shell, createDirCmd, 60000, true);
|
|
1702
1702
|
|
|
1703
1703
|
// Write Chrome preferences
|
|
1704
1704
|
const chromePrefs = {
|
|
@@ -1735,7 +1735,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
1735
1735
|
? `[System.IO.File]::WriteAllText("${prefsPath}", '${JSON.stringify(chromePrefs).replace(/'/g, "''")}')`
|
|
1736
1736
|
: `cat > "${prefsPath}" << 'EOF'\n${prefsJson}\nEOF`;
|
|
1737
1737
|
|
|
1738
|
-
await this.exec(shell, writePrefCmd,
|
|
1738
|
+
await this.exec(shell, writePrefCmd, 60000, true);
|
|
1739
1739
|
|
|
1740
1740
|
// Build Chrome launch command
|
|
1741
1741
|
const chromeArgs = [];
|
|
@@ -1814,7 +1814,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
1814
1814
|
? `New-Item -ItemType File -Path "${logPath}" -Force | Out-Null`
|
|
1815
1815
|
: `touch ${logPath}`;
|
|
1816
1816
|
|
|
1817
|
-
await this.exec(shell, createLogCmd,
|
|
1817
|
+
await this.exec(shell, createLogCmd, 60000, true);
|
|
1818
1818
|
await this._dashcam.addFileLog(logPath, "TestDriver Log");
|
|
1819
1819
|
}
|
|
1820
1820
|
|
|
@@ -1909,7 +1909,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
1909
1909
|
? `New-Item -ItemType File -Path "${logPath}" -Force | Out-Null`
|
|
1910
1910
|
: `touch ${logPath}`;
|
|
1911
1911
|
|
|
1912
|
-
await this.exec(shell, createLogCmd,
|
|
1912
|
+
await this.exec(shell, createLogCmd, 60000, true);
|
|
1913
1913
|
await this._dashcam.addFileLog(logPath, "TestDriver Log");
|
|
1914
1914
|
}
|
|
1915
1915
|
|
|
@@ -3250,7 +3250,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
3250
3250
|
* @param {Object} [options] - Execution options
|
|
3251
3251
|
* @param {number} [options.tries=7] - Maximum number of check/retry attempts before giving up
|
|
3252
3252
|
* @returns {Promise<ActResult>} Result object with success status and details
|
|
3253
|
-
* @throws {
|
|
3253
|
+
* @throws {AIError} When the task fails after all tries are exhausted
|
|
3254
3254
|
*
|
|
3255
3255
|
* @typedef {Object} ActResult
|
|
3256
3256
|
* @property {boolean} success - Whether the task completed successfully
|
|
@@ -3296,8 +3296,8 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
3296
3296
|
const originalCheckCount = this.agent.checkCount;
|
|
3297
3297
|
this.agent.checkCount = 0;
|
|
3298
3298
|
|
|
3299
|
-
// Emit scoped start marker for
|
|
3300
|
-
this.emitter.emit(events.log.log, formatter.
|
|
3299
|
+
// Emit scoped start marker for ai()
|
|
3300
|
+
this.emitter.emit(events.log.log, formatter.formatAIStart(task));
|
|
3301
3301
|
|
|
3302
3302
|
try {
|
|
3303
3303
|
// Use the agent's exploratoryLoop method directly
|
|
@@ -3306,7 +3306,7 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
3306
3306
|
const duration = Date.now() - startTime;
|
|
3307
3307
|
const triesUsed = this.agent.checkCount;
|
|
3308
3308
|
|
|
3309
|
-
this.emitter.emit(events.log.log, formatter.
|
|
3309
|
+
this.emitter.emit(events.log.log, formatter.formatAIComplete(duration, true));
|
|
3310
3310
|
|
|
3311
3311
|
// Restore original checkLimit
|
|
3312
3312
|
this.agent.checkLimit = originalCheckLimit;
|
|
@@ -3324,14 +3324,14 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
3324
3324
|
const duration = Date.now() - startTime;
|
|
3325
3325
|
const triesUsed = this.agent.checkCount;
|
|
3326
3326
|
|
|
3327
|
-
this.emitter.emit(events.log.log, formatter.
|
|
3327
|
+
this.emitter.emit(events.log.log, formatter.formatAIComplete(duration, false, error.message));
|
|
3328
3328
|
|
|
3329
3329
|
// Restore original checkLimit
|
|
3330
3330
|
this.agent.checkLimit = originalCheckLimit;
|
|
3331
3331
|
this.agent.checkCount = originalCheckCount;
|
|
3332
3332
|
|
|
3333
|
-
// Create an enhanced error with additional context using
|
|
3334
|
-
throw new
|
|
3333
|
+
// Create an enhanced error with additional context using AIError class
|
|
3334
|
+
throw new AIError(`AI failed: ${error.message}`, {
|
|
3335
3335
|
task,
|
|
3336
3336
|
tries: triesUsed,
|
|
3337
3337
|
maxTries: tries,
|
|
@@ -3358,4 +3358,4 @@ with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
|
|
3358
3358
|
module.exports = TestDriverSDK;
|
|
3359
3359
|
module.exports.Element = Element;
|
|
3360
3360
|
module.exports.ElementNotFoundError = ElementNotFoundError;
|
|
3361
|
-
module.exports.
|
|
3361
|
+
module.exports.AIError = AIError;
|