explorbot 0.2.0 → 0.2.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/README.md +21 -5
- package/bin/explorbot-cli.ts +29 -7
- package/boat/api-tester/src/config.ts +45 -3
- package/boat/doc-collector/src/ai/documentarian.ts +8 -2
- package/boat/doc-collector/src/ai/tools.ts +29 -16
- package/boat/doc-collector/src/cli.ts +2 -6
- package/boat/doc-collector/src/config.ts +2 -0
- package/boat/doc-collector/src/docbot.ts +42 -14
- package/boat/doc-collector/src/interaction-screenshots.ts +160 -0
- package/boat/doc-collector/src/screenshots.ts +24 -16
- package/dist/bin/explorbot-cli.js +26 -6
- package/dist/boat/api-tester/src/config.js +43 -4
- package/dist/boat/doc-collector/src/ai/documentarian.js +7 -2
- package/dist/boat/doc-collector/src/ai/tools.js +21 -15
- package/dist/boat/doc-collector/src/cli.js +2 -5
- package/dist/boat/doc-collector/src/config.js +1 -0
- package/dist/boat/doc-collector/src/docbot.js +39 -13
- package/dist/boat/doc-collector/src/interaction-screenshots.js +156 -0
- package/dist/boat/doc-collector/src/screenshots.js +25 -16
- package/dist/models.json +30 -0
- package/dist/package.json +8 -2
- package/dist/src/action.d.ts +11 -3
- package/dist/src/action.js +22 -5
- package/dist/src/ai/agent.d.ts +17 -0
- package/dist/src/ai/captain/idle-mode.js +1 -1
- package/dist/src/ai/captain/test-mode.js +1 -1
- package/dist/src/ai/captain/web-mode.js +18 -22
- package/dist/src/ai/captain.js +13 -26
- package/dist/src/ai/driller.d.ts +2 -13
- package/dist/src/ai/driller.js +23 -38
- package/dist/src/ai/historian/codeceptjs.js +1 -1
- package/dist/src/ai/historian/playwright.d.ts +3 -2
- package/dist/src/ai/historian/playwright.js +1 -1
- package/dist/src/ai/historian/screencast.d.ts +2 -1
- package/dist/src/ai/historian/screencast.js +2 -2
- package/dist/src/ai/historian.d.ts +5 -4
- package/dist/src/ai/navigator.d.ts +6 -2
- package/dist/src/ai/navigator.js +26 -22
- package/dist/src/ai/pilot.d.ts +13 -6
- package/dist/src/ai/pilot.js +49 -44
- package/dist/src/ai/planner.d.ts +3 -2
- package/dist/src/ai/planner.js +19 -17
- package/dist/src/ai/provider.js +0 -1
- package/dist/src/ai/quartermaster.d.ts +3 -2
- package/dist/src/ai/quartermaster.js +4 -4
- package/dist/src/ai/rerunner.d.ts +2 -11
- package/dist/src/ai/rerunner.js +9 -22
- package/dist/src/ai/researcher/coordinates.js +4 -3
- package/dist/src/ai/researcher/deep-analysis.d.ts +2 -0
- package/dist/src/ai/researcher/deep-analysis.js +6 -6
- package/dist/src/ai/researcher/locators.d.ts +9 -2
- package/dist/src/ai/researcher/locators.js +65 -8
- package/dist/src/ai/researcher/sections.d.ts +2 -0
- package/dist/src/ai/researcher/sections.js +2 -2
- package/dist/src/ai/researcher.js +29 -54
- package/dist/src/ai/task-agent.d.ts +18 -5
- package/dist/src/ai/task-agent.js +35 -6
- package/dist/src/ai/tester.d.ts +6 -12
- package/dist/src/ai/tester.js +37 -51
- package/dist/src/ai/tools.d.ts +11 -10
- package/dist/src/ai/tools.js +24 -36
- package/dist/src/command-handler.js +1 -1
- package/dist/src/commands/context-aria-command.js +1 -1
- package/dist/src/commands/context-command.js +7 -5
- package/dist/src/commands/context-data-command.js +2 -2
- package/dist/src/commands/context-experience-command.js +2 -2
- package/dist/src/commands/context-html-command.js +2 -2
- package/dist/src/commands/context-knowledge-command.js +1 -1
- package/dist/src/commands/drill-command.js +1 -1
- package/dist/src/commands/explore-command.js +4 -3
- package/dist/src/commands/freesail-command.js +2 -2
- package/dist/src/commands/learn-command.js +4 -4
- package/dist/src/commands/path-command.js +1 -1
- package/dist/src/commands/research-command.js +1 -1
- package/dist/src/commands/test-command.js +1 -1
- package/dist/src/components/App.js +1 -1
- package/dist/src/config.d.ts +17 -0
- package/dist/src/config.js +144 -10
- package/dist/src/experience-tracker.js +1 -1
- package/dist/src/explorbot.d.ts +17 -8
- package/dist/src/explorbot.js +74 -36
- package/dist/src/explorer.d.ts +67 -91
- package/dist/src/explorer.js +327 -567
- package/dist/src/state-manager.d.ts +6 -1
- package/dist/src/state-manager.js +1 -0
- package/dist/src/utils/hooks-runner.js +2 -4
- package/dist/src/utils/test-files.js +1 -1
- package/dist/src/utils/web-annotate.d.ts +5 -0
- package/dist/src/utils/web-annotate.js +58 -0
- package/dist/src/utils/web-eidx.d.ts +2 -0
- package/dist/src/utils/web-eidx.js +20 -0
- package/dist/src/utils/web-element.d.ts +1 -0
- package/dist/src/utils/web-element.js +29 -0
- package/models.json +30 -0
- package/package.json +8 -2
- package/src/action.ts +25 -5
- package/src/ai/agent.ts +20 -0
- package/src/ai/captain/idle-mode.ts +1 -1
- package/src/ai/captain/test-mode.ts +1 -1
- package/src/ai/captain/web-mode.ts +18 -23
- package/src/ai/captain.ts +12 -25
- package/src/ai/driller.ts +50 -67
- package/src/ai/historian/codeceptjs.ts +1 -1
- package/src/ai/historian/playwright.ts +4 -3
- package/src/ai/historian/screencast.ts +4 -3
- package/src/ai/historian.ts +3 -2
- package/src/ai/navigator.ts +30 -25
- package/src/ai/pilot.ts +55 -47
- package/src/ai/planner.ts +22 -20
- package/src/ai/provider.ts +0 -1
- package/src/ai/quartermaster.ts +5 -4
- package/src/ai/rerunner.ts +10 -29
- package/src/ai/researcher/coordinates.ts +4 -3
- package/src/ai/researcher/deep-analysis.ts +8 -6
- package/src/ai/researcher/locators.ts +66 -9
- package/src/ai/researcher/sections.ts +4 -2
- package/src/ai/researcher.ts +32 -61
- package/src/ai/task-agent.ts +45 -11
- package/src/ai/tester.ts +40 -57
- package/src/ai/tools.ts +32 -53
- package/src/command-handler.ts +1 -1
- package/src/commands/context-aria-command.ts +1 -1
- package/src/commands/context-command.ts +7 -5
- package/src/commands/context-data-command.ts +2 -2
- package/src/commands/context-experience-command.ts +2 -2
- package/src/commands/context-html-command.ts +2 -2
- package/src/commands/context-knowledge-command.ts +1 -1
- package/src/commands/drill-command.ts +1 -1
- package/src/commands/explore-command.ts +4 -3
- package/src/commands/freesail-command.ts +2 -2
- package/src/commands/learn-command.ts +4 -4
- package/src/commands/path-command.ts +1 -1
- package/src/commands/research-command.ts +1 -1
- package/src/commands/test-command.ts +1 -1
- package/src/components/App.tsx +1 -1
- package/src/config.ts +173 -11
- package/src/experience-tracker.ts +1 -1
- package/src/explorbot.ts +78 -39
- package/src/explorer.ts +388 -626
- package/src/state-manager.ts +7 -1
- package/src/utils/hooks-runner.ts +2 -4
- package/src/utils/test-files.ts +1 -1
- package/src/utils/web-annotate.ts +64 -0
- package/src/utils/web-eidx.ts +21 -0
- package/src/utils/web-element.ts +30 -0
package/dist/src/explorbot.js
CHANGED
|
@@ -22,6 +22,9 @@ import { ConfigParser } from "./config.js";
|
|
|
22
22
|
import { ExperienceTracker } from "./experience-tracker.js";
|
|
23
23
|
import Explorer from "./explorer.js";
|
|
24
24
|
import { KnowledgeTracker } from "./knowledge-tracker.js";
|
|
25
|
+
import { PlaywrightRecorder } from "./playwright-recorder.js";
|
|
26
|
+
import { Reporter } from "./reporter.js";
|
|
27
|
+
import { StateManager } from "./state-manager.js";
|
|
25
28
|
import { Stats } from "./stats.js";
|
|
26
29
|
import { Plan } from "./test-plan.js";
|
|
27
30
|
import { browserErrorMessage } from "./utils/browser-errors.js";
|
|
@@ -45,6 +48,10 @@ export class ExplorBot {
|
|
|
45
48
|
lastReportedTestCount = 0;
|
|
46
49
|
_experienceTracker;
|
|
47
50
|
_knowledgeTracker;
|
|
51
|
+
_stateManager;
|
|
52
|
+
_reporter;
|
|
53
|
+
_requestStore;
|
|
54
|
+
_playwrightRecorder;
|
|
48
55
|
constructor(options = {}) {
|
|
49
56
|
this.options = options;
|
|
50
57
|
this.configParser = ConfigParser.getInstance();
|
|
@@ -54,18 +61,25 @@ export class ExplorBot {
|
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
get isExploring() {
|
|
57
|
-
return this.explorer
|
|
64
|
+
return !!this.explorer;
|
|
58
65
|
}
|
|
59
66
|
setUserResolve(fn) {
|
|
60
67
|
this.userResolveFn = fn;
|
|
61
68
|
}
|
|
62
69
|
async start() {
|
|
63
|
-
if (this.explorer
|
|
70
|
+
if (this.explorer) {
|
|
64
71
|
return;
|
|
65
72
|
}
|
|
66
73
|
try {
|
|
67
74
|
await this.startProviderOnly();
|
|
68
|
-
|
|
75
|
+
const explorerOptions = { ...this.options, session: typeof this.options.session === 'string' ? this.options.session : undefined };
|
|
76
|
+
this.explorer = new Explorer(this.config, explorerOptions, {
|
|
77
|
+
stateManager: this.stateManager(),
|
|
78
|
+
knowledgeTracker: this.knowledgeTracker(),
|
|
79
|
+
reporter: this.reporter(),
|
|
80
|
+
requestStore: this.requestStore(),
|
|
81
|
+
playwrightRecorder: this.playwrightRecorder(),
|
|
82
|
+
});
|
|
69
83
|
await this.explorer.start();
|
|
70
84
|
if (!this.options.incognito) {
|
|
71
85
|
await this.agentExperienceCompactor().autocompact();
|
|
@@ -81,6 +95,8 @@ export class ExplorBot {
|
|
|
81
95
|
if (this.provider)
|
|
82
96
|
return;
|
|
83
97
|
this.config = await this.configParser.loadConfig(this.options);
|
|
98
|
+
if (this.options.session === true)
|
|
99
|
+
this.options.session = path.join(this.configParser.getOutputDir(), 'session.json');
|
|
84
100
|
this.provider = new AIProvider(this.config.ai);
|
|
85
101
|
await this.provider.validateConnection();
|
|
86
102
|
}
|
|
@@ -95,11 +111,11 @@ export class ExplorBot {
|
|
|
95
111
|
async visit(url) {
|
|
96
112
|
return this.agentNavigator().visit(url);
|
|
97
113
|
}
|
|
98
|
-
async
|
|
99
|
-
await this.explorer.
|
|
114
|
+
async openTab() {
|
|
115
|
+
await this.explorer.openTab();
|
|
100
116
|
}
|
|
101
117
|
getCurrentState() {
|
|
102
|
-
return this.
|
|
118
|
+
return this._stateManager?.getCurrentState() ?? null;
|
|
103
119
|
}
|
|
104
120
|
getExplorer() {
|
|
105
121
|
return this.explorer;
|
|
@@ -110,6 +126,18 @@ export class ExplorBot {
|
|
|
110
126
|
experienceTracker() {
|
|
111
127
|
return (this._experienceTracker ||= new ExperienceTracker(this.knowledgeTracker()));
|
|
112
128
|
}
|
|
129
|
+
stateManager() {
|
|
130
|
+
return (this._stateManager ||= new StateManager(this.experienceTracker(), this.knowledgeTracker()));
|
|
131
|
+
}
|
|
132
|
+
reporter() {
|
|
133
|
+
return (this._reporter ||= new Reporter(this.config.reporter, this.stateManager()));
|
|
134
|
+
}
|
|
135
|
+
requestStore() {
|
|
136
|
+
return (this._requestStore ||= new RequestStore(this.configParser.getOutputDir()));
|
|
137
|
+
}
|
|
138
|
+
playwrightRecorder() {
|
|
139
|
+
return (this._playwrightRecorder ||= new PlaywrightRecorder());
|
|
140
|
+
}
|
|
113
141
|
getConfig() {
|
|
114
142
|
return this.config;
|
|
115
143
|
}
|
|
@@ -124,22 +152,24 @@ export class ExplorBot {
|
|
|
124
152
|
explorer: this.explorer,
|
|
125
153
|
ai: this.provider,
|
|
126
154
|
config: this.config,
|
|
155
|
+
stateManager: this.stateManager(),
|
|
156
|
+
knowledgeTracker: this.knowledgeTracker(),
|
|
157
|
+
requestStore: this.requestStore(),
|
|
158
|
+
playwrightRecorder: this.playwrightRecorder(),
|
|
127
159
|
});
|
|
128
160
|
const agentName = agent.constructor.name.toLowerCase();
|
|
129
161
|
tag('debug').log(`Created ${agentName} agent`);
|
|
130
162
|
return agent;
|
|
131
163
|
}
|
|
132
164
|
agentResearcher() {
|
|
133
|
-
return (this.agents.researcher ||= this.createAgent((
|
|
165
|
+
return (this.agents.researcher ||= this.createAgent((deps) => new Researcher(deps)));
|
|
134
166
|
}
|
|
135
167
|
agentNavigator() {
|
|
136
|
-
return (this.agents.navigator ||= this.createAgent((
|
|
137
|
-
return new Navigator(explorer, ai);
|
|
138
|
-
}));
|
|
168
|
+
return (this.agents.navigator ||= this.createAgent((deps) => new Navigator(deps)));
|
|
139
169
|
}
|
|
140
170
|
agentPlanner() {
|
|
141
171
|
if (!this.agents.planner) {
|
|
142
|
-
this.agents.planner = this.createAgent((
|
|
172
|
+
this.agents.planner = this.createAgent((deps) => new Planner(deps, this.agentResearcher()));
|
|
143
173
|
const fisherman = this.agentFisherman();
|
|
144
174
|
if (fisherman)
|
|
145
175
|
this.agents.planner.setFisherman(fisherman);
|
|
@@ -147,25 +177,26 @@ export class ExplorBot {
|
|
|
147
177
|
return this.agents.planner;
|
|
148
178
|
}
|
|
149
179
|
agentPilot() {
|
|
150
|
-
return (this.agents.pilot ||= this.createAgent((
|
|
180
|
+
return (this.agents.pilot ||= this.createAgent((deps) => {
|
|
151
181
|
const researcher = this.agentResearcher();
|
|
152
182
|
const navigator = this.agentNavigator();
|
|
153
|
-
const tools = createAgentTools({
|
|
154
|
-
return new Pilot(
|
|
183
|
+
const tools = createAgentTools({ ...deps, researcher, navigator, supervisor: true });
|
|
184
|
+
return new Pilot(deps, tools, researcher);
|
|
155
185
|
}));
|
|
156
186
|
}
|
|
157
187
|
agentTester() {
|
|
158
188
|
if (!this.agents.tester) {
|
|
159
|
-
this.agents.tester = this.createAgent((
|
|
189
|
+
this.agents.tester = this.createAgent((deps) => {
|
|
160
190
|
const researcher = this.agentResearcher();
|
|
161
191
|
const navigator = this.agentNavigator();
|
|
162
|
-
const tools = createAgentTools({
|
|
163
|
-
return new Tester(
|
|
192
|
+
const tools = createAgentTools({ ...deps, researcher, navigator });
|
|
193
|
+
return new Tester(deps, researcher, navigator, tools);
|
|
164
194
|
});
|
|
165
195
|
const qm = this.agentQuartermaster();
|
|
166
196
|
if (qm)
|
|
167
197
|
this.agents.tester.setQuartermaster(qm);
|
|
168
|
-
|
|
198
|
+
if (this.isHistorianEnabled())
|
|
199
|
+
this.agents.tester.setHistorian(this.agentHistorian());
|
|
169
200
|
this.agents.tester.setPilot(this.agentPilot());
|
|
170
201
|
this.agents.tester.setCaptain(this.agentCaptain());
|
|
171
202
|
const fisherman = this.agentFisherman();
|
|
@@ -191,36 +222,35 @@ export class ExplorBot {
|
|
|
191
222
|
this.agents.quartermaster = new Quartermaster(this.provider, {
|
|
192
223
|
model: config?.model,
|
|
193
224
|
});
|
|
194
|
-
this.agents.quartermaster.start(this.explorer
|
|
225
|
+
this.agents.quartermaster.start(this.explorer, this.stateManager());
|
|
195
226
|
}
|
|
196
227
|
return this.agents.quartermaster;
|
|
197
228
|
}
|
|
198
229
|
agentHistorian() {
|
|
199
|
-
return (this.agents.historian ||= this.createAgent(({ ai, explorer, config }) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
recorder: explorer.getPlaywrightRecorder(),
|
|
204
|
-
helper: explorer.playwrightHelper,
|
|
230
|
+
return (this.agents.historian ||= this.createAgent(({ ai, explorer, config, stateManager, playwrightRecorder }) => {
|
|
231
|
+
return new Historian(ai, this.experienceTracker(), this.reporter(), stateManager, config, {
|
|
232
|
+
recorder: playwrightRecorder,
|
|
233
|
+
explorer,
|
|
205
234
|
});
|
|
206
235
|
}));
|
|
207
236
|
}
|
|
208
237
|
agentRerunner() {
|
|
209
238
|
if (!this.agents.rerunner) {
|
|
210
|
-
this.agents.rerunner = this.createAgent((
|
|
239
|
+
this.agents.rerunner = this.createAgent((deps) => {
|
|
211
240
|
const researcher = this.agentResearcher();
|
|
212
241
|
const navigator = this.agentNavigator();
|
|
213
|
-
const tools = createAgentTools({
|
|
214
|
-
return new Rerunner(
|
|
242
|
+
const tools = createAgentTools({ ...deps, researcher, navigator, withExperience: false });
|
|
243
|
+
return new Rerunner(deps, tools);
|
|
215
244
|
});
|
|
216
|
-
|
|
245
|
+
if (this.isHistorianEnabled())
|
|
246
|
+
this.agents.rerunner.setHistorian(this.agentHistorian());
|
|
217
247
|
}
|
|
218
248
|
return this.agents.rerunner;
|
|
219
249
|
}
|
|
220
250
|
agentDriller() {
|
|
221
|
-
return (this.agents.driller ||= this.createAgent((
|
|
251
|
+
return (this.agents.driller ||= this.createAgent((deps) => {
|
|
222
252
|
const navigator = this.agentNavigator();
|
|
223
|
-
return new Driller(
|
|
253
|
+
return new Driller(deps, navigator);
|
|
224
254
|
}));
|
|
225
255
|
}
|
|
226
256
|
agentSessionAnalyst() {
|
|
@@ -234,7 +264,7 @@ export class ExplorBot {
|
|
|
234
264
|
if (!this.agents.fisherman) {
|
|
235
265
|
const apiConfig = this.config.api;
|
|
236
266
|
const outputDir = this.configParser.getOutputDir();
|
|
237
|
-
const requestStore = this.
|
|
267
|
+
const requestStore = this.requestStore();
|
|
238
268
|
const baseEndpoint = apiConfig?.baseEndpoint || this.config.playwright.url;
|
|
239
269
|
const configHeaders = apiConfig?.headers || {};
|
|
240
270
|
const apiClient = new ApiClient(baseEndpoint);
|
|
@@ -249,7 +279,12 @@ export class ExplorBot {
|
|
|
249
279
|
return null;
|
|
250
280
|
}
|
|
251
281
|
};
|
|
252
|
-
const cookieProvider = () =>
|
|
282
|
+
const cookieProvider = async () => {
|
|
283
|
+
const cookies = await this.explorer.withPage((page) => page.context().cookies()).catch(() => []);
|
|
284
|
+
if (!cookies.length)
|
|
285
|
+
return {};
|
|
286
|
+
return { Cookie: cookies.map((c) => `${c.name}=${c.value}`).join('; ') };
|
|
287
|
+
};
|
|
253
288
|
this.agents.fisherman = this.createAgent(({ ai }) => {
|
|
254
289
|
return new Fisherman(ai, apiClient, requestStore, specLoader, baseEndpoint, cookieProvider, configHeaders, hasApiConfig);
|
|
255
290
|
});
|
|
@@ -275,7 +310,7 @@ export class ExplorBot {
|
|
|
275
310
|
this.clearPlan();
|
|
276
311
|
}
|
|
277
312
|
if (!opts.extend && this.currentPlan?.url) {
|
|
278
|
-
const currentUrl = this.
|
|
313
|
+
const currentUrl = this._stateManager?.getCurrentState()?.url;
|
|
279
314
|
if (currentUrl && currentUrl !== this.currentPlan.url) {
|
|
280
315
|
tag('info').log('Different page detected, clearing previous plan');
|
|
281
316
|
this.clearPlan();
|
|
@@ -324,7 +359,7 @@ export class ExplorBot {
|
|
|
324
359
|
return planPath;
|
|
325
360
|
}
|
|
326
361
|
generatePlanFilename(feature) {
|
|
327
|
-
const state = this.
|
|
362
|
+
const state = this._stateManager?.getCurrentState();
|
|
328
363
|
const urlPath = state?.url || '/';
|
|
329
364
|
const urlPart = sanitizeFilename(urlPath) || 'root';
|
|
330
365
|
const suffix = '.md';
|
|
@@ -398,7 +433,7 @@ export class ExplorBot {
|
|
|
398
433
|
tag('multiline').log(markdown, { maxLines: 22 });
|
|
399
434
|
const filePath = this.agentSessionAnalyst().writeReport(markdown);
|
|
400
435
|
tag('info').log(`Session report saved: ${relativeToCwd(filePath)}`);
|
|
401
|
-
const reporter = this.
|
|
436
|
+
const reporter = this._reporter;
|
|
402
437
|
if (reporter?.isEnabled()) {
|
|
403
438
|
let description = markdown;
|
|
404
439
|
const modelsTable = Stats.modelsTable(this.provider.getConfiguredModels());
|
|
@@ -413,4 +448,7 @@ export class ExplorBot {
|
|
|
413
448
|
tag('warning').log(`Session analysis failed: ${message}`);
|
|
414
449
|
}
|
|
415
450
|
}
|
|
451
|
+
isHistorianEnabled() {
|
|
452
|
+
return this.config.ai?.agents?.historian?.enabled !== false;
|
|
453
|
+
}
|
|
416
454
|
}
|
package/dist/src/explorer.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type { BrowserContextOptions } from 'playwright';
|
|
1
|
+
import type { BrowserContextOptions, Page } from 'playwright';
|
|
2
2
|
import { ActionResult } from './action-result.js';
|
|
3
3
|
import Action from './action.js';
|
|
4
|
-
import {
|
|
5
|
-
import { RequestStore } from './api/request-store.js';
|
|
4
|
+
import type { RequestStore } from './api/request-store.js';
|
|
6
5
|
import { XhrCapture } from './api/xhr-capture.js';
|
|
7
6
|
import type { ExplorbotConfig } from './config.js';
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { StateManager } from './state-manager.js';
|
|
7
|
+
import type { KnowledgeTracker } from './knowledge-tracker.js';
|
|
8
|
+
import type { PlaywrightRecorder } from './playwright-recorder.js';
|
|
9
|
+
import type { Reporter } from './reporter.js';
|
|
10
|
+
import type { StateManager } from './state-manager.js';
|
|
13
11
|
import { Test } from './test-plan.js';
|
|
14
|
-
import { WebElement } from './utils/web-element.js';
|
|
15
12
|
declare global {
|
|
16
13
|
namespace NodeJS {
|
|
17
14
|
interface Global {
|
|
@@ -24,106 +21,85 @@ declare namespace CodeceptJS {
|
|
|
24
21
|
[key: string]: any;
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
interface TabInfo {
|
|
28
|
-
url: string;
|
|
29
|
-
title: string;
|
|
30
|
-
}
|
|
31
|
-
interface BrowserExecutionErrorResult {
|
|
32
|
-
action: 'continue' | 'stop';
|
|
33
|
-
message: string;
|
|
34
|
-
recovered?: boolean;
|
|
35
|
-
}
|
|
36
24
|
declare class Explorer {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
isStarted: boolean;
|
|
40
|
-
isSharedBrowser: boolean;
|
|
41
|
-
actor: CodeceptJS.I;
|
|
25
|
+
config: ExplorbotConfig;
|
|
26
|
+
options?: ExplorerOptions;
|
|
42
27
|
stateManager: StateManager;
|
|
43
28
|
knowledgeTracker: KnowledgeTracker;
|
|
44
|
-
config: ExplorbotConfig;
|
|
45
|
-
options?: {
|
|
46
|
-
show?: boolean;
|
|
47
|
-
headless?: boolean;
|
|
48
|
-
incognito?: boolean;
|
|
49
|
-
session?: string;
|
|
50
|
-
};
|
|
51
29
|
reporter: Reporter;
|
|
52
|
-
|
|
53
|
-
_activeTest: Test | null;
|
|
54
|
-
xhrCapture: XhrCapture | null;
|
|
55
|
-
requestStore: RequestStore | null;
|
|
30
|
+
requestStore: RequestStore;
|
|
56
31
|
playwrightRecorder: PlaywrightRecorder;
|
|
32
|
+
playwrightHelper: any;
|
|
33
|
+
_actor: CodeceptJS.I;
|
|
34
|
+
started: boolean;
|
|
35
|
+
isSharedBrowser: boolean;
|
|
36
|
+
xhrCapture: XhrCapture | null;
|
|
37
|
+
_activeTest: Test | null;
|
|
57
38
|
observedTestPages: Set<any>;
|
|
58
39
|
testPageErrorHandler: ((error: Error) => void) | null;
|
|
59
40
|
testConsoleHandler: ((message: any) => void) | null;
|
|
60
41
|
testDialogHandler: ((dialog: any) => void) | null;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
eventDispatcher: any;
|
|
43
|
+
constructor(config: ExplorbotConfig, options: ExplorerOptions | undefined, deps: ExplorerDeps);
|
|
44
|
+
get actor(): CodeceptJS.I;
|
|
45
|
+
get page(): Page | null;
|
|
46
|
+
get activeTest(): Test | null;
|
|
47
|
+
start(): Promise<void>;
|
|
48
|
+
stop(): Promise<void>;
|
|
49
|
+
action(): Action;
|
|
50
|
+
visit(url: string, opts?: CaptureOpts): Promise<ActionResult>;
|
|
51
|
+
capture(opts?: CaptureOpts): Promise<ActionResult>;
|
|
52
|
+
withPage<T>(fn: (page: Page) => Promise<T>): Promise<T>;
|
|
53
|
+
recover(error?: unknown): Promise<Recovery>;
|
|
54
|
+
beginTest(test: Test): Promise<TestRun>;
|
|
55
|
+
openTab(): Promise<void>;
|
|
67
56
|
initializeContainer(): void;
|
|
68
57
|
convertToCodeceptConfig(config: ExplorbotConfig): any;
|
|
69
|
-
getConfig(): ExplorbotConfig;
|
|
70
|
-
getAIProvider(): AIProvider;
|
|
71
|
-
getStateManager(): StateManager;
|
|
72
|
-
getKnowledgeTracker(): KnowledgeTracker;
|
|
73
|
-
getReporter(): Reporter;
|
|
74
|
-
getRequestStore(): RequestStore | null;
|
|
75
|
-
extractCookies(): Promise<Record<string, string>>;
|
|
76
|
-
setupXhrCapture(reuseRequestStore?: boolean): void;
|
|
77
|
-
start(): Promise<any>;
|
|
78
58
|
connectOrLaunchBrowser(): Promise<void>;
|
|
79
59
|
createBrowserContextOptions(): BrowserContextOptions;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
capturePageState(opts?: {
|
|
83
|
-
includeScreenshot?: boolean;
|
|
84
|
-
}): Promise<ActionResult>;
|
|
85
|
-
capturePageWithScreenshot(): Promise<ActionResult>;
|
|
86
|
-
executeAction(code: string): Promise<Action>;
|
|
87
|
-
attemptAction(code: string, originalMessage?: string): Promise<boolean>;
|
|
88
|
-
getPlaywrightRecorder(): PlaywrightRecorder;
|
|
89
|
-
visit(url: string): Promise<Action>;
|
|
60
|
+
attachXhrCapture(): void;
|
|
61
|
+
runWithRecovery<T>(label: string, operation: () => Promise<T>): Promise<T>;
|
|
90
62
|
visitOnce(url: string): Promise<Action>;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}): Promise<number>;
|
|
98
|
-
getEidxInContainer(containerCss: string | null): Promise<string[]>;
|
|
99
|
-
getEidxByLocator(locator: string, container?: string | null): Promise<string | null>;
|
|
100
|
-
resolveBrowserUrl(url?: string): string | null;
|
|
101
|
-
isFatalBrowserError(error: unknown): boolean;
|
|
102
|
-
recoverFromBrowserError(): Promise<boolean>;
|
|
63
|
+
recoverFromExecutionError(error: unknown): Promise<Recovery>;
|
|
64
|
+
recoverOrRestart(): Promise<boolean>;
|
|
65
|
+
recoverPage(): Promise<boolean>;
|
|
66
|
+
activateNewPage(context: any): Promise<void>;
|
|
67
|
+
stopCaptures(): Promise<void>;
|
|
68
|
+
closeBrowserContext(): Promise<void>;
|
|
103
69
|
restartBrowser(): Promise<boolean>;
|
|
104
|
-
|
|
70
|
+
resolveBrowserUrl(url?: string): string | null;
|
|
105
71
|
waitForPageReadiness(): Promise<boolean>;
|
|
106
|
-
isInsideIframe(): Promise<boolean>;
|
|
107
|
-
getCurrentIframeInfo(): string | null;
|
|
108
|
-
hasOtherTabs(): boolean;
|
|
109
|
-
getOtherTabsInfo(): TabInfo[];
|
|
110
|
-
clearOtherTabsInfo(): void;
|
|
111
72
|
listenToStateChanged(): void;
|
|
112
|
-
stop(): Promise<void>;
|
|
113
|
-
get activeTest(): Test | null;
|
|
114
|
-
startTest(test: Test): Promise<boolean>;
|
|
115
|
-
ensurePageAvailable(): Promise<boolean>;
|
|
116
|
-
handleExecutionError(error: unknown): Promise<BrowserExecutionErrorResult>;
|
|
117
|
-
watchActiveTestPage(page?: any): void;
|
|
118
|
-
stopTest(test: Test, meta?: Record<string, string>): Promise<void>;
|
|
119
|
-
unwatchActiveTestPages(): void;
|
|
120
|
-
playwrightLocatorCount(locatorFn: (page: any) => any): Promise<number>;
|
|
121
73
|
bindFrameNavigated(page: any): void;
|
|
122
|
-
openFreshTab(): Promise<void>;
|
|
123
74
|
closeOtherTabs(): Promise<void>;
|
|
75
|
+
finishTest(test: Test, meta?: Record<string, string>): Promise<void>;
|
|
76
|
+
watchActiveTestPage(page?: any): void;
|
|
77
|
+
unwatchActiveTestPages(): void;
|
|
78
|
+
}
|
|
79
|
+
export interface ExplorerOptions {
|
|
80
|
+
show?: boolean;
|
|
81
|
+
headless?: boolean;
|
|
82
|
+
incognito?: boolean;
|
|
83
|
+
session?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ExplorerDeps {
|
|
86
|
+
stateManager: StateManager;
|
|
87
|
+
knowledgeTracker: KnowledgeTracker;
|
|
88
|
+
reporter: Reporter;
|
|
89
|
+
requestStore: RequestStore;
|
|
90
|
+
playwrightRecorder: PlaywrightRecorder;
|
|
91
|
+
}
|
|
92
|
+
export interface Recovery {
|
|
93
|
+
ok: boolean;
|
|
94
|
+
action: 'continue' | 'stop';
|
|
95
|
+
message: string;
|
|
96
|
+
recovered?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface TestRun {
|
|
99
|
+
started: boolean;
|
|
100
|
+
stop(meta?: Record<string, string>): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
export interface CaptureOpts {
|
|
103
|
+
screenshot?: boolean;
|
|
124
104
|
}
|
|
125
|
-
export declare function annotatePageElements(page: any): Promise<{
|
|
126
|
-
ariaSnapshot: string;
|
|
127
|
-
elements: WebElement[];
|
|
128
|
-
}>;
|
|
129
105
|
export default Explorer;
|