@tangle-network/agent-bench 0.14.1 → 0.14.4
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/CHANGELOG.md +16 -0
- package/package.json +6 -6
- package/scripts/verify-packed-consumer.mjs +0 -1
- package/src/atom-mcp-e2e.mts +14 -2
- package/src/coordination-mcp-container-reach.mts +5 -5
- package/src/gate.ts +1 -1
- package/src/mcp-mount-probe.mts +7 -5
- package/src/run-benchmarks.test.mts +0 -4
- package/src/search-bench/profiles.ts +1 -1
- package/src/tb-supervisor-sidecar.mts +1 -1
- package/tb_agents/opencode_supervisor_agent.py +2 -2
- package/src/browser/adapters/bad-design-audit.ts +0 -153
- package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
- package/src/browser/adapters/bad.ts +0 -165
- package/src/browser/agent-adapter.ts +0 -145
- package/src/browser/process-adapter.ts +0 -146
- package/src/browser/run-to-spans.ts +0 -105
- package/src/browser/run-to-spans.verify.ts +0 -89
- package/src/browser/ui-reviewer.ts +0 -200
- package/src/browser/ui-reviewer.verify.ts +0 -94
- package/src/browser/verify.ts +0 -96
- package/src/clbench-codebase-gate.mts +0 -314
- package/src/clbench-context-gate.mts +0 -341
- package/src/commit0-env-run.mts +0 -62
- package/src/commit0-env.ts +0 -172
- package/src/commit0-gate.mts +0 -558
- package/src/egress-probe.mts +0 -26
- package/src/humaneval-repair-gate.mts +0 -182
- package/src/profile-coordinates.ts +0 -134
- package/src/run-benchmarks-report.ts +0 -66
- package/src/skill-sandbox-smoke.mts +0 -101
- package/src/supervisor-arena.mts +0 -825
- package/src/swe-emit-patch.mts +0 -125
- package/src/swe-local-proof.mts +0 -265
- package/src/swe-repro-calibrate.mts +0 -451
- package/src/swe-stream.mts +0 -1561
- package/src/trajectory-assemble.mjs +0 -130
- package/src/worker-browser.ts +0 -115
- package/src/worker-cad.ts +0 -470
- package/src/workspace-loop.mts +0 -133
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.4
|
|
4
|
+
|
|
5
|
+
Use the Runtime 0.321 cohort: Eval `>=0.214.0 <0.215.0` and Knowledge `^22.0.2`, whose Eval peer admits Eval 0.214.
|
|
6
|
+
Benchmark execution and grading are unchanged.
|
|
7
|
+
|
|
8
|
+
## 0.14.3
|
|
9
|
+
|
|
10
|
+
Align benchmark package dependencies with the Runtime release cohort in `release/cohort.json`.
|
|
11
|
+
Benchmark execution and grading are unchanged.
|
|
12
|
+
|
|
13
|
+
## 0.14.2
|
|
14
|
+
|
|
15
|
+
Use the qualified Eval 0.203 through 0.205, Interface 2.17, and Knowledge 19 cohort.
|
|
16
|
+
Consume Runtime 0.293 through the workspace dependency.
|
|
17
|
+
Benchmark execution and grading remain unchanged.
|
|
18
|
+
|
|
3
19
|
## 0.14.1
|
|
4
20
|
|
|
5
21
|
Require Interface 2.16 and Sandbox 0.60 through the shared catalog.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-bench",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Benchmark adapters and execution for agent-runtime across coding, tool-use, RAG, memory, browser, and terminal tasks.",
|
|
6
6
|
"repository": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tangle-network/agent-eval": ">=0.
|
|
29
|
-
"@tangle-network/agent-interface": "^2.
|
|
30
|
-
"@tangle-network/agent-knowledge": "^
|
|
31
|
-
"@tangle-network/sandbox": "
|
|
32
|
-
"@tangle-network/agent-runtime": "^0.
|
|
28
|
+
"@tangle-network/agent-eval": ">=0.214.0 <0.215.0",
|
|
29
|
+
"@tangle-network/agent-interface": "^5.2.1",
|
|
30
|
+
"@tangle-network/agent-knowledge": "^22.0.2",
|
|
31
|
+
"@tangle-network/sandbox": ">=0.60.49 <0.61.0",
|
|
32
|
+
"@tangle-network/agent-runtime": "^0.321.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@arethetypeswrong/cli": "0.18.5",
|
|
@@ -186,7 +186,6 @@ const report = await runBenchmarks({
|
|
|
186
186
|
judge: async (_task, artifact) => ({ resolved: artifact === 'corrected', score: artifact === 'corrected' ? 1 : 0 }),
|
|
187
187
|
}),
|
|
188
188
|
resolveClient: () => ({
|
|
189
|
-
criuStatus: async () => ({ available: false }),
|
|
190
189
|
create: async () => ({
|
|
191
190
|
id: 'packed-fixture',
|
|
192
191
|
async *streamPrompt(prompt: string, options?: { sessionId?: string }) {
|
package/src/atom-mcp-e2e.mts
CHANGED
|
@@ -171,12 +171,18 @@ async function main(): Promise<void> {
|
|
|
171
171
|
const root: Agent<unknown, unknown> = {
|
|
172
172
|
name: 'supervisor',
|
|
173
173
|
async act(_t, scope: Scope<unknown>) {
|
|
174
|
+
let awaitSettlement = undefined as
|
|
175
|
+
| ((workerIds: ReadonlyArray<string>) => Promise<ReadonlyArray<string>>)
|
|
176
|
+
| undefined
|
|
174
177
|
const mcp = await serveCoordinationMcp({
|
|
175
178
|
scope,
|
|
176
179
|
blobs,
|
|
177
180
|
makeWorkerAgent: (raw) => makeWorker(raw, ws, n++),
|
|
178
181
|
perWorker: { maxIterations: 2, maxTokens: 200_000 },
|
|
179
|
-
toolNames: ['spawn_worker'
|
|
182
|
+
toolNames: ['spawn_worker'],
|
|
183
|
+
onCoordinationTools: (_tools, coordination) => {
|
|
184
|
+
awaitSettlement = coordination.awaitSettlement
|
|
185
|
+
},
|
|
180
186
|
})
|
|
181
187
|
// The supervisor's cwd carries the REAL skill file (opencode loads it from the cwd skill dirs).
|
|
182
188
|
const supCwd = mkdtempSync(join(tmpdir(), 'e2e-sup-'))
|
|
@@ -190,13 +196,19 @@ async function main(): Promise<void> {
|
|
|
190
196
|
messages: [
|
|
191
197
|
{
|
|
192
198
|
role: 'user',
|
|
193
|
-
content: `${TASK}\n\nYou are a SUPERVISOR. You have the "supervise" skill and a "coordination" MCP with
|
|
199
|
+
content: `${TASK}\n\nYou are a SUPERVISOR. You have the "supervise" skill and a "coordination" MCP with the tool spawn_worker. Do NOT write code yourself. Author a worker profile (a JSON object with name + a rich systemPrompt telling the worker exactly what to implement) and call spawn_worker with it, then end your turn; the worker runs after you finish and its result is checked there.`,
|
|
194
200
|
},
|
|
195
201
|
],
|
|
196
202
|
cwd: supCwd,
|
|
197
203
|
mcpUrl: mcp.url,
|
|
198
204
|
})
|
|
199
205
|
transcripts.push({ who: 'supervisor', said: said.slice(0, 400) })
|
|
206
|
+
// The harness ended its turn after spawning. This bare coordination server has no manager
|
|
207
|
+
// loop to wake it, so wait here for the workers to settle into the ledger.
|
|
208
|
+
const workerIds = scope.view.nodes
|
|
209
|
+
.filter((node) => node.id !== scope.view.root)
|
|
210
|
+
.map((node) => node.id)
|
|
211
|
+
await awaitSettlement?.(workerIds)
|
|
200
212
|
const settled = mcp.settled()
|
|
201
213
|
const delivered = settled.filter((w) => w.status === 'done' && w.valid === true)
|
|
202
214
|
console.error(`[e2e] supervisor spawned ${settled.length} worker(s), ${delivered.length} delivered`)
|
|
@@ -118,7 +118,7 @@ async function main(): Promise<void> {
|
|
|
118
118
|
blobs,
|
|
119
119
|
makeWorkerAgent: () => trivialWorker('w'),
|
|
120
120
|
perWorker: { maxIterations: 4, maxTokens: 2000 },
|
|
121
|
-
toolNames: ['spawn_worker', '
|
|
121
|
+
toolNames: ['spawn_worker', 'observe_agent'],
|
|
122
122
|
host: HOST_BIND,
|
|
123
123
|
})
|
|
124
124
|
// Docker containers reach the host through the bridge gateway, not the 0.0.0.0 bind URL.
|
|
@@ -141,10 +141,10 @@ async function main(): Promise<void> {
|
|
|
141
141
|
|
|
142
142
|
const toolNames = (parsed.result?.tools ?? []).map((t) => t.name)
|
|
143
143
|
const hasSpawn = toolNames.includes('spawn_worker')
|
|
144
|
-
const
|
|
144
|
+
const hasObserve = toolNames.includes('observe_agent')
|
|
145
145
|
console.error(`[probe] tools advertised: ${toolNames.join(', ')}`)
|
|
146
|
-
console.error(`[probe] spawn_worker present = ${hasSpawn};
|
|
147
|
-
ok = hasSpawn &&
|
|
146
|
+
console.error(`[probe] spawn_worker present = ${hasSpawn}; observe_agent present = ${hasObserve}`)
|
|
147
|
+
ok = hasSpawn && hasObserve
|
|
148
148
|
|
|
149
149
|
if (ok) {
|
|
150
150
|
console.error('')
|
|
@@ -170,7 +170,7 @@ async function main(): Promise<void> {
|
|
|
170
170
|
|
|
171
171
|
console.error(
|
|
172
172
|
ok
|
|
173
|
-
? 'CONTAINER-REACHABLE: docker tools/list returned spawn_worker and
|
|
173
|
+
? 'CONTAINER-REACHABLE: docker tools/list returned spawn_worker and observe_agent.'
|
|
174
174
|
: 'NOT reachable from container; see output above.',
|
|
175
175
|
)
|
|
176
176
|
process.exit(ok ? 0 : 1)
|
package/src/gate.ts
CHANGED
|
@@ -387,7 +387,7 @@ export async function runGate(opts: RunGateOptions): Promise<GateReport> {
|
|
|
387
387
|
root: a.label,
|
|
388
388
|
nodes: [],
|
|
389
389
|
total: acc.get(a.label)!.spend,
|
|
390
|
-
statusCounts: { done: 0, failed: 0, cancelled: 0, pending: 0
|
|
390
|
+
statusCounts: { done: 0, failed: 0, cancelled: 0, pending: 0 },
|
|
391
391
|
},
|
|
392
392
|
}))
|
|
393
393
|
const equalK = equalKOnCost(equalKArms)
|
package/src/mcp-mount-probe.mts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* actually MOUNT my coordination MCP and CALL spawn_worker — landing on a real Scope.spawn?
|
|
4
4
|
*
|
|
5
5
|
* Serves the coordination MCP over a live Scope, then asks the bridge's opencode (with that MCP in
|
|
6
|
-
* its config) to call spawn_worker
|
|
6
|
+
* its config) to call spawn_worker. If the Scope spawned+settled, the in-box driving
|
|
7
7
|
* path is real. No mock.
|
|
8
8
|
*
|
|
9
9
|
* ROUTER_BASE=http://127.0.0.1:3355/v1 TANGLE_API_KEY=<bridge-bearer> \
|
|
@@ -90,7 +90,7 @@ async function main(): Promise<void> {
|
|
|
90
90
|
blobs,
|
|
91
91
|
makeWorkerAgent: () => deliveringLeaf('w', { ok: true }),
|
|
92
92
|
perWorker: { maxIterations: 4, maxTokens: 2000 },
|
|
93
|
-
toolNames: ['spawn_worker', '
|
|
93
|
+
toolNames: ['spawn_worker', 'stop'],
|
|
94
94
|
})
|
|
95
95
|
console.error(`[probe] coordination MCP live at ${mcp.url}`)
|
|
96
96
|
try {
|
|
@@ -99,13 +99,15 @@ async function main(): Promise<void> {
|
|
|
99
99
|
{
|
|
100
100
|
role: 'user',
|
|
101
101
|
content:
|
|
102
|
-
'You have an MCP server named "coordination" with tools: spawn_worker,
|
|
103
|
-
'Call spawn_worker with arguments {"profile":{},"task":"hello"}.
|
|
104
|
-
'Then reply with exactly what
|
|
102
|
+
'You have an MCP server named "coordination" with tools: spawn_worker, stop. ' +
|
|
103
|
+
'Call spawn_worker with arguments {"profile":{},"task":"hello"}. ' +
|
|
104
|
+
'Then reply with exactly what spawn_worker returned.',
|
|
105
105
|
},
|
|
106
106
|
],
|
|
107
107
|
mcp.url,
|
|
108
108
|
)
|
|
109
|
+
// The harness ended its turn after spawning; move the settled worker into the ledger.
|
|
110
|
+
await mcp.drainResolved()
|
|
109
111
|
const settled = mcp.settled()
|
|
110
112
|
mounted = settled.length > 0
|
|
111
113
|
console.error(`[probe] opencode replied: ${content.slice(0, 400)}`)
|
|
@@ -269,9 +269,6 @@ async function main(): Promise<void> {
|
|
|
269
269
|
},
|
|
270
270
|
}
|
|
271
271
|
},
|
|
272
|
-
async criuStatus() {
|
|
273
|
-
return { available: false }
|
|
274
|
-
},
|
|
275
272
|
}
|
|
276
273
|
const boxAdapter: BenchmarkAdapter = {
|
|
277
274
|
name: 'boxy',
|
|
@@ -431,7 +428,6 @@ async function managedExecutionProof(): Promise<void> {
|
|
|
431
428
|
async delete() { operations.push('delete') },
|
|
432
429
|
}
|
|
433
430
|
},
|
|
434
|
-
async criuStatus() { return { available: false } },
|
|
435
431
|
}
|
|
436
432
|
const adapter: BenchmarkAdapter = {
|
|
437
433
|
name: 'managed',
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* (provider-pinned: you / exa / …). The agent's only web access is the MCP.
|
|
8
8
|
*
|
|
9
9
|
* The disable directive is the harness-agnostic `tools` map landed in
|
|
10
|
-
* agent-
|
|
10
|
+
* agent-container#1810 (claude `--disallowed-tools`, codex
|
|
11
11
|
* `-c tools.web_search=false`, opencode `tools.{websearch,webfetch}`). We set
|
|
12
12
|
* both canonical (`web_search`/`web_fetch`) and opencode-native
|
|
13
13
|
* (`websearch`/`webfetch`) keys so a single profile is correct on every harness
|
|
@@ -113,7 +113,7 @@ async function main(): Promise<void> {
|
|
|
113
113
|
blobs,
|
|
114
114
|
makeWorkerAgent,
|
|
115
115
|
perWorker: { maxIterations: 40, maxTokens: 200_000 },
|
|
116
|
-
toolNames: ['spawn_worker', 'observe_agent', '
|
|
116
|
+
toolNames: ['spawn_worker', 'observe_agent', 'stop'],
|
|
117
117
|
host: '0.0.0.0',
|
|
118
118
|
onEvent: (event) => logEvent('bus', event),
|
|
119
119
|
})
|
|
@@ -201,10 +201,10 @@ class OpenCodeSupervisorAgent(OpenCodeRouterAgent):
|
|
|
201
201
|
supervised_instruction = (
|
|
202
202
|
"You are the supervisor. You have an MCP server named \"coordination\" with "
|
|
203
203
|
"tools including spawn_worker(profile, task), observe_agent(workerId), "
|
|
204
|
-
"
|
|
204
|
+
"and stop(). A spawned worker runs a full coding agent INSIDE "
|
|
205
205
|
"THIS SAME container and its file changes persist here, so you may delegate "
|
|
206
206
|
"concrete sub-tasks (e.g. \"install perl and 7z\", \"crack the hash with john\") "
|
|
207
|
-
"to workers via spawn_worker, then observe_agent
|
|
207
|
+
"to workers via spawn_worker, then observe_agent and check the container for their results. "
|
|
208
208
|
"Delegate independent or heavy sub-tasks to workers when useful; do the rest "
|
|
209
209
|
"yourself. Complete the task fully.\n\n"
|
|
210
210
|
f"TASK:\n{instruction}"
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UiReviewerAdapter for browser-agent-driver's `bad design-audit --json` — the
|
|
3
|
-
* reviewer that carries the DETERMINISTIC floor (axe a11y + WCAG contrast) the
|
|
4
|
-
* panel verdict is derived from. One of N pluggable reviewers behind the neutral
|
|
5
|
-
* UiReviewerAdapter contract; its subjective LLM findings are surfaced, its
|
|
6
|
-
* MEASURED floor is what `judgeUiFloor` attests.
|
|
7
|
-
*
|
|
8
|
-
* `badDesignAuditToReviewRuns` is a pure, unit-testable mapper kept separate from
|
|
9
|
-
* the spawn so the report-shape mapping is exercised without a browser/LLM.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { spawn } from 'node:child_process'
|
|
13
|
-
import { mkdtemp, readFile, rm } from 'node:fs/promises'
|
|
14
|
-
import { tmpdir } from 'node:os'
|
|
15
|
-
import { join } from 'node:path'
|
|
16
|
-
import type {
|
|
17
|
-
DesignMeasurements,
|
|
18
|
-
UiFinding,
|
|
19
|
-
UiReviewRun,
|
|
20
|
-
UiReviewTarget,
|
|
21
|
-
UiReviewerAdapter,
|
|
22
|
-
} from '../ui-reviewer'
|
|
23
|
-
|
|
24
|
-
export interface BadDesignAuditConfig {
|
|
25
|
-
/** Path to the bad CLI entry (default: $BAD_CLI or ~/code/browser-agent-driver/dist/cli.js). */
|
|
26
|
-
badCli?: string
|
|
27
|
-
/** Design-audit profile (saas/defi/…); forwarded as --profile when set. */
|
|
28
|
-
profile?: string
|
|
29
|
-
model?: string
|
|
30
|
-
/** OpenAI-compatible endpoint — point at our router. */
|
|
31
|
-
baseUrl?: string
|
|
32
|
-
apiKey?: string
|
|
33
|
-
/** Pages to crawl from the start URL (bad --pages). */
|
|
34
|
-
pages?: number
|
|
35
|
-
timeoutMs?: number
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface BadFinding {
|
|
39
|
-
category?: string
|
|
40
|
-
severity?: 'critical' | 'major' | 'minor'
|
|
41
|
-
title?: string
|
|
42
|
-
description?: string
|
|
43
|
-
recommendation?: string
|
|
44
|
-
selector?: string
|
|
45
|
-
}
|
|
46
|
-
interface BadMeasurements {
|
|
47
|
-
contrast?: { aaFailures?: unknown[]; totalChecked?: number; summary?: { aaPassRate?: number } }
|
|
48
|
-
a11y?: { violations?: Array<{ id?: string; impact?: string }> }
|
|
49
|
-
}
|
|
50
|
-
interface BadPage {
|
|
51
|
-
route?: string
|
|
52
|
-
url?: string
|
|
53
|
-
findings?: BadFinding[]
|
|
54
|
-
measurements?: BadMeasurements
|
|
55
|
-
score?: number
|
|
56
|
-
healthScore?: number
|
|
57
|
-
}
|
|
58
|
-
/** Wire shape of `bad design-audit --json` (the report.json the CLI writes). */
|
|
59
|
-
export interface BadDesignReport {
|
|
60
|
-
pages?: BadPage[]
|
|
61
|
-
summary?: { healthScore?: number; avgScore?: number }
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Pure mapper: `bad design-audit --json` report → neutral UiReviewRun[] (one per
|
|
65
|
-
* page). The measured floor (axe + contrast) becomes DesignMeasurements; the LLM
|
|
66
|
-
* findings become UiFinding[]; healthScore is recorded as selfReportedScore only. */
|
|
67
|
-
export function badDesignAuditToReviewRuns(report: BadDesignReport): UiReviewRun[] {
|
|
68
|
-
const pages = report.pages ?? []
|
|
69
|
-
return pages.map((p, i) => {
|
|
70
|
-
const route = p.route ?? p.url ?? `page-${i}`
|
|
71
|
-
const findings: UiFinding[] = (p.findings ?? []).map((f) => ({
|
|
72
|
-
reviewerId: 'bad-design-audit',
|
|
73
|
-
lens: f.category ?? 'design',
|
|
74
|
-
severity: f.severity ?? 'minor',
|
|
75
|
-
route,
|
|
76
|
-
title: f.title ?? '(finding)',
|
|
77
|
-
observation: f.description ?? f.title ?? '',
|
|
78
|
-
suggestedFix: f.recommendation,
|
|
79
|
-
selector: f.selector,
|
|
80
|
-
}))
|
|
81
|
-
const m = p.measurements
|
|
82
|
-
let measurements: DesignMeasurements | undefined
|
|
83
|
-
if (m?.contrast || m?.a11y) {
|
|
84
|
-
const failures = m.contrast?.aaFailures?.length ?? 0
|
|
85
|
-
const total = m.contrast?.totalChecked ?? 0
|
|
86
|
-
measurements = {
|
|
87
|
-
a11yViolations: (m.a11y?.violations ?? []).map((v) => ({ id: v.id ?? 'unknown', impact: v.impact })),
|
|
88
|
-
contrastAaPassRate: m.contrast?.summary?.aaPassRate ?? (total > 0 ? 1 - failures / total : 1),
|
|
89
|
-
contrastAaFailures: failures,
|
|
90
|
-
contrastTotalChecked: total,
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
reviewerId: 'bad-design-audit',
|
|
95
|
-
route,
|
|
96
|
-
findings,
|
|
97
|
-
measurements,
|
|
98
|
-
selfReportedScore: p.healthScore ?? p.score,
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function resolveCli(cfg: BadDesignAuditConfig): string {
|
|
104
|
-
return cfg.badCli ?? process.env.BAD_CLI ?? join(process.env.HOME ?? '', 'code/browser-agent-driver/dist/cli.js')
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** A UiReviewerAdapter backed by `bad design-audit`. Drives a real browser audit
|
|
108
|
-
* (LLM findings + measured axe/contrast floor); the panel judge attests the floor. */
|
|
109
|
-
export function badDesignAuditReviewer(cfg: BadDesignAuditConfig = {}): UiReviewerAdapter {
|
|
110
|
-
const cli = resolveCli(cfg)
|
|
111
|
-
const timeoutMs = cfg.timeoutMs ?? 600_000
|
|
112
|
-
return {
|
|
113
|
-
id: 'bad-design-audit',
|
|
114
|
-
async review(target: UiReviewTarget): Promise<UiReviewRun[]> {
|
|
115
|
-
const dir = await mkdtemp(join(tmpdir(), 'bad-design-'))
|
|
116
|
-
const args = [cli, 'design-audit', '--url', target.url, '--json', '--output', dir]
|
|
117
|
-
if (cfg.profile) args.push('--profile', cfg.profile)
|
|
118
|
-
if (cfg.pages) args.push('--pages', String(cfg.pages))
|
|
119
|
-
if (cfg.model) args.push('--model', cfg.model)
|
|
120
|
-
if (cfg.baseUrl) args.push('--base-url', cfg.baseUrl)
|
|
121
|
-
if (cfg.apiKey) args.push('--api-key', cfg.apiKey)
|
|
122
|
-
if (target.storageState) args.push('--storage-state', target.storageState)
|
|
123
|
-
try {
|
|
124
|
-
await runChild('node', args, dir, timeoutMs)
|
|
125
|
-
const report = JSON.parse(await readFile(join(dir, 'report.json'), 'utf8')) as BadDesignReport
|
|
126
|
-
return badDesignAuditToReviewRuns(report)
|
|
127
|
-
} finally {
|
|
128
|
-
await rm(dir, { recursive: true, force: true }).catch(() => {})
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function runChild(cmd: string, args: string[], cwd: string, timeoutMs: number): Promise<void> {
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
const child = spawn(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
137
|
-
let err = ''
|
|
138
|
-
const timer = setTimeout(() => {
|
|
139
|
-
child.kill('SIGKILL')
|
|
140
|
-
reject(new Error(`bad design-audit timed out after ${timeoutMs}ms`))
|
|
141
|
-
}, timeoutMs)
|
|
142
|
-
child.stderr.on('data', (d) => (err += d.toString()))
|
|
143
|
-
child.on('error', (e) => {
|
|
144
|
-
clearTimeout(timer)
|
|
145
|
-
reject(new Error(`bad design-audit failed to spawn: ${e.message}`))
|
|
146
|
-
})
|
|
147
|
-
child.on('close', (code) => {
|
|
148
|
-
clearTimeout(timer)
|
|
149
|
-
if (code !== 0) reject(new Error(`bad design-audit exited ${code}: ${err.slice(-300)}`))
|
|
150
|
-
else resolve()
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic self-check for the bad-design-audit reviewer mapper —
|
|
3
|
-
* `tsx src/browser/adapters/bad-design-audit.verify.ts`.
|
|
4
|
-
*
|
|
5
|
-
* Proves the `bad design-audit --json` report maps to the neutral UiReviewRun with
|
|
6
|
-
* the DETERMINISTIC floor intact, and that the panel verdict is then driven by that
|
|
7
|
-
* measured floor — not the audit's self-reported healthScore.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { judgeUiFloor } from '../ui-reviewer'
|
|
11
|
-
import { badDesignAuditToReviewRuns, type BadDesignReport } from './bad-design-audit'
|
|
12
|
-
|
|
13
|
-
let failures = 0
|
|
14
|
-
function check(name: string, cond: boolean, detail = '') {
|
|
15
|
-
if (cond) console.log(` ✓ ${name}`)
|
|
16
|
-
else {
|
|
17
|
-
failures += 1
|
|
18
|
-
console.log(` ✗ ${name} ${detail}`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// A bad design-audit --json report shaped exactly like the CLI writes: one clean
|
|
23
|
-
// page + one page whose MEASURED floor is blocking, while it self-reports a high
|
|
24
|
-
// healthScore (the dishonesty the floor verdict must override).
|
|
25
|
-
const report: BadDesignReport = {
|
|
26
|
-
summary: { avgScore: 7, healthScore: 80 },
|
|
27
|
-
pages: [
|
|
28
|
-
{
|
|
29
|
-
route: 'home',
|
|
30
|
-
url: 'https://shop.test/',
|
|
31
|
-
score: 8,
|
|
32
|
-
healthScore: 88,
|
|
33
|
-
findings: [
|
|
34
|
-
{ category: 'hierarchy', severity: 'major', title: 'Weak CTA hierarchy', description: 'primary + secondary look identical', recommendation: 'differentiate weight', selector: 'button.cta' },
|
|
35
|
-
],
|
|
36
|
-
measurements: {
|
|
37
|
-
contrast: { aaFailures: [{}, {}], totalChecked: 100, summary: { aaPassRate: 0.98 } },
|
|
38
|
-
a11y: { violations: [{ id: 'image-alt', impact: 'moderate' }] },
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
route: 'checkout',
|
|
43
|
-
url: 'https://shop.test/checkout',
|
|
44
|
-
score: 4,
|
|
45
|
-
healthScore: 95, // self-reports GREAT — but the measured floor is blocking
|
|
46
|
-
findings: [],
|
|
47
|
-
measurements: {
|
|
48
|
-
contrast: { aaFailures: new Array(40).fill({}), totalChecked: 100, summary: { aaPassRate: 0.6 } },
|
|
49
|
-
a11y: {
|
|
50
|
-
violations: [
|
|
51
|
-
{ id: 'label', impact: 'critical' },
|
|
52
|
-
{ id: 'button-name', impact: 'critical' },
|
|
53
|
-
{ id: 'aria-required', impact: 'critical' },
|
|
54
|
-
{ id: 'link-name', impact: 'serious' },
|
|
55
|
-
{ id: 'color-contrast', impact: 'serious' },
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
console.log('bad-design-audit reviewer mapper verify:')
|
|
64
|
-
|
|
65
|
-
const runs = badDesignAuditToReviewRuns(report)
|
|
66
|
-
check('maps one UiReviewRun per page', runs.length === 2, `got ${runs.length}`)
|
|
67
|
-
check('carries the deterministic floor (axe + contrast) on each page', runs.every((r) => r.measurements != null))
|
|
68
|
-
const home = runs.find((r) => r.route === 'home')!
|
|
69
|
-
check('home contrast pass rate mapped', home.measurements?.contrastAaPassRate === 0.98)
|
|
70
|
-
check('home finding mapped to a UiFinding (lens=category, severity preserved, selector kept)', home.findings.length === 1 && home.findings[0]?.lens === 'hierarchy' && home.findings[0]?.severity === 'major' && home.findings[0]?.selector === 'button.cta')
|
|
71
|
-
check('self-reported healthScore recorded but NOT the verdict', home.selfReportedScore === 88)
|
|
72
|
-
|
|
73
|
-
const verdict = judgeUiFloor(runs)
|
|
74
|
-
check('panel verdict is BLOCKING — the measured checkout floor (3 critical a11y + 40% contrast fail) overrides the 95 self-report', verdict.resolved === false, verdict.detail)
|
|
75
|
-
check('blocking score is low', verdict.score < 0.6, verdict.detail)
|
|
76
|
-
|
|
77
|
-
// A reviewer with NO measurements (e.g. a findings-only audit) contributes no floor.
|
|
78
|
-
const noFloor = badDesignAuditToReviewRuns({ pages: [{ route: 'x', findings: [], score: 5 }] } satisfies BadDesignReport)
|
|
79
|
-
check('a page without measurements yields no floor (subjective-only run)', noFloor[0]?.measurements === undefined)
|
|
80
|
-
|
|
81
|
-
if (failures > 0) {
|
|
82
|
-
console.log(`\n❌ ${failures} check(s) failed`)
|
|
83
|
-
process.exit(1)
|
|
84
|
-
}
|
|
85
|
-
console.log('\n✅ bad-design-audit reviewer verified — floor mapped from --json, verdict driven by the measured floor not the self-report')
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reference BrowserAgentAdapter for @tangle-network/browser-agent-driver (the `bad`
|
|
3
|
-
* CLI). One of N pluggable drivers behind the neutral harness — it conforms to the
|
|
4
|
-
* SAME BrowserAgentAdapter contract as a browser-use runner or any other agent.
|
|
5
|
-
*
|
|
6
|
-
* `bad run --cases <file> --sink <dir>` emits a structured report.json; we map its
|
|
7
|
-
* `agentResult` to the neutral BrowserRun and let `judgeBrowserRun` derive the
|
|
8
|
-
* DETERMINISTIC verdict. We record `bad`'s own success/goalVerification only as
|
|
9
|
-
* `selfReportedSuccess` — it never decides the outcome (attestation, not trust).
|
|
10
|
-
*
|
|
11
|
-
* `badReportToRun` is a pure, unit-testable mapper kept separate from the spawn so
|
|
12
|
-
* the report-shape mapping can be exercised without launching a browser.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { spawn } from 'node:child_process'
|
|
16
|
-
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
17
|
-
import { tmpdir } from 'node:os'
|
|
18
|
-
import { join } from 'node:path'
|
|
19
|
-
import type { BrowserAgentAdapter, BrowserRun, BrowserStep, BrowserTask } from '../agent-adapter'
|
|
20
|
-
|
|
21
|
-
export interface BadAdapterConfig {
|
|
22
|
-
/** Path to the bad CLI entry (default: $BAD_CLI or ~/code/browser-agent-driver/dist/cli.js). */
|
|
23
|
-
badCli?: string
|
|
24
|
-
model?: string
|
|
25
|
-
provider?: string
|
|
26
|
-
/** OpenAI-compatible endpoint — point at our router. */
|
|
27
|
-
baseUrl?: string
|
|
28
|
-
apiKey?: string
|
|
29
|
-
maxTurns?: number
|
|
30
|
-
timeoutMs?: number
|
|
31
|
-
/** Capture a per-turn screenshot into each turn's state.screenshot (bad
|
|
32
|
-
* full-evidence mode). Off by default — opt in for the navigation film. */
|
|
33
|
-
captureScreenshots?: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface BadReport {
|
|
37
|
-
results?: Array<{
|
|
38
|
-
testCase?: { id?: string }
|
|
39
|
-
// Real token/cost telemetry (bad >=0.33 reports these per result) — forwarded to
|
|
40
|
-
// BrowserRun so a real run never reads as a {0,0} backend-integrity stub.
|
|
41
|
-
estimatedCostUsd?: number
|
|
42
|
-
inputTokens?: number
|
|
43
|
-
outputTokens?: number
|
|
44
|
-
agentResult?: {
|
|
45
|
-
success?: boolean
|
|
46
|
-
result?: string
|
|
47
|
-
turns?: Array<{
|
|
48
|
-
turn?: number
|
|
49
|
-
// state.screenshot is INLINE base64 (no data: prefix) — the durable frame
|
|
50
|
-
// source for the film, since the adapter's temp sink is reaped after the run.
|
|
51
|
-
state?: { url?: string; title?: string; snapshot?: string; screenshot?: string }
|
|
52
|
-
action?: { action?: string; selector?: string; text?: string; result?: string }
|
|
53
|
-
}>
|
|
54
|
-
}
|
|
55
|
-
}>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Pure mapper: bad's report.json → the neutral BrowserRun for taskId. The final
|
|
59
|
-
* turn's state.url is the observable final URL; its snapshot is the final DOM the
|
|
60
|
-
* deterministic dom-* checks read. */
|
|
61
|
-
export function badReportToRun(report: BadReport, taskId: string): BrowserRun {
|
|
62
|
-
const res = report.results?.find((r) => r.testCase?.id === taskId) ?? report.results?.[0]
|
|
63
|
-
const ar = res?.agentResult ?? {}
|
|
64
|
-
const turns = Array.isArray(ar.turns) ? ar.turns : []
|
|
65
|
-
const steps: BrowserStep[] = turns.map((t, i) => ({
|
|
66
|
-
index: typeof t.turn === 'number' ? t.turn : i + 1,
|
|
67
|
-
url: t.state?.url ?? '',
|
|
68
|
-
action: t.action?.action ?? 'decide',
|
|
69
|
-
target: t.action?.selector ?? (t.action?.text ? `"${t.action.text}"` : undefined),
|
|
70
|
-
// The frame for the film: bad's per-turn base64 JPEG, normalized to a data: URI.
|
|
71
|
-
screenshot: t.state?.screenshot ? `data:image/jpeg;base64,${t.state.screenshot}` : undefined,
|
|
72
|
-
}))
|
|
73
|
-
const last = turns[turns.length - 1]
|
|
74
|
-
const input = typeof res?.inputTokens === 'number' ? res.inputTokens : undefined
|
|
75
|
-
const output = typeof res?.outputTokens === 'number' ? res.outputTokens : undefined
|
|
76
|
-
return {
|
|
77
|
-
taskId,
|
|
78
|
-
steps,
|
|
79
|
-
finalUrl: last?.state?.url ?? '',
|
|
80
|
-
finalDom: typeof last?.state?.snapshot === 'string' ? last.state.snapshot : undefined,
|
|
81
|
-
answer: typeof ar.result === 'string' ? ar.result : undefined,
|
|
82
|
-
selfReportedSuccess: typeof ar.success === 'boolean' ? ar.success : undefined,
|
|
83
|
-
usage: input !== undefined || output !== undefined ? { input: input ?? 0, output: output ?? 0 } : undefined,
|
|
84
|
-
costUsd: typeof res?.estimatedCostUsd === 'number' ? res.estimatedCostUsd : undefined,
|
|
85
|
-
driverId: 'bad',
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function resolveCli(cfg: BadAdapterConfig): string {
|
|
90
|
-
return cfg.badCli ?? process.env.BAD_CLI ?? join(process.env.HOME ?? '', 'code/browser-agent-driver/dist/cli.js')
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** A BrowserAgentAdapter backed by the `bad` CLI. Runs one task through a real
|
|
94
|
-
* browser; the harness judge attests the outcome. */
|
|
95
|
-
export function badBrowserAdapter(cfg: BadAdapterConfig = {}): BrowserAgentAdapter {
|
|
96
|
-
const cli = resolveCli(cfg)
|
|
97
|
-
const timeoutMs = cfg.timeoutMs ?? 300_000
|
|
98
|
-
return {
|
|
99
|
-
id: 'bad',
|
|
100
|
-
async run(task: BrowserTask): Promise<BrowserRun> {
|
|
101
|
-
const dir = await mkdtemp(join(tmpdir(), 'bad-adapter-'))
|
|
102
|
-
const casesPath = join(dir, 'cases.json')
|
|
103
|
-
const sink = join(dir, 'sink')
|
|
104
|
-
const cases = [
|
|
105
|
-
{
|
|
106
|
-
id: task.id,
|
|
107
|
-
name: task.id,
|
|
108
|
-
goal: task.goal,
|
|
109
|
-
url: task.startUrl,
|
|
110
|
-
maxTurns: task.maxSteps ?? cfg.maxTurns ?? 20,
|
|
111
|
-
},
|
|
112
|
-
]
|
|
113
|
-
await writeFile(casesPath, JSON.stringify(cases))
|
|
114
|
-
const args = [
|
|
115
|
-
cli,
|
|
116
|
-
'run',
|
|
117
|
-
'--cases',
|
|
118
|
-
casesPath,
|
|
119
|
-
'--sink',
|
|
120
|
-
sink,
|
|
121
|
-
'--provider',
|
|
122
|
-
cfg.provider ?? 'openai',
|
|
123
|
-
'--model',
|
|
124
|
-
cfg.model ?? 'deepseek-v4-flash',
|
|
125
|
-
'--max-turns',
|
|
126
|
-
String(task.maxSteps ?? cfg.maxTurns ?? 20),
|
|
127
|
-
'--headless',
|
|
128
|
-
]
|
|
129
|
-
// full-evidence + every-turn capture populates each turn's state.screenshot,
|
|
130
|
-
// which badReportToRun lifts into BrowserStep.screenshot for the film.
|
|
131
|
-
if (cfg.captureScreenshots) args.push('--mode', 'full-evidence', '--screenshot-interval', '1')
|
|
132
|
-
if (cfg.baseUrl) args.push('--base-url', cfg.baseUrl)
|
|
133
|
-
if (cfg.apiKey) args.push('--api-key', cfg.apiKey)
|
|
134
|
-
if (task.storageState) args.push('--storage-state', task.storageState)
|
|
135
|
-
try {
|
|
136
|
-
await runChild('node', args, dir, timeoutMs)
|
|
137
|
-
const report = JSON.parse(await readFile(join(sink, 'report.json'), 'utf8')) as BadReport
|
|
138
|
-
return badReportToRun(report, task.id)
|
|
139
|
-
} finally {
|
|
140
|
-
await rm(dir, { recursive: true, force: true }).catch(() => {})
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function runChild(cmd: string, args: string[], cwd: string, timeoutMs: number): Promise<void> {
|
|
147
|
-
return new Promise((resolve, reject) => {
|
|
148
|
-
const child = spawn(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
149
|
-
let err = ''
|
|
150
|
-
const timer = setTimeout(() => {
|
|
151
|
-
child.kill('SIGKILL')
|
|
152
|
-
reject(new Error(`bad adapter timed out after ${timeoutMs}ms`))
|
|
153
|
-
}, timeoutMs)
|
|
154
|
-
child.stderr.on('data', (d) => (err += d.toString()))
|
|
155
|
-
child.on('error', (e) => {
|
|
156
|
-
clearTimeout(timer)
|
|
157
|
-
reject(new Error(`bad adapter failed to spawn: ${e.message}`))
|
|
158
|
-
})
|
|
159
|
-
child.on('close', (code) => {
|
|
160
|
-
clearTimeout(timer)
|
|
161
|
-
if (code !== 0) reject(new Error(`bad exited ${code}: ${err.slice(-300)}`))
|
|
162
|
-
else resolve()
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
}
|