Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ai/fisherman-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function extractKeyFields(body: any, result: Record<string, any> = {}, depth = 0
}

for (const [key, value] of Object.entries(body)) {
if (value === null || value === undefined) continue;
if (value == null) continue;
if (typeof value === 'object') {
extractKeyFields(value, result, depth + 1);
continue;
Expand Down
75 changes: 34 additions & 41 deletions src/ai/quartermaster.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { z } from 'zod';
import type { ActionResult } from '../action-result.ts';
import { ConfigParser } from '../config.ts';
import { outputPath } from '../config.ts';
import type { StateManager, StateTransition, WebPageState } from '../state-manager.ts';
import type { Task } from '../test-plan.ts';
import { createDebug, tag } from '../utils/logger.ts';
Expand All @@ -12,36 +12,6 @@ import type { Provider } from './provider.ts';

const debugLog = createDebug('explorbot:quartermaster');

interface AxeViolation {
id: string;
impact: 'critical' | 'serious' | 'moderate' | 'minor';
description: string;
helpUrl: string;
nodes: Array<{ html: string; target: string[] }>;
}

interface PageAnalysis {
url: string;
stateHash: string;
timestamp: string;
axeViolations: AxeViolation[];
}

interface SemanticIssue {
type: 'unclear_intention' | 'confusing_naming' | 'hard_to_interact';
element: string;
issue: string;
suggestion: string;
}

interface AnalysisReport {
scenario: string;
timestamp: string;
url: string;
axeViolations: AxeViolation[];
semanticIssues: SemanticIssue[];
}

export class Quartermaster {
private provider: Provider;
private model?: any;
Expand All @@ -55,13 +25,12 @@ export class Quartermaster {
this.provider = provider;
this.model = options?.model;

const configParser = ConfigParser.getInstance();
this.outputDir = join(configParser.getOutputDir(), 'a11y');
this.outputDir = outputPath('a11y');
}

start(playwrightHelper: any, stateManager: StateManager): void {
this.playwrightHelper = playwrightHelper;
this.ensureDirectory();
mkdirSync(this.outputDir, { recursive: true });

this.unsubscribe = stateManager.onStateChange((event) => {
this.onPageChange(event);
Expand All @@ -78,12 +47,6 @@ export class Quartermaster {
debugLog('Quartermaster stopped');
}

private ensureDirectory(): void {
if (!existsSync(this.outputDir)) {
mkdirSync(this.outputDir, { recursive: true });
}
}

private onPageChange(event: StateTransition): void {
const state = event.toState;
if (!state?.hash) return;
Expand Down Expand Up @@ -284,3 +247,33 @@ Focus on what would confuse a real user or caused the agent to make mistakes.`;
return content;
}
}

interface AxeViolation {
id: string;
impact: 'critical' | 'serious' | 'moderate' | 'minor';
description: string;
helpUrl: string;
nodes: Array<{ html: string; target: string[] }>;
}

interface PageAnalysis {
url: string;
stateHash: string;
timestamp: string;
axeViolations: AxeViolation[];
}

interface SemanticIssue {
type: 'unclear_intention' | 'confusing_naming' | 'hard_to_interact';
element: string;
issue: string;
suggestion: string;
}

interface AnalysisReport {
scenario: string;
timestamp: string;
url: string;
axeViolations: AxeViolation[];
semanticIssues: SemanticIssue[];
}
Loading