explorbot 0.1.9 → 0.1.11
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 +27 -1
- package/bin/explorbot-cli.ts +86 -15
- package/boat/api-tester/src/ai/curler-tools.ts +3 -3
- package/boat/api-tester/src/ai/curler.ts +1 -1
- package/boat/api-tester/src/apibot.ts +2 -2
- package/boat/api-tester/src/config.ts +1 -1
- package/dist/bin/explorbot-cli.js +85 -14
- package/dist/boat/api-tester/src/ai/curler-tools.js +2 -2
- package/dist/boat/api-tester/src/apibot.js +2 -2
- package/dist/package.json +2 -2
- package/dist/rules/navigator/output.md +9 -0
- package/dist/rules/navigator/verification-actions.md +2 -0
- package/dist/src/action-result.js +23 -1
- package/dist/src/action.js +46 -38
- package/dist/src/ai/bosun.js +16 -2
- package/dist/src/ai/conversation.js +39 -0
- package/dist/src/ai/experience-compactor.js +235 -50
- package/dist/src/ai/historian/codeceptjs.js +109 -0
- package/dist/src/ai/historian/experience.js +320 -0
- package/dist/src/ai/historian/mixin.js +2 -0
- package/dist/src/ai/historian/playwright.js +145 -0
- package/dist/src/ai/historian/utils.js +18 -0
- package/dist/src/ai/historian.js +19 -398
- package/dist/src/ai/navigator.js +133 -80
- package/dist/src/ai/pilot.js +254 -13
- package/dist/src/ai/planner/subpages.js +1 -30
- package/dist/src/ai/planner.js +33 -13
- package/dist/src/ai/provider.js +55 -18
- package/dist/src/ai/rerunner.js +3 -3
- package/dist/src/ai/researcher/deep-analysis.js +1 -1
- package/dist/src/ai/researcher/fingerprint-worker.js +1 -1
- package/dist/src/ai/researcher/locators.js +1 -1
- package/dist/src/ai/researcher/sections.js +8 -1
- package/dist/src/ai/researcher.js +43 -41
- package/dist/src/ai/rules.js +26 -14
- package/dist/src/ai/tester.js +90 -26
- package/dist/src/ai/tools.js +18 -10
- package/dist/src/api/request-store.js +20 -0
- package/dist/src/api/xhr-capture.js +19 -3
- package/dist/src/browser-server.js +16 -3
- package/dist/src/command-handler.js +1 -1
- package/dist/src/commands/add-rule-command.js +12 -9
- package/dist/src/commands/base-command.js +20 -0
- package/dist/src/commands/clean-command.js +3 -2
- package/dist/src/commands/compact-command.js +138 -0
- package/dist/src/commands/context-command.js +7 -1
- package/dist/src/commands/drill-command.js +4 -1
- package/dist/src/commands/experience-command.js +104 -0
- package/dist/src/commands/explore-command.js +54 -19
- package/dist/src/commands/freesail-command.js +2 -0
- package/dist/src/commands/index.js +7 -3
- package/dist/src/commands/init-command.js +11 -10
- package/dist/src/commands/learn-command.js +1 -1
- package/dist/src/commands/navigate-command.js +4 -1
- package/dist/src/commands/plan-clear-command.js +4 -1
- package/dist/src/commands/plan-command.js +43 -4
- package/dist/src/commands/plan-edit-command.js +1 -1
- package/dist/src/commands/plan-load-command.js +4 -1
- package/dist/src/commands/plan-reload-command.js +4 -1
- package/dist/src/commands/plan-save-command.js +20 -8
- package/dist/src/commands/rerun-command.js +4 -0
- package/dist/src/commands/research-command.js +5 -2
- package/dist/src/commands/start-command.js +5 -1
- package/dist/src/commands/test-command.js +7 -1
- package/dist/src/components/App.js +15 -5
- package/dist/src/execution-controller.js +13 -2
- package/dist/src/experience-tracker.js +174 -83
- package/dist/src/explorbot.js +31 -22
- package/dist/src/explorer.js +12 -5
- package/dist/src/observability.js +50 -99
- package/dist/src/playwright-recorder.js +309 -0
- package/dist/src/reporter.js +17 -2
- package/dist/src/stats.js +2 -0
- package/dist/src/suite.js +1 -1
- package/dist/src/test-plan.js +12 -0
- package/dist/src/utils/aria.js +37 -1
- package/dist/src/utils/error-page.js +30 -7
- package/dist/src/utils/logger.js +1 -1
- package/dist/src/utils/next-steps.js +37 -0
- package/dist/src/utils/rules-loader.js +1 -1
- package/dist/src/utils/test-files.js +1 -1
- package/dist/src/utils/url-matcher.js +50 -0
- package/package.json +2 -2
- package/rules/navigator/output.md +9 -0
- package/rules/navigator/verification-actions.md +2 -0
- package/src/action-result.ts +26 -1
- package/src/action.ts +44 -37
- package/src/ai/bosun.ts +16 -2
- package/src/ai/conversation.ts +37 -0
- package/src/ai/experience-compactor.ts +270 -63
- package/src/ai/historian/codeceptjs.ts +130 -0
- package/src/ai/historian/experience.ts +383 -0
- package/src/ai/historian/mixin.ts +4 -0
- package/src/ai/historian/playwright.ts +169 -0
- package/src/ai/historian/utils.ts +23 -0
- package/src/ai/historian.ts +35 -468
- package/src/ai/navigator.ts +140 -85
- package/src/ai/pilot.ts +259 -14
- package/src/ai/planner/subpages.ts +1 -24
- package/src/ai/planner.ts +34 -14
- package/src/ai/provider.ts +52 -18
- package/src/ai/rerunner.ts +3 -3
- package/src/ai/researcher/deep-analysis.ts +1 -1
- package/src/ai/researcher/fingerprint-worker.ts +1 -1
- package/src/ai/researcher/locators.ts +2 -2
- package/src/ai/researcher/sections.ts +7 -1
- package/src/ai/researcher.ts +47 -42
- package/src/ai/rules.ts +27 -14
- package/src/ai/task-agent.ts +1 -1
- package/src/ai/tester.ts +94 -26
- package/src/ai/tools.ts +53 -29
- package/src/api/request-store.ts +22 -0
- package/src/api/xhr-capture.ts +21 -3
- package/src/browser-server.ts +17 -3
- package/src/command-handler.ts +1 -1
- package/src/commands/add-rule-command.ts +13 -9
- package/src/commands/base-command.ts +26 -1
- package/src/commands/clean-command.ts +4 -3
- package/src/commands/compact-command.ts +156 -0
- package/src/commands/context-command.ts +8 -2
- package/src/commands/drill-command.ts +5 -2
- package/src/commands/experience-command.ts +125 -0
- package/src/commands/explore-command.ts +58 -21
- package/src/commands/freesail-command.ts +2 -0
- package/src/commands/index.ts +7 -3
- package/src/commands/init-command.ts +11 -10
- package/src/commands/learn-command.ts +2 -2
- package/src/commands/navigate-command.ts +5 -2
- package/src/commands/plan-clear-command.ts +5 -2
- package/src/commands/plan-command.ts +47 -5
- package/src/commands/plan-edit-command.ts +2 -2
- package/src/commands/plan-load-command.ts +5 -2
- package/src/commands/plan-reload-command.ts +5 -2
- package/src/commands/plan-save-command.ts +20 -9
- package/src/commands/rerun-command.ts +5 -0
- package/src/commands/research-command.ts +6 -3
- package/src/commands/start-command.ts +6 -2
- package/src/commands/test-command.ts +8 -2
- package/src/components/App.tsx +16 -5
- package/src/config.ts +6 -1
- package/src/execution-controller.ts +14 -3
- package/src/experience-tracker.ts +198 -100
- package/src/explorbot.ts +33 -23
- package/src/explorer.ts +14 -5
- package/src/observability.ts +50 -109
- package/src/playwright-recorder.ts +305 -0
- package/src/reporter.ts +17 -3
- package/src/stats.ts +4 -0
- package/src/suite.ts +1 -1
- package/src/test-plan.ts +12 -0
- package/src/utils/aria.ts +38 -1
- package/src/utils/error-page.ts +32 -7
- package/src/utils/logger.ts +1 -1
- package/src/utils/next-steps.ts +51 -0
- package/src/utils/rules-loader.ts +1 -1
- package/src/utils/test-files.ts +1 -1
- package/src/utils/url-matcher.ts +43 -0
package/src/ai/pilot.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type ExperienceTracker, renderExperienceToc } from '../experience-track
|
|
|
7
7
|
import type Explorer from '../explorer.ts';
|
|
8
8
|
import { type Test, TestResult } from '../test-plan.ts';
|
|
9
9
|
import { collectInteractiveNodes, detectFocusArea, extractFocusedElement } from '../utils/aria.ts';
|
|
10
|
+
import { ErrorPageError } from '../utils/error-page.ts';
|
|
10
11
|
import { createDebug, tag } from '../utils/logger.ts';
|
|
11
12
|
|
|
12
13
|
const debugLog = createDebug('explorbot:pilot');
|
|
@@ -14,6 +15,7 @@ import { truncateJson } from '../utils/strings.ts';
|
|
|
14
15
|
import type { Agent } from './agent.ts';
|
|
15
16
|
import type { Conversation } from './conversation.ts';
|
|
16
17
|
import type { Fisherman } from './fisherman.ts';
|
|
18
|
+
import type { Navigator } from './navigator.ts';
|
|
17
19
|
import type { Provider } from './provider.ts';
|
|
18
20
|
import type { Researcher } from './researcher.ts';
|
|
19
21
|
import { isInteractive } from './task-agent.ts';
|
|
@@ -56,25 +58,30 @@ export class Pilot implements Agent {
|
|
|
56
58
|
return this.conversation.getLastMessage() || null;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
async reviewStop(task: Test, currentState: ActionResult, testerConversation: Conversation): Promise<boolean> {
|
|
60
|
-
return this.reviewDecision('stop', task, currentState, testerConversation);
|
|
61
|
+
async reviewStop(task: Test, currentState: ActionResult, testerConversation: Conversation, navigator?: Navigator): Promise<boolean> {
|
|
62
|
+
return this.reviewDecision('stop', task, currentState, testerConversation, navigator);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
async reviewFinish(task: Test, currentState: ActionResult, testerConversation: Conversation): Promise<boolean> {
|
|
64
|
-
return this.reviewDecision('finish', task, currentState, testerConversation);
|
|
65
|
+
async reviewFinish(task: Test, currentState: ActionResult, testerConversation: Conversation, navigator?: Navigator): Promise<boolean> {
|
|
66
|
+
return this.reviewDecision('finish', task, currentState, testerConversation, navigator);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
async reviewCompletion(task: Test, currentState: ActionResult, testerConversation: Conversation): Promise<boolean> {
|
|
69
|
+
async reviewCompletion(task: Test, currentState: ActionResult, testerConversation: Conversation, navigator?: Navigator): Promise<boolean> {
|
|
68
70
|
const verdictType = task.hasAchievedAny() ? 'finish' : 'stop';
|
|
69
|
-
return this.reviewDecision(verdictType, task, currentState, testerConversation);
|
|
71
|
+
return this.reviewDecision(verdictType, task, currentState, testerConversation, navigator);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
async finalReview(task: Test, currentState: ActionResult, testerConversation: Conversation): Promise<boolean> {
|
|
74
|
+
async finalReview(task: Test, currentState: ActionResult, testerConversation: Conversation, navigator?: Navigator): Promise<boolean> {
|
|
73
75
|
if (task.hasFinished) return false;
|
|
74
|
-
return this.reviewCompletion(task, currentState, testerConversation);
|
|
76
|
+
return this.reviewCompletion(task, currentState, testerConversation, navigator);
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
async reviewReset(task: Test, currentState: ActionResult, reason: string, testerConversation: Conversation): Promise<boolean> {
|
|
80
|
+
return this.reviewResetDecision(task, currentState, reason, testerConversation);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private async reviewDecision(type: 'finish' | 'stop', task: Test, currentState: ActionResult, testerConversation: Conversation, navigator?: Navigator): Promise<boolean> {
|
|
84
|
+
if (task.hasFinished) return false;
|
|
78
85
|
tag('substep').log(`Pilot reviewing ${type} verdict...`);
|
|
79
86
|
|
|
80
87
|
const sessionLog = this.formatSessionLog(testerConversation);
|
|
@@ -98,6 +105,12 @@ export class Pilot implements Agent {
|
|
|
98
105
|
decision: z.enum(['pass', 'fail', 'continue', 'skipped']).describe('pass = test succeeded, fail = test failed, continue = tester should keep going, skipped = scenario is irrelevant OR systematic execution failures prevented testing'),
|
|
99
106
|
reason: z.string().describe('What happened and why (1-2 sentences). Do NOT repeat the decision status (e.g. "scenario goal achieved/not achieved") — just explain the evidence. For continue: explain why rejected and suggest alternatives.'),
|
|
100
107
|
guidance: z.string().nullable().describe('Required for "continue": specific actionable instruction for the tester — what exactly to verify, retry differently, or complete next. Be concrete.'),
|
|
108
|
+
requestVerification: z
|
|
109
|
+
.string()
|
|
110
|
+
.nullable()
|
|
111
|
+
.describe(
|
|
112
|
+
'REQUIRED whenever decision is "pass" — provide a specific assertion that proves the scenario goal on the current page (e.g., "New test suite \\"Foo\\" is visible in the suites list"). The system runs it and bakes the resulting assertion into the generated test file; without it the test file has no verifiable expect(). Also use when evidence is insufficient before deciding pass/fail. Leave null for "continue", "fail", or "skipped".'
|
|
113
|
+
),
|
|
101
114
|
});
|
|
102
115
|
|
|
103
116
|
const userContent = dedent`
|
|
@@ -126,6 +139,12 @@ export class Pilot implements Agent {
|
|
|
126
139
|
- "continue" if tester hasn't completed the scenario goal yet — even if milestones were checked
|
|
127
140
|
- If evidence is mixed, but final state indicates goal completion, choose "pass"
|
|
128
141
|
- If evidence is mixed and final state is unclear, prefer "continue" over "fail"
|
|
142
|
+
|
|
143
|
+
When deciding "pass", you MUST also set requestVerification to a CodeceptJS assertion that
|
|
144
|
+
proves the scenario goal on the current page. Choose the strongest single evidence (a unique
|
|
145
|
+
element/text that exists ONLY because the scenario succeeded). The assertion is executed and
|
|
146
|
+
then converted into the spec file's expect() — without it the generated test has nothing to
|
|
147
|
+
assert and is worthless.
|
|
129
148
|
`;
|
|
130
149
|
|
|
131
150
|
const messages = [
|
|
@@ -148,6 +167,29 @@ export class Pilot implements Agent {
|
|
|
148
167
|
return false;
|
|
149
168
|
}
|
|
150
169
|
|
|
170
|
+
if (result.requestVerification && navigator) {
|
|
171
|
+
tag('substep').log(`Pilot requesting verification: ${result.requestVerification}`);
|
|
172
|
+
try {
|
|
173
|
+
const verifyResult = await navigator.verifyState(result.requestVerification, currentState);
|
|
174
|
+
if (verifyResult.verified) {
|
|
175
|
+
if (verifyResult.assertionSteps?.length) {
|
|
176
|
+
this.explorer.getPlaywrightRecorder().recordVerification(verifyResult.assertionSteps);
|
|
177
|
+
}
|
|
178
|
+
tag('substep').log(`Pilot verified: ${result.requestVerification}`);
|
|
179
|
+
} else {
|
|
180
|
+
tag('substep').log(`Pilot verification failed: ${result.requestVerification}`);
|
|
181
|
+
if (result.decision === 'pass') {
|
|
182
|
+
const flipMessage = `Verification "${result.requestVerification}" did not match the page. Adjust approach and re-verify before finishing.`;
|
|
183
|
+
result.decision = 'continue';
|
|
184
|
+
result.reason = flipMessage;
|
|
185
|
+
result.guidance = result.guidance ?? flipMessage;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch (verifyErr: any) {
|
|
189
|
+
tag('warning').log(`Pilot verification errored: ${verifyErr.message}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
151
193
|
tag('info').log(`Pilot: ${result.decision} — ${result.reason}`);
|
|
152
194
|
task.summary = result.reason;
|
|
153
195
|
|
|
@@ -180,6 +222,142 @@ export class Pilot implements Agent {
|
|
|
180
222
|
}
|
|
181
223
|
}
|
|
182
224
|
|
|
225
|
+
private async reviewResetDecision(task: Test, currentState: ActionResult, reason: string, testerConversation: Conversation): Promise<boolean> {
|
|
226
|
+
if (task.hasFinished) return false;
|
|
227
|
+
tag('substep').log(`Pilot reviewing reset (count=${task.resetCount})...`);
|
|
228
|
+
|
|
229
|
+
const sessionLog = this.formatSessionLog(testerConversation);
|
|
230
|
+
const stateContext = this.buildStateContext(currentState);
|
|
231
|
+
const notes = task.notesToString() || 'No notes recorded.';
|
|
232
|
+
|
|
233
|
+
const schema = z.object({
|
|
234
|
+
decision: z.enum(['allow', 'fail', 'continue', 'skipped']).describe('allow = reset proceeds, fail = test failed (stop looping), continue = veto reset, tester should act on current page instead, skipped = scenario is irrelevant or cannot be executed'),
|
|
235
|
+
reason: z.string().describe('What evidence justifies this decision (1-2 sentences). Do not restate the decision.'),
|
|
236
|
+
guidance: z.string().nullable().describe('Required for "continue": concrete instruction for what the tester should do instead of resetting (e.g. which tool to call, what to verify).'),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const userContent = dedent`
|
|
240
|
+
Tester requested reset. Previous reset count: ${task.resetCount - 1}.
|
|
241
|
+
|
|
242
|
+
Reason given by tester: ${reason || '(none)'}
|
|
243
|
+
|
|
244
|
+
<state>
|
|
245
|
+
${stateContext}
|
|
246
|
+
</state>
|
|
247
|
+
|
|
248
|
+
${this.formatExpectations(task)}
|
|
249
|
+
|
|
250
|
+
<notes>
|
|
251
|
+
${notes}
|
|
252
|
+
</notes>
|
|
253
|
+
|
|
254
|
+
<session_log>
|
|
255
|
+
${sessionLog || 'No actions recorded'}
|
|
256
|
+
</session_log>
|
|
257
|
+
|
|
258
|
+
Decide:
|
|
259
|
+
- "allow" — the reset is legitimate (navigation dead-end, wrong page, irrecoverable error on current page).
|
|
260
|
+
- "continue" — veto the reset; something on the current page can still be used to progress or verify. Provide guidance.
|
|
261
|
+
- "fail" — reset-looping: tester has already reset and the underlying obstacle will not change. Stop the test as failed.
|
|
262
|
+
- "skipped" — the scenario is inapplicable to this application or cannot be executed here.
|
|
263
|
+
`;
|
|
264
|
+
|
|
265
|
+
const messages = [
|
|
266
|
+
{
|
|
267
|
+
role: 'system' as const,
|
|
268
|
+
content: this.buildResetSystemPrompt(task),
|
|
269
|
+
},
|
|
270
|
+
{ role: 'user' as const, content: userContent },
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
const response = await this.provider.generateObject(messages, schema, this.provider.getAgenticModel('pilot'), {
|
|
275
|
+
agentName: 'pilot',
|
|
276
|
+
experimental_telemetry: { functionId: 'pilot.reviewReset' },
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const result = response?.object;
|
|
280
|
+
if (!result) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
tag('info').log(`Pilot reset verdict: ${result.decision} — ${result.reason}`);
|
|
285
|
+
|
|
286
|
+
if (result.decision === 'allow') {
|
|
287
|
+
tag('substep').log(`Pilot allowed reset: ${result.reason}`);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (result.decision === 'fail') {
|
|
292
|
+
task.addNote(`Pilot: reset refused — ${result.reason}`, TestResult.FAILED);
|
|
293
|
+
task.finish(TestResult.FAILED);
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (result.decision === 'skipped') {
|
|
298
|
+
task.addNote(`Pilot: skipped — ${result.reason}`, TestResult.SKIPPED);
|
|
299
|
+
task.finish(TestResult.SKIPPED);
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
tag('substep').log(`Pilot vetoed reset: ${result.reason}`);
|
|
304
|
+
const guidanceText = result.guidance ? `\n\nWhat to do instead: ${result.guidance}` : '';
|
|
305
|
+
testerConversation.addUserText(`Pilot vetoed reset: ${result.reason}${guidanceText}`);
|
|
306
|
+
return false;
|
|
307
|
+
} catch (error: any) {
|
|
308
|
+
tag('warning').log(`Pilot reset review failed: ${error.message}`);
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private buildResetSystemPrompt(task: Test): string {
|
|
314
|
+
return dedent`
|
|
315
|
+
You are Pilot — the supervisor that decides whether a reset is legitimate.
|
|
316
|
+
Tester wants to reset (navigate back to the start URL and discard progress).
|
|
317
|
+
|
|
318
|
+
SCENARIO: ${task.scenario}
|
|
319
|
+
|
|
320
|
+
Reset is DESTRUCTIVE. It abandons all work done in this iteration. In stateful apps, any
|
|
321
|
+
side effects (records created, forms submitted) persist on the server — resetting does not
|
|
322
|
+
undo them. Unnecessary resets create duplicate data and loop forever.
|
|
323
|
+
|
|
324
|
+
LEGITIMATE RESET (decide "allow"):
|
|
325
|
+
- The current page is unrelated to the scenario and no path leads back.
|
|
326
|
+
- Navigation is stuck in an error state with no recoverable action.
|
|
327
|
+
- The tester arrived on a page that cannot host the scenario at all.
|
|
328
|
+
|
|
329
|
+
ILLEGITIMATE RESET (decide "continue"):
|
|
330
|
+
- The previous action already succeeded (URL changed to a success/detail page, record visible,
|
|
331
|
+
confirmation shown) and tester wants to redo it because an assertion did not match.
|
|
332
|
+
The work is done — verify, record, or finish instead of restarting.
|
|
333
|
+
- A single expectation / milestone does not match app reality but the scenario goal may still
|
|
334
|
+
have been achieved. Do not redo — instruct the tester to verify the actual outcome.
|
|
335
|
+
- Tester wants to "try again with different input" after a form was submitted. Submitting
|
|
336
|
+
again creates a duplicate; guide toward editing the existing record or accepting the state.
|
|
337
|
+
|
|
338
|
+
RESET-LOOP (decide "fail"):
|
|
339
|
+
- resetCount >= 2 and the previous resets did not change the underlying situation.
|
|
340
|
+
- The same flow has been attempted twice with the same failure mode.
|
|
341
|
+
- Repeating the reset cannot produce new information.
|
|
342
|
+
|
|
343
|
+
SCENARIO INAPPLICABLE (decide "skipped"):
|
|
344
|
+
- The feature the scenario targets does not exist on this app, or prerequisites cannot be met.
|
|
345
|
+
|
|
346
|
+
PRIORITY:
|
|
347
|
+
1) Evidence of successful side effects in session_log (URL transition, new record visible).
|
|
348
|
+
If present, almost never allow the reset — the work is done.
|
|
349
|
+
2) resetCount. Each prior reset raises the bar for allowing another.
|
|
350
|
+
3) Tester's stated reason. Weigh it against the observed evidence, do not trust it blindly.
|
|
351
|
+
|
|
352
|
+
GUIDANCE FIELD (required when decision is "continue"):
|
|
353
|
+
Give a specific next action on the current page: which tool to call, what to verify, or how to
|
|
354
|
+
record the outcome. Do not suggest repeating actions that already succeeded.
|
|
355
|
+
|
|
356
|
+
EXPECTED RESULTS (milestones, not the goal):
|
|
357
|
+
${task.expected.map((e) => `- ${e}`).join('\n')}
|
|
358
|
+
`;
|
|
359
|
+
}
|
|
360
|
+
|
|
183
361
|
private buildVerdictSystemPrompt(type: string, task: Test): string {
|
|
184
362
|
return dedent`
|
|
185
363
|
You are Pilot — the final decision maker for test pass/fail.
|
|
@@ -281,10 +459,14 @@ export class Pilot implements Agent {
|
|
|
281
459
|
the elements needed for the scenario. The page summary does not list every element.
|
|
282
460
|
Prefer interacting with the current page over navigating away.
|
|
283
461
|
|
|
462
|
+
If you load a recipe via learn_experience, do NOT rewrite its code in your plan — the
|
|
463
|
+
raw recipe is forwarded to Tester automatically. Reference it by step ("apply recipe
|
|
464
|
+
steps 1–3, then…") and call out anywhere your scenario diverges from it.
|
|
465
|
+
|
|
284
466
|
Be concise and specific. Tester will follow your plan.
|
|
285
467
|
`,
|
|
286
468
|
'pilot.planTest',
|
|
287
|
-
{ tools: true, maxToolRoundtrips: 3, task }
|
|
469
|
+
{ tools: true, planningOnly: true, maxToolRoundtrips: 3, task }
|
|
288
470
|
);
|
|
289
471
|
}
|
|
290
472
|
|
|
@@ -377,7 +559,7 @@ export class Pilot implements Agent {
|
|
|
377
559
|
return `CHECKED: ${checked.length > 0 ? checked.join(', ') : 'none'}\nREMAINING: ${remaining.length > 0 ? remaining.join(', ') : 'none'}`;
|
|
378
560
|
}
|
|
379
561
|
|
|
380
|
-
private async sendToPilot(userText: string, functionId: string, opts: { tools?: boolean; maxToolRoundtrips?: number; task?: Test } = {}): Promise<string> {
|
|
562
|
+
private async sendToPilot(userText: string, functionId: string, opts: { tools?: boolean; planningOnly?: boolean; maxToolRoundtrips?: number; task?: Test } = {}): Promise<string> {
|
|
381
563
|
debugLog(`sendToPilot: ${functionId}, tools: ${!!opts.tools}, roundtrips: ${opts.maxToolRoundtrips ?? 0}`);
|
|
382
564
|
|
|
383
565
|
let finalUserText = userText;
|
|
@@ -388,7 +570,10 @@ export class Pilot implements Agent {
|
|
|
388
570
|
}
|
|
389
571
|
}
|
|
390
572
|
this.conversation!.addUserText(finalUserText);
|
|
391
|
-
let tools
|
|
573
|
+
let tools: any;
|
|
574
|
+
if (opts.tools) {
|
|
575
|
+
tools = opts.planningOnly ? this.pickPlanningTools() : this.agentTools;
|
|
576
|
+
}
|
|
392
577
|
|
|
393
578
|
if (opts.tools && opts.task) {
|
|
394
579
|
tools = { ...tools, ...this.buildPreconditionTool(opts.task) };
|
|
@@ -399,7 +584,19 @@ export class Pilot implements Agent {
|
|
|
399
584
|
agentName: 'pilot',
|
|
400
585
|
experimental_telemetry: { functionId },
|
|
401
586
|
});
|
|
402
|
-
|
|
587
|
+
const text = result?.response?.text || '';
|
|
588
|
+
const learned = (result?.toolExecutions || []).filter((e: any) => e.toolName === 'learn_experience' && e.output?.content).map((e: any) => e.output.content);
|
|
589
|
+
if (learned.length === 0) return text;
|
|
590
|
+
return dedent`
|
|
591
|
+
${text}
|
|
592
|
+
|
|
593
|
+
<applied_experience>
|
|
594
|
+
Recipes from prior successful runs that Pilot judged relevant. Locators worked then; the page may have changed since.
|
|
595
|
+
Treat code blocks below as a starting hypothesis. If a locator misses, fall back to ARIA/UI-map.
|
|
596
|
+
|
|
597
|
+
${learned.join('\n\n')}
|
|
598
|
+
</applied_experience>
|
|
599
|
+
`;
|
|
403
600
|
}
|
|
404
601
|
|
|
405
602
|
private getExperienceToc(): string {
|
|
@@ -411,6 +608,19 @@ export class Pilot implements Agent {
|
|
|
411
608
|
return renderExperienceToc(toc);
|
|
412
609
|
}
|
|
413
610
|
|
|
611
|
+
private pickPlanningTools() {
|
|
612
|
+
const { see, context, verify, research, getVisitedStates, xpathCheck, learn_experience } = this.agentTools ?? {};
|
|
613
|
+
const planning: Record<string, unknown> = {};
|
|
614
|
+
if (see) planning.see = see;
|
|
615
|
+
if (context) planning.context = context;
|
|
616
|
+
if (verify) planning.verify = verify;
|
|
617
|
+
if (research) planning.research = research;
|
|
618
|
+
if (getVisitedStates) planning.getVisitedStates = getVisitedStates;
|
|
619
|
+
if (xpathCheck) planning.xpathCheck = xpathCheck;
|
|
620
|
+
if (learn_experience) planning.learn_experience = learn_experience;
|
|
621
|
+
return planning;
|
|
622
|
+
}
|
|
623
|
+
|
|
414
624
|
private buildPreconditionTool(task: Test) {
|
|
415
625
|
return {
|
|
416
626
|
precondition: tool({
|
|
@@ -487,6 +697,28 @@ export class Pilot implements Agent {
|
|
|
487
697
|
lines.push(`verifications: ${verifyLines.join(', ')}`);
|
|
488
698
|
}
|
|
489
699
|
|
|
700
|
+
const consoleErrors = (state.browserLogs ?? []).filter((l: any) => (l.type || l.level) === 'error');
|
|
701
|
+
if (consoleErrors.length > 0) {
|
|
702
|
+
const sample = consoleErrors
|
|
703
|
+
.slice(0, 3)
|
|
704
|
+
.map((e: any) => e.text || e.message || String(e))
|
|
705
|
+
.join(' | ');
|
|
706
|
+
lines.push(`console errors: ${consoleErrors.length} (${sample})`);
|
|
707
|
+
} else {
|
|
708
|
+
lines.push('console errors: none');
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const failedRequests = this.explorer.getRequestStore()?.getFailedRequests() ?? [];
|
|
712
|
+
if (failedRequests.length > 0) {
|
|
713
|
+
const sample = failedRequests
|
|
714
|
+
.slice(-5)
|
|
715
|
+
.map((r) => `${r.method} ${r.path} → ${r.status}`)
|
|
716
|
+
.join(', ');
|
|
717
|
+
lines.push(`network errors: ${sample}`);
|
|
718
|
+
} else {
|
|
719
|
+
lines.push('network errors: none');
|
|
720
|
+
}
|
|
721
|
+
|
|
490
722
|
const interactiveNodes = collectInteractiveNodes(state.ariaSnapshot);
|
|
491
723
|
const disabledButtons = interactiveNodes.filter((n) => n.role === 'button' && n.disabled === true && n.name).map((n) => n.name);
|
|
492
724
|
lines.push(`disabled buttons: ${disabledButtons.length > 0 ? disabledButtons.join(', ') : 'none'}`);
|
|
@@ -536,7 +768,13 @@ export class Pilot implements Agent {
|
|
|
536
768
|
}
|
|
537
769
|
|
|
538
770
|
if (text.includes('ATTACH_UI_MAP')) {
|
|
539
|
-
|
|
771
|
+
let uiMap = '';
|
|
772
|
+
try {
|
|
773
|
+
uiMap = await this.researcher.research(currentState);
|
|
774
|
+
} catch (err) {
|
|
775
|
+
if (!(err instanceof ErrorPageError)) throw err;
|
|
776
|
+
tag('warning').log(`Pilot UI map skipped: ${err.message}`);
|
|
777
|
+
}
|
|
540
778
|
if (uiMap) {
|
|
541
779
|
parts.push(dedent`
|
|
542
780
|
<page_ui_map>
|
|
@@ -705,6 +943,13 @@ export class Pilot implements Agent {
|
|
|
705
943
|
- If the goal was achieved by a previous action (SUCCESS in recent_actions with confirming ariaDiff): instruct Tester to verify() the result and finish(). Do NOT repeat the same action.
|
|
706
944
|
- If Tester keeps re-opening the same panel and re-submitting the same data — STOP. The action was already completed.
|
|
707
945
|
|
|
946
|
+
Action-goal alignment — classify every recent successful action:
|
|
947
|
+
- GOAL-ADVANCING: creates, edits, removes, submits, or verifies the scenario's subject data (the object the scenario actually changes).
|
|
948
|
+
- VIEW-ONLY: toggles layout, filters, tabs, segment controls, sort orders, collapse/expand — changes which data is shown without modifying it.
|
|
949
|
+
- A single VIEW-ONLY action is legitimate when needed to reveal a target element for the next GOAL-ADVANCING action.
|
|
950
|
+
- A run of two or more consecutive successful VIEW-ONLY actions with no interleaved GOAL-ADVANCING action is thrashing — Tester is exploring UI instead of executing the scenario. Redirect Tester to the specific mutation or verification the scenario requires.
|
|
951
|
+
- VIEW-ONLY actions also tend to produce large page diffs with many htmlParts; if you see that pattern repeatedly in recent_actions, treat it as evidence of thrashing.
|
|
952
|
+
|
|
708
953
|
Navigation awareness — always compare current page url to START URL:
|
|
709
954
|
- subpage navigation (deeper path from START URL) — OK, scenario may need sub-pages
|
|
710
955
|
- outer-page navigation (parent/sibling path from START URL) — SUSPICIOUS. The scenario target is on the START page. Do NOT rationalize leaving it. Instruct Tester to back() or reset().
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import dedent from 'dedent';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { ConfigParser } from '../../config.ts';
|
|
4
3
|
import { normalizeUrl } from '../../state-manager.ts';
|
|
5
4
|
import type { StateManager } from '../../state-manager.ts';
|
|
6
5
|
import type { Plan } from '../../test-plan.ts';
|
|
7
6
|
import { tag } from '../../utils/logger.ts';
|
|
7
|
+
import { isDynamicSegment } from '../../utils/url-matcher.ts';
|
|
8
8
|
import type { Provider } from '../provider.ts';
|
|
9
9
|
import type { Constructor } from '../researcher/mixin.ts';
|
|
10
10
|
|
|
@@ -38,29 +38,6 @@ function buildKey(url: string, feature?: string): string {
|
|
|
38
38
|
return normalized;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export function isDynamicSegment(segment: string): boolean {
|
|
42
|
-
try {
|
|
43
|
-
const configRegex = ConfigParser.getInstance().getConfig().dynamicPageRegex;
|
|
44
|
-
if (configRegex) return new RegExp(configRegex, 'i').test(segment);
|
|
45
|
-
} catch {
|
|
46
|
-
/* config not loaded yet */
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// numeric: /users/123
|
|
50
|
-
if (/^\d+$/.test(segment)) return true;
|
|
51
|
-
// UUID: /items/550e8400-e29b-41d4-a716-446655440000
|
|
52
|
-
if (/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(segment)) return true;
|
|
53
|
-
// ULID: /items/01ARZ3NDEKTSV4RRFFQ69G5FAV
|
|
54
|
-
if (/^[0-9A-HJKMNP-TV-Z]{26}$/.test(segment)) return true;
|
|
55
|
-
// hex ID (4+ chars): /suite/70dae98a
|
|
56
|
-
if (/^[a-f0-9]{4,}$/i.test(segment)) return true;
|
|
57
|
-
// hex-prefixed slug (8+ hex before dash): /suite/95ef0c94-mobile
|
|
58
|
-
if (/^[a-f0-9]{8,}-/i.test(segment)) return true;
|
|
59
|
-
// short mixed alphanumeric (digits + letters, ≤8 chars, no dash): /item/x7f2
|
|
60
|
-
if (segment.length <= 8 && !segment.includes('-') && /\d/.test(segment) && /[a-z]/i.test(segment)) return true;
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
41
|
export function isTemplateMatch(urlA: string, urlB: string): boolean {
|
|
65
42
|
const partsA = normalizeUrl(urlA).split('/');
|
|
66
43
|
const partsB = normalizeUrl(urlB).split('/');
|
package/src/ai/planner.ts
CHANGED
|
@@ -8,22 +8,22 @@ import type Explorer from '../explorer.ts';
|
|
|
8
8
|
import { Observability } from '../observability.ts';
|
|
9
9
|
import type { StateManager } from '../state-manager.js';
|
|
10
10
|
import { Stats } from '../stats.ts';
|
|
11
|
+
import { Suite } from '../suite.ts';
|
|
11
12
|
import { Plan, Test } from '../test-plan.ts';
|
|
12
|
-
import { planToCompactAiContext } from '../utils/test-plan-markdown.ts';
|
|
13
13
|
import { createDebug, tag } from '../utils/logger.js';
|
|
14
14
|
import { jsonToTable } from '../utils/markdown-parser.ts';
|
|
15
15
|
import { mdq } from '../utils/markdown-query.js';
|
|
16
|
+
import { planToCompactAiContext } from '../utils/test-plan-markdown.ts';
|
|
16
17
|
import type { Agent } from './agent.js';
|
|
17
18
|
import { Conversation } from './conversation.ts';
|
|
18
19
|
import type { Fisherman } from './fisherman.ts';
|
|
19
|
-
import { getActiveStyle, getStyles } from './planner/styles.ts';
|
|
20
20
|
import { WithSessionDedup } from './planner/session-dedup.ts';
|
|
21
|
+
import { getActiveStyle, getStyles } from './planner/styles.ts';
|
|
21
22
|
import { WithSubPages, getPlannedByStateHash, getRegisteredPlan, registerPlan } from './planner/subpages.ts';
|
|
22
|
-
import { findSimilarStateHash } from './researcher/cache.ts';
|
|
23
23
|
import type { Provider } from './provider.js';
|
|
24
|
-
import { hasFocusedSection } from './researcher/focus.ts';
|
|
25
24
|
import { POSSIBLE_SECTIONS, Researcher } from './researcher.ts';
|
|
26
|
-
import {
|
|
25
|
+
import { findSimilarStateHash } from './researcher/cache.ts';
|
|
26
|
+
import { hasFocusedSection } from './researcher/focus.ts';
|
|
27
27
|
import { fileUploadRule, protectionRule } from './rules.ts';
|
|
28
28
|
|
|
29
29
|
const debugLog = createDebug('explorbot:planner');
|
|
@@ -447,6 +447,34 @@ export class Planner extends PlannerBase implements Agent {
|
|
|
447
447
|
const titleListing = allTests.map((t) => `- "${t.scenario}" [${t.result || 'pending'}]`).join('\n');
|
|
448
448
|
const compactContext = planToCompactAiContext(this.currentPlan);
|
|
449
449
|
|
|
450
|
+
let planningStrategy: string;
|
|
451
|
+
if (feature) {
|
|
452
|
+
planningStrategy = dedent`
|
|
453
|
+
<planning_strategy>
|
|
454
|
+
Stay strictly inside the "${feature}" feature area. Do NOT switch to a different, unrelated feature even if it has no coverage.
|
|
455
|
+
Propose ${this.MIN_TASKS}-${this.MAX_TASKS} additional scenarios for "${feature}" that are not already in the tested list.
|
|
456
|
+
Use the <approach> above to decide which new angles to explore — different controls, inputs, states, outcome categories, or combinations — all within "${feature}".
|
|
457
|
+
Return an empty scenarios array only when no genuinely new scenario for "${feature}" remains.
|
|
458
|
+
</planning_strategy>
|
|
459
|
+
`;
|
|
460
|
+
} else {
|
|
461
|
+
let extendedResearchHint = '';
|
|
462
|
+
if (mdq(plannerResearch).query('section("Extended Research")').count() > 0) {
|
|
463
|
+
extendedResearchHint = 'IMPORTANT: The research contains "Extended Research" sections with dropdowns, modals, and panels. Prioritize testing features from Extended Research that have no coverage yet.';
|
|
464
|
+
}
|
|
465
|
+
planningStrategy = dedent`
|
|
466
|
+
<planning_strategy>
|
|
467
|
+
Find a feature area in the research that has NO or minimal test coverage.
|
|
468
|
+
Pick that ONE feature and propose ${this.MIN_TASKS}-${this.MAX_TASKS} tests for it.
|
|
469
|
+
${extendedResearchHint}
|
|
470
|
+
|
|
471
|
+
Follow the <approach> described above when proposing tests for this feature.
|
|
472
|
+
|
|
473
|
+
If ALL features across ALL research sections are covered, return empty scenarios array.
|
|
474
|
+
</planning_strategy>
|
|
475
|
+
`;
|
|
476
|
+
}
|
|
477
|
+
|
|
450
478
|
conversation.addUserText(dedent`
|
|
451
479
|
CRITICAL: This plan already has tests.
|
|
452
480
|
|
|
@@ -466,15 +494,7 @@ export class Planner extends PlannerBase implements Agent {
|
|
|
466
494
|
${compactContext}
|
|
467
495
|
</tested_scenarios>
|
|
468
496
|
|
|
469
|
-
|
|
470
|
-
Find a feature area in the research that has NO or minimal test coverage.
|
|
471
|
-
Pick that ONE feature and propose ${this.MIN_TASKS}-${this.MAX_TASKS} tests for it.
|
|
472
|
-
${mdq(plannerResearch).query('section("Extended Research")').count() > 0 ? 'IMPORTANT: The research contains "Extended Research" sections with dropdowns, modals, and panels. Prioritize testing features from Extended Research that have no coverage yet.' : ''}
|
|
473
|
-
|
|
474
|
-
Follow the <approach> described above when proposing tests for this feature.
|
|
475
|
-
|
|
476
|
-
If ALL features across ALL research sections are covered, return empty scenarios array.
|
|
477
|
-
</planning_strategy>
|
|
497
|
+
${planningStrategy}
|
|
478
498
|
|
|
479
499
|
<context_from_previous_tests>
|
|
480
500
|
During testing, the following pages were visited:
|
package/src/ai/provider.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { LangfuseSpanProcessor } from '@langfuse/otel';
|
|
2
2
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
3
|
-
import { generateObject, generateText } from 'ai';
|
|
3
|
+
import { generateObject, generateText, stepCountIs } from 'ai';
|
|
4
4
|
import type { ModelMessage } from 'ai';
|
|
5
5
|
import { clearActivity, setActivity } from '../activity.ts';
|
|
6
6
|
import type { AIConfig } from '../config.js';
|
|
7
|
-
import { RulesLoader } from '../utils/rules-loader.ts';
|
|
8
7
|
import { executionController } from '../execution-controller.ts';
|
|
9
8
|
import { Observability } from '../observability.ts';
|
|
10
9
|
import { Stats } from '../stats.ts';
|
|
11
10
|
import { createDebug, tag } from '../utils/logger.js';
|
|
12
11
|
import { type RetryOptions, withRetry } from '../utils/retry.js';
|
|
12
|
+
import { RulesLoader } from '../utils/rules-loader.ts';
|
|
13
13
|
import { Conversation } from './conversation.js';
|
|
14
14
|
|
|
15
15
|
const debugLog = createDebug('explorbot:provider');
|
|
@@ -19,6 +19,20 @@ const responseLog = createDebug('explorbot:provider:in');
|
|
|
19
19
|
class AiError extends Error {}
|
|
20
20
|
export class ContextLengthError extends Error {}
|
|
21
21
|
|
|
22
|
+
function rejectAfterIdle(ms: number, signal: { cancelled: boolean }): Promise<never> {
|
|
23
|
+
return new Promise((_, reject) => {
|
|
24
|
+
const tick = () => {
|
|
25
|
+
if (signal.cancelled) return;
|
|
26
|
+
if (executionController.isAwaitingInput()) {
|
|
27
|
+
setTimeout(tick, ms);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
reject(new Error('AI request timeout'));
|
|
31
|
+
};
|
|
32
|
+
setTimeout(tick, ms);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
export class Provider {
|
|
23
37
|
private config: AIConfig;
|
|
24
38
|
private telemetryEnabled = false;
|
|
@@ -286,14 +300,19 @@ export class Provider {
|
|
|
286
300
|
promptLog(messages[messages.length - 1].content);
|
|
287
301
|
|
|
288
302
|
const telemetry = this.getTelemetry(options);
|
|
303
|
+
const maxRoundtrips = options.maxToolRoundtrips ?? 5;
|
|
304
|
+
const extraStop = options.stopWhen;
|
|
305
|
+
const stopConditions: any[] = [stepCountIs(maxRoundtrips)];
|
|
306
|
+
if (extraStop) stopConditions.push(extraStop);
|
|
307
|
+
const { stopWhen: _ignoredStopWhen, ...optionsWithoutStop } = options;
|
|
289
308
|
const config = this.mergeProviderOptions(
|
|
290
309
|
{
|
|
291
310
|
tools,
|
|
292
311
|
maxTokens: 16384,
|
|
293
|
-
maxToolRoundtrips: options.maxToolRoundtrips ?? 5,
|
|
294
312
|
toolChoice: 'auto',
|
|
295
313
|
...(this.config.config || {}),
|
|
296
|
-
...
|
|
314
|
+
...optionsWithoutStop,
|
|
315
|
+
stopWhen: stopConditions,
|
|
297
316
|
...(telemetry ? { experimental_telemetry: telemetry } : {}),
|
|
298
317
|
model,
|
|
299
318
|
abortSignal: executionController.getAbortSignal(),
|
|
@@ -303,13 +322,23 @@ export class Provider {
|
|
|
303
322
|
try {
|
|
304
323
|
const response = await withRetry(async () => {
|
|
305
324
|
const timeout = config.timeout || 30000;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
325
|
+
const cancel = { cancelled: false };
|
|
326
|
+
try {
|
|
327
|
+
const result = (await Promise.race([
|
|
328
|
+
generateText({
|
|
329
|
+
messages,
|
|
330
|
+
...config,
|
|
331
|
+
}),
|
|
332
|
+
rejectAfterIdle(timeout, cancel),
|
|
333
|
+
])) as any;
|
|
334
|
+
const hasToolCall = (result.toolCalls?.length || 0) > 0;
|
|
335
|
+
if (!result.text && !hasToolCall && result.finishReason === 'length') {
|
|
336
|
+
throw new ContextLengthError('AI response empty: output truncated at maxTokens. Increase maxTokens in config or use a model with higher output capacity.');
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
} finally {
|
|
340
|
+
cancel.cancelled = true;
|
|
341
|
+
}
|
|
313
342
|
}, this.getRetryOptions(options));
|
|
314
343
|
|
|
315
344
|
clearActivity();
|
|
@@ -380,13 +409,18 @@ export class Provider {
|
|
|
380
409
|
promptLog(messages[messages.length - 1].content);
|
|
381
410
|
const response = await withRetry(async () => {
|
|
382
411
|
const timeout = config.timeout || 30000;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
412
|
+
const cancel = { cancelled: false };
|
|
413
|
+
try {
|
|
414
|
+
return (await Promise.race([
|
|
415
|
+
generateObject({
|
|
416
|
+
messages,
|
|
417
|
+
...config,
|
|
418
|
+
}),
|
|
419
|
+
rejectAfterIdle(timeout, cancel),
|
|
420
|
+
])) as any;
|
|
421
|
+
} finally {
|
|
422
|
+
cancel.cancelled = true;
|
|
423
|
+
}
|
|
390
424
|
}, this.getRetryOptions(options));
|
|
391
425
|
|
|
392
426
|
clearActivity();
|
package/src/ai/rerunner.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { highlight } from 'cli-highlight';
|
|
|
7
7
|
import * as codeceptjs from 'codeceptjs';
|
|
8
8
|
import heal from 'codeceptjs/lib/heal';
|
|
9
9
|
import aiTracePlugin from 'codeceptjs/lib/plugin/aiTrace';
|
|
10
|
-
import figureSet from 'figures';
|
|
11
10
|
import dedent from 'dedent';
|
|
11
|
+
import figureSet from 'figures';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { ActionResult } from '../action-result.ts';
|
|
14
14
|
import { setActivity } from '../activity.ts';
|
|
@@ -19,14 +19,14 @@ import { Stats } from '../stats.ts';
|
|
|
19
19
|
import { Task, Test, TestResult } from '../test-plan.ts';
|
|
20
20
|
import { createDebug, tag } from '../utils/logger.ts';
|
|
21
21
|
import { loop } from '../utils/loop.ts';
|
|
22
|
+
import { RulesLoader } from '../utils/rules-loader.ts';
|
|
22
23
|
import { loadTestSuites, printTestList } from '../utils/test-files.ts';
|
|
23
24
|
import type { Agent } from './agent.ts';
|
|
24
25
|
import { toolExecutionLabel } from './conversation.ts';
|
|
25
26
|
import type { Navigator } from './navigator.ts';
|
|
26
27
|
import { Provider } from './provider.ts';
|
|
27
|
-
import {
|
|
28
|
+
import { actionRule, locatorRule, sectionContextRule } from './rules.ts';
|
|
28
29
|
import { TaskAgent } from './task-agent.ts';
|
|
29
|
-
import { RulesLoader } from '../utils/rules-loader.ts';
|
|
30
30
|
import { createCodeceptJSTools } from './tools.ts';
|
|
31
31
|
|
|
32
32
|
const debugLog = createDebug('explorbot:rerunner');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import dedent from 'dedent';
|
|
2
2
|
import { ActionResult, type Diff } from '../../action-result.js';
|
|
3
|
+
import { executionController } from '../../execution-controller.ts';
|
|
3
4
|
import type Explorer from '../../explorer.ts';
|
|
4
5
|
import type { StateManager } from '../../state-manager.js';
|
|
5
6
|
import { WebPageState } from '../../state-manager.js';
|
|
6
7
|
import { detectFocusArea, diffAriaSnapshots } from '../../utils/aria.ts';
|
|
7
|
-
import { executionController } from '../../execution-controller.ts';
|
|
8
8
|
import { tag } from '../../utils/logger.js';
|
|
9
9
|
import { mdq } from '../../utils/markdown-query.ts';
|
|
10
10
|
import type { Provider } from '../provider.js';
|