Skip to content

Commit b653a8c

Browse files
committed
chore(support): align agent-browser config, schemas, and validation helpers
- Add agent-browser.json project config (allowedDomains defaults) - Drop legacy support/browser wrapper (obsolete .env.browser sourcing) - browser-validate.ts: replace busy-wait sleep with async setTimeout, wrap precomputeData return in Promise, await its call - Unify subagent-browser-schema.json into browser-validation-schema.json (add testName, error, session_id; relax metrics/checks requirements) - Update CONFIG-REPO-VALIDATION.md and subagent-spawning-pattern.md to reference the unified schema
1 parent 3baed27 commit b653a8c

7 files changed

Lines changed: 37 additions & 112 deletions

‎agent-browser.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"allowedDomains": [
3+
"localhost",
4+
"127.0.0.1",
5+
"*.example.com",
6+
"*.github.com",
7+
"*.wikipedia.org",
8+
"developer.chrome.com"
9+
]
10+
}

‎doc/CONFIG-REPO-VALIDATION.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ config/
7070
├── docs/
7171
│ └── subagent-spawning-pattern.md
7272
└── schemas/
73-
├── browser-validation-schema.json
74-
└── subagent-browser-schema.json
73+
└── browser-validation-schema.json
7574
```
7675

7776
---
@@ -134,8 +133,7 @@ All reference `/opt/pi-support` for support files (correct — install.sh copies
134133
| `config/agent-browser-action-policy.json` | Destructive action gates | ✅ |
135134
| `config/subagent-browser-prompt.txt` | Subagent browser prompt template | ✅ |
136135
| `docs/subagent-spawning-pattern.md` | Orchestration docs | ✅ |
137-
| `schemas/browser-validation-schema.json` | Validation report schema | ✅ |
138-
| `schemas/subagent-browser-schema.json` | Subagent result schema | ✅ |
136+
| `schemas/browser-validation-schema.json` | Unified validation report schema | ✅ |
139137

140138
---
141139

‎support/browser‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎support/browser-validate.ts‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ function agentBrowser(...args: string[]): string {
6565

6666
// ─── Task 2.4: Pre-computation ──────────────────────────────────────────────
6767

68-
function precomputeData(
68+
async function precomputeData(
6969
url: string,
7070
sessionId: string,
71-
): { vitals: string; a11y: string; snapshot: string; screenshotPath: string } {
71+
): Promise<{ vitals: string; a11y: string; snapshot: string; screenshotPath: string }> {
7272
const screenshotPath = `/browser-states/${sessionId}/screenshot.png`;
7373

7474
// Ensure session directory exists
@@ -77,7 +77,7 @@ function precomputeData(
7777
// Navigate
7878
agentBrowser("--session", sessionId, "open", url);
7979
// Small delay for page to load
80-
sleep(1000);
80+
await sleep(1000);
8181

8282
// Collect vitals JSON
8383
const vitals = agentBrowser("--session", sessionId, "vitals", "--json");
@@ -309,11 +309,8 @@ function saveReport(sessionId: string, report: ValidationReport): string {
309309

310310
// ─── Helpers ─────────────────────────────────────────────────────────────────
311311

312-
function sleep(ms: number): void {
313-
const start = Date.now();
314-
while (Date.now() - start < ms) {
315-
// busy wait (sync for simplicity)
316-
}
312+
function sleep(ms: number): Promise<void> {
313+
return new Promise(resolve => setTimeout(resolve, ms));
317314
}
318315

319316
// ─── Main ────────────────────────────────────────────────────────────────────
@@ -341,7 +338,7 @@ async function main(): Promise<void> {
341338
try {
342339
// Step 1: Pre-compute structured data
343340
console.log("→ Pre-computing structured data...");
344-
const { vitals, a11y, snapshot, screenshotPath } = precomputeData(
341+
const { vitals, a11y, snapshot, screenshotPath } = await precomputeData(
345342
url,
346343
sessionId,
347344
);

‎support/docs/subagent-spawning-pattern.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ subagent({
3939
4040
Session ID: ${SESSION_ID}
4141
Prompt: ${PROMPT}`,
42-
outputSchema: JSON.parse(readFileSync("subagent-browser-schema.json")),
42+
outputSchema: JSON.parse(readFileSync("browser-validation-schema.json")),
4343
});
4444
```
4545

@@ -88,6 +88,6 @@ if (!result.success) {
8888
| File | Purpose |
8989
|------|---------|
9090
| `bin/session-uuid.ts` | Generate unique session IDs |
91-
| `subagent-browser-schema.json` | JSON schema for subagent results |
91+
| `browser-validation-schema.json` | Unified JSON schema (all fields) |
9292
| `subagent-browser-prompt.txt` | System prompt template |
9393
| `bin/validate-subagent-output.ts` | Parent-side validation utility |

‎support/schemas/browser-validation-schema.json‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "BrowserValidationReport",
4-
"description": "Structured validation report produced by the vision model for a web application",
4+
"description": "Structured validation report from browser tests (vision model or subagent). All fields except url/status/metrics/checks are optional.",
55
"type": "object",
66
"required": ["url", "status", "metrics", "checks"],
77
"properties": {
88
"url": {
99
"type": "string",
1010
"format": "uri",
11-
"description": "The URL that was validated"
11+
"description": "The URL that was tested or validated"
1212
},
1313
"status": {
1414
"type": "string",
1515
"enum": ["PASS", "WARN", "FAIL"],
16-
"description": "Overall validation status"
16+
"description": "Overall test/validation result"
17+
},
18+
"testName": {
19+
"type": "string",
20+
"description": "Name of the test that was run (subagent/browser-test only)"
1721
},
1822
"metrics": {
1923
"type": "object",
20-
"required": [
21-
"lcp_ms",
22-
"cls",
23-
"ttfb_ms",
24-
"a11y_violations",
25-
"a11y_passes"
26-
],
24+
"required": ["lcp_ms", "cls", "ttfb_ms", "a11y_violations", "a11y_passes"],
2725
"properties": {
2826
"lcp_ms": {
2927
"type": "number",
@@ -55,7 +53,7 @@
5553
"type": "array",
5654
"items": {
5755
"type": "object",
58-
"required": ["check", "description", "pass"],
56+
"required": ["check", "pass"],
5957
"properties": {
6058
"check": {
6159
"type": "string",
@@ -76,6 +74,14 @@
7674
}
7775
}
7876
},
77+
"error": {
78+
"type": "string",
79+
"description": "Error message if the test/validation failed"
80+
},
81+
"session_id": {
82+
"type": "string",
83+
"description": "The browser session ID used for this test"
84+
},
7985
"screenshot_path": {
8086
"type": "string",
8187
"description": "Path to the annotated screenshot used for validation"

‎support/schemas/subagent-browser-schema.json‎

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)