explorbot 0.1.13 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +3 -2
- package/dist/src/action.js +3 -2
- package/dist/src/ai/conversation.js +20 -4
- package/dist/src/ai/historian/utils.js +8 -1
- package/dist/src/ai/pilot.js +198 -260
- package/dist/src/ai/provider.js +25 -12
- package/dist/src/ai/quartermaster.js +2 -2
- package/dist/src/ai/researcher/focus.js +51 -10
- package/dist/src/ai/researcher/sections.js +8 -4
- package/dist/src/ai/researcher.js +9 -24
- package/dist/src/ai/rules.js +2 -0
- package/dist/src/ai/session-analyst.js +46 -41
- package/dist/src/ai/tester.js +63 -22
- package/dist/src/ai/tools.js +19 -4
- package/dist/src/commands/explore-command.js +8 -2
- package/dist/src/components/StatusPane.js +6 -1
- package/dist/src/experience-tracker.js +9 -0
- package/dist/src/explorer.js +2 -5
- package/dist/src/reporter.js +41 -1
- package/dist/src/stats.js +2 -1
- package/dist/src/test-plan.js +47 -3
- package/package.json +3 -2
- package/src/action.ts +3 -2
- package/src/ai/conversation.ts +21 -4
- package/src/ai/historian/utils.ts +8 -1
- package/src/ai/pilot.ts +199 -259
- package/src/ai/provider.ts +24 -12
- package/src/ai/quartermaster.ts +2 -2
- package/src/ai/researcher/focus.ts +57 -8
- package/src/ai/researcher/sections.ts +7 -3
- package/src/ai/researcher.ts +8 -23
- package/src/ai/rules.ts +2 -0
- package/src/ai/session-analyst.ts +47 -41
- package/src/ai/tester.ts +55 -20
- package/src/ai/tools.ts +18 -4
- package/src/commands/explore-command.ts +9 -2
- package/src/components/StatusPane.tsx +6 -3
- package/src/experience-tracker.ts +9 -0
- package/src/explorer.ts +1 -4
- package/src/reporter.ts +44 -1
- package/src/stats.ts +3 -1
- package/src/test-plan.ts +62 -3
package/dist/src/ai/pilot.js
CHANGED
|
@@ -89,7 +89,7 @@ export class Pilot {
|
|
|
89
89
|
requestVerification: z
|
|
90
90
|
.string()
|
|
91
91
|
.nullable()
|
|
92
|
-
.describe('REQUIRED whenever decision is "pass" —
|
|
92
|
+
.describe('REQUIRED whenever decision is "pass" — a one-sentence natural-language claim about the current page that, if true, proves the scenario goal (e.g., "New test suite \\"Foo\\" is visible in the suites list"). NOT code: do not write I.*, expect(), .then(), grabTitle, or any JavaScript. Navigator translates the claim into CodeceptJS assertions and runs them; passing assertions are saved to the generated test file. Also use when evidence is insufficient before deciding pass/fail. Leave null for "continue", "fail", or "skipped".'),
|
|
93
93
|
});
|
|
94
94
|
const userContent = dedent `
|
|
95
95
|
Tester wants to ${type} the test.
|
|
@@ -110,19 +110,20 @@ export class Pilot {
|
|
|
110
110
|
${sessionLog || 'No actions recorded'}
|
|
111
111
|
</session_log>
|
|
112
112
|
|
|
113
|
-
Decide
|
|
114
|
-
|
|
115
|
-
- "
|
|
116
|
-
- "
|
|
117
|
-
- "
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
When deciding "pass", you MUST also set requestVerification to a
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
Decide and commit. "continue" extends the loop and burns iterations — choose it only when
|
|
114
|
+
evidence is genuinely insufficient to call pass/fail, not as a safety hedge.
|
|
115
|
+
- "pass" if final state proves the SCENARIO GOAL is accomplished. Set requestVerification.
|
|
116
|
+
- "fail" if scenario was attempted but goal not achieved.
|
|
117
|
+
- "skipped" if scenario is irrelevant/inapplicable, OR systematic infrastructure failures.
|
|
118
|
+
- "continue" only when a concrete missing piece of evidence (a verify/see) would change your verdict.
|
|
119
|
+
- Mixed evidence + final state shows success → pass. Mixed + final state unclear → continue with guidance.
|
|
120
|
+
|
|
121
|
+
When deciding "pass", you MUST also set requestVerification to a one-sentence natural-language
|
|
122
|
+
claim about the current page (e.g., "New test suite Foo is visible in the suites list"). NOT
|
|
123
|
+
code — do not write I.*, expect(), .then(), or any JavaScript. Choose the strongest single
|
|
124
|
+
piece of evidence (a unique element/text that exists ONLY because the scenario succeeded).
|
|
125
|
+
Navigator translates the claim into CodeceptJS assertions; without it the generated test has
|
|
126
|
+
nothing to assert and is worthless.
|
|
126
127
|
`;
|
|
127
128
|
const messages = [
|
|
128
129
|
{
|
|
@@ -144,37 +145,25 @@ export class Pilot {
|
|
|
144
145
|
if (result.decision === 'pass' && result.requestVerification && navigator) {
|
|
145
146
|
tag('substep').log(`Pilot requesting verification: ${result.requestVerification}`);
|
|
146
147
|
const verifyResult = await navigator.verifyState(result.requestVerification, currentState).catch(() => null);
|
|
147
|
-
if (verifyResult?.verified) {
|
|
148
|
-
|
|
149
|
-
this.explorer.getPlaywrightRecorder().recordVerification(verifyResult.assertionSteps);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
let answer = null;
|
|
154
|
-
if (screenshotState?.screenshot) {
|
|
155
|
-
answer = await this.researcher.answerQuestionAboutScreenshot(screenshotState, `Does the screen confirm: "${result.requestVerification}"? Answer YES or NO only.`);
|
|
156
|
-
}
|
|
157
|
-
if (!(answer || '').trim().toUpperCase().startsWith('YES')) {
|
|
158
|
-
task.addNote(`Pilot: verification failed — ${result.requestVerification}`, TestResult.FAILED);
|
|
159
|
-
task.finish(TestResult.FAILED);
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
148
|
+
if (verifyResult?.verified && verifyResult.assertionSteps?.length) {
|
|
149
|
+
this.explorer.getPlaywrightRecorder().recordVerification(verifyResult.assertionSteps);
|
|
162
150
|
}
|
|
163
151
|
}
|
|
164
152
|
tag('info').log(`Pilot: ${result.decision} — ${result.reason}`);
|
|
165
153
|
task.summary = result.reason;
|
|
154
|
+
const verdictState = screenshotState || currentState;
|
|
166
155
|
if (result.decision === 'pass') {
|
|
167
|
-
task.
|
|
156
|
+
task.setVerification(`Pilot: ${result.reason}`, TestResult.PASSED, verdictState);
|
|
168
157
|
task.finish(TestResult.PASSED);
|
|
169
158
|
return false;
|
|
170
159
|
}
|
|
171
160
|
if (result.decision === 'fail') {
|
|
172
|
-
task.
|
|
161
|
+
task.setVerification(`Pilot: ${result.reason}`, TestResult.FAILED, verdictState);
|
|
173
162
|
task.finish(TestResult.FAILED);
|
|
174
163
|
return false;
|
|
175
164
|
}
|
|
176
165
|
if (result.decision === 'skipped') {
|
|
177
|
-
task.
|
|
166
|
+
task.setVerification(`Pilot: skipped — ${result.reason}`, TestResult.SKIPPED, verdictState);
|
|
178
167
|
task.finish(TestResult.SKIPPED);
|
|
179
168
|
return false;
|
|
180
169
|
}
|
|
@@ -267,109 +256,89 @@ export class Pilot {
|
|
|
267
256
|
return true;
|
|
268
257
|
}
|
|
269
258
|
}
|
|
270
|
-
|
|
259
|
+
buildSharedEvidenceRules(task) {
|
|
271
260
|
return dedent `
|
|
272
|
-
You are Pilot — the supervisor that decides whether a reset is legitimate.
|
|
273
|
-
Tester wants to reset (navigate back to the start URL and discard progress).
|
|
274
|
-
|
|
275
261
|
SCENARIO: ${task.scenario}
|
|
276
262
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
263
|
+
EVIDENCE PRIORITY (strict):
|
|
264
|
+
1) Final observable state proving the scenario goal
|
|
265
|
+
2) verify()/see() results in the LAST few actions before stop/finish
|
|
266
|
+
3) Intermediate action outcomes (diagnostic, not decisive)
|
|
267
|
+
Mixed evidence with a clear final-state success → pass. Mixed with unclear final state → continue.
|
|
268
|
+
|
|
269
|
+
EVIDENCE SOURCES disagree often: verify(), see(), visual_analysis, session_log. No single source
|
|
270
|
+
overrides the others — weigh them together. Tester's record() notes are the LEAST reliable; always
|
|
271
|
+
cross-check against actual actions and state. Visual screenshot analysis is strong for UI state
|
|
272
|
+
(active tabs, visible counts, colors).
|
|
273
|
+
|
|
274
|
+
SCENARIO TITLE defines what must happen. Action verbs require persisted evidence:
|
|
275
|
+
- "Create X" → X must exist (visible, redirected to its page, or success message). Opening a form is NOT enough.
|
|
276
|
+
- "Delete X" → X must be gone. Clicking delete is NOT enough.
|
|
277
|
+
- "Edit X" → updated value must be persisted (visible in list/detail). Opening edit is NOT enough; redirect after save with the new value visible IS enough.
|
|
278
|
+
- Negative tests ("without a name", "invalid", "duplicate", "unauthorized") → success means the system PREVENTED the action with validation/error.
|
|
279
|
+
|
|
280
|
+
PROVENANCE for create/edit scenarios: the task prompt instructs the tester to inject the
|
|
281
|
+
session marker "${task.sessionName ?? ''}" into newly created or edited free-text values.
|
|
282
|
+
When that marker COULD be injected, the entity used as proof MUST contain it. A record
|
|
283
|
+
matching the goal by text alone but missing the marker is a stale leftover from a prior
|
|
284
|
+
run — it is NOT evidence the current scenario produced anything. Vote \`fail\`, not \`pass\`.
|
|
285
|
+
This does not apply when the field is restricted (numeric only, enum, etc.) or when the
|
|
286
|
+
session_log shows no fillField/type/select actions were attempted at all (in that case
|
|
287
|
+
the scenario clearly didn't run — also vote \`fail\`).
|
|
288
|
+
|
|
289
|
+
Expected results are MILESTONES, not the goal. Never fail because a milestone (toast, icon, styling)
|
|
290
|
+
didn't match if the scenario goal IS accomplished.
|
|
280
291
|
|
|
281
|
-
|
|
282
|
-
- The current page is unrelated to the scenario and no path leads back.
|
|
283
|
-
- Navigation is stuck in an error state with no recoverable action.
|
|
284
|
-
- The tester arrived on a page that cannot host the scenario at all.
|
|
292
|
+
${this.buildDeletionScope(task)}
|
|
285
293
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
EXPECTED RESULTS (milestones):
|
|
295
|
+
${task.expected.map((e) => `- ${e}`).join('\n')}
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
buildResetSystemPrompt(task) {
|
|
299
|
+
return dedent `
|
|
300
|
+
You are Pilot — decide whether a reset is legitimate. Reset is DESTRUCTIVE: it abandons this
|
|
301
|
+
iteration's work, but server-side side effects (records created, forms submitted) persist.
|
|
302
|
+
Unnecessary resets create duplicate data and infinite loops.
|
|
294
303
|
|
|
295
|
-
|
|
296
|
-
- resetCount >= 2 and the previous resets did not change the underlying situation.
|
|
297
|
-
- The same flow has been attempted twice with the same failure mode.
|
|
298
|
-
- Repeating the reset cannot produce new information.
|
|
304
|
+
${this.buildSharedEvidenceRules(task)}
|
|
299
305
|
|
|
300
|
-
|
|
301
|
-
-
|
|
306
|
+
DECISION:
|
|
307
|
+
- "allow": current page cannot host the scenario, irrecoverable error, or no path back.
|
|
308
|
+
- "continue": prior action already succeeded (URL changed, record visible, confirmation shown) — verify/finish instead. Or scenario goal may already be met; instruct tester to verify the actual outcome rather than redo. Provide guidance.
|
|
309
|
+
- "fail": resetCount >= 2 and underlying situation hasn't changed; same flow tried twice with same failure mode.
|
|
310
|
+
- "skipped": feature doesn't exist on this app or prerequisites can't be met.
|
|
302
311
|
|
|
303
312
|
PRIORITY:
|
|
304
|
-
1)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
3) Tester's stated reason. Weigh it against the observed evidence, do not trust it blindly.
|
|
308
|
-
|
|
309
|
-
GUIDANCE FIELD (required when decision is "continue"):
|
|
310
|
-
Give a specific next action on the current page: which tool to call, what to verify, or how to
|
|
311
|
-
record the outcome. Do not suggest repeating actions that already succeeded.
|
|
313
|
+
1) Successful side effects in session_log → almost never allow reset.
|
|
314
|
+
2) resetCount — each prior reset raises the bar.
|
|
315
|
+
3) Tester's stated reason — weigh against evidence, don't trust blindly.
|
|
312
316
|
|
|
313
|
-
|
|
314
|
-
|
|
317
|
+
GUIDANCE (required for "continue"): a specific next action on the current page — which tool, what
|
|
318
|
+
to verify, how to record. Do not suggest repeating actions that already succeeded.
|
|
315
319
|
`;
|
|
316
320
|
}
|
|
317
321
|
buildVerdictSystemPrompt(type, task) {
|
|
318
322
|
return dedent `
|
|
319
|
-
You are Pilot —
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
For edit/update/rename scenarios, persisted updated value visible in list/detail view is valid save evidence, even without toast and even if page redirected away from edit view.
|
|
339
|
-
DO NOT trust Tester's self-assessment in notes (like "scenario goal achieved"). Verify against actual actions and state.
|
|
340
|
-
EVIDENCE SOURCES: verify(), see(), visual_analysis, and action results in session_log are all evidence. They may disagree — analyze all of them together to reach your decision. No single source automatically overrides the others. Visual analysis from screenshots is strong evidence for UI state (active tabs, visible items, counts, colors). Tester's self-assessment in record() notes is the least reliable — always cross-check against actual evidence.
|
|
341
|
-
SESSION LOG shows ALL actions grouped by URL. If the scenario requires changing data (edit/create/delete) but all form/click actions FAILED, the test cannot pass — even if a verify() found matching content that existed before the test.
|
|
342
|
-
|
|
343
|
-
VERIFICATION RULE: Only the LAST few actions before finish/stop count as verification evidence.
|
|
344
|
-
- If verify() or see() is among the last actions → use its result as evidence.
|
|
345
|
-
- If no verification was done → prefer "continue" with guidance telling tester what to verify.
|
|
346
|
-
- If verify assertion describes a state that was ALREADY TRUE before the test started, the verification proves nothing — reject with "continue".
|
|
347
|
-
|
|
348
|
-
requestVerification — pick assertions DOM can actually express. Some content is not assertable via DOM (iframe text, canvas, custom widgets, Monaco/CodeMirror editors). When the scenario goal lives in such a region, target a STABLE LANDMARK (container element, ARIA role, the parent that wraps the widget) rather than literal text inside it. Your "pass" verdict is honored even if the DOM assertion can't be made — pick the strongest landmark you can.
|
|
349
|
-
|
|
350
|
-
GUIDANCE FIELD: When decision is "continue", you MUST provide "guidance" — a specific actionable instruction:
|
|
351
|
-
- If evidence is insufficient: tell tester to verify with see()/verify(), specify WHAT to check
|
|
352
|
-
- If approach was wrong: tell tester to try a different method, suggest which one
|
|
353
|
-
- If remaining steps exist: tell tester which steps to complete next
|
|
354
|
-
Be concrete. Example: "Use see() to check if the description text appears in the Description tab panel" not "verify the result".
|
|
355
|
-
Do NOT tell tester to redo the same actions that already succeeded.
|
|
356
|
-
|
|
357
|
-
NEGATIVE TESTS: Some scenarios test that something CANNOT or SHOULD NOT happen.
|
|
358
|
-
Patterns: "without a name", "with invalid data", "empty field", "wrong password", "unauthorized", "duplicate".
|
|
359
|
-
For negative tests, success means the system PREVENTED the action — error messages, validation, disabled buttons.
|
|
360
|
-
Example: "Create X without a name" PASSES if X was NOT created and validation appeared.
|
|
361
|
-
|
|
362
|
-
SKIPPED TESTS: Choose "skipped" in two cases:
|
|
363
|
-
1) Scenario is irrelevant: feature doesn't exist on the page, required UI elements are completely absent, scenario prerequisites cannot be met.
|
|
364
|
-
2) Systematic execution failures: repeated LLM/API errors, navigation crashes, tool failures unrelated to the scenario itself. These are infrastructure problems, not test failures.
|
|
365
|
-
Do NOT use "skipped" when the feature exists but the test just failed to interact with it — that's "fail" or "continue".
|
|
366
|
-
|
|
367
|
-
${this.buildDeletionScope(task)}
|
|
368
|
-
|
|
369
|
-
REASON FORMAT: The "reason" field goes into the test report. Do NOT start with "The scenario goal was/was not achieved" or similar status phrases — the decision field already conveys that. Instead, state what happened: what was verified, what failed, or what evidence was found.
|
|
370
|
-
|
|
371
|
-
EXPECTED RESULTS (milestones, not the goal):
|
|
372
|
-
${task.expected.map((e) => `- ${e}`).join('\n')}
|
|
323
|
+
You are Pilot — final decision maker for test pass/fail. Tester requested ${type}. Review the
|
|
324
|
+
evidence and commit to a verdict; "continue" only when evidence is genuinely insufficient.
|
|
325
|
+
|
|
326
|
+
${this.buildSharedEvidenceRules(task)}
|
|
327
|
+
|
|
328
|
+
DECISION:
|
|
329
|
+
- "pass": scenario goal is fully accomplished. Set requestVerification to a one-sentence claim about
|
|
330
|
+
the current page that proves it (a unique element/text that exists ONLY because the scenario succeeded).
|
|
331
|
+
Pick assertions DOM can express; for non-DOM regions (iframes, canvas, Monaco/CodeMirror), target a
|
|
332
|
+
stable landmark (container, ARIA role) instead of literal inner text. Your "pass" stands even if the
|
|
333
|
+
DOM assertion can't be made.
|
|
334
|
+
- "fail": scenario was attempted but the goal was not achieved.
|
|
335
|
+
- "skipped": scenario is irrelevant to the app, OR systematic infrastructure failures (LLM errors,
|
|
336
|
+
crashes) prevented testing. NOT for "test failed to interact" — that's "fail" or "continue".
|
|
337
|
+
- "continue": tester hasn't completed the goal; provide concrete guidance (which tool, what to check).
|
|
338
|
+
If a verify() asserted a state that was ALREADY TRUE before the test, it proves nothing — reject.
|
|
339
|
+
|
|
340
|
+
reason field: do NOT restate the decision ("scenario goal achieved/not achieved"). State what happened —
|
|
341
|
+
what was verified, what failed, what evidence was found.
|
|
373
342
|
`;
|
|
374
343
|
}
|
|
375
344
|
async planTest(task, currentState) {
|
|
@@ -379,7 +348,9 @@ export class Pilot {
|
|
|
379
348
|
allowNewResearch: false,
|
|
380
349
|
});
|
|
381
350
|
const agenticModel = this.provider.getAgenticModel('pilot');
|
|
382
|
-
this.conversation = this.provider.startConversation(this.getSystemPrompt(task, currentState
|
|
351
|
+
this.conversation = this.provider.startConversation(this.getSystemPrompt(task, currentState), 'pilot', agenticModel);
|
|
352
|
+
this.conversation.markLastMessageCacheable();
|
|
353
|
+
this.conversation.protectPrefix(1);
|
|
383
354
|
const stateContext = this.buildStateContext(currentState);
|
|
384
355
|
return this.sendToPilot(dedent `
|
|
385
356
|
<state>
|
|
@@ -460,11 +431,9 @@ export class Pilot {
|
|
|
460
431
|
async analyzeProgress(task, currentState, testerConversation) {
|
|
461
432
|
tag('substep').log('Pilot analyzing progress...');
|
|
462
433
|
if (!this.conversation) {
|
|
463
|
-
const pageSummary = await this.researcher.summary(currentState, {
|
|
464
|
-
allowNewResearch: false,
|
|
465
|
-
});
|
|
466
434
|
const agenticModel = this.provider.getAgenticModel('pilot');
|
|
467
|
-
this.conversation = this.provider.startConversation(this.getSystemPrompt(task, currentState
|
|
435
|
+
this.conversation = this.provider.startConversation(this.getSystemPrompt(task, currentState), 'pilot', agenticModel);
|
|
436
|
+
this.conversation.markLastMessageCacheable();
|
|
468
437
|
}
|
|
469
438
|
const toolCalls = testerConversation.getToolExecutions().slice(-this.stepsToReview);
|
|
470
439
|
const actionsContext = this.formatActions(toolCalls);
|
|
@@ -517,6 +486,7 @@ export class Pilot {
|
|
|
517
486
|
const result = await this.provider.invokeConversation(this.conversation, tools, {
|
|
518
487
|
maxToolRoundtrips: opts.maxToolRoundtrips ?? 0,
|
|
519
488
|
agentName: 'pilot',
|
|
489
|
+
stopWhen: opts.task ? () => opts.task.hasFinished : undefined,
|
|
520
490
|
experimental_telemetry: { functionId },
|
|
521
491
|
});
|
|
522
492
|
const text = result?.response?.text || '';
|
|
@@ -575,12 +545,18 @@ export class Pilot {
|
|
|
575
545
|
tag('info').log(`Precondition: ${description}`);
|
|
576
546
|
debugLog(`precondition: ${description}, fisherman: ${this.fisherman?.isAvailable() ? 'available' : 'none'}`);
|
|
577
547
|
if (!this.fisherman || !this.fisherman.isAvailable()) {
|
|
548
|
+
const skipReason = await this.checkDataAvailability(task, description, 'Fisherman not available');
|
|
549
|
+
if (skipReason)
|
|
550
|
+
return { noted: true, prepared: false, skipped: true, reason: skipReason };
|
|
578
551
|
return { noted: true, prepared: false, reason: 'Fisherman not available' };
|
|
579
552
|
}
|
|
580
553
|
const result = await this.fisherman.prepareData(description, task.startUrl, task.sessionName);
|
|
581
554
|
if (!result.success || result.created.length === 0) {
|
|
582
555
|
if (result.summary)
|
|
583
556
|
tag('warning').log(`Precondition failed: ${result.summary}`);
|
|
557
|
+
const skipReason = await this.checkDataAvailability(task, description, result.summary);
|
|
558
|
+
if (skipReason)
|
|
559
|
+
return { noted: true, prepared: false, skipped: true, reason: skipReason };
|
|
584
560
|
return { noted: true, prepared: false, reason: result.summary };
|
|
585
561
|
}
|
|
586
562
|
const items = result.created.map((c) => {
|
|
@@ -599,6 +575,36 @@ export class Pilot {
|
|
|
599
575
|
}),
|
|
600
576
|
};
|
|
601
577
|
}
|
|
578
|
+
async checkDataAvailability(task, requestedData, fishermanReason) {
|
|
579
|
+
if (!this.provider.hasVision())
|
|
580
|
+
return null;
|
|
581
|
+
const action = this.explorer.createAction();
|
|
582
|
+
const screenshotState = await action.caputrePageWithScreenshot().catch(() => null);
|
|
583
|
+
if (!screenshotState?.screenshot)
|
|
584
|
+
return null;
|
|
585
|
+
const question = dedent `
|
|
586
|
+
Test scenario: "${task.scenario}"
|
|
587
|
+
Data we tried to create automatically (and failed): ${requestedData}
|
|
588
|
+
Failure reason: ${fishermanReason || 'unknown'}
|
|
589
|
+
|
|
590
|
+
Looking at the current page only, can this scenario still be carried out?
|
|
591
|
+
- YES if the page already shows the items the scenario will act on, OR if the page exposes a UI control that creates such items (an "Add", "New", "+" button, an empty-state CTA, etc.).
|
|
592
|
+
- NO if the scenario needs items that aren't visible AND there is no way to create them from this page (e.g. a filter/search/select scenario over an empty list with no creation affordance).
|
|
593
|
+
|
|
594
|
+
Reply with YES or NO on the first line, then a one-sentence reason on the second line.
|
|
595
|
+
`;
|
|
596
|
+
const answer = await this.researcher.answerQuestionAboutScreenshot(screenshotState, question);
|
|
597
|
+
if (!answer)
|
|
598
|
+
return null;
|
|
599
|
+
const firstLine = answer.split('\n')[0]?.trim().toUpperCase() ?? '';
|
|
600
|
+
if (!firstLine.startsWith('NO'))
|
|
601
|
+
return null;
|
|
602
|
+
const reason = answer.split('\n').slice(1).join(' ').trim() || 'Required data is absent and cannot be created from this page';
|
|
603
|
+
task.setVerification(`Pilot: skipped — ${reason}`, TestResult.SKIPPED, screenshotState);
|
|
604
|
+
task.finish(TestResult.SKIPPED);
|
|
605
|
+
tag('info').log(`Pilot: precondition failed and page lacks required data — skipping test (${reason})`);
|
|
606
|
+
return reason;
|
|
607
|
+
}
|
|
602
608
|
buildStateContext(state) {
|
|
603
609
|
const lines = [];
|
|
604
610
|
lines.push(`url: ${state.url}`);
|
|
@@ -750,12 +756,13 @@ export class Pilot {
|
|
|
750
756
|
}
|
|
751
757
|
}
|
|
752
758
|
const analysisText = exec.output?.analysis;
|
|
753
|
-
const resultMessage = analysisText ? (analysisText.length >
|
|
759
|
+
const resultMessage = analysisText ? (analysisText.length > 300 ? `${analysisText.slice(0, 300)}...` : analysisText) : exec.output?.message || exec.output?.result;
|
|
754
760
|
if (resultMessage && (CHECK_TOOLS.includes(exec.toolName) || !exec.wasSuccessful)) {
|
|
755
761
|
line += `\n result: ${resultMessage}`;
|
|
756
762
|
}
|
|
757
763
|
groups.get(currentUrl).lines.push(line);
|
|
758
764
|
}
|
|
765
|
+
const PER_GROUP_CAP = 25;
|
|
759
766
|
const parts = [];
|
|
760
767
|
for (const [url, group] of groups) {
|
|
761
768
|
const header = [url];
|
|
@@ -766,7 +773,11 @@ export class Pilot {
|
|
|
766
773
|
if (group.h3)
|
|
767
774
|
header.push(` h3: ${group.h3}`);
|
|
768
775
|
header.push('');
|
|
769
|
-
const
|
|
776
|
+
const omitted = Math.max(0, group.lines.length - PER_GROUP_CAP);
|
|
777
|
+
const visibleLines = omitted > 0 ? group.lines.slice(-PER_GROUP_CAP) : group.lines;
|
|
778
|
+
const lines = visibleLines.map((l) => ` ${l}`);
|
|
779
|
+
if (omitted > 0)
|
|
780
|
+
lines.unshift(` [...${omitted} earlier action(s) omitted...]`);
|
|
770
781
|
parts.push([...header, ...lines].join('\n'));
|
|
771
782
|
}
|
|
772
783
|
return parts.join('\n\n');
|
|
@@ -823,11 +834,11 @@ export class Pilot {
|
|
|
823
834
|
}
|
|
824
835
|
return '';
|
|
825
836
|
}
|
|
826
|
-
getSystemPrompt(task, initialState
|
|
837
|
+
getSystemPrompt(task, initialState) {
|
|
827
838
|
const interactive = isInteractive();
|
|
828
839
|
const stepsText = task.plannedSteps.length > 0 ? task.plannedSteps.map((s, i) => `${i + 1}. ${s}`).join('\n') : 'No planned steps';
|
|
829
840
|
return dedent `
|
|
830
|
-
You are Pilot
|
|
841
|
+
You are Pilot — a supervisor that detects problems and intervenes only when needed.
|
|
831
842
|
|
|
832
843
|
SCENARIO: ${task.scenario}
|
|
833
844
|
START URL: ${initialState.url}
|
|
@@ -839,136 +850,63 @@ export class Pilot {
|
|
|
839
850
|
PLANNED STEPS:
|
|
840
851
|
${stepsText}
|
|
841
852
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
-
|
|
861
|
-
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
-
|
|
868
|
-
-
|
|
869
|
-
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
-
|
|
873
|
-
-
|
|
874
|
-
-
|
|
875
|
-
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
-
|
|
887
|
-
|
|
888
|
-
-
|
|
889
|
-
-
|
|
890
|
-
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
- If Tester's explanation mentions TWO distinct actions in ONE tool call → flag this. Each distinct action should be a separate tool call. Instruct Tester to split into individual steps.
|
|
900
|
-
|
|
901
|
-
Complex component patterns — when Tester fails to interact with dropdowns/selects:
|
|
902
|
-
- Search-and-select dropdowns require a SEQUENCE: click/focus the trigger input, type to filter, then click an option from the dropdown list. Instruct Tester to split this into separate tool calls.
|
|
903
|
-
- If Tester clicks a generic dropdown trigger and ariaDiff shows unrelated options → wrong dropdown was triggered. Instruct Tester to use a more specific selector with container context.
|
|
904
|
-
- If Tester types into an input but no dropdown appears → they may need to click the trigger element first. Suggest using context() to check the current DOM state.
|
|
905
|
-
|
|
906
|
-
Tester ignoring visible elements:
|
|
907
|
-
- If <state> shows "active form" fields but Tester is clicking elements not found in ARIA, or trying buttons that don't exist → Tester is ignoring interactive elements that are actually on the page. Instruct Tester to focus on the elements listed in "active form" — these are the real interactive controls on the current page. The UI map may be outdated.
|
|
908
|
-
|
|
909
|
-
When Tester IS stuck finding an element, use xpathCheck() with COMBINED XPaths:
|
|
910
|
-
- NEVER guess one exact text. UI labels differ from scenario wording.
|
|
911
|
-
- Combine multiple guesses into ONE XPath using "or" operator.
|
|
912
|
-
- Include: synonyms, partial text, aria-label, title, role, icon classes.
|
|
913
|
-
- Example: looking for a "create project" button:
|
|
914
|
-
//*[(contains(., "Create project") or contains(., "New project") or contains(., "Add project") or contains(@aria-label, "project")) or (contains(., "project") and (contains(@class, "add") or contains(@class, "plus") or contains(@class, "create") or .//*[contains(@class, "plus") or contains(@class, "add") or contains(@class, "icon-add")]))][@role="button" or @role="link" or self::button or self::a]
|
|
915
|
-
- Key: combine text synonyms + icon classes on children (.//*[contains(@class,...)]) + aria attributes
|
|
916
|
-
- If no results, broaden: drop the role filter, or search by role only, then check results for relevant text.
|
|
917
|
-
- After finding candidates, narrow down and include discovered XPath in NEXT instruction.
|
|
918
|
-
|
|
919
|
-
If you need more page context, mention ATTACH_HTML, ATTACH_ARIA, or ATTACH_UI_MAP — but only when recent actions show failures.
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
Available Tester tools:
|
|
923
|
-
- click(locator) — click elements
|
|
924
|
-
- pressKey(key) — keyboard keys
|
|
925
|
-
- form(code) — execute multiple commands (fillField, type, selectOption, attachFile)
|
|
926
|
-
- see(request) — visual screenshot analysis
|
|
927
|
-
- verify(assertion) — AI-powered DOM assertion (uses I.see, I.seeElement, I.seeInField, I.dontSee)
|
|
928
|
-
- context() — fresh HTML/ARIA snapshot
|
|
929
|
-
- research() — get UI map
|
|
930
|
-
- xpathCheck(xpath) — find elements by XPath
|
|
931
|
-
- visualClick(element) — coordinate-based click
|
|
932
|
-
- back() — return to previous page
|
|
933
|
-
- getVisitedStates() — list all visited pages (deduped by URL)
|
|
934
|
-
- reset() — return to initial page
|
|
935
|
-
- stop(reason) — abort test
|
|
936
|
-
- finish(verify) — complete test successfully
|
|
937
|
-
- record(notes) — document findings
|
|
938
|
-
|
|
939
|
-
YOUR tools (Pilot-only):
|
|
940
|
-
- precondition(description) — create FRESH test data via API that the test will act on. Do NOT request users.
|
|
941
|
-
|
|
942
|
-
PRECONDITIONS — when and what to create:
|
|
943
|
-
Preconditions create NEW disposable items that the test will modify, delete, or interact with.
|
|
944
|
-
|
|
945
|
-
Ask yourself: "What object will this test change/delete/use? Create THAT."
|
|
946
|
-
|
|
947
|
-
When to call precondition():
|
|
948
|
-
- Scenario edits/deletes/modifies an item → create a disposable target
|
|
949
|
-
- Scenario needs auxiliary data (labels, categories, statuses to filter by)
|
|
950
|
-
- Tester failed because required data is missing (empty dropdown, no items to select)
|
|
951
|
-
|
|
952
|
-
When to SKIP precondition():
|
|
953
|
-
- Scenario is "Create X" — the test itself creates the item, no precondition needed
|
|
954
|
-
- Current page already shows the exact data needed (check <state> h1/title and <page_summary>)
|
|
955
|
-
- Scenario tests navigation, search UI, or viewing — no data mutation involved
|
|
956
|
-
|
|
957
|
-
Examples — when to create:
|
|
958
|
-
- "Edit test description" → precondition("1 test") — the test will edit this item
|
|
959
|
-
- "Delete a comment" → precondition("1 comment") — the test will delete this item
|
|
960
|
-
- "Assign a label to item" → precondition("1 item and 1 label named Bug") — test assigns the label
|
|
961
|
-
- "Filter by status" → precondition("3 items: 2 with status Open, 1 with status Closed")
|
|
962
|
-
|
|
963
|
-
Examples — when to skip:
|
|
964
|
-
- "Create a new blog post" → SKIP, the test creates it
|
|
965
|
-
- "Edit blog post" while on a blog post page → SKIP, data already exists
|
|
966
|
-
- "View dashboard" → SKIP, no data mutation
|
|
967
|
-
|
|
968
|
-
WRONG: precondition("1 test suite named Updated Suite with existing tests") — describes the page, not what to create
|
|
969
|
-
RIGHT: precondition("1 test") — create a fresh test that the scenario will edit
|
|
970
|
-
|
|
971
|
-
Keep descriptions short and specific.
|
|
853
|
+
Your job: plan, review new pages, detect stuck patterns, suggest concrete next steps. Track which
|
|
854
|
+
expectations are checked. When things go well, encourage briefly and let Tester continue. The current
|
|
855
|
+
page is usually richer than the page summary lists — prefer exploring it before navigating away.
|
|
856
|
+
|
|
857
|
+
Already-achieved detection: if the scenario goal is met in the current state (page_summary, ariaDiff,
|
|
858
|
+
state), instruct Tester to verify() and finish(). If goal was already true at the start, propose
|
|
859
|
+
different input data so the test is meaningful. If Tester repeats the same successful action, STOP.
|
|
860
|
+
|
|
861
|
+
Action classification: GOAL-ADVANCING actions mutate the scenario's subject data (create/edit/delete/submit/verify).
|
|
862
|
+
VIEW-ONLY actions toggle filters/tabs/sort/collapse without changing data. One VIEW-ONLY to reveal a
|
|
863
|
+
target is fine; ≥2 consecutive VIEW-ONLY actions with no GOAL-ADVANCING action in between is thrashing
|
|
864
|
+
— redirect Tester to the actual mutation or verification. Repeated large htmlParts diffs are a thrashing signal.
|
|
865
|
+
|
|
866
|
+
Navigation: compare current url to START URL. Subpage = OK. Parent/sibling = suspicious, instruct
|
|
867
|
+
back()/reset(). Different domain = wrong, reset() immediately.
|
|
868
|
+
|
|
869
|
+
Tool usage policy:
|
|
870
|
+
- When Tester is making progress with no failures, do NOT call see/context/research — Tester already has ARIA/HTML.
|
|
871
|
+
- Use see/context only after 2+ failures on the same element or action.
|
|
872
|
+
- Use xpathCheck proactively on the FIRST element-not-found error or when ARIA role looks wrong; pass the discovered locator into your next instruction.
|
|
873
|
+
${interactive ? '- Use askUser() only as last resort.' : ''}
|
|
874
|
+
|
|
875
|
+
Diagnostic patterns (use <state>, executed/element/skipped fields, ariaDiff):
|
|
876
|
+
- Click failed + button in "disabled buttons" → required field missing. Instruct fill first.
|
|
877
|
+
- "modal: none" but Tester targets a modal → modal closed; re-trigger.
|
|
878
|
+
- Action SUCCESS but ariaDiff empty → may have worked without visible DOM change; check result message.
|
|
879
|
+
- MultipleElementsFound → xpathCheck() to identify the right one, then precise locator or visualClick().
|
|
880
|
+
- Wrong page (settings vs feature) → getVisitedStates() then back() or reset(). Don't try breadcrumbs (SPA back-nav is unreliable).
|
|
881
|
+
- Click SUCCESS but executed locator ≠ explanation intent, or "skipped" attempts present → wrong element clicked.
|
|
882
|
+
- form(I.type()) SUCCESS but "element" shows a button/link → keys went to wrong element; click the input first.
|
|
883
|
+
- ariaDiff shows 5+ added/removed → page entered new mode (editor/modal); call context() before guessing selectors.
|
|
884
|
+
- Empty dropdown/list when items expected → missing data; call precondition() to create it.
|
|
885
|
+
- Search-and-select needs SEQUENCE: focus trigger → type to filter → click option. Tell Tester to split into separate tool calls.
|
|
886
|
+
- Multi-action explanation in one tool call → instruct Tester to split.
|
|
887
|
+
|
|
888
|
+
xpathCheck strategy when stuck: never guess one exact text. Combine synonyms, aria-label, title,
|
|
889
|
+
role, icon classes with "or" in one XPath. If empty, broaden (drop role filter). Pass discovered
|
|
890
|
+
XPath into NEXT instruction.
|
|
891
|
+
|
|
892
|
+
To request more context, mention ATTACH_HTML, ATTACH_ARIA, or ATTACH_UI_MAP — only when recent actions show failures.
|
|
893
|
+
|
|
894
|
+
Tester tools: click, pressKey, form, see, verify, context, research, xpathCheck, visualClick,
|
|
895
|
+
back, getVisitedStates, reset, stop, finish, record.
|
|
896
|
+
|
|
897
|
+
YOUR Pilot-only tool: precondition(description) — create FRESH disposable test data via API. Never
|
|
898
|
+
request users. Use when:
|
|
899
|
+
- Scenario edits/deletes/modifies an item → create a disposable target ("1 post").
|
|
900
|
+
- Scenario needs auxiliary data (labels, categories, statuses for filtering).
|
|
901
|
+
- Tester failed because required data is missing (empty dropdown, empty list).
|
|
902
|
+
|
|
903
|
+
Skip precondition() when:
|
|
904
|
+
- Scenario is "Create X" — the test creates it itself.
|
|
905
|
+
- Current page already shows the exact data needed.
|
|
906
|
+
- Scenario tests navigation, search UI, or viewing.
|
|
907
|
+
|
|
908
|
+
Describe WHAT to create, not what exists. RIGHT: precondition("1 test"). WRONG:
|
|
909
|
+
precondition("1 test suite named Updated Suite with existing tests"). Keep descriptions short.
|
|
972
910
|
|
|
973
911
|
Response format:
|
|
974
912
|
PROGRESS: <1 sentence assessment>
|