explorbot 0.0.5 → 0.1.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.
Files changed (85) hide show
  1. package/bin/explorbot-cli.ts +97 -39
  2. package/dist/bin/explorbot-cli.js +75 -19
  3. package/dist/rules/rerunner/healing-approach.md +19 -0
  4. package/dist/src/action.js +8 -7
  5. package/dist/src/ai/historian.js +34 -3
  6. package/dist/src/ai/navigator.js +35 -28
  7. package/dist/src/ai/pilot.js +33 -9
  8. package/dist/src/ai/planner/subpages.js +42 -6
  9. package/dist/src/ai/planner.js +44 -13
  10. package/dist/src/ai/rerunner.js +472 -0
  11. package/dist/src/ai/researcher/cache.js +13 -8
  12. package/dist/src/ai/researcher/coordinates.js +4 -2
  13. package/dist/src/ai/researcher/deep-analysis.js +16 -19
  14. package/dist/src/ai/researcher/locators.js +1 -1
  15. package/dist/src/ai/researcher/parser.js +4 -3
  16. package/dist/src/ai/researcher/research-result.js +2 -0
  17. package/dist/src/ai/researcher.js +3 -3
  18. package/dist/src/ai/rules.js +2 -2
  19. package/dist/src/ai/tools.js +6 -2
  20. package/dist/src/commands/add-rule-command.js +1 -2
  21. package/dist/src/commands/base-command.js +12 -0
  22. package/dist/src/commands/context-command.js +10 -3
  23. package/dist/src/commands/drill-command.js +0 -1
  24. package/dist/src/commands/explore-command.js +21 -6
  25. package/dist/src/commands/freesail-command.js +8 -22
  26. package/dist/src/commands/index.js +4 -0
  27. package/dist/src/commands/init-command.js +7 -5
  28. package/dist/src/commands/path-command.js +2 -1
  29. package/dist/src/commands/plan-command.js +38 -11
  30. package/dist/src/commands/rerun-command.js +42 -0
  31. package/dist/src/commands/research-command.js +10 -4
  32. package/dist/src/commands/runs-command.js +22 -0
  33. package/dist/src/commands/start-command.js +0 -1
  34. package/dist/src/commands/test-command.js +3 -3
  35. package/dist/src/components/App.js +8 -0
  36. package/dist/src/config.js +3 -0
  37. package/dist/src/explorbot.js +20 -1
  38. package/dist/src/explorer.js +59 -16
  39. package/dist/src/suite.js +115 -0
  40. package/dist/src/utils/html.js +2 -5
  41. package/dist/src/utils/rules-loader.js +33 -17
  42. package/dist/src/utils/test-files.js +103 -0
  43. package/dist/src/utils/web-element.js +6 -4
  44. package/package.json +3 -2
  45. package/rules/rerunner/healing-approach.md +19 -0
  46. package/src/action.ts +8 -6
  47. package/src/ai/historian.ts +37 -3
  48. package/src/ai/navigator.ts +35 -28
  49. package/src/ai/pilot.ts +33 -9
  50. package/src/ai/planner/subpages.ts +37 -7
  51. package/src/ai/planner.ts +44 -12
  52. package/src/ai/rerunner.ts +532 -0
  53. package/src/ai/researcher/cache.ts +14 -8
  54. package/src/ai/researcher/coordinates.ts +8 -7
  55. package/src/ai/researcher/deep-analysis.ts +18 -21
  56. package/src/ai/researcher/locators.ts +3 -3
  57. package/src/ai/researcher/parser.ts +4 -4
  58. package/src/ai/researcher/research-result.ts +1 -0
  59. package/src/ai/researcher.ts +3 -3
  60. package/src/ai/rules.ts +2 -2
  61. package/src/ai/tools.ts +7 -2
  62. package/src/commands/add-rule-command.ts +1 -2
  63. package/src/commands/base-command.ts +13 -0
  64. package/src/commands/context-command.ts +10 -3
  65. package/src/commands/drill-command.ts +0 -1
  66. package/src/commands/explore-command.ts +22 -6
  67. package/src/commands/freesail-command.ts +6 -23
  68. package/src/commands/index.ts +4 -0
  69. package/src/commands/init-command.ts +8 -5
  70. package/src/commands/path-command.ts +2 -1
  71. package/src/commands/plan-command.ts +46 -12
  72. package/src/commands/rerun-command.ts +46 -0
  73. package/src/commands/research-command.ts +10 -4
  74. package/src/commands/runs-command.ts +27 -0
  75. package/src/commands/start-command.ts +0 -1
  76. package/src/commands/test-command.ts +3 -3
  77. package/src/components/App.tsx +8 -0
  78. package/src/config.ts +24 -0
  79. package/src/explorbot.ts +22 -1
  80. package/src/explorer.ts +68 -20
  81. package/src/suite.ts +135 -0
  82. package/src/utils/html.ts +1 -5
  83. package/src/utils/rules-loader.ts +35 -17
  84. package/src/utils/test-files.ts +122 -0
  85. package/src/utils/web-element.ts +12 -10
@@ -7,6 +7,7 @@ type RawElementData = NonNullable<ReturnType<typeof extractElementData>>;
7
7
 
8
8
  export class WebElement {
9
9
  tag: string;
10
+ role: string;
10
11
  xpath: string;
11
12
  clickXPath: string;
12
13
  attrs: Record<string, string>;
@@ -14,8 +15,9 @@ export class WebElement {
14
15
  outerHTML: string;
15
16
  x: number;
16
17
  y: number;
17
- constructor(data: { tag: string; xpath: string; clickXPath: string; attrs: Record<string, string>; text: string; outerHTML?: string; x: number; y: number }) {
18
+ constructor(data: { tag: string; role?: string; xpath: string; clickXPath: string; attrs: Record<string, string>; text: string; outerHTML?: string; x: number; y: number }) {
18
19
  this.tag = data.tag;
20
+ this.role = data.role || data.attrs.role || '';
19
21
  this.xpath = data.xpath;
20
22
  this.clickXPath = data.clickXPath;
21
23
  this.attrs = data.attrs;
@@ -40,9 +42,8 @@ export class WebElement {
40
42
  return `(${this.x}, ${this.y})`;
41
43
  }
42
44
 
43
- get eidx(): number | null {
44
- const val = this.attrs['data-explorbot-eidx'] || this.attrs.eidx;
45
- return val ? Number.parseInt(val, 10) : null;
45
+ get eidx(): string | null {
46
+ return this.attrs['data-explorbot-eidx'] || this.attrs.eidx || null;
46
47
  }
47
48
 
48
49
  get isNavigationLink(): boolean {
@@ -56,9 +57,10 @@ export class WebElement {
56
57
  return cls.split(/\s+/).filter((c) => c.length > 2 && !isDynamicId(c) && !isGenericClass(c));
57
58
  }
58
59
 
59
- private static fromRawData(d: RawElementData): WebElement {
60
+ static fromRawData(d: RawElementData, role?: string): WebElement {
60
61
  return new WebElement({
61
62
  tag: d.tag,
63
+ role,
62
64
  xpath: '',
63
65
  clickXPath: buildClickableXPath({ tag: d.tag, allAttrs: d.allAttrs, text: d.text } as XPathMatch),
64
66
  attrs: d.allAttrs,
@@ -93,15 +95,15 @@ export class WebElement {
93
95
  }
94
96
  }
95
97
 
96
- static async fromEidx(page: any, eidx: number): Promise<WebElement | null> {
98
+ static async fromEidx(page: any, eidx: string): Promise<WebElement | null> {
97
99
  return WebElement.fromPlaywrightLocator(page.locator(`[data-explorbot-eidx="${eidx}"]`));
98
100
  }
99
101
 
100
- static async fromEidxList(page: any, eidxList: number[]): Promise<WebElement[]> {
102
+ static async fromEidxList(page: any, eidxList: string[]): Promise<WebElement[]> {
101
103
  if (eidxList.length === 0) return [];
102
104
 
103
105
  const rawList: RawElementData[] = await page.evaluate(
104
- ([list, extractFnStr]: [number[], string]) => {
106
+ ([list, extractFnStr]: [string[], string]) => {
105
107
  const extract = new Function(`return ${extractFnStr}`)() as (el: Element) => any;
106
108
  const results: any[] = [];
107
109
  for (const eidx of list) {
@@ -112,7 +114,7 @@ export class WebElement {
112
114
  }
113
115
  return results;
114
116
  },
115
- [eidxList, extractElementData.toString()] as [number[], string]
117
+ [eidxList, extractElementData.toString()] as [string[], string]
116
118
  );
117
119
 
118
120
  return rawList.map((d) => WebElement.fromRawData(d));
@@ -125,7 +127,7 @@ export class WebElement {
125
127
  }
126
128
  }
127
129
 
128
- function extractElementData(el: Element) {
130
+ export function extractElementData(el: Element) {
129
131
  const rect = el.getBoundingClientRect();
130
132
  if (rect.width === 0 && rect.height === 0) return null;
131
133