explorbot 0.2.0 → 0.2.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 (141) hide show
  1. package/README.md +21 -5
  2. package/bin/explorbot-cli.ts +29 -7
  3. package/boat/api-tester/src/config.ts +45 -3
  4. package/boat/doc-collector/src/ai/documentarian.ts +5 -2
  5. package/boat/doc-collector/src/ai/tools.ts +12 -11
  6. package/boat/doc-collector/src/cli.ts +1 -6
  7. package/boat/doc-collector/src/docbot.ts +3 -3
  8. package/boat/doc-collector/src/screenshots.ts +2 -2
  9. package/dist/bin/explorbot-cli.js +26 -6
  10. package/dist/boat/api-tester/src/config.js +43 -4
  11. package/dist/boat/doc-collector/src/ai/documentarian.js +4 -2
  12. package/dist/boat/doc-collector/src/ai/tools.js +11 -11
  13. package/dist/boat/doc-collector/src/cli.js +1 -5
  14. package/dist/boat/doc-collector/src/docbot.js +3 -3
  15. package/dist/boat/doc-collector/src/screenshots.js +2 -2
  16. package/dist/models.json +30 -0
  17. package/dist/package.json +5 -2
  18. package/dist/src/action.d.ts +11 -3
  19. package/dist/src/action.js +22 -5
  20. package/dist/src/ai/agent.d.ts +17 -0
  21. package/dist/src/ai/captain/idle-mode.js +1 -1
  22. package/dist/src/ai/captain/test-mode.js +1 -1
  23. package/dist/src/ai/captain/web-mode.js +18 -22
  24. package/dist/src/ai/captain.js +13 -26
  25. package/dist/src/ai/driller.d.ts +2 -13
  26. package/dist/src/ai/driller.js +23 -38
  27. package/dist/src/ai/historian/codeceptjs.js +1 -1
  28. package/dist/src/ai/historian/playwright.d.ts +3 -2
  29. package/dist/src/ai/historian/playwright.js +1 -1
  30. package/dist/src/ai/historian/screencast.d.ts +2 -1
  31. package/dist/src/ai/historian/screencast.js +2 -2
  32. package/dist/src/ai/historian.d.ts +5 -4
  33. package/dist/src/ai/navigator.d.ts +6 -2
  34. package/dist/src/ai/navigator.js +26 -22
  35. package/dist/src/ai/pilot.d.ts +13 -6
  36. package/dist/src/ai/pilot.js +49 -44
  37. package/dist/src/ai/planner.d.ts +3 -2
  38. package/dist/src/ai/planner.js +19 -17
  39. package/dist/src/ai/provider.js +0 -1
  40. package/dist/src/ai/quartermaster.d.ts +3 -2
  41. package/dist/src/ai/quartermaster.js +4 -4
  42. package/dist/src/ai/rerunner.d.ts +2 -11
  43. package/dist/src/ai/rerunner.js +9 -22
  44. package/dist/src/ai/researcher/coordinates.js +4 -3
  45. package/dist/src/ai/researcher/deep-analysis.d.ts +2 -0
  46. package/dist/src/ai/researcher/deep-analysis.js +6 -6
  47. package/dist/src/ai/researcher/locators.d.ts +9 -2
  48. package/dist/src/ai/researcher/locators.js +65 -8
  49. package/dist/src/ai/researcher/sections.d.ts +2 -0
  50. package/dist/src/ai/researcher/sections.js +2 -2
  51. package/dist/src/ai/researcher.js +29 -54
  52. package/dist/src/ai/task-agent.d.ts +18 -5
  53. package/dist/src/ai/task-agent.js +35 -6
  54. package/dist/src/ai/tester.d.ts +6 -12
  55. package/dist/src/ai/tester.js +37 -51
  56. package/dist/src/ai/tools.d.ts +11 -10
  57. package/dist/src/ai/tools.js +24 -36
  58. package/dist/src/command-handler.js +1 -1
  59. package/dist/src/commands/context-aria-command.js +1 -1
  60. package/dist/src/commands/context-command.js +7 -5
  61. package/dist/src/commands/context-data-command.js +2 -2
  62. package/dist/src/commands/context-experience-command.js +2 -2
  63. package/dist/src/commands/context-html-command.js +2 -2
  64. package/dist/src/commands/context-knowledge-command.js +1 -1
  65. package/dist/src/commands/drill-command.js +1 -1
  66. package/dist/src/commands/explore-command.js +4 -3
  67. package/dist/src/commands/freesail-command.js +2 -2
  68. package/dist/src/commands/learn-command.js +4 -4
  69. package/dist/src/commands/path-command.js +1 -1
  70. package/dist/src/commands/research-command.js +1 -1
  71. package/dist/src/commands/test-command.js +1 -1
  72. package/dist/src/components/App.js +1 -1
  73. package/dist/src/config.d.ts +17 -0
  74. package/dist/src/config.js +144 -10
  75. package/dist/src/experience-tracker.js +1 -1
  76. package/dist/src/explorbot.d.ts +17 -8
  77. package/dist/src/explorbot.js +74 -36
  78. package/dist/src/explorer.d.ts +66 -91
  79. package/dist/src/explorer.js +326 -567
  80. package/dist/src/state-manager.d.ts +6 -1
  81. package/dist/src/state-manager.js +1 -0
  82. package/dist/src/utils/hooks-runner.js +2 -4
  83. package/dist/src/utils/test-files.js +1 -1
  84. package/dist/src/utils/web-annotate.d.ts +5 -0
  85. package/dist/src/utils/web-annotate.js +58 -0
  86. package/dist/src/utils/web-eidx.d.ts +2 -0
  87. package/dist/src/utils/web-eidx.js +20 -0
  88. package/dist/src/utils/web-element.d.ts +1 -0
  89. package/dist/src/utils/web-element.js +29 -0
  90. package/models.json +30 -0
  91. package/package.json +5 -2
  92. package/src/action.ts +25 -5
  93. package/src/ai/agent.ts +20 -0
  94. package/src/ai/captain/idle-mode.ts +1 -1
  95. package/src/ai/captain/test-mode.ts +1 -1
  96. package/src/ai/captain/web-mode.ts +18 -23
  97. package/src/ai/captain.ts +12 -25
  98. package/src/ai/driller.ts +50 -67
  99. package/src/ai/historian/codeceptjs.ts +1 -1
  100. package/src/ai/historian/playwright.ts +4 -3
  101. package/src/ai/historian/screencast.ts +4 -3
  102. package/src/ai/historian.ts +3 -2
  103. package/src/ai/navigator.ts +30 -25
  104. package/src/ai/pilot.ts +55 -47
  105. package/src/ai/planner.ts +22 -20
  106. package/src/ai/provider.ts +0 -1
  107. package/src/ai/quartermaster.ts +5 -4
  108. package/src/ai/rerunner.ts +10 -29
  109. package/src/ai/researcher/coordinates.ts +4 -3
  110. package/src/ai/researcher/deep-analysis.ts +8 -6
  111. package/src/ai/researcher/locators.ts +66 -9
  112. package/src/ai/researcher/sections.ts +4 -2
  113. package/src/ai/researcher.ts +32 -61
  114. package/src/ai/task-agent.ts +45 -11
  115. package/src/ai/tester.ts +40 -57
  116. package/src/ai/tools.ts +32 -53
  117. package/src/command-handler.ts +1 -1
  118. package/src/commands/context-aria-command.ts +1 -1
  119. package/src/commands/context-command.ts +7 -5
  120. package/src/commands/context-data-command.ts +2 -2
  121. package/src/commands/context-experience-command.ts +2 -2
  122. package/src/commands/context-html-command.ts +2 -2
  123. package/src/commands/context-knowledge-command.ts +1 -1
  124. package/src/commands/drill-command.ts +1 -1
  125. package/src/commands/explore-command.ts +4 -3
  126. package/src/commands/freesail-command.ts +2 -2
  127. package/src/commands/learn-command.ts +4 -4
  128. package/src/commands/path-command.ts +1 -1
  129. package/src/commands/research-command.ts +1 -1
  130. package/src/commands/test-command.ts +1 -1
  131. package/src/components/App.tsx +1 -1
  132. package/src/config.ts +173 -11
  133. package/src/experience-tracker.ts +1 -1
  134. package/src/explorbot.ts +78 -39
  135. package/src/explorer.ts +389 -628
  136. package/src/state-manager.ts +7 -1
  137. package/src/utils/hooks-runner.ts +2 -4
  138. package/src/utils/test-files.ts +1 -1
  139. package/src/utils/web-annotate.ts +64 -0
  140. package/src/utils/web-eidx.ts +21 -0
  141. package/src/utils/web-element.ts +30 -0
@@ -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?.isStarted;
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?.isStarted) {
70
+ if (this.explorer) {
64
71
  return;
65
72
  }
66
73
  try {
67
74
  await this.startProviderOnly();
68
- this.explorer = new Explorer(this.config, this.provider, this.options, this.experienceTracker(), this.knowledgeTracker());
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 openFreshTab() {
99
- await this.explorer.openFreshTab();
114
+ async openTab() {
115
+ await this.explorer.openTab();
100
116
  }
101
117
  getCurrentState() {
102
- return this.explorer?.getStateManager().getCurrentState() ?? null;
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(({ ai, explorer }) => new Researcher(explorer, ai)));
165
+ return (this.agents.researcher ||= this.createAgent((deps) => new Researcher(deps)));
134
166
  }
135
167
  agentNavigator() {
136
- return (this.agents.navigator ||= this.createAgent(({ ai, explorer }) => {
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(({ ai, explorer }) => new Planner(explorer, ai, this.agentResearcher()));
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(({ ai, explorer }) => {
180
+ return (this.agents.pilot ||= this.createAgent((deps) => {
151
181
  const researcher = this.agentResearcher();
152
182
  const navigator = this.agentNavigator();
153
- const tools = createAgentTools({ explorer, researcher, navigator, supervisor: true });
154
- return new Pilot(ai, tools, researcher, explorer);
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(({ ai, explorer }) => {
189
+ this.agents.tester = this.createAgent((deps) => {
160
190
  const researcher = this.agentResearcher();
161
191
  const navigator = this.agentNavigator();
162
- const tools = createAgentTools({ explorer, researcher, navigator });
163
- return new Tester(explorer, ai, researcher, navigator, tools);
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
- this.agents.tester.setHistorian(this.agentHistorian());
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.playwrightHelper, this.explorer.getStateManager());
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
- const experienceTracker = explorer.getStateManager().getExperienceTracker();
201
- const reporter = explorer.getReporter();
202
- return new Historian(ai, experienceTracker, reporter, explorer.getStateManager(), config, {
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(({ ai, explorer }) => {
239
+ this.agents.rerunner = this.createAgent((deps) => {
211
240
  const researcher = this.agentResearcher();
212
241
  const navigator = this.agentNavigator();
213
- const tools = createAgentTools({ explorer, researcher, navigator, withExperience: false });
214
- return new Rerunner(explorer, ai, tools);
242
+ const tools = createAgentTools({ ...deps, researcher, navigator, withExperience: false });
243
+ return new Rerunner(deps, tools);
215
244
  });
216
- this.agents.rerunner.setHistorian(this.agentHistorian());
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(({ ai, explorer }) => {
251
+ return (this.agents.driller ||= this.createAgent((deps) => {
222
252
  const navigator = this.agentNavigator();
223
- return new Driller(explorer, ai, navigator);
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.explorer.getRequestStore() || new RequestStore(outputDir);
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 = () => this.explorer.extractCookies();
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.explorer?.getStateManager().getCurrentState()?.url;
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.explorer?.getStateManager().getCurrentState();
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.explorer?.getReporter();
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
  }
@@ -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 { AIProvider } from './ai/provider.js';
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 { ExperienceTracker } from './experience-tracker.js';
9
- import { KnowledgeTracker } from './knowledge-tracker.js';
10
- import { PlaywrightRecorder } from './playwright-recorder.js';
11
- import { Reporter } from './reporter.js';
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,84 @@ 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
- aiProvider: AIProvider;
38
- playwrightHelper: any;
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
- otherTabs: TabInfo[];
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
- constructor(config: ExplorbotConfig, aiProvider: AIProvider, options: {
62
- show?: boolean;
63
- headless?: boolean;
64
- incognito?: boolean;
65
- session?: string;
66
- } | undefined, experienceTracker: ExperienceTracker, knowledgeTracker: KnowledgeTracker);
42
+ constructor(config: ExplorbotConfig, options: ExplorerOptions | undefined, deps: ExplorerDeps);
43
+ get actor(): CodeceptJS.I;
44
+ get page(): Page | null;
45
+ get activeTest(): Test | null;
46
+ start(): Promise<void>;
47
+ stop(): Promise<void>;
48
+ action(): Action;
49
+ visit(url: string, opts?: CaptureOpts): Promise<ActionResult>;
50
+ capture(opts?: CaptureOpts): Promise<ActionResult>;
51
+ withPage<T>(fn: (page: Page) => Promise<T>): Promise<T>;
52
+ recover(error?: unknown): Promise<Recovery>;
53
+ beginTest(test: Test): Promise<TestRun>;
54
+ openTab(): Promise<void>;
67
55
  initializeContainer(): void;
68
56
  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
57
  connectOrLaunchBrowser(): Promise<void>;
79
58
  createBrowserContextOptions(): BrowserContextOptions;
80
- createAction(): Action;
81
- runWithBrowserRecovery<T>(label: string, operation: () => Promise<T>): Promise<T>;
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>;
59
+ attachXhrCapture(): void;
60
+ runWithRecovery<T>(label: string, operation: () => Promise<T>): Promise<T>;
90
61
  visitOnce(url: string): Promise<Action>;
91
- annotateElements(): Promise<WebElement[]>;
92
- visuallyAnnotateElements(opts?: {
93
- containers?: Array<{
94
- css: string;
95
- label: string;
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>;
62
+ recoverFromExecutionError(error: unknown): Promise<Recovery>;
63
+ recoverOrRestart(): Promise<boolean>;
64
+ recoverPage(): Promise<boolean>;
65
+ activateNewPage(context: any): Promise<void>;
66
+ stopCaptures(): Promise<void>;
67
+ closeBrowserContext(): Promise<void>;
103
68
  restartBrowser(): Promise<boolean>;
104
- switchToMainFrame(): Promise<void>;
69
+ resolveBrowserUrl(url?: string): string | null;
105
70
  waitForPageReadiness(): Promise<boolean>;
106
- isInsideIframe(): Promise<boolean>;
107
- getCurrentIframeInfo(): string | null;
108
- hasOtherTabs(): boolean;
109
- getOtherTabsInfo(): TabInfo[];
110
- clearOtherTabsInfo(): void;
111
71
  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
72
  bindFrameNavigated(page: any): void;
122
- openFreshTab(): Promise<void>;
123
73
  closeOtherTabs(): Promise<void>;
74
+ finishTest(test: Test, meta?: Record<string, string>): Promise<void>;
75
+ watchActiveTestPage(page?: any): void;
76
+ unwatchActiveTestPages(): void;
77
+ }
78
+ export interface ExplorerOptions {
79
+ show?: boolean;
80
+ headless?: boolean;
81
+ incognito?: boolean;
82
+ session?: string;
83
+ }
84
+ export interface ExplorerDeps {
85
+ stateManager: StateManager;
86
+ knowledgeTracker: KnowledgeTracker;
87
+ reporter: Reporter;
88
+ requestStore: RequestStore;
89
+ playwrightRecorder: PlaywrightRecorder;
90
+ }
91
+ export interface Recovery {
92
+ ok: boolean;
93
+ action: 'continue' | 'stop';
94
+ message: string;
95
+ recovered?: boolean;
96
+ }
97
+ export interface TestRun {
98
+ started: boolean;
99
+ stop(meta?: Record<string, string>): Promise<void>;
100
+ }
101
+ export interface CaptureOpts {
102
+ screenshot?: boolean;
124
103
  }
125
- export declare function annotatePageElements(page: any): Promise<{
126
- ariaSnapshot: string;
127
- elements: WebElement[];
128
- }>;
129
104
  export default Explorer;