@nexface/tools 0.1.15-alpha.1 → 0.1.15-alpha.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.
Files changed (83) hide show
  1. package/dist/browser/actions.js +34 -10
  2. package/dist/browser/controller.js +53 -74
  3. package/dist/browser/diagnostics.js +8 -3
  4. package/dist/browser/dom.js +12 -28
  5. package/dist/browser/feedback.js +6 -5
  6. package/dist/browser/focus.js +0 -1
  7. package/dist/browser/locator.js +3 -9
  8. package/dist/browser/prompt.generated.js +0 -1
  9. package/dist/browser/prompt.js +0 -1
  10. package/dist/browser/snapshot.js +10 -22
  11. package/dist/browser/toolset.js +42 -36
  12. package/dist/browser/types.d.ts +1 -1
  13. package/dist/browser/types.js +0 -1
  14. package/dist/browser/worker-runner.js +0 -1
  15. package/dist/definition.d.ts +1 -3
  16. package/dist/definition.js +2 -2
  17. package/dist/index.browser.js +0 -1
  18. package/dist/index.js +0 -1
  19. package/dist/internal-react.d.ts +1 -1
  20. package/dist/internal-react.js +3 -4
  21. package/dist/internal-types.js +0 -1
  22. package/dist/navigation.js +0 -1
  23. package/dist/operation-lock.js +36 -2
  24. package/dist/operation-runtime.js +41 -13
  25. package/dist/operation-surface.js +118 -41
  26. package/dist/operation-types.js +0 -1
  27. package/dist/operation-view.d.ts +1 -1
  28. package/dist/operation-view.js +120 -60
  29. package/dist/react.js +9 -14
  30. package/dist/registration.js +4 -3
  31. package/dist/runtime.d.ts +4 -2
  32. package/dist/runtime.js +112 -47
  33. package/dist/shared/definition.js +2 -3
  34. package/dist/shared/errors.d.ts +1 -1
  35. package/dist/shared/errors.js +0 -1
  36. package/dist/shared/page-protocol.js +0 -1
  37. package/dist/shared/page-tools.js +0 -1
  38. package/dist/shared/runtime-controller.d.ts +1 -0
  39. package/dist/shared/runtime-controller.js +0 -1
  40. package/dist/shared/runtime-execution.js +0 -1
  41. package/dist/shared/schema.js +45 -19
  42. package/dist/styles.css +879 -109
  43. package/dist/tool-search.d.ts +11 -0
  44. package/dist/tool-search.js +117 -0
  45. package/dist/types.js +0 -1
  46. package/dist/webmcp.js +39 -13
  47. package/package.json +6 -2
  48. package/dist/browser/actions.js.map +0 -1
  49. package/dist/browser/controller.js.map +0 -1
  50. package/dist/browser/diagnostics.js.map +0 -1
  51. package/dist/browser/dom.js.map +0 -1
  52. package/dist/browser/feedback.js.map +0 -1
  53. package/dist/browser/focus.js.map +0 -1
  54. package/dist/browser/locator.js.map +0 -1
  55. package/dist/browser/prompt.generated.js.map +0 -1
  56. package/dist/browser/prompt.js.map +0 -1
  57. package/dist/browser/snapshot.js.map +0 -1
  58. package/dist/browser/toolset.js.map +0 -1
  59. package/dist/browser/types.js.map +0 -1
  60. package/dist/browser/worker-runner.js.map +0 -1
  61. package/dist/definition.js.map +0 -1
  62. package/dist/index.browser.js.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/internal-react.js.map +0 -1
  65. package/dist/internal-types.js.map +0 -1
  66. package/dist/navigation.js.map +0 -1
  67. package/dist/operation-lock.js.map +0 -1
  68. package/dist/operation-runtime.js.map +0 -1
  69. package/dist/operation-surface.js.map +0 -1
  70. package/dist/operation-types.js.map +0 -1
  71. package/dist/operation-view.js.map +0 -1
  72. package/dist/react.js.map +0 -1
  73. package/dist/registration.js.map +0 -1
  74. package/dist/runtime.js.map +0 -1
  75. package/dist/shared/definition.js.map +0 -1
  76. package/dist/shared/errors.js.map +0 -1
  77. package/dist/shared/page-protocol.js.map +0 -1
  78. package/dist/shared/page-tools.js.map +0 -1
  79. package/dist/shared/runtime-controller.js.map +0 -1
  80. package/dist/shared/runtime-execution.js.map +0 -1
  81. package/dist/shared/schema.js.map +0 -1
  82. package/dist/types.js.map +0 -1
  83. package/dist/webmcp.js.map +0 -1
@@ -6,12 +6,22 @@ export function collectElementActions(actions, ref, element, role, label, state,
6
6
  return;
7
7
  const id = `a${actions.size + 1}`;
8
8
  actions.set(id, {
9
- candidate: { id, operation, ref, role, label: (optionElement ? `${label} / ${option}` : label).slice(0, 500), state, ...(option === undefined ? {} : { option: option.slice(0, 500) }) },
9
+ candidate: {
10
+ id,
11
+ operation,
12
+ ref,
13
+ role,
14
+ label: (optionElement ? `${label} / ${option}` : label).slice(0, 500),
15
+ state,
16
+ ...(option === undefined ? {} : { option: option.slice(0, 500) }),
17
+ },
10
18
  command: { target, method, args },
11
19
  ...(optionElement ? { optionElement } : {}),
12
20
  });
13
21
  };
14
- if (state.disabled || element.closest('[inert],[aria-disabled="true"]') || element.matches(":disabled"))
22
+ if (state.disabled ||
23
+ element.closest('[inert],[aria-disabled="true"]') ||
24
+ element.matches(":disabled"))
15
25
  return;
16
26
  if (scrollable) {
17
27
  if (element.scrollTop > 0)
@@ -30,18 +40,25 @@ export function collectElementActions(actions, ref, element, role, label, state,
30
40
  counts.set(option.value, (counts.get(option.value) ?? 0) + 1);
31
41
  for (const option of element.options) {
32
42
  if (element.multiple) {
33
- if (counts.get(option.value) === 1 && !option.disabled && !option.closest("optgroup[disabled]")) {
43
+ if (counts.get(option.value) === 1 &&
44
+ !option.disabled &&
45
+ !option.closest("optgroup[disabled]")) {
34
46
  add(option.selected ? "uncheck" : "check", "setOptionSelected", [option.value, !option.selected, option.label], option.label, option);
35
47
  }
36
48
  continue;
37
49
  }
38
- if (counts.get(option.value) === 1 && !(element.required && option.value === "") && !option.disabled && !option.selected && !option.closest("optgroup[disabled]"))
50
+ if (counts.get(option.value) === 1 &&
51
+ !(element.required && option.value === "") &&
52
+ !option.disabled &&
53
+ !option.selected &&
54
+ !option.closest("optgroup[disabled]"))
39
55
  add("select", "selectOption", [option.value], option.label);
40
56
  }
41
57
  return;
42
58
  }
43
- if (role === "option" && element.closest('[role="listbox"]')?.getAttribute("aria-multiselectable") === "true"
44
- && ["true", "false"].includes(element.getAttribute("aria-selected") ?? "")) {
59
+ if (role === "option" &&
60
+ element.closest('[role="listbox"]')?.getAttribute("aria-multiselectable") === "true" &&
61
+ ["true", "false"].includes(element.getAttribute("aria-selected") ?? "")) {
45
62
  const field = computeName(element.closest('[role="listbox"]'));
46
63
  label = field ? `${field} / ${label}` : label;
47
64
  add(state.selected ? "uncheck" : "check", state.selected ? "uncheck" : "check", []);
@@ -54,15 +71,23 @@ export function collectElementActions(actions, ref, element, role, label, state,
54
71
  add("uncheck", "uncheck", []);
55
72
  return;
56
73
  }
57
- const editable = element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || (element instanceof HTMLElement && element.isContentEditable);
58
- if (editable && !("readOnly" in element && element.readOnly) && element.getAttribute("aria-readonly") !== "true" && ["textbox", "searchbox", "combobox", "spinbutton"].includes(role)) {
74
+ const editable = element instanceof HTMLInputElement ||
75
+ element instanceof HTMLTextAreaElement ||
76
+ (element instanceof HTMLElement && element.isContentEditable);
77
+ if (editable &&
78
+ !("readOnly" in element && element.readOnly) &&
79
+ element.getAttribute("aria-readonly") !== "true" &&
80
+ ["textbox", "searchbox", "combobox", "spinbutton"].includes(role)) {
59
81
  add("fill", "fill", []);
60
82
  }
61
83
  add("click", "click", []);
62
84
  }
63
85
  export function collectPageActions(actions) {
64
86
  const add = (id, operation, method, args) => {
65
- actions.set(id, { candidate: { id, operation, label: operation, role: "page", state: {} }, command: { target: { type: "page" }, method, args } });
87
+ actions.set(id, {
88
+ candidate: { id, operation, label: operation, role: "page", state: {} },
89
+ command: { target: { type: "page" }, method, args },
90
+ });
66
91
  };
67
92
  if (window.scrollY > 0)
68
93
  add("pageUp", "scrollUp", "scrollBy", [{ y: -560 }]);
@@ -70,4 +95,3 @@ export function collectPageActions(actions) {
70
95
  add("pageDown", "scrollDown", "scrollBy", [{ y: 560 }]);
71
96
  add("wait", "wait", "waitForTimeout", [100]);
72
97
  }
73
- //# sourceMappingURL=actions.js.map
@@ -20,11 +20,7 @@ const LOCATOR_METHODS = new Set([
20
20
  "text",
21
21
  "waitFor",
22
22
  ]);
23
- const PAGE_METHODS = new Set([
24
- "scrollBy",
25
- "waitForTimeout",
26
- "waitForURL",
27
- ]);
23
+ const PAGE_METHODS = new Set(["scrollBy", "waitForTimeout", "waitForURL"]);
28
24
  const WAIT_FOR_URL_TIMEOUT_MS = 3_000;
29
25
  const URL_POLL_INTERVAL_MS = 50;
30
26
  const ACTION_METHODS = new Set([
@@ -65,7 +61,7 @@ function dispatchClickSequence(element) {
65
61
  message: "Click target does not have an uncovered hit point.",
66
62
  });
67
63
  }
68
- const { element: hitTarget, clientX, clientY, } = hit;
64
+ const { element: hitTarget, clientX, clientY } = hit;
69
65
  const init = {
70
66
  bubbles: true,
71
67
  cancelable: true,
@@ -195,8 +191,7 @@ function validateArgs(command, maxChars) {
195
191
  }
196
192
  if (command.method === "selectOption") {
197
193
  if (command.args.length !== 1 ||
198
- (typeof command.args[0] !== "string" &&
199
- !Array.isArray(command.args[0]))) {
194
+ (typeof command.args[0] !== "string" && !Array.isArray(command.args[0]))) {
200
195
  throw invalidCommand("selectOption() requires a string or string array.");
201
196
  }
202
197
  if (Array.isArray(command.args[0]) &&
@@ -204,8 +199,11 @@ function validateArgs(command, maxChars) {
204
199
  throw invalidCommand("selectOption() array values must be strings.");
205
200
  }
206
201
  }
207
- if (command.method === "setOptionSelected" && (command.args.length !== 3
208
- || typeof command.args[0] !== "string" || typeof command.args[1] !== "boolean" || typeof command.args[2] !== "string")) {
202
+ if (command.method === "setOptionSelected" &&
203
+ (command.args.length !== 3 ||
204
+ typeof command.args[0] !== "string" ||
205
+ typeof command.args[1] !== "boolean" ||
206
+ typeof command.args[2] !== "string")) {
209
207
  throw invalidCommand("Invalid observed option selection.");
210
208
  }
211
209
  if (command.method === "waitFor") {
@@ -221,9 +219,7 @@ function validateArgs(command, maxChars) {
221
219
  throw invalidCommand("waitFor() state is invalid.");
222
220
  }
223
221
  if (value?.timeout !== undefined &&
224
- (typeof value.timeout !== "number" ||
225
- !Number.isFinite(value.timeout) ||
226
- value.timeout < 0)) {
222
+ (typeof value.timeout !== "number" || !Number.isFinite(value.timeout) || value.timeout < 0)) {
227
223
  throw invalidCommand("waitFor() timeout is invalid.");
228
224
  }
229
225
  }
@@ -264,10 +260,8 @@ function validateArgs(command, maxChars) {
264
260
  Array.isArray(value) ||
265
261
  Object.keys(value).length === 0 ||
266
262
  Object.keys(value).some((key) => !["x", "y"].includes(key)) ||
267
- (value.x !== undefined &&
268
- (typeof value.x !== "number" || !Number.isFinite(value.x))) ||
269
- (value.y !== undefined &&
270
- (typeof value.y !== "number" || !Number.isFinite(value.y)))) {
263
+ (value.x !== undefined && (typeof value.x !== "number" || !Number.isFinite(value.x))) ||
264
+ (value.y !== undefined && (typeof value.y !== "number" || !Number.isFinite(value.y)))) {
271
265
  throw invalidCommand("scrollBy() requires finite numeric x/y values.");
272
266
  }
273
267
  }
@@ -281,8 +275,7 @@ function validateArgs(command, maxChars) {
281
275
  Object.keys(value).some((key) => !["left", "top"].includes(key)) ||
282
276
  (value.left !== undefined &&
283
277
  (typeof value.left !== "number" || !Number.isFinite(value.left))) ||
284
- (value.top !== undefined &&
285
- (typeof value.top !== "number" || !Number.isFinite(value.top)))) {
278
+ (value.top !== undefined && (typeof value.top !== "number" || !Number.isFinite(value.top)))) {
286
279
  throw invalidCommand("scrollTo() requires finite numeric left/top values.");
287
280
  }
288
281
  }
@@ -340,9 +333,7 @@ export class PageController {
340
333
  throw invalidCommand("Command envelope is invalid.");
341
334
  }
342
335
  const record = this.executions.get(command.executionId);
343
- if (!record ||
344
- record.status !== "running" ||
345
- record.abortController.signal.aborted) {
336
+ if (!record || record.status !== "running" || record.abortController.signal.aborted) {
346
337
  throw new PageCommandError({
347
338
  code: "EXECUTION_CANCELLED",
348
339
  message: "The execution is no longer active.",
@@ -393,15 +384,16 @@ export class PageController {
393
384
  record = this.requireActive(command);
394
385
  const value = command.target.type === "page"
395
386
  ? await this.executePage(command, record)
396
- : await this.executeTarget(command, record, beforeAction && (async () => {
397
- try {
398
- await beforeAction();
399
- }
400
- catch (error) {
401
- presentationFailed = true;
402
- throw error;
403
- }
404
- }));
387
+ : await this.executeTarget(command, record, beforeAction &&
388
+ (async () => {
389
+ try {
390
+ await beforeAction();
391
+ }
392
+ catch (error) {
393
+ presentationFailed = true;
394
+ throw error;
395
+ }
396
+ }));
405
397
  if (ACTION_METHODS.has(command.method) &&
406
398
  !record.completedActions.some((action) => action.callIndex === command.commandSeq)) {
407
399
  this.recordCompletedAction(record, command);
@@ -521,9 +513,7 @@ export class PageController {
521
513
  return record.registry.refs.get(command.target.ref);
522
514
  }
523
515
  locator(command) {
524
- return command.target.type === "locator"
525
- ? command.target.locator
526
- : undefined;
516
+ return command.target.type === "locator" ? command.target.locator : undefined;
527
517
  }
528
518
  async executeTarget(command, record, beforeAction) {
529
519
  const signal = record.abortController.signal;
@@ -557,11 +547,7 @@ export class PageController {
557
547
  return null;
558
548
  }
559
549
  if (command.method === "text") {
560
- const element = ref
561
- ? requireValidRef(ref)
562
- : locator
563
- ? requireUnique(locator)
564
- : undefined;
550
+ const element = ref ? requireValidRef(ref) : locator ? requireUnique(locator) : undefined;
565
551
  if (!element)
566
552
  throw invalidCommand("Target is missing.");
567
553
  if (element instanceof HTMLInputElement ||
@@ -572,11 +558,7 @@ export class PageController {
572
558
  return normalizeText(element.textContent);
573
559
  }
574
560
  if (command.method === "scrollIntoView") {
575
- const element = ref
576
- ? requireValidRef(ref)
577
- : locator
578
- ? requireUnique(locator)
579
- : undefined;
561
+ const element = ref ? requireValidRef(ref) : locator ? requireUnique(locator) : undefined;
580
562
  if (!element)
581
563
  throw invalidCommand("Target is missing.");
582
564
  const beforeIdentity = createIdentity(element);
@@ -597,11 +579,7 @@ export class PageController {
597
579
  return null;
598
580
  }
599
581
  if (command.method === "scrollBy" || command.method === "scrollTo") {
600
- const element = ref
601
- ? ref.element
602
- : locator
603
- ? requireUnique(locator)
604
- : undefined;
582
+ const element = ref ? ref.element : locator ? requireUnique(locator) : undefined;
605
583
  if (!(element instanceof HTMLElement)) {
606
584
  throw new PageCommandError({
607
585
  code: "UNSUPPORTED_OPERATION",
@@ -648,12 +626,8 @@ export class PageController {
648
626
  }
649
627
  else {
650
628
  const value = command.args[0];
651
- if ((value.left !== undefined &&
652
- value.left !== element.scrollLeft &&
653
- !scrollability.x) ||
654
- (value.top !== undefined &&
655
- value.top !== element.scrollTop &&
656
- !scrollability.y)) {
629
+ if ((value.left !== undefined && value.left !== element.scrollLeft && !scrollability.x) ||
630
+ (value.top !== undefined && value.top !== element.scrollTop && !scrollability.y)) {
657
631
  throw new PageCommandError({
658
632
  code: "UNSUPPORTED_OPERATION",
659
633
  message: "Requested axis does not have a scroll range.",
@@ -682,7 +656,9 @@ export class PageController {
682
656
  this.requireStillActive(record);
683
657
  const element = ref
684
658
  ? await prepareRefForAction(ref, signal)
685
- : locator ? await prepareLocatorForAction(locator, signal) : undefined;
659
+ : locator
660
+ ? await prepareLocatorForAction(locator, signal)
661
+ : undefined;
686
662
  if (!element)
687
663
  throw invalidCommand("Target is missing.");
688
664
  this.requireStillActive(record);
@@ -692,9 +668,13 @@ export class PageController {
692
668
  await feedback;
693
669
  this.requireStillActive(record);
694
670
  await beforeAction?.();
695
- if (!element.isConnected || createIdentity(element) !== identity
696
- || (locator && requireUnique(locator) !== element)) {
697
- throw new PageCommandError({ code: "REF_ACTION_FAILED", message: "Target changed before the action." });
671
+ if (!element.isConnected ||
672
+ createIdentity(element) !== identity ||
673
+ (locator && requireUnique(locator) !== element)) {
674
+ throw new PageCommandError({
675
+ code: "REF_ACTION_FAILED",
676
+ message: "Target changed before the action.",
677
+ });
698
678
  }
699
679
  ensureActionable(element);
700
680
  this.requireStillActive(record);
@@ -714,8 +694,7 @@ export class PageController {
714
694
  });
715
695
  }
716
696
  requireStillActive(record) {
717
- if (record.status !== "running" ||
718
- record.abortController.signal.aborted) {
697
+ if (record.status !== "running" || record.abortController.signal.aborted) {
719
698
  throw new PageCommandError({
720
699
  code: "EXECUTION_CANCELLED",
721
700
  message: "Execution was cancelled before the DOM action.",
@@ -729,8 +708,7 @@ export class PageController {
729
708
  }
730
709
  if (command.method === "fill") {
731
710
  const value = String(command.args[0] ?? "");
732
- if ((element instanceof HTMLInputElement ||
733
- element instanceof HTMLTextAreaElement) &&
711
+ if ((element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) &&
734
712
  !element.readOnly) {
735
713
  focusForAgent(element);
736
714
  setNativeValue(element, value);
@@ -755,15 +733,14 @@ export class PageController {
755
733
  }
756
734
  if (command.method === "check" || command.method === "uncheck") {
757
735
  const checked = command.method === "check";
758
- if (element.getAttribute("role") === "option"
759
- && element.closest('[role="listbox"]')?.getAttribute("aria-multiselectable") === "true"
760
- && ["true", "false"].includes(element.getAttribute("aria-selected") ?? "")) {
736
+ if (element.getAttribute("role") === "option" &&
737
+ element.closest('[role="listbox"]')?.getAttribute("aria-multiselectable") === "true" &&
738
+ ["true", "false"].includes(element.getAttribute("aria-selected") ?? "")) {
761
739
  if ((element.getAttribute("aria-selected") === "true") !== checked)
762
740
  dispatchClickSequence(element);
763
741
  return null;
764
742
  }
765
- if (element instanceof HTMLInputElement &&
766
- ["checkbox", "radio"].includes(element.type)) {
743
+ if (element instanceof HTMLInputElement && ["checkbox", "radio"].includes(element.type)) {
767
744
  if (element.type === "radio" && !checked) {
768
745
  throw new PageCommandError({
769
746
  code: "UNSUPPORTED_OPERATION",
@@ -789,9 +766,14 @@ export class PageController {
789
766
  if (command.method === "setOptionSelected") {
790
767
  const [value, selected, label] = command.args;
791
768
  const options = element instanceof HTMLSelectElement && element.multiple
792
- ? [...element.options].filter((option) => option.value === value) : [];
769
+ ? [...element.options].filter((option) => option.value === value)
770
+ : [];
793
771
  const option = options[0];
794
- if (options.length !== 1 || !option || option.label !== label || option.disabled || option.closest("optgroup[disabled]")) {
772
+ if (options.length !== 1 ||
773
+ !option ||
774
+ option.label !== label ||
775
+ option.disabled ||
776
+ option.closest("optgroup[disabled]")) {
795
777
  throw invalidCommand("The observed multiple-select option is no longer available.");
796
778
  }
797
779
  if (option.selected !== selected) {
@@ -808,9 +790,7 @@ export class PageController {
808
790
  });
809
791
  }
810
792
  const requested = command.args[0];
811
- const values = Array.isArray(requested)
812
- ? requested.map(String)
813
- : [String(requested ?? "")];
793
+ const values = Array.isArray(requested) ? requested.map(String) : [String(requested ?? "")];
814
794
  const availableValues = new Set(Array.from(element.options, (option) => option.value));
815
795
  const missing = values.filter((value) => !availableValues.has(value));
816
796
  if (missing.length > 0) {
@@ -841,4 +821,3 @@ export class PageController {
841
821
  throw invalidCommand(`Unsupported locator method: ${command.method}`);
842
822
  }
843
823
  }
844
- //# sourceMappingURL=controller.js.map
@@ -11,10 +11,15 @@ export async function measurePagePhase(phase, execute) {
11
11
  }
12
12
  finally {
13
13
  try {
14
- performance.measure("nexface.browser.phase", { start, end: performance.now(), detail: { phase, status } });
14
+ performance.measure("nexface.browser.phase", {
15
+ start,
16
+ end: performance.now(),
17
+ detail: { phase, status },
18
+ });
15
19
  performance.clearMeasures("nexface.browser.phase");
16
20
  }
17
- catch { /* Diagnostics must never interrupt execution. */ }
21
+ catch {
22
+ /* Diagnostics must never interrupt execution. */
23
+ }
18
24
  }
19
25
  }
20
- //# sourceMappingURL=diagnostics.js.map
@@ -108,9 +108,7 @@ export function* walkComposedElements(root = document) {
108
108
  function hasGenericInteractionEvidence(element) {
109
109
  if (!(element instanceof HTMLElement))
110
110
  return false;
111
- return (element.tabIndex >= 0 ||
112
- element.hasAttribute("onclick") ||
113
- element.isContentEditable);
111
+ return element.tabIndex >= 0 || element.hasAttribute("onclick") || element.isContentEditable;
114
112
  }
115
113
  export function computeRole(element) {
116
114
  const explicit = normalizeText(element.getAttribute("role"))
@@ -146,9 +144,7 @@ export function computeRole(element) {
146
144
  }
147
145
  function referencedText(element, attribute) {
148
146
  const root = element.getRootNode();
149
- const ids = normalizeText(element.getAttribute(attribute))
150
- .split(" ")
151
- .filter(Boolean);
147
+ const ids = normalizeText(element.getAttribute(attribute)).split(" ").filter(Boolean);
152
148
  return normalizeText(ids
153
149
  .map((id) => {
154
150
  if (root instanceof Document || root instanceof ShadowRoot) {
@@ -187,24 +183,14 @@ export function computeNameInfo(element) {
187
183
  if (caption)
188
184
  return { value: caption, source: "explicit" };
189
185
  }
190
- if (element instanceof HTMLInputElement &&
191
- ["button", "submit", "reset"].includes(element.type)) {
186
+ if (element instanceof HTMLInputElement && ["button", "submit", "reset"].includes(element.type)) {
192
187
  const value = normalizeText(element.value);
193
188
  if (value)
194
189
  return { value, source: "fallback" };
195
190
  }
196
191
  const role = computeRole(element);
197
192
  if (isActionableRole(role) ||
198
- [
199
- "cell",
200
- "columnheader",
201
- "heading",
202
- "listitem",
203
- "option",
204
- "row",
205
- "tab",
206
- "treeitem",
207
- ].includes(role)) {
193
+ ["cell", "columnheader", "heading", "listitem", "option", "row", "tab", "treeitem"].includes(role)) {
208
194
  const content = normalizeText(element.textContent);
209
195
  if (content)
210
196
  return { value: content, source: "content" };
@@ -212,8 +198,7 @@ export function computeNameInfo(element) {
212
198
  const title = normalizeText(element.getAttribute("title"));
213
199
  if (title)
214
200
  return { value: title, source: "fallback" };
215
- if (element instanceof HTMLInputElement ||
216
- element instanceof HTMLTextAreaElement) {
201
+ if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
217
202
  return {
218
203
  value: normalizeText(element.placeholder),
219
204
  source: "fallback",
@@ -228,10 +213,8 @@ const SCROLLABLE_OVERFLOW = new Set(["auto", "scroll", "overlay", "hidden"]);
228
213
  export function getElementScrollability(element, style = getComputedStyle(element)) {
229
214
  if (!(element instanceof HTMLElement))
230
215
  return undefined;
231
- const x = SCROLLABLE_OVERFLOW.has(style.overflowX) &&
232
- element.scrollWidth > element.clientWidth + 2;
233
- const y = SCROLLABLE_OVERFLOW.has(style.overflowY) &&
234
- element.scrollHeight > element.clientHeight + 2;
216
+ const x = SCROLLABLE_OVERFLOW.has(style.overflowX) && element.scrollWidth > element.clientWidth + 2;
217
+ const y = SCROLLABLE_OVERFLOW.has(style.overflowY) && element.scrollHeight > element.clientHeight + 2;
235
218
  if (!x && !y)
236
219
  return undefined;
237
220
  return {
@@ -329,7 +312,10 @@ export function computeState(element) {
329
312
  if (element instanceof HTMLSelectElement) {
330
313
  if (element.multiple) {
331
314
  state.multiple = true;
332
- state.selectedOptions = [...element.selectedOptions].map((option) => ({ value: option.value, label: normalizeText(option.label) }));
315
+ state.selectedOptions = [...element.selectedOptions].map((option) => ({
316
+ value: option.value,
317
+ label: normalizeText(option.label),
318
+ }));
333
319
  }
334
320
  if (element.value)
335
321
  state.value = element.value;
@@ -382,8 +368,7 @@ export function isElementRendered(element, style = getComputedStyle(element)) {
382
368
  }
383
369
  if (isAgentIgnored(element))
384
370
  return false;
385
- if (element.hasAttribute("hidden") ||
386
- element.getAttribute("aria-hidden") === "true") {
371
+ if (element.hasAttribute("hidden") || element.getAttribute("aria-hidden") === "true") {
387
372
  return false;
388
373
  }
389
374
  return style.display !== "none" && style.visibility !== "hidden";
@@ -442,4 +427,3 @@ export function matchesText(value, matcher, exact = false) {
442
427
  const expected = normalizeText(matcher);
443
428
  return exact ? normalized === expected : normalized.includes(expected);
444
429
  }
445
- //# sourceMappingURL=dom.js.map
@@ -5,10 +5,11 @@ export class ActionFeedback {
5
5
  this.assertActive?.();
6
6
  const read = ["text", "exists", "waitFor", "waitForTimeout", "waitForURL"].includes(action);
7
7
  const scroll = ["scrollBy", "scrollTo", "scrollIntoView"].includes(action);
8
- return this.listener?.(scroll ? {} : {
9
- effect: read ? "read" : "action",
10
- ...(!read && target ? { target } : {}),
11
- });
8
+ return this.listener?.(scroll
9
+ ? {}
10
+ : {
11
+ effect: read ? "read" : "action",
12
+ ...(!read && target ? { target } : {}),
13
+ });
12
14
  }
13
15
  }
14
- //# sourceMappingURL=feedback.js.map
@@ -26,4 +26,3 @@ export function focusForAgent(element) {
26
26
  focusingForAgent = previous;
27
27
  }
28
28
  }
29
- //# sourceMappingURL=focus.js.map
@@ -123,7 +123,7 @@ function animationFrame(signal) {
123
123
  reject(abortError());
124
124
  return;
125
125
  }
126
- requestAnimationFrame(() => signal.aborted ? reject(abortError()) : resolve());
126
+ requestAnimationFrame(() => (signal.aborted ? reject(abortError()) : resolve()));
127
127
  });
128
128
  }
129
129
  async function waitForStable(element, signal) {
@@ -159,15 +159,10 @@ function ensureNotCovered(element) {
159
159
  });
160
160
  }
161
161
  export function findElementHitTarget(element) {
162
- const candidates = [
163
- element,
164
- ...Array.from(walkComposedElements(element)).slice(0, 127),
165
- ].filter((candidate) => !isAgentIgnored(candidate));
162
+ const candidates = [element, ...Array.from(walkComposedElements(element)).slice(0, 127)].filter((candidate) => !isAgentIgnored(candidate));
166
163
  for (const candidate of candidates) {
167
164
  const clientRects = Array.from(candidate.getClientRects()).filter((rect) => rect.width > 0 && rect.height > 0);
168
- const rects = clientRects.length > 0
169
- ? clientRects
170
- : [candidate.getBoundingClientRect()];
165
+ const rects = clientRects.length > 0 ? clientRects : [candidate.getBoundingClientRect()];
171
166
  for (const rect of rects) {
172
167
  const left = Math.max(0, rect.left);
173
168
  const right = Math.min(window.innerWidth, rect.right);
@@ -274,4 +269,3 @@ export function requireValidRef(target) {
274
269
  validateIdentity(target);
275
270
  return target.element;
276
271
  }
277
- //# sourceMappingURL=locator.js.map
@@ -54,4 +54,3 @@ Execution policy:
54
54
  - Return JSON-serializable data when reading information from the page.
55
55
  - A successful Page action receipt proves only that the action ran. Confirm business success through visible feedback, field readback, or an application tool result.
56
56
  - nxf_executeAction automatically returns a best-effort viewport snapshot. If refsExpired, postSnapshotTimedOut, or snapshotUnavailable is true, or the expected page state is absent, call nxf_getSnapshot before another write or nxf_finish.`;
57
- //# sourceMappingURL=prompt.generated.js.map
@@ -6,4 +6,3 @@ export const BROWSER_TOOLS_SKILL = {
6
6
  export function serializeBrowserToolsSkill() {
7
7
  return `[NEXFACE_SKILL_V1 name="${BROWSER_TOOLS_SKILL.name}"]\n${BROWSER_TOOLS_SKILL.content}\n[/NEXFACE_SKILL_V1]`;
8
8
  }
9
- //# sourceMappingURL=prompt.js.map
@@ -156,10 +156,7 @@ function normalizeNodeChildren(node) {
156
156
  const merged = [];
157
157
  for (const child of node.children) {
158
158
  const previous = merged.at(-1);
159
- if (child.role === "text" &&
160
- previous?.role === "text" &&
161
- !child.element &&
162
- !previous.element) {
159
+ if (child.role === "text" && previous?.role === "text" && !child.element && !previous.element) {
163
160
  previous.name = normalizeText(`${previous.name} ${child.name}`);
164
161
  previous.normalizedName = previous.name;
165
162
  continue;
@@ -171,9 +168,7 @@ function normalizeNodeChildren(node) {
171
168
  .map((child) => child.name)
172
169
  .join(" "));
173
170
  node.children =
174
- node.normalizedName &&
175
- directText &&
176
- node.normalizedName === directText
171
+ node.normalizedName && directText && node.normalizedName === directText
177
172
  ? merged.filter((child) => child.role !== "text")
178
173
  : merged;
179
174
  const onlyChild = node.children.length === 1 ? node.children[0] : undefined;
@@ -202,7 +197,8 @@ function visitNode(node, context) {
202
197
  const parent = node.parentElement;
203
198
  if (parent && !isAllowedByModal(parent, context))
204
199
  return [];
205
- return [{
200
+ return [
201
+ {
206
202
  role: "text",
207
203
  name: normalizeText(node.data),
208
204
  normalizedName: normalizeText(node.data),
@@ -210,7 +206,8 @@ function visitNode(node, context) {
210
206
  state: {},
211
207
  actionable: false,
212
208
  children: [],
213
- }];
209
+ },
210
+ ];
214
211
  }
215
212
  if (!(node instanceof Element))
216
213
  return [];
@@ -249,9 +246,7 @@ function visitNode(node, context) {
249
246
  : computedName.value || (scrollable ? findNearestHeadingText(node) : "");
250
247
  const renderNode = {
251
248
  element: node,
252
- role: scrollable && (!role || role === "actionable")
253
- ? "scrollable"
254
- : role || "group",
249
+ role: scrollable && (!role || role === "actionable") ? "scrollable" : role || "group",
255
250
  name: scrollableName,
256
251
  normalizedName: normalizeText(scrollableName),
257
252
  nameSource: computedName.source,
@@ -340,9 +335,7 @@ function renderTree(nodes, context) {
340
335
  const name = node.name ? ` ${JSON.stringify(normalizeText(node.name))}` : "";
341
336
  const state = serializeState(node.state);
342
337
  const scrollability = serializeScrollability(node.scrollable);
343
- const nextRef = node.actionable || node.scrollable
344
- ? `@${context.refs.size + 1}`
345
- : undefined;
338
+ const nextRef = node.actionable || node.scrollable ? `@${context.refs.size + 1}` : undefined;
346
339
  const refText = nextRef ? ` [ref=${nextRef}]` : "";
347
340
  const prefix = node.role === "text" ? `${indent}- text:` : `${indent}- ${node.role}`;
348
341
  const line = node.role === "text"
@@ -380,9 +373,7 @@ export async function createSnapshot(scope = "viewport", limits = {}, execution,
380
373
  const walkContext = {
381
374
  scope,
382
375
  ...(activeModal ? { activeModal } : {}),
383
- allowedPortalRoots: activeModal
384
- ? findPortalRoots(activeModal, execution)
385
- : new Set(),
376
+ allowedPortalRoots: activeModal ? findPortalRoots(activeModal, execution) : new Set(),
386
377
  styles: new WeakMap(),
387
378
  rects: new WeakMap(),
388
379
  visitedNodes: 0,
@@ -402,9 +393,7 @@ export async function createSnapshot(scope = "viewport", limits = {}, execution,
402
393
  const renderContext = {
403
394
  ...(actions ? { actions } : {}),
404
395
  refs: registry.refs,
405
- maxChars: scope === "viewport"
406
- ? resolvedLimits.viewportMaxChars
407
- : resolvedLimits.fullMaxChars,
396
+ maxChars: scope === "viewport" ? resolvedLimits.viewportMaxChars : resolvedLimits.fullMaxChars,
408
397
  usedChars: 0,
409
398
  lines: [],
410
399
  truncated: false,
@@ -429,4 +418,3 @@ export async function createSnapshot(scope = "viewport", limits = {}, execution,
429
418
  export async function getSnapshot(scope = "viewport", limits = {}) {
430
419
  return (await createSnapshot(scope, limits)).snapshot;
431
420
  }
432
- //# sourceMappingURL=snapshot.js.map