@tangle-network/agent-bench 0.14.2 → 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +6 -6
  3. package/scripts/verify-packed-consumer.mjs +0 -1
  4. package/src/atom-mcp-e2e.mts +14 -2
  5. package/src/coordination-mcp-container-reach.mts +5 -5
  6. package/src/gate.ts +1 -1
  7. package/src/mcp-mount-probe.mts +7 -5
  8. package/src/run-benchmarks.test.mts +0 -4
  9. package/src/search-bench/profiles.ts +1 -1
  10. package/src/tb-supervisor-sidecar.mts +1 -1
  11. package/tb_agents/opencode_supervisor_agent.py +2 -2
  12. package/src/browser/adapters/bad-design-audit.ts +0 -153
  13. package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
  14. package/src/browser/adapters/bad.ts +0 -165
  15. package/src/browser/agent-adapter.ts +0 -145
  16. package/src/browser/process-adapter.ts +0 -146
  17. package/src/browser/run-to-spans.ts +0 -105
  18. package/src/browser/run-to-spans.verify.ts +0 -89
  19. package/src/browser/ui-reviewer.ts +0 -200
  20. package/src/browser/ui-reviewer.verify.ts +0 -94
  21. package/src/browser/verify.ts +0 -96
  22. package/src/clbench-codebase-gate.mts +0 -314
  23. package/src/clbench-context-gate.mts +0 -341
  24. package/src/commit0-env-run.mts +0 -62
  25. package/src/commit0-env.ts +0 -172
  26. package/src/commit0-gate.mts +0 -558
  27. package/src/egress-probe.mts +0 -26
  28. package/src/humaneval-repair-gate.mts +0 -182
  29. package/src/profile-coordinates.ts +0 -134
  30. package/src/run-benchmarks-report.ts +0 -66
  31. package/src/skill-sandbox-smoke.mts +0 -101
  32. package/src/supervisor-arena.mts +0 -825
  33. package/src/swe-emit-patch.mts +0 -125
  34. package/src/swe-local-proof.mts +0 -265
  35. package/src/swe-repro-calibrate.mts +0 -451
  36. package/src/swe-stream.mts +0 -1561
  37. package/src/trajectory-assemble.mjs +0 -130
  38. package/src/worker-browser.ts +0 -115
  39. package/src/worker-cad.ts +0 -470
  40. package/src/workspace-loop.mts +0 -133
@@ -1,130 +0,0 @@
1
- // Step A (increment 1) of the trajectory-capture pipeline: turn a Claude Code session
2
- // transcript (you driving the top-level agent) into the human-driving signal — the
3
- // (intent, steer-move, fan-out) half — and emit FeedbackTrajectory-SHAPED records plus a
4
- // driving-policy summary. This is the imitation corpus: "what Drew steers toward."
5
- //
6
- // Increment 1 = the MAIN transcript's human signal (intent turns, short steers, the
7
- // explicit AskUserQuestion forks, and per-turn subagent/workflow fan-out). Increment 2
8
- // joins the subagent/workflow subtrees + attaches outcomes, and wires agent-eval's real
9
- // FeedbackTrajectory type + summarizePreferenceMemory. Plain Node ESM (streams big files).
10
- //
11
- // node trajectory-assemble.mjs [transcript.jsonl] [outDir]
12
-
13
- import { createReadStream, mkdirSync, writeFileSync } from 'node:fs'
14
- import { createInterface } from 'node:readline'
15
-
16
- const TRANSCRIPT =
17
- process.argv[2] ??
18
- '/home/drew/.claude/projects/-home-drew-code-agent-runtime/52d557cf-89a5-45b8-b590-8c598fb378ab.jsonl'
19
- const OUT_DIR = process.argv[3] ?? '/tmp/trajectory'
20
-
21
- // A short imperative/approval turn is a STEER (a course-correction on the prior move);
22
- // a longer turn is a fresh INTENT. Crude but matches how driving reads on the wire.
23
- const STEER_MAX = 160
24
- const STEER_HINT = /^(yes|yep|yeah|yalla|ok|okay|do it|go|sure|nah|no|stop|push|merge|continue|keep going|build it|ship it|lgtm|sounds good|great|perfect|exactly|right)/i
25
-
26
- const intents = [] // { uuid, promptId, ts, text, kind: 'intent'|'steer' }
27
- const asks = [] // { ts, promptId, toolUseId, questions:[{q,header,options[]}], chosen }
28
- const spawnsByPrompt = new Map() // promptId -> { agents, workflows }
29
- const toolCounts = new Map()
30
- let assistantTurns = 0
31
-
32
- const bump = (m, k) => m.set(k, (m.get(k) ?? 0) + 1)
33
-
34
- const rl = createInterface({ input: createReadStream(TRANSCRIPT), crlfDelay: Infinity })
35
- for await (const line of rl) {
36
- if (!line.trim()) continue
37
- let r
38
- try {
39
- r = JSON.parse(line)
40
- } catch {
41
- continue
42
- }
43
- const c = r?.message?.content
44
- if (r.type === 'user' && typeof c === 'string' && r.isSidechain !== true) {
45
- const text = c.trim()
46
- if (!text) continue
47
- const kind = text.length <= STEER_MAX && STEER_HINT.test(text) ? 'steer' : 'intent'
48
- intents.push({ uuid: r.uuid, promptId: r.promptId, ts: r.timestamp, text, kind })
49
- } else if (r.type === 'assistant' && Array.isArray(c)) {
50
- assistantTurns += 1
51
- for (const b of c) {
52
- if (b?.type !== 'tool_use') continue
53
- bump(toolCounts, b.name)
54
- if (b.name === 'Agent' || b.name === 'Workflow') {
55
- const pid = r.promptId ?? 'unknown'
56
- const cur = spawnsByPrompt.get(pid) ?? { agents: 0, workflows: 0 }
57
- if (b.name === 'Agent') cur.agents += 1
58
- else cur.workflows += 1
59
- spawnsByPrompt.set(pid, cur)
60
- }
61
- if (b.name === 'AskUserQuestion') {
62
- const questions = (b.input?.questions ?? []).map((q) => ({
63
- q: q.question,
64
- header: q.header,
65
- options: (q.options ?? []).map((o) => o.label),
66
- }))
67
- asks.push({ ts: r.timestamp, promptId: r.promptId, toolUseId: b.id, questions, chosen: null })
68
- }
69
- }
70
- } else if (r.type === 'user' && Array.isArray(c)) {
71
- for (const b of c) {
72
- if (b?.type !== 'tool_result') continue
73
- const tur = r.toolUseResult
74
- const a = asks.find((x) => x.toolUseId === b.tool_use_id && x.chosen === null)
75
- if (a && tur && (tur.answers || tur.metadata)) a.chosen = tur.answers ?? null
76
- }
77
- }
78
- }
79
-
80
- const steers = intents.filter((i) => i.kind === 'steer')
81
- const realIntents = intents.filter((i) => i.kind === 'intent')
82
- const fanouts = [...spawnsByPrompt.entries()]
83
- .map(([pid, v]) => ({ pid, ...v, total: v.agents + v.workflows }))
84
- .filter((x) => x.total >= 2)
85
- .sort((a, b) => b.total - a.total)
86
-
87
- // FeedbackTrajectory-SHAPED records (one per human turn) — the imitation corpus root nodes.
88
- const trajectory = intents.map((i) => ({
89
- id: i.uuid,
90
- createdAt: i.ts,
91
- task: { intent: i.text },
92
- labels: [{ source: 'user', kind: i.kind, value: i.text }],
93
- tags: { promptId: i.promptId, fanout: spawnsByPrompt.get(i.promptId) ?? null },
94
- attempts: [], // increment 2: join the assistant actions + subagent subtrees here
95
- outcome: null, // increment 2: label success (verifiable reward / later approval)
96
- }))
97
-
98
- mkdirSync(OUT_DIR, { recursive: true })
99
- writeFileSync(`${OUT_DIR}/trajectory.jsonl`, `${trajectory.map((t) => JSON.stringify(t)).join('\n')}\n`)
100
-
101
- const top = (m, n) =>
102
- [...m.entries()].sort((a, b) => b[1] - a[1]).slice(0, n).map(([k, v]) => `${k}:${v}`).join(' ')
103
-
104
- console.log(`\n=== DRIVING-POLICY EXTRACT (${TRANSCRIPT.split('/').pop()}) ===`)
105
- console.log(`human turns: ${intents.length} (intents ${realIntents.length} · steers ${steers.length})`)
106
- console.log(`assistant turns: ${assistantTurns} tool calls: ${top(toolCounts, 12)}`)
107
- console.log(`explicit forks (AskUserQuestion): ${asks.length} parallel fan-out turns (>=2 spawns): ${fanouts.length}`)
108
-
109
- console.log(`\n--- the explicit decisions you made at forks (your steering policy, labeled) ---`)
110
- for (const a of asks.slice(0, 30)) {
111
- for (const q of a.questions) {
112
- const chosenLabel = a.chosen ? Object.values(a.chosen).map((v) => (typeof v === 'string' ? v : JSON.stringify(v))).join(' / ') : '(unmatched)'
113
- console.log(` [${q.header ?? '?'}] ${String(q.q).slice(0, 80)}`)
114
- console.log(` options: ${q.options.join(' | ')}`)
115
- console.log(` CHOSE: ${chosenLabel}`)
116
- }
117
- }
118
-
119
- console.log(`\n--- your recurring short steers (the corrections you repeat) ---`)
120
- const steerCounts = new Map()
121
- for (const s of steers) bump(steerCounts, s.text.toLowerCase().slice(0, 40))
122
- for (const [phrase, n] of [...steerCounts.entries()].sort((a, b) => b[1] - a[1]).slice(0, 15)) {
123
- console.log(` ${n}x ${phrase}`)
124
- }
125
-
126
- console.log(`\n--- biggest parallel fan-outs (one intent → N concurrent agents/workflows) ---`)
127
- for (const f of fanouts.slice(0, 8)) console.log(` ${f.total} spawns (agents ${f.agents}, workflows ${f.workflows}) promptId ${String(f.pid).slice(0, 12)}`)
128
-
129
- console.log(`\nwrote ${trajectory.length} FeedbackTrajectory-shaped records → ${OUT_DIR}/trajectory.jsonl`)
130
- console.log(`(increment 2: join subagent/workflow subtrees + outcome labels + agent-eval FeedbackTrajectory/summarizePreferenceMemory)`)
@@ -1,115 +0,0 @@
1
- /**
2
- * Mind2Web browser worker: one shot = the model, under the candidate authoring
3
- * DIRECTIVE, reads the task + candidate elements and commits to a single next
4
- * action (ELEMENT / ACTION / VALUE). The artifact is scored by the deterministic
5
- * mind2web judge (element-match + op/value match); the produced trace carries the
6
- * step's REAL page screenshot so run-capsule's screen capsule turns the run into a
7
- * film — the actual page the agent acted on, not a re-rendered DOM.
8
- *
9
- * `directive` is the GEPA-optimizable surface: a minimal element-selection
10
- * instruction with headroom for the optimizer to learn the discrimination moves
11
- * (prefer the element whose role/label matches the goal step, disambiguate
12
- * look-alikes) that move the deterministic Step-SR gate.
13
- *
14
- * Reports REAL token usage so the campaign's backend-integrity guard sees a real
15
- * backend, never a fabricated zero.
16
- */
17
-
18
- import { readFile } from 'node:fs/promises'
19
- import type { Span } from '@tangle-network/agent-eval'
20
- import type { BenchTask } from './benchmarks/types'
21
- import { runBenchRouterTurn } from './router-turn'
22
-
23
- export interface BrowserLocalConfig {
24
- routerBaseUrl: string
25
- routerKey: string
26
- model: string
27
- /** The element-selection directive (system prompt) — the GEPA-optimizable surface. */
28
- directive?: string
29
- }
30
-
31
- export interface BrowserShot {
32
- /** The ELEMENT/ACTION/VALUE the model produced — the artifact the judge scores. */
33
- artifact: string
34
- trace: Span[]
35
- usage?: { input: number; output: number }
36
- ok: boolean
37
- detail?: string
38
- }
39
-
40
- /**
41
- * The hand-written baseline element-selection directive — the SURFACE the GEPA
42
- * loop optimizes. Deliberately minimal: states the job and the output contract,
43
- * not HOW to discriminate the right element, leaving headroom for the optimizer.
44
- */
45
- export const DEFAULT_MIND2WEB_DIRECTIVE =
46
- 'You are a web agent choosing the NEXT UI action toward the task goal. Read the task and the candidate elements, then pick the single element that makes progress and the correct action (CLICK, or TYPE/SELECT with a value). Respond with ONLY the three required lines.'
47
-
48
- interface Mind2WebMetaView {
49
- task?: string
50
- website?: string
51
- screenshotPath?: string
52
- }
53
-
54
- /**
55
- * One element-selection shot under `directive`. Returns the artifact, REAL token
56
- * usage, and a screenshot-rich trace (task → chosen action → a browser.<op> span
57
- * carrying the page screenshot) for run-capsule.
58
- */
59
- export async function solveBrowserLocal(task: BenchTask, cfg: BrowserLocalConfig): Promise<BrowserShot> {
60
- const directive = cfg.directive ?? DEFAULT_MIND2WEB_DIRECTIVE
61
- const meta = (task.metadata ?? {}) as Mind2WebMetaView
62
- const runId = `m2w-${task.id}`
63
- let ts = Date.now()
64
- const tick = () => (ts += 1)
65
- const trace: Span[] = []
66
- const goal = meta.task ?? task.prompt
67
-
68
- trace.push({ spanId: 's-task', runId, kind: 'llm', name: 'web task', model: cfg.model, messages: [{ role: 'user', content: goal }], startedAt: tick(), endedAt: tick(), status: 'ok' } as Span)
69
-
70
- const turn = await runBenchRouterTurn(
71
- {
72
- routerBaseUrl: cfg.routerBaseUrl,
73
- routerKey: cfg.routerKey,
74
- profile: {
75
- name: 'browser-local-worker',
76
- model: { provider: 'tangle-router', default: cfg.model },
77
- prompt: { systemPrompt: directive },
78
- },
79
- },
80
- task.prompt,
81
- )
82
- const content = turn.finalText
83
- const usage =
84
- turn.usage.tokensKnown === false
85
- ? undefined
86
- : { input: turn.usage.input, output: turn.usage.output }
87
- const artifact = content.trim()
88
-
89
- const elementId = /ELEMENT:\s*\[?(\d+)\]?/i.exec(artifact)?.[1] ?? ''
90
- const op = (/ACTION:\s*(CLICK|TYPE|SELECT)/i.exec(artifact)?.[1] ?? 'CLICK').toUpperCase()
91
- const value = (/VALUE:\s*(.*)/i.exec(artifact)?.[1] ?? '').trim()
92
-
93
- trace.push({ spanId: 's-reply', runId, kind: 'llm', name: 'choose action', model: cfg.model, messages: [{ role: 'user', content: goal }], output: artifact.slice(0, 400), startedAt: tick(), endedAt: tick(), status: 'ok' } as Span)
94
-
95
- let screenshot: string | undefined
96
- if (typeof meta.screenshotPath === 'string' && meta.screenshotPath) {
97
- const buf = await readFile(meta.screenshotPath).catch(() => undefined)
98
- if (buf) screenshot = `data:image/jpeg;base64,${buf.toString('base64')}`
99
- }
100
- const label = `${op}${value ? ` "${value.slice(0, 40)}"` : ''} element #${elementId}`
101
- trace.push({
102
- spanId: 's-act',
103
- runId,
104
- kind: 'tool',
105
- name: `browser ${op.toLowerCase()}`,
106
- toolName: `browser.${op.toLowerCase()}`,
107
- args: { action: label, url: meta.website ? `https://${meta.website}` : undefined, selector: `[backend_node_id="${elementId}"]` },
108
- attributes: screenshot ? { screenshot } : {},
109
- startedAt: tick(),
110
- endedAt: tick(),
111
- status: 'ok',
112
- } as Span)
113
-
114
- return { artifact, trace, usage, ok: artifact.length > 0, detail: label }
115
- }