Skip to content

Commit 83998b1

Browse files
authored
fix(aio-hybrid-operator): transform arrowDirecton key to direction key (#1641)
1 parent e35aa78 commit 83998b1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

multimodal/gui-agent/operator-aio/src/AIOHybridOperator.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ import type { AIOHybridOptions } from './types';
2020

2121
const defaultLogger = new ConsoleLogger(undefined, LogLevel.DEBUG);
2222

23+
const arrowKeyMap = {
24+
arrowup: 'up',
25+
arrowdown: 'down',
26+
arrowleft: 'left',
27+
arrowright: 'right',
28+
};
29+
2330
export class AIOHybridOperator extends Operator {
2431
private static currentInstance: AIOHybridOperator | null = null;
2532
public static async create(options: AIOHybridOptions): Promise<AIOHybridOperator> {
@@ -223,15 +230,18 @@ export class AIOHybridOperator extends Operator {
223230
}
224231
case 'hotkey':
225232
case 'press': {
226-
const keyStr = actionInputs?.key || actionInputs?.hotkey;
233+
let keyStr = actionInputs?.key || actionInputs?.hotkey;
227234
if (typeof keyStr !== 'string') {
228235
throw new Error('key string is required when press or hotkey');
229236
}
230-
const keys = keyStr.split(/[\s+]/).filter((k) => k.length > 0);
237+
keyStr = keyStr.toLowerCase();
238+
const keys = (keyStr as string).split(/[\s+]/).filter((k) => k.length > 0);
231239
if (keys.length > 1) {
232240
await this.aioComputer.hotkey(keys);
233241
} else {
234-
await this.aioComputer.press(keyStr);
242+
// Check if the key can be mapped using arrowKeyMap
243+
const mappedKey = arrowKeyMap[keyStr as keyof typeof arrowKeyMap] || keyStr;
244+
await this.aioComputer.press(mappedKey);
235245
}
236246
break;
237247
}

0 commit comments

Comments
 (0)