Files
hanzo.ai/scripts/tools.mjs
zeekay 891bcc564b benchmarks: the agent tools board, each kai_* tool as its research runs hold it
/benchmarks#tools draws hanzo-mcp's injection screen, command guard, tool
selection and log triage from GET /v1/research/runs?org=hanzo&benchmark=
mcp.<tool>: the handler now, its parts read alone, and the handler it
replaced, each table linking its runs. The snapshot is saved at prebuild
and the page refetches the same addresses, so a newly filed run shows
without a rebuild. The price tile's speed check reads the tile, not the
page, so the coding board's measured "faster" no longer trips it.

Claude-Session: https://claude.ai/code/session_01M8RoubcPN71KgJuZ8LdBUL
2026-10-14 19:53:05 -07:00

41 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
/**
* Hanzo MCP's tool handlers, as the research API holds them.
*
* node scripts/tools.mjs [api base URL]
*
* Saves the public runs at each tool's address, `GET
* /v1/research/runs?org=hanzo&benchmark=<id>` (lib/tools.ts TOOLS and `runs`),
* as lib/data/benchmarks-tools.json: the snapshot /benchmarks renders before its
* own fetch of the same addresses returns. Part of `prebuild`, so every build
* ships the latest runs. The committed snapshot is kept, and the build goes on,
* when an address cannot be reached or answers with an error, or the runs hold
* no table the page would draw.
*/
import { writeFileSync } from 'node:fs'
const FILE = new URL('../lib/data/benchmarks-tools.json', import.meta.url)
const keep = (why) => {
console.log(`tools: kept the frozen snapshot (${why})`)
process.exit(0)
}
try {
const { TOOLS, derive, runs } = await import('../lib/tools.ts')
const base = process.argv[2]?.replace(/\/$/, '')
const data = []
for (const t of TOOLS) {
const url = base ? runs(t.id).replace(new URL(runs(t.id)).origin, base) : runs(t.id)
const res = await fetch(url, { signal: AbortSignal.timeout(20_000) })
if (!res.ok) keep(`${url}: ${res.status}`)
const body = await res.json()
data.push(...(body.data ?? []).filter((r) => (r.visibility ?? 'public') === 'public'))
}
const boards = derive(data)
if (!boards.length) keep('no table to draw')
writeFileSync(FILE, `{\n"data": [\n${data.map((r) => JSON.stringify(r)).join(',\n')}\n]\n}\n`)
console.log(`tools: ${data.length} runs; ${boards.map((b) => `${b.id} (${b.splits.map((s) => s.split).join(', ')})`).join('; ')}`)
} catch (e) {
keep(e instanceof Error ? e.message : String(e))
}