@anusornneal/chat-relay 1.2.3 → 1.3.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.
|
@@ -310,7 +310,35 @@ export class DesktopManager {
|
|
|
310
310
|
return this.runControl(() => this.runner("mouse_click", { x, y, button, clicks }));
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
async
|
|
313
|
+
async clickImageTarget(input = {}) {
|
|
314
|
+
const gate = this.gate();
|
|
315
|
+
if (gate) return gate;
|
|
316
|
+
const { imageWidth, imageHeight, desktopOriginX, desktopOriginY, desktopWidth, desktopHeight } = input;
|
|
317
|
+
const numbers = [imageWidth, imageHeight, desktopOriginX, desktopOriginY, desktopWidth, desktopHeight, input.x, input.y];
|
|
318
|
+
if (numbers.some((value) => !Number.isFinite(value)) ||
|
|
319
|
+
!numbers.every(Number.isInteger) ||
|
|
320
|
+
imageWidth <= 0 || imageHeight <= 0 || desktopWidth <= 0 || desktopHeight <= 0 ||
|
|
321
|
+
input.x < 0 || input.x >= imageWidth || input.y < 0 || input.y >= imageHeight) {
|
|
322
|
+
return { ok: false, error: "invalid_image_coordinates" };
|
|
323
|
+
}
|
|
324
|
+
const targetWidth = input.targetWidth ?? 1;
|
|
325
|
+
const targetHeight = input.targetHeight ?? 1;
|
|
326
|
+
if (![targetWidth, targetHeight].every(Number.isInteger) ||
|
|
327
|
+
targetWidth <= 0 || targetHeight <= 0 ||
|
|
328
|
+
input.x + targetWidth > imageWidth || input.y + targetHeight > imageHeight) {
|
|
329
|
+
return { ok: false, error: "invalid_target_bounds" };
|
|
330
|
+
}
|
|
331
|
+
const x = desktopOriginX + Math.floor((input.x + targetWidth / 2) * desktopWidth / imageWidth);
|
|
332
|
+
const y = desktopOriginY + Math.floor((input.y + targetHeight / 2) * desktopHeight / imageHeight);
|
|
333
|
+
const button = String(input.button || "left").toLowerCase();
|
|
334
|
+
const clicks = Number(input.clicks ?? 1);
|
|
335
|
+
if (!["left", "right", "middle"].includes(button)) return { ok: false, error: "invalid_button" };
|
|
336
|
+
if (clicks !== 1 && clicks !== 2) return { ok: false, error: "invalid_click_count" };
|
|
337
|
+
return this.runControl(async () => {
|
|
338
|
+
const result = await this.runner("mouse_click", { x, y, button, clicks });
|
|
339
|
+
return { ...result, target: { x, y, source: "image", verified: false } };
|
|
340
|
+
});
|
|
341
|
+
} async keyboardInput(input = {}) {
|
|
314
342
|
const gate = this.gate();
|
|
315
343
|
if (gate) return gate;
|
|
316
344
|
|
package/agent/local-agent.mjs
CHANGED
|
@@ -246,6 +246,8 @@ async function handlePayload(payload) {
|
|
|
246
246
|
return desktop.listWindows(payload);
|
|
247
247
|
case "desktop.window.focus":
|
|
248
248
|
return desktop.focusWindow(payload);
|
|
249
|
+
case "desktop.mouse.click_image":
|
|
250
|
+
return desktop.clickImageTarget(payload);
|
|
249
251
|
case "desktop.mouse.click":
|
|
250
252
|
return desktop.mouseClick(payload);
|
|
251
253
|
case "desktop.keyboard.input":
|
|
@@ -247,6 +247,8 @@ export function humanizeToolCall(payload = {}) {
|
|
|
247
247
|
return "List open windows";
|
|
248
248
|
case "desktop.window.focus":
|
|
249
249
|
return `Focus window · ${cleanText(payload.title ?? payload.windowId ?? payload.handle ?? "", 64)}`;
|
|
250
|
+
case "desktop.mouse.click_image":
|
|
251
|
+
return "Click screenshot target";
|
|
250
252
|
case "desktop.mouse.click": {
|
|
251
253
|
const button = cleanText(payload.button || "left", 12);
|
|
252
254
|
return `${button[0]?.toUpperCase() || "L"}${button.slice(1)} click`;
|
package/package.json
CHANGED