@oagi/oagi 0.2.0 → 0.2.1
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/dist/{chunk-LA6CBP44.js → chunk-CNCUINOM.js} +39 -11
- package/dist/{chunk-LA6CBP44.js.map → chunk-CNCUINOM.js.map} +1 -1
- package/dist/cli.cjs +74 -37
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +11 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -4
package/dist/cli.cjs
CHANGED
|
@@ -2261,8 +2261,32 @@ asyncAgentRegister("tasker:software_qa")(
|
|
|
2261
2261
|
);
|
|
2262
2262
|
|
|
2263
2263
|
// src/handler.ts
|
|
2264
|
-
var
|
|
2265
|
-
|
|
2264
|
+
var _robot;
|
|
2265
|
+
async function getRobot() {
|
|
2266
|
+
if (!_robot) {
|
|
2267
|
+
try {
|
|
2268
|
+
_robot = (await import("robotjs")).default;
|
|
2269
|
+
} catch {
|
|
2270
|
+
throw new Error(
|
|
2271
|
+
"robotjs is not available. Install it with: npm install robotjs\nOn Linux, ensure libx11-dev and libxtst-dev are installed."
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
return _robot;
|
|
2276
|
+
}
|
|
2277
|
+
var _sharp;
|
|
2278
|
+
async function getSharp() {
|
|
2279
|
+
if (!_sharp) {
|
|
2280
|
+
try {
|
|
2281
|
+
_sharp = (await import("sharp")).default;
|
|
2282
|
+
} catch {
|
|
2283
|
+
throw new Error(
|
|
2284
|
+
"sharp is not available. Install it with: npm install sharp"
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
return _sharp;
|
|
2289
|
+
}
|
|
2266
2290
|
var sleep3 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2267
2291
|
var toSharpKernel = (resample) => {
|
|
2268
2292
|
switch (resample) {
|
|
@@ -2321,8 +2345,10 @@ var ScreenshotMaker = class _ScreenshotMaker {
|
|
|
2321
2345
|
return arraybuffer;
|
|
2322
2346
|
}
|
|
2323
2347
|
async provide() {
|
|
2324
|
-
const
|
|
2325
|
-
const
|
|
2348
|
+
const robot = await getRobot();
|
|
2349
|
+
const sharp = await getSharp();
|
|
2350
|
+
const { width, height } = robot.getScreenSize();
|
|
2351
|
+
const screenshot = robot.screen.capture(0, 0, width, height);
|
|
2326
2352
|
const channels = 3;
|
|
2327
2353
|
const data = new Uint8Array(
|
|
2328
2354
|
screenshot.width * screenshot.height * channels
|
|
@@ -2336,7 +2362,7 @@ var ScreenshotMaker = class _ScreenshotMaker {
|
|
|
2336
2362
|
data[offset + 2] = screenshot.image.readUInt8(offset2 + 0);
|
|
2337
2363
|
}
|
|
2338
2364
|
}
|
|
2339
|
-
let p = (
|
|
2365
|
+
let p = sharp(Buffer.from(data), {
|
|
2340
2366
|
raw: {
|
|
2341
2367
|
width: screenshot.width,
|
|
2342
2368
|
height: screenshot.height,
|
|
@@ -2370,8 +2396,9 @@ var DefaultActionHandler = class {
|
|
|
2370
2396
|
}
|
|
2371
2397
|
}
|
|
2372
2398
|
}
|
|
2373
|
-
#denormalize(x, y) {
|
|
2374
|
-
const
|
|
2399
|
+
async #denormalize(x, y) {
|
|
2400
|
+
const robot = await getRobot();
|
|
2401
|
+
const { width, height } = robot.getScreenSize();
|
|
2375
2402
|
let px = Math.floor(x * width / 1e3);
|
|
2376
2403
|
let py = Math.floor(y * height / 1e3);
|
|
2377
2404
|
if (px < 1) px = 1;
|
|
@@ -2381,51 +2408,52 @@ var DefaultActionHandler = class {
|
|
|
2381
2408
|
return { x: px, y: py };
|
|
2382
2409
|
}
|
|
2383
2410
|
async #handleOne(action) {
|
|
2411
|
+
const robot = await getRobot();
|
|
2384
2412
|
const arg = stripOuterParens(action.argument);
|
|
2385
2413
|
switch (action.type) {
|
|
2386
2414
|
case "click": {
|
|
2387
2415
|
const coords = parseCoords(arg);
|
|
2388
2416
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2389
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2390
|
-
|
|
2391
|
-
|
|
2417
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2418
|
+
robot.moveMouse(p.x, p.y);
|
|
2419
|
+
robot.mouseClick("left", false);
|
|
2392
2420
|
return;
|
|
2393
2421
|
}
|
|
2394
2422
|
case "left_double": {
|
|
2395
2423
|
const coords = parseCoords(arg);
|
|
2396
2424
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2397
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2398
|
-
|
|
2399
|
-
|
|
2425
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2426
|
+
robot.moveMouse(p.x, p.y);
|
|
2427
|
+
robot.mouseClick("left", true);
|
|
2400
2428
|
return;
|
|
2401
2429
|
}
|
|
2402
2430
|
case "left_triple": {
|
|
2403
2431
|
const coords = parseCoords(arg);
|
|
2404
2432
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2405
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2433
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2434
|
+
robot.moveMouse(p.x, p.y);
|
|
2435
|
+
robot.mouseClick("left", true);
|
|
2436
|
+
robot.mouseClick("left", false);
|
|
2409
2437
|
return;
|
|
2410
2438
|
}
|
|
2411
2439
|
case "right_single": {
|
|
2412
2440
|
const coords = parseCoords(arg);
|
|
2413
2441
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2414
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2415
|
-
|
|
2416
|
-
|
|
2442
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2443
|
+
robot.moveMouse(p.x, p.y);
|
|
2444
|
+
robot.mouseClick("right", false);
|
|
2417
2445
|
return;
|
|
2418
2446
|
}
|
|
2419
2447
|
case "drag": {
|
|
2420
2448
|
const coords = parseDragCoords(arg);
|
|
2421
2449
|
if (!coords) throw new Error(`Invalid drag coords: ${arg}`);
|
|
2422
|
-
const p1 = this.#denormalize(coords[0], coords[1]);
|
|
2423
|
-
const p2 = this.#denormalize(coords[2], coords[3]);
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2450
|
+
const p1 = await this.#denormalize(coords[0], coords[1]);
|
|
2451
|
+
const p2 = await this.#denormalize(coords[2], coords[3]);
|
|
2452
|
+
robot.moveMouse(p1.x, p1.y);
|
|
2453
|
+
robot.mouseToggle("down", "left");
|
|
2454
|
+
robot.dragMouse(p2.x, p2.y);
|
|
2427
2455
|
await sleep3(this.#cfg.dragDurationMs);
|
|
2428
|
-
|
|
2456
|
+
robot.mouseToggle("up", "left");
|
|
2429
2457
|
return;
|
|
2430
2458
|
}
|
|
2431
2459
|
case "hotkey": {
|
|
@@ -2434,7 +2462,7 @@ var DefaultActionHandler = class {
|
|
|
2434
2462
|
});
|
|
2435
2463
|
if (keys.length === 1 && keys[0] === "capslock") {
|
|
2436
2464
|
if (this.#cfg.capslockMode === "system") {
|
|
2437
|
-
|
|
2465
|
+
robot.keyTap("capslock");
|
|
2438
2466
|
} else {
|
|
2439
2467
|
this.#sessionCapsEnabled = !this.#sessionCapsEnabled;
|
|
2440
2468
|
}
|
|
@@ -2443,24 +2471,24 @@ var DefaultActionHandler = class {
|
|
|
2443
2471
|
const last = keys.at(-1);
|
|
2444
2472
|
if (!last) return;
|
|
2445
2473
|
const modifiers = keys.slice(0, -1);
|
|
2446
|
-
|
|
2474
|
+
robot.keyTap(last, modifiers.length ? modifiers : []);
|
|
2447
2475
|
await sleep3(this.#cfg.hotkeyDelayMs);
|
|
2448
2476
|
return;
|
|
2449
2477
|
}
|
|
2450
2478
|
case "type": {
|
|
2451
2479
|
const raw = arg.replace(/^['"]/, "").replace(/['"]$/, "");
|
|
2452
2480
|
const text = applySessionCaps(raw, this.#sessionCapsEnabled);
|
|
2453
|
-
|
|
2481
|
+
robot.typeString(text);
|
|
2454
2482
|
return;
|
|
2455
2483
|
}
|
|
2456
2484
|
case "scroll": {
|
|
2457
2485
|
const parsed = parseScroll(arg);
|
|
2458
2486
|
if (!parsed) throw new Error(`Invalid scroll: ${arg}`);
|
|
2459
|
-
const p = this.#denormalize(parsed[0], parsed[1]);
|
|
2487
|
+
const p = await this.#denormalize(parsed[0], parsed[1]);
|
|
2460
2488
|
const direction = parsed[2];
|
|
2461
|
-
|
|
2489
|
+
robot.moveMouse(p.x, p.y);
|
|
2462
2490
|
const amount = direction === "up" ? this.#cfg.scrollAmount : -this.#cfg.scrollAmount;
|
|
2463
|
-
|
|
2491
|
+
robot.scrollMouse(0, amount);
|
|
2464
2492
|
return;
|
|
2465
2493
|
}
|
|
2466
2494
|
case "wait": {
|
|
@@ -2554,7 +2582,6 @@ var StepTracker = class extends StepObserver {
|
|
|
2554
2582
|
};
|
|
2555
2583
|
|
|
2556
2584
|
// src/cli/agent.ts
|
|
2557
|
-
var import_node_mac_permissions = __toESM(require("@hurdlegroup/node-mac-permissions"), 1);
|
|
2558
2585
|
var logger6 = logger_default("cli.agent");
|
|
2559
2586
|
var checkPermissions = async () => {
|
|
2560
2587
|
if (process.platform !== "darwin") {
|
|
@@ -2566,18 +2593,28 @@ var checkPermissions = async () => {
|
|
|
2566
2593
|
);
|
|
2567
2594
|
return;
|
|
2568
2595
|
}
|
|
2569
|
-
|
|
2570
|
-
|
|
2596
|
+
let macPerm;
|
|
2597
|
+
try {
|
|
2598
|
+
macPerm = (await import("@hurdlegroup/node-mac-permissions")).default;
|
|
2599
|
+
} catch {
|
|
2600
|
+
console.error(
|
|
2601
|
+
"node-mac-permissions not available. Install with: npm install @hurdlegroup/node-mac-permissions"
|
|
2602
|
+
);
|
|
2603
|
+
process.exitCode = 1;
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
const screenPermission = macPerm.getAuthStatus("screen");
|
|
2607
|
+
const accessibilityPermission = macPerm.getAuthStatus("accessibility");
|
|
2571
2608
|
console.log("Checking permissions...");
|
|
2572
2609
|
console.log(` ${screenPermission ? "[OK]" : "[MISSING]"} Screen Recording`);
|
|
2573
2610
|
console.log(
|
|
2574
2611
|
` ${accessibilityPermission ? "[OK]" : "[MISSING]"} Accessibility`
|
|
2575
2612
|
);
|
|
2576
2613
|
if (!screenPermission) {
|
|
2577
|
-
|
|
2614
|
+
macPerm.askForScreenCaptureAccess(true);
|
|
2578
2615
|
}
|
|
2579
2616
|
if (!accessibilityPermission) {
|
|
2580
|
-
|
|
2617
|
+
macPerm.askForAccessibilityAccess();
|
|
2581
2618
|
}
|
|
2582
2619
|
if (screenPermission && accessibilityPermission) {
|
|
2583
2620
|
console.log("All permissions granted. You can run the agent.");
|