HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
Local blob store lists only its prefix; support matrix runner fixes and the recycle scenario (#74)
github-actions[bot]0cf2abf4c0a7
diff --git a/gateway/backing.py b/gateway/backing.pyindex 04c2373b..0934aa7b 100644--- a/gateway/backing.py+++ b/gateway/backing.py@@ -238,15 +238,27 @@ class FileBlobStore:return await asyncio.to_thread(_do)async def list(self, kb: str, prefix: str, limit: int = 20, cursor: str | None = None) -> dict:+ # Walk only the subtree the prefix names: everything before its last "/" is a directory+ # under the store, the rest a name prefix inside it. Walking the whole store cost every+ # blob on every call, and a paged listing repeated the walk per page: with 15k blobs on a+ # self-hosted volume one turns read took 55 s and the gateway sat at 150% CPU (2026-09-06).def _do():- base = self._root / kb- if not base.is_dir():+ base = (self._root / kb).resolve()+ dir_part, _, _ = prefix.rpartition("/")+ top = (base / dir_part).resolve() if dir_part else base+ if not str(top).startswith(str(base)) or not top.is_dir(): # escape or nothing therereturn {"items": [], "cursor": None}- keys = sorted(str(f.relative_to(base)) for f in base.rglob("*")- if f.is_file() and not f.name.endswith(".tmp")- and str(f.relative_to(base)).startswith(prefix))- if cursor:- keys = [k for k in keys if k > cursor]+ root_len = len(str(base)) + 1+ keys: list[str] = []+ for root, _dirs, files in os.walk(top):+ rel = root[root_len:].replace(os.sep, "/") if len(root) > root_len else ""+ for name in files:+ if name.endswith(".tmp"):+ continue+ key = f"{rel}/{name}" if rel else name+ if key.startswith(prefix) and (not cursor or key > cursor):+ keys.append(key)+ keys.sort()page = keys[:limit]nxt = page[-1] if len(keys) > limit else Nonereturn {"items": [{"file_id": k} for k in page], "cursor": nxt}diff --git a/gateway/tests/test_file_blob_list.py b/gateway/tests/test_file_blob_list.pynew file mode 100644index 00000000..0ca30402--- /dev/null+++ b/gateway/tests/test_file_blob_list.py@@ -0,0 +1,56 @@+"""The local blob store lists by walking only the subtree its prefix names, in key order, paged."""+import asyncio+import os+import pathlib+import sys++sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))+from backing import FileBlobStore # noqa: E402+++def _store(tmp_path):+ st = FileBlobStore(str(tmp_path))+ for k in ("a/idx/1", "a/idx/2", "a/idxh/x/3", "a/other/4", "b/idx/5", "top"):+ assert asyncio.run(st.put("kb", k, b"x"))+ (tmp_path / "kb" / "a" / "idx" / "9.tmp").write_bytes(b"torn")+ return st+++def test_a_directory_prefix_lists_its_files_only(tmp_path):+ st = _store(tmp_path)+ r = asyncio.run(st.list("kb", "a/idx/", limit=20))+ assert [i["file_id"] for i in r["items"]] == ["a/idx/1", "a/idx/2"] and r["cursor"] is None+++def test_a_name_prefix_spans_sibling_directories(tmp_path):+ st = _store(tmp_path)+ r = asyncio.run(st.list("kb", "a/idx", limit=20))+ assert [i["file_id"] for i in r["items"]] == ["a/idx/1", "a/idx/2", "a/idxh/x/3"]+++def test_paging_follows_the_cursor(tmp_path):+ st = _store(tmp_path)+ first = asyncio.run(st.list("kb", "a/", limit=2))+ assert [i["file_id"] for i in first["items"]] == ["a/idx/1", "a/idx/2"] and first["cursor"] == "a/idx/2"+ rest = asyncio.run(st.list("kb", "a/", limit=2, cursor=first["cursor"]))+ assert [i["file_id"] for i in rest["items"]] == ["a/idxh/x/3", "a/other/4"] and rest["cursor"] is None+++def test_the_walk_starts_at_the_prefix_directory_not_the_store(tmp_path, monkeypatch):+ st = _store(tmp_path)+ tops = []+ real = os.walk+ monkeypatch.setattr(os, "walk", lambda top, *a, **k: (tops.append(str(top)), real(top, *a, **k))[1])+ asyncio.run(st.list("kb", "a/idx/", limit=20))+ assert tops == [str((tmp_path / "kb" / "a" / "idx").resolve())]+++def test_an_empty_prefix_lists_the_whole_store(tmp_path):+ st = _store(tmp_path)+ r = asyncio.run(st.list("kb", "", limit=20))+ assert [i["file_id"] for i in r["items"]] == ["a/idx/1", "a/idx/2", "a/idxh/x/3", "a/other/4", "b/idx/5", "top"]+++def test_a_prefix_that_escapes_the_store_lists_nothing(tmp_path):+ st = _store(tmp_path)+ assert asyncio.run(st.list("kb", "../", limit=20)) == {"items": [], "cursor": None}diff --git a/scripts/support-matrix/README.md b/scripts/support-matrix/README.mdindex 042a8381..a479e85c 100644--- a/scripts/support-matrix/README.md+++ b/scripts/support-matrix/README.md@@ -1,8 +1,10 @@# Support matrix suite-Drives the console as one user and, for every harness and every model its menu offers, runs four+Drives the console as one user and, for every harness and every model its menu offers, runs fivescenarios in one session: a first turn, a follow-up, a switch to another model of the harness (then-back), and an artifact (a file the task must produce, checked on the transcript's file cards).+back), an artifact (a file the task must produce, checked on the transcript's file cards), and a+recycle (the session's sandbox is let go on purpose through the internal recycle route, then a+follow-up must recall the first message: the history survived the checkpoint round trip).Results are one JSON record per harness x model with the outcome, seconds and reason of eachscenario; `fill-connection.py` stamps each record with the connection its session actually ran on;`render.py` turns the records into `docs/support-matrix.md`.@@ -18,8 +20,9 @@ python3 render.py <(jq -s add results-A.json results-B.json) > ../../docs/supporNeeds `playwright` (`npm i playwright` next to `run.mjs`, then `npx playwright install chromium`).Resumable: a pair already recorded is skipped, so a killed worker is relaunched and continues; apair whose record carries `error` (the runner's own failure) is re-run. To re-run failed pairs,-delete their records and relaunch. `PROVIDER` is a label for the column: run once per key you-want a column for, with that key wired in Integrations first. `MODELS` (comma list) limits a run+delete their records and relaunch. `PROVIDER` is a label for the table: run once per provider, with the model map pointing every+model that provider serves at its integration (one provider at a time, since a model has one+integration). `MODELS` (comma list) limits a runto some models, which is how a single failing pair is reproduced with tracing on. Set`IGNORE_TLS=1` for an instance on a self-signed certificate.diff --git a/scripts/support-matrix/render.py b/scripts/support-matrix/render.pyindex 4212fff9..f90109d0 100644--- a/scripts/support-matrix/render.py+++ b/scripts/support-matrix/render.py@@ -4,18 +4,18 @@ res = json.load(open(sys.argv[1]))mark = lambda r: 'n/a' if not r or r.get('ok') is None else ('pass' if r.get('ok') else 'FAIL')by = collections.defaultdict(list)for k, r in res.items(): by[r['provider']].append(r)-out = ["# Harness support matrix", "", "Scenarios: first turn, follow-up in the same session, switch model mid-session, artifact (a file the task must produce). pass = ran and answered as asked, FAIL = failed (reason in the notes), n/a = not run.", ""]+out = ["# Harness support matrix", "", "Scenarios: first turn, follow-up in the same session, switch model mid-session, artifact (a file the task must produce), recycle (the sandbox is let go on purpose, then a follow-up must recall the first message). pass = ran and answered as asked, FAIL = failed (reason in the notes), n/a = not run.", ""]for prov, rows in sorted(by.items()):- out += [f"## Provider: {prov}", "", "| Harness | Model | First | Follow-up | Switch | Artifact | Notes |", "|---|---|---|---|---|---|---|"]+ out += [f"## Provider: {prov}", "", "| Harness | Model | First | Follow-up | Switch | Artifact | Recycle | Notes |", "|---|---|---|---|---|---|---|---|"]for r in sorted(rows, key=lambda r: (r['harness'], r['model'])):notes = []- for sc in ('first', 'followup', 'switch', 'artifact'):+ for sc in ('first', 'followup', 'switch', 'artifact', 'recycle'):x = r.get(sc) or {}if x.get('ok') is False and x.get('why'): notes.append(f"{sc}: {x['why'][:140]}")if r.get('error'): notes.append(f"runner: {r['error'][:100]}")sw = r.get('switch') or {}- out.append(f"| {r['harness']} | {r['model']} | {mark(r.get('first'))} | {mark(r.get('followup'))} | {mark(sw)}{(' ('+sw['to']+')') if sw.get('to') else ''} | {mark(r.get('artifact'))} | {' ; '.join(notes).replace('|', '/')} |")- ok = sum(1 for r in rows for sc in ('first','followup','switch','artifact') if (r.get(sc) or {}).get('ok') is True)- tot = sum(1 for r in rows for sc in ('first','followup','switch','artifact') if (r.get(sc) or {}).get('ok') is not None)+ out.append(f"| {r['harness']} | {r['model']} | {mark(r.get('first'))} | {mark(r.get('followup'))} | {mark(sw)}{(' ('+sw['to']+')') if sw.get('to') else ''} | {mark(r.get('artifact'))} | {mark(r.get('recycle'))} | {' ; '.join(notes).replace('|', '/')} |")+ ok = sum(1 for r in rows for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is True)+ tot = sum(1 for r in rows for sc in ('first','followup','switch','artifact','recycle') if (r.get(sc) or {}).get('ok') is not None)out += ["", f"{len(rows)} pairs, {ok} of {tot} scenario runs passed.", ""]print("\n".join(out))diff --git a/scripts/support-matrix/run.mjs b/scripts/support-matrix/run.mjsindex 85df89c1..d6d3f25d 100644--- a/scripts/support-matrix/run.mjs+++ b/scripts/support-matrix/run.mjs@@ -1,4 +1,4 @@-// Support matrix runner: harness x model x provider x {first, followup, switch, artifact}.+// Support matrix runner: harness x model x provider x {first, followup, switch, artifact, recycle}.// Drives the console as one user; one task at a time per worker; resumable (pairs already complete// in the results file are skipped). Env: BASE, HR_USER, HR_PASS, HARNESSES (comma), PROVIDER// (a label for the column), RESULTS (json path), LOG (append log), MODELS (optional comma filter),@@ -21,46 +21,53 @@ const files = () => page.evaluate(() => [...document.querySelectorAll('.wbx-fileconst door = () => page.evaluate(() => document.querySelector('[role=dialog]:not(.welcome-overlay)')?.innerText?.replace(/\s+/g, ' ').trim() || '');const dismissWelcome = async () => { for (let i = 0; i < 4 && (await page.locator('.welcome-overlay').count()); i++) { await page.locator('.welcome-overlay .welcome-wide-close').click().catch(() => {}); await sleep(600); } };const TERMINAL = new Set(['done', 'completed', 'failed', 'error', 'cancelled', 'incomplete', 'max_turns', 'timeout']);+const LIVE = new Set(['running', 'starting', 'in_progress', 'queued']);const sidOf = () => new URL(page.url()).searchParams.get('sid') || '';-// the server's own record of the session's turns, read through the console's proxy (same cookie)+// the server's own record, read through the console's proxy (same cookie). The session detail is+// the cheap read (vertex plus card) and is what the wait polls; the turns feed rebuilds a live turn+// from its trace chunks on every read, so it is read only once the turn has settled.+const detailOf = (sid) => page.evaluate(async (s) => { const r = await fetch(`/api/harness/v1/sessions/${s}`); return r.ok ? await r.json() : null; }, sid).catch(() => null);const turnsOf = (sid) => page.evaluate(async (s) => { const r = await fetch(`/api/harness/v1/sessions/${s}/turns`); return r.ok ? ((await r.json()).turns || []) : null; }, sid).catch(() => null);// send one message on the open session and wait for it to settle; returns the outcome. The turn-// settles on the server's word (the turns feed), not on the task pill: the pill reads the task card,-// which lands a while after the turn does, and a turn scored off it was scored off the previous turn.+// settles on the server's word, not on the task pill: the pill reads the task card, which lands a+// while after the turn does, and a turn scored off it was scored off the previous turn.async function turn(text, { maxS = 420, expectFiles = false } = {}) {- const before = await transcript(); const t0 = Date.now(); const secs = () => Math.round((Date.now() - t0) / 10) / 100;+ const t0 = Date.now(); const secs = () => Math.round((Date.now() - t0) / 10) / 100;+ const mark = text.slice(0, 60);// the composer refuses a message while the previous turn's stream is still open (its Send is// disabled): wait for it to take input again, or the message is dropped on the floor- const ready = () => page.evaluate(() => { const b = document.querySelector('.wbx-composer .uic-send'); const ta = document.querySelector('.wbx-composer textarea'); return !!ta && !ta.disabled && !!b && !b.disabled; });- await page.fill('.wbx-composer textarea, textarea', text);- let canSend = await ready(); for (let i = 0; i < 90 && !canSend; i++) { await sleep(1000); canSend = await ready(); }- if (!canSend) return { ok: false, s: secs(), tail: '', why: 'the composer stayed busy for 90 s after the previous turn settled' };+ const ready = () => page.evaluate(() => { const b = document.querySelector('.wbx-composer .wbx-send, .wbx-composer .uic-send'); const ta = document.querySelector('.wbx-composer textarea'); return !!ta && !ta.disabled && !!b && !b.disabled; });const sid0 = sidOf(); const n0 = sid0 ? ((await turnsOf(sid0)) || []).length : 0;- await page.keyboard.press('Enter');- let sid = sid0, turns = null;- for (let i = 0; i < 120; i++) { await sleep(1000); sid = sid || sidOf(); if (!sid) continue; turns = await turnsOf(sid); if (turns && turns.length > n0) break; }- if (!turns || turns.length <= n0) return { ok: false, s: secs(), tail: '', why: 'the message was not taken: no turn record after 120 s' };- // settle on the server's word for the turn: two reads that agree on a terminal status, with the- // answer (or the reason) stored, and the produced files when the task was asked for one. The- // status lands a moment before the output does, and once read failed on a turn that completed.- let last = null, prev = '', agreed = 0, history = [];- for (let i = 0; i < maxS / 3; i++) {- await sleep(3000); const d = await door(); if (d) return { ok: false, s: secs(), tail: '', why: 'door: ' + d.slice(0, 160) };- turns = await turnsOf(sid); last = turns ? turns[turns.length - 1] : null; const st = String(last?.status || '');- if (st !== prev) { history.push(st); prev = st; }- if (!TERMINAL.has(st)) { agreed = 0; continue; }- const stored = !!(last.assistant || last.error || last.incomplete_reason || (last.files || []).length);- const filesIn = !expectFiles || (last.files || []).length > 0;- agreed = stored ? agreed + 1 : 0;- if (agreed >= 2 && (filesIn || agreed >= 8)) break;+ const before = await transcript(); const sentAt = () => transcript().then((t) => t.lastIndexOf(mark));+ // send, and see the message land in the transcript (the console shows it at once); a message a+ // re-render swallowed (a model pick rebuilds the composer) is typed and sent once more+ let shown = false;+ for (let attempt = 0; attempt < 2 && !shown; attempt++) {+ await page.fill('.wbx-composer textarea, textarea', text);+ let canSend = await ready(); for (let i = 0; i < 90 && !canSend; i++) { await sleep(1000); canSend = await ready(); }+ if (!canSend) return { ok: false, s: secs(), tail: '', why: 'the composer stayed busy for 90 s after the previous turn settled' };+ await page.keyboard.press('Enter');+ for (let i = 0; i < 10 && !shown; i++) { await sleep(1000); shown = (await sentAt()) >= before.lastIndexOf(mark) + 1 || ((await sentAt()) >= 0 && before.lastIndexOf(mark) < 0); }}+ if (!shown) return { ok: false, s: secs(), tail: '', why: 'the message never appeared in the transcript after two sends' };+ // taken: the server opened a turn for it (a new task gets its session id in the URL first)+ let sid = sid0, d = null, taken = false, n1 = n0;+ for (let i = 0; i < 60 && !taken; i++) { await sleep(2000); sid = sid || sidOf(); if (!sid) continue; d = await detailOf(sid); if (LIVE.has(String(d?.turn_status || d?.status || ''))) taken = true; else if (i % 5 === 4) { const ts = await turnsOf(sid); n1 = ts ? ts.length : n1; taken = n1 > n0; } }+ if (!taken) return { ok: false, s: secs(), tail: '', why: 'the message was not taken: the session never opened a turn in 120 s' };+ // settle on the session's status; then the turns feed, until the new turn's answer (or reason)+ // and the produced files are stored: the status lands a moment before the output does+ let st = '';+ for (let i = 0; i < maxS / 3; i++) { await sleep(3000); const dr = await door(); if (dr) return { ok: false, s: secs(), tail: '', why: 'door: ' + dr.slice(0, 160) }; d = await detailOf(sid); st = String(d?.turn_status || d?.status || ''); if (TERMINAL.has(st)) break; }+ let last = null, turns = null;+ for (let i = 0; i < 10; i++) { turns = await turnsOf(sid); last = turns && turns.length > n0 ? turns[turns.length - 1] : null; const stored = !!(last && TERMINAL.has(String(last.status)) && (last.assistant || last.error || last.incomplete_reason || (last.files || []).length)); if (stored && (!expectFiles || (last.files || []).length)) break; await sleep(3000); }// then let the console render what the server storedconst head = String(last?.assistant || '').replace(/\s+/g, ' ').trim().slice(0, 40);- for (let i = 0; i < 12; i++) { const t = await transcript(); if (!/Working…/.test(t.slice(before.length)) && (!head || t.includes(head))) break; await sleep(1500); }+ for (let i = 0; i < 12; i++) { const t = await transcript(); const from = t.lastIndexOf(mark); if (!/Working…/.test(t.slice(from)) && (!head || t.slice(from).includes(head))) break; await sleep(1500); }await sleep(1500);- const t = await transcript(); const tail = t.slice(before.length).trim().slice(-400);- const ok = !!last && (last.status === 'done' || last.status === 'completed');- return { ok, status: last ? last.status : 'none', status_history: history, pill: await pill(), s: secs(), tail, turn_files: (last?.files || []).map((f) => f.filename || f.name || ''), why: ok ? '' : (last?.error || last?.incomplete_reason || tail.slice(-220) || `status ${last?.status}`) };+ const t = await transcript(); const from = t.lastIndexOf(mark); const tail = t.slice(from >= 0 ? from : before.length).trim().slice(-400);+ const status = String(last?.status || (turns && turns.length > n0 ? st : 'none'));+ const ok = status === 'done' || status === 'completed';+ return { ok, status, pill: await pill(), s: secs(), tail, turn_files: (last?.files || []).map((f) => f.filename || f.name || ''), why: ok ? '' : (last?.error || last?.incomplete_reason || tail.slice(-220) || `status ${status}`) };}const expectWord = (r, word) => r.ok && (r.tail || '').includes(word) ? r : { ...r, ok: false, why: r.why || `answered without ${word}: ${(r.tail || '').slice(-200)}` };try {@@ -71,20 +78,23 @@ try {}await sleep(1500); await dismissWelcome();for (const h of process.env.HARNESSES.split(',')) {- // the menu starts from a placeholder list and takes the gateway's catalog when it lands: wait for that- const catalog = page.waitForResponse((r) => r.url().includes('/v1/models'), { timeout: 30000 }).catch(() => null);- await page.goto(`${BASE}/harnesses?h=${h}`, { waitUntil: 'domcontentloaded' }); await catalog; await sleep(3500); await dismissWelcome();+ await page.goto(`${BASE}/harnesses?h=${h}`, { waitUntil: 'domcontentloaded' }); await sleep(3500); await dismissWelcome();for (let i = 0; i < 10 && !(await page.locator('.wbx-conv-main.is-hero').count()); i++) { await page.click('button:has-text("New task")').catch(() => {}); await sleep(800); }+ // the menu starts from the console's placeholder list and takes the gateway's catalog when it+ // lands: the catalog says how many models this harness serves, so wait until the menu has them+ const backend = h === 'claude-code' ? 'claude' : h;+ const served = await page.evaluate(async (b) => { const r = await fetch('/api/harness/v1/models'); const j = await r.json(); return ((((j || {}).backends || {})[b] || {}).models || []).length; }, backend).catch(() => 0);const readMenu = () => page.evaluate(() => [...document.querySelectorAll('.wbx-model-opt')].map((o) => ({ id: o.querySelector('span')?.textContent.trim(), ok: !o.disabled })));await page.click('.ar2-chip'); await sleep(600);let models = await readMenu();- for (let i = 0; i < 10; i++) { await sleep(1500); const again = await readMenu(); if (again.length === models.length && models.length) break; models = again; }+ for (let i = 0; i < 40 && models.length < served; i++) { await page.keyboard.press('Escape'); await sleep(1500); await page.click('.ar2-chip'); await sleep(400); models = await readMenu(); }+ if (models.length < served) log(`MENU ${h} shows ${models.length} of ${served} served models after 60 s`);await page.keyboard.press('Escape'); await sleep(300);const enabled = models.filter((m) => m.ok && (!process.env.MODELS || process.env.MODELS.split(',').includes(m.id))).map((m) => m.id);log(`HARNESS ${h} models ${models.length} runnable ${enabled.length}: ${enabled.join(',')}`);for (const m of enabled) {const res = load(); const k = key(h, m);- if (res[k] && res[k].artifact && !res[k].error) { log(`SKIP ${k} (done)`); continue; } // a runner error is not a result+ if (res[k] && res[k].recycle && !res[k].error) { log(`SKIP ${k} (done)`); continue; } // a runner error is not a resultconst rec = res[k] || { provider: PROVIDER, harness: h, model: m, at: new Date().toISOString() };try {await page.goto(`${BASE}/harnesses?h=${h}`, { waitUntil: 'domcontentloaded' }); await sleep(3000);@@ -105,7 +115,16 @@ try {let fl = await files(); for (let i = 0; i < 10 && fl.length < (a.turn_files || []).length; i++) { await sleep(1500); fl = await files(); }rec.artifact = { ...a, files: fl, ok: a.ok && fl.some((f) => f.includes(`hello-${h}.txt`)), why: a.ok && !fl.some((f) => f.includes(`hello-${h}.txt`)) ? `no file card (files: ${fl.join(',') || 'none'}); ${a.tail.slice(-160)}` : a.why };log(`ARTIFACT ${k} ${rec.artifact.ok ? 'ok' : 'FAIL'} ${rec.artifact.s}s ${rec.artifact.why}`);- } else { rec.followup = { ok: null, why: 'first turn failed' }; rec.switch = { ok: null, why: 'first turn failed' }; rec.artifact = { ok: null, why: 'first turn failed' }; }+ // the sandbox is let go on purpose (what the pool does between visits) and the next turn must+ // carry on from the durable checkpoint: the history, the files, the resume id+ const rc = await page.evaluate(async (sid) => { const r = await fetch(`/api/harness/internal/sessions/${sid}/recycle`, { method: 'POST' }); return { code: r.status, body: (await r.text()).slice(0, 200) }; }, rec.sid);+ if (rc.code === 200) {+ await sleep(2000);+ const r5 = await turn('What exact word did I ask you to reply with in my very first message of this task? Reply with just that word.');+ rec.recycle = expectWord(r5, `M1-${m}`); rec.recycle.recycled = rc;+ } else rec.recycle = { ok: false, s: 0, why: `recycle refused: HTTP ${rc.code} ${rc.body}`, recycled: rc };+ log(`RECYCLE ${k} ${rec.recycle.ok ? 'ok' : 'FAIL'} ${rec.recycle.s}s ${rec.recycle.why}`);+ } else { rec.followup = { ok: null, why: 'first turn failed' }; rec.switch = { ok: null, why: 'first turn failed' }; rec.artifact = { ok: null, why: 'first turn failed' }; rec.recycle = { ok: null, why: 'first turn failed' }; }} catch (e) { rec.error = String(e).slice(0, 300); log(`ERROR ${k} ${rec.error}`); if (/has been closed/.test(rec.error)) throw e; } // a closed browser ends the worker; the next launch resumesconst all = load(); all[k] = rec; save(all); log(`PAIR_DONE ${k}`);}