@lardexx/arenacode 2.11.0 → 2.11.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lardexx/arenacode",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "description": "Terminal client for ArenaCode: talks to an arena-bridge, streams the Agent Mode timeline, and runs local commands, file operations and computer automation on your PC (windows-use.dll on Windows, Xlib/XTest on Linux, osascript on macOS). Node port of the ArenaCode desktop client.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -285,6 +285,20 @@ function tool(kind, args = {}) {
285
285
  }
286
286
 
287
287
  /** The value inside {"ok":true,"result":…}, or {ok:false,error} unchanged. */
288
+ /**
289
+ * The request windows-use expects for typing. The two forms are not interchangeable:
290
+ * with the coordinates of the field it is `type_tool` (`loc` is required, the DLL
291
+ * answers "loc: field required" otherwise), without them it is `type_focus_tool`,
292
+ * which writes into whatever holds the focus.
293
+ */
294
+ function typeRequest(text, x = null, y = null) {
295
+ const value = String(text);
296
+ const located = Number.isFinite(x) && Number.isFinite(y);
297
+ return located
298
+ ? { tool: TOOLS.type, args: { loc: [Math.round(x), Math.round(y)], text: value } }
299
+ : { tool: TOOLS.type_focus, args: { text: value } };
300
+ }
301
+
288
302
  function result(answer) {
289
303
  if (!answer || typeof answer !== 'object') return { ok: false, error: 'no answer' };
290
304
  if (answer.ok === false) return { ok: false, error: answer.error || 'windows-use error' };
@@ -400,12 +414,13 @@ const backend = {
400
414
  },
401
415
 
402
416
  typeText(text, x = null, y = null) {
403
- if (x !== null && y !== null) {
404
- const clicked = backend.click(x, y);
405
- if (!clicked.ok) return clicked;
406
- }
407
- const r = result(tool('type', { text: String(text) }));
408
- return r.ok ? { ok: true, chars: String(text).length, typed: String(text).length } : r;
417
+ // windows-use has two forms and they are not interchangeable: type_tool needs the
418
+ // coordinates of the field (loc), type_focus_tool writes into the focused element.
419
+ // Without loc the DLL answers "loc: field required".
420
+ const value = String(text);
421
+ const r = result(raw(typeRequest(value, x, y)));
422
+ if (!r.ok) return r;
423
+ return { ok: true, chars: value.length, typed: value.length };
409
424
  },
410
425
 
411
426
  pressKeys(combo) {
@@ -484,6 +499,7 @@ module.exports = {
484
499
  load,
485
500
  version,
486
501
  tool,
502
+ typeRequest,
487
503
  result,
488
504
  raw,
489
505
  backend,