testdriverai 5.5.9 → 5.6.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.
- package/lib/commands.js +9 -12
- package/lib/parser.js +9 -11
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -434,6 +434,7 @@ let commands = {
|
|
|
434
434
|
// press keys
|
|
435
435
|
// different than `type`, becasue it can press multiple keys at once
|
|
436
436
|
"press-keys": async (inputKeys) => {
|
|
437
|
+
|
|
437
438
|
await redraw.start();
|
|
438
439
|
|
|
439
440
|
// robotjs is finiky with key-up on modifier keys
|
|
@@ -458,14 +459,6 @@ let commands = {
|
|
|
458
459
|
}
|
|
459
460
|
});
|
|
460
461
|
|
|
461
|
-
// make sure all keys are valid
|
|
462
|
-
keysPressed.forEach((key) => {
|
|
463
|
-
if (keymap[key] === undefined) {
|
|
464
|
-
logger.error(`Key not found: ${key}`);
|
|
465
|
-
throw new AiError(`Key not found: ${key}`);
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
|
|
469
462
|
// only one key can be pressed at a time
|
|
470
463
|
if (!config.TD_VM && keysPressed.length > 1) {
|
|
471
464
|
throw new AiError(
|
|
@@ -477,14 +470,18 @@ let commands = {
|
|
|
477
470
|
let modsToPress = [];
|
|
478
471
|
|
|
479
472
|
if (!config.TD_VM) {
|
|
480
|
-
modifierKeysPressed.map((key) => {
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
throw new AiError(`Modifier key not found: ${key}`);
|
|
473
|
+
modsToPress = modifierKeysPressed.map((key) => {
|
|
474
|
+
if (modifierKeys[key] === undefined) {
|
|
475
|
+
return key;
|
|
484
476
|
} else {
|
|
485
477
|
return keymap[key];
|
|
486
478
|
}
|
|
487
479
|
});
|
|
480
|
+
|
|
481
|
+
modsToPress.forEach((key) => {
|
|
482
|
+
robot.keyToggle(key, "down");
|
|
483
|
+
});
|
|
484
|
+
|
|
488
485
|
robot.keyTap(keysPressed[0], modsToPress);
|
|
489
486
|
} else {
|
|
490
487
|
await sandbox.send({ type: "press", keys: keysPressed });
|
package/lib/parser.js
CHANGED
|
@@ -24,19 +24,17 @@ function formatAjvError(error) {
|
|
|
24
24
|
|
|
25
25
|
// use markdown parser to find code blocks within AI response
|
|
26
26
|
const findCodeBlocks = async function (markdownContent) {
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
parser.parse(markdownContent, (err, result) => {
|
|
29
|
-
if (err) {
|
|
30
|
-
return reject(err);
|
|
31
|
-
}
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
return code.code.indexOf("yml") > -1 || code.code.indexOf("yaml") > -1;
|
|
35
|
-
});
|
|
28
|
+
console.log(markdownContent)
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
let md = markdownContent.match(/```yaml\n([\s\S]*?)```/);
|
|
31
|
+
console.log('returning')
|
|
32
|
+
|
|
33
|
+
if (md) {
|
|
34
|
+
return [{code: md[1]}];
|
|
35
|
+
} else {
|
|
36
|
+
return []
|
|
37
|
+
}
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
// use markdown parser to find code blocks within AI response
|