qazen-cli 0.1.5 → 0.1.7
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/dist/lib/visionNavigator.js +19 -4
- package/package.json +1 -1
|
@@ -15,6 +15,15 @@ export class VisionNavigator {
|
|
|
15
15
|
baseUrl;
|
|
16
16
|
maxPages;
|
|
17
17
|
visitedUrls = new Set();
|
|
18
|
+
normalizeUrl(url) {
|
|
19
|
+
try {
|
|
20
|
+
const u = new URL(url);
|
|
21
|
+
return u.origin + u.pathname.replace(/\/$/, "");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
18
27
|
explorationQueue = [];
|
|
19
28
|
pages = [];
|
|
20
29
|
screenshots = [];
|
|
@@ -79,9 +88,10 @@ export class VisionNavigator {
|
|
|
79
88
|
};
|
|
80
89
|
}
|
|
81
90
|
async explorePage(url, context, onEvent) {
|
|
82
|
-
|
|
91
|
+
const normalizedUrl = this.normalizeUrl(url);
|
|
92
|
+
if (this.visitedUrls.has(normalizedUrl))
|
|
83
93
|
return;
|
|
84
|
-
this.visitedUrls.add(
|
|
94
|
+
this.visitedUrls.add(normalizedUrl);
|
|
85
95
|
onEvent({ type: "page_start", url, message: url });
|
|
86
96
|
try {
|
|
87
97
|
await this.page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
@@ -118,7 +128,7 @@ export class VisionNavigator {
|
|
|
118
128
|
for (const element of highPriority) {
|
|
119
129
|
try {
|
|
120
130
|
const newUrl = await this.clickElement(element, pageMap, onEvent);
|
|
121
|
-
if (newUrl && !this.visitedUrls.has(newUrl)) {
|
|
131
|
+
if (newUrl && !this.visitedUrls.has(this.normalizeUrl(newUrl))) {
|
|
122
132
|
this.explorationQueue.push({
|
|
123
133
|
url: newUrl,
|
|
124
134
|
context: `Navigated from ${url} by clicking "${element.description}"`,
|
|
@@ -145,7 +155,7 @@ export class VisionNavigator {
|
|
|
145
155
|
}
|
|
146
156
|
});
|
|
147
157
|
for (const link of links) {
|
|
148
|
-
if (!this.visitedUrls.has(link)) {
|
|
158
|
+
if (!this.visitedUrls.has(this.normalizeUrl(link))) {
|
|
149
159
|
this.explorationQueue.push({ url: link, context: `Link found on ${url}` });
|
|
150
160
|
}
|
|
151
161
|
}
|
|
@@ -192,6 +202,11 @@ Analyse this screenshot and return ONLY valid JSON:
|
|
|
192
202
|
]
|
|
193
203
|
}
|
|
194
204
|
|
|
205
|
+
Already visited URLs — do NOT suggest clicking these as high priority:
|
|
206
|
+
${Array.from(this.visitedUrls).join("\n")}
|
|
207
|
+
|
|
208
|
+
If an element links to an already-visited URL, set its priority to 'low'.
|
|
209
|
+
|
|
195
210
|
Focus on:
|
|
196
211
|
- Navigation items and menu links (high priority)
|
|
197
212
|
- Primary action buttons (high priority)
|