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.
- package/bin/explorbot-cli.ts +97 -39
- package/dist/bin/explorbot-cli.js +75 -19
- package/dist/rules/rerunner/healing-approach.md +19 -0
- package/dist/src/action.js +8 -7
- package/dist/src/ai/historian.js +34 -3
- package/dist/src/ai/navigator.js +35 -28
- package/dist/src/ai/pilot.js +33 -9
- package/dist/src/ai/planner/subpages.js +42 -6
- package/dist/src/ai/planner.js +44 -13
- package/dist/src/ai/rerunner.js +472 -0
- package/dist/src/ai/researcher/cache.js +13 -8
- package/dist/src/ai/researcher/coordinates.js +4 -2
- package/dist/src/ai/researcher/deep-analysis.js +16 -19
- package/dist/src/ai/researcher/locators.js +1 -1
- package/dist/src/ai/researcher/parser.js +4 -3
- package/dist/src/ai/researcher/research-result.js +2 -0
- package/dist/src/ai/researcher.js +3 -3
- package/dist/src/ai/rules.js +2 -2
- package/dist/src/ai/tools.js +6 -2
- package/dist/src/commands/add-rule-command.js +1 -2
- package/dist/src/commands/base-command.js +12 -0
- package/dist/src/commands/context-command.js +10 -3
- package/dist/src/commands/drill-command.js +0 -1
- package/dist/src/commands/explore-command.js +21 -6
- package/dist/src/commands/freesail-command.js +8 -22
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/init-command.js +7 -5
- package/dist/src/commands/path-command.js +2 -1
- package/dist/src/commands/plan-command.js +38 -11
- package/dist/src/commands/rerun-command.js +42 -0
- package/dist/src/commands/research-command.js +10 -4
- package/dist/src/commands/runs-command.js +22 -0
- package/dist/src/commands/start-command.js +0 -1
- package/dist/src/commands/test-command.js +3 -3
- package/dist/src/components/App.js +8 -0
- package/dist/src/config.js +3 -0
- package/dist/src/explorbot.js +20 -1
- package/dist/src/explorer.js +59 -16
- package/dist/src/suite.js +115 -0
- package/dist/src/utils/html.js +2 -5
- package/dist/src/utils/rules-loader.js +33 -17
- package/dist/src/utils/test-files.js +103 -0
- package/dist/src/utils/web-element.js +6 -4
- package/package.json +3 -2
- package/rules/rerunner/healing-approach.md +19 -0
- package/src/action.ts +8 -6
- package/src/ai/historian.ts +37 -3
- package/src/ai/navigator.ts +35 -28
- package/src/ai/pilot.ts +33 -9
- package/src/ai/planner/subpages.ts +37 -7
- package/src/ai/planner.ts +44 -12
- package/src/ai/rerunner.ts +532 -0
- package/src/ai/researcher/cache.ts +14 -8
- package/src/ai/researcher/coordinates.ts +8 -7
- package/src/ai/researcher/deep-analysis.ts +18 -21
- package/src/ai/researcher/locators.ts +3 -3
- package/src/ai/researcher/parser.ts +4 -4
- package/src/ai/researcher/research-result.ts +1 -0
- package/src/ai/researcher.ts +3 -3
- package/src/ai/rules.ts +2 -2
- package/src/ai/tools.ts +7 -2
- package/src/commands/add-rule-command.ts +1 -2
- package/src/commands/base-command.ts +13 -0
- package/src/commands/context-command.ts +10 -3
- package/src/commands/drill-command.ts +0 -1
- package/src/commands/explore-command.ts +22 -6
- package/src/commands/freesail-command.ts +6 -23
- package/src/commands/index.ts +4 -0
- package/src/commands/init-command.ts +8 -5
- package/src/commands/path-command.ts +2 -1
- package/src/commands/plan-command.ts +46 -12
- package/src/commands/rerun-command.ts +46 -0
- package/src/commands/research-command.ts +10 -4
- package/src/commands/runs-command.ts +27 -0
- package/src/commands/start-command.ts +0 -1
- package/src/commands/test-command.ts +3 -3
- package/src/components/App.tsx +8 -0
- package/src/config.ts +24 -0
- package/src/explorbot.ts +22 -1
- package/src/explorer.ts +68 -20
- package/src/suite.ts +135 -0
- package/src/utils/html.ts +1 -5
- package/src/utils/rules-loader.ts +35 -17
- package/src/utils/test-files.ts +122 -0
- package/src/utils/web-element.ts +12 -10
package/src/utils/web-element.ts
CHANGED
|
@@ -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():
|
|
44
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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]: [
|
|
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 [
|
|
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
|
|