nullius-eval 0.1.0rc1__py3-none-any.whl

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 (268) hide show
  1. _nullius_app/.env.example +54 -0
  2. _nullius_app/app.py +96 -0
  3. _nullius_app/requirements.txt +1 -0
  4. _nullius_app/static/brand/README.md +16 -0
  5. _nullius_app/static/brand/favicon.svg +1 -0
  6. _nullius_app/static/brand/mark-dark.svg +1 -0
  7. _nullius_app/static/brand/marks.svg +34 -0
  8. _nullius_app/static/brand/tokens.json +51 -0
  9. _nullius_app/static/brand/typesafe.png +0 -0
  10. _nullius_app/static/brand/wordmark-dark.svg +1 -0
  11. _nullius_app/static/builder/command-builder-core.js +744 -0
  12. _nullius_app/static/builder/command-builder.css +248 -0
  13. _nullius_app/static/builder/command-builder.js +994 -0
  14. _nullius_app/static/builder/model-picker.js +113 -0
  15. _nullius_app/static/catalogue/add.js +46 -0
  16. _nullius_app/static/catalogue/agents/README.md +19 -0
  17. _nullius_app/static/catalogue/agents/goose.svg +1 -0
  18. _nullius_app/static/catalogue/agents/jiuwenswarm.svg +33 -0
  19. _nullius_app/static/catalogue/agents/marks.json +8 -0
  20. _nullius_app/static/catalogue/agents/mini-swe-agent.svg +7 -0
  21. _nullius_app/static/catalogue/agents/opencode.svg +7 -0
  22. _nullius_app/static/catalogue/catalogue.css +453 -0
  23. _nullius_app/static/catalogue/catalogue.js +87 -0
  24. _nullius_app/static/catalogue/marks.svg +25 -0
  25. _nullius_app/static/catalogue/new.js +78 -0
  26. _nullius_app/static/catalogue/versions.js +27 -0
  27. _nullius_app/static/compare/comparison.css +117 -0
  28. _nullius_app/static/controls.js +117 -0
  29. _nullius_app/static/disclosures.js +70 -0
  30. _nullius_app/static/fonts/0569c822cab6c510.ttf +0 -0
  31. _nullius_app/static/fonts/DMSans-Medium.woff2 +0 -0
  32. _nullius_app/static/fonts/DMSans-Regular.woff2 +0 -0
  33. _nullius_app/static/fonts/IBMPlexMono-Medium.woff2 +0 -0
  34. _nullius_app/static/fonts/IBMPlexMono-Regular.woff2 +0 -0
  35. _nullius_app/static/fonts/InstrumentSerif-Italic.woff2 +0 -0
  36. _nullius_app/static/fonts/InstrumentSerif-Regular.woff2 +0 -0
  37. _nullius_app/static/fonts/README.md +11 -0
  38. _nullius_app/static/fonts/c1e7453ea26a1d1e.ttf +0 -0
  39. _nullius_app/static/fonts/dmsans-OFL.txt +93 -0
  40. _nullius_app/static/fonts/ibmplexmono-OFL.txt +93 -0
  41. _nullius_app/static/fonts/instrumentserif-OFL.txt +93 -0
  42. _nullius_app/static/fonts.css +49 -0
  43. _nullius_app/static/notifications.js +34 -0
  44. _nullius_app/static/onboarding.css +78 -0
  45. _nullius_app/static/onboarding.js +158 -0
  46. _nullius_app/static/runs/board.css +354 -0
  47. _nullius_app/static/runs/board.js +127 -0
  48. _nullius_app/static/runs/launches.css +87 -0
  49. _nullius_app/static/runs/live-board.css +186 -0
  50. _nullius_app/static/runs/live-board.js +387 -0
  51. _nullius_app/static/runs/path-suggestions.js +119 -0
  52. _nullius_app/static/runs/start.css +38 -0
  53. _nullius_app/static/settings/autosave.js +145 -0
  54. _nullius_app/static/settings/judges.js +61 -0
  55. _nullius_app/static/settings/modal.css +32 -0
  56. _nullius_app/static/settings/modal.js +91 -0
  57. _nullius_app/static/settings/navigation.js +55 -0
  58. _nullius_app/static/settings/providers.js +78 -0
  59. _nullius_app/static/settings/sandbox.js +83 -0
  60. _nullius_app/static/settings/settings.css +229 -0
  61. _nullius_app/static/style.css +1751 -0
  62. _nullius_app/static/traces/conversation.css +49 -0
  63. _nullius_app/static/traces/conversation.js +215 -0
  64. _nullius_app/templates/agents/entry.html +145 -0
  65. _nullius_app/templates/agents/kits.html +55 -0
  66. _nullius_app/templates/agents/standard.html +58 -0
  67. _nullius_app/templates/base.html +477 -0
  68. _nullius_app/templates/builder/new_run.html +55 -0
  69. _nullius_app/templates/catalogue/add_dialog.html +32 -0
  70. _nullius_app/templates/catalogue/benchmark.html +301 -0
  71. _nullius_app/templates/catalogue/benchmarks.html +92 -0
  72. _nullius_app/templates/catalogue/new.html +141 -0
  73. _nullius_app/templates/catalogue/use_bundle.html +11 -0
  74. _nullius_app/templates/compare/_detail.html +37 -0
  75. _nullius_app/templates/compare/compare.html +298 -0
  76. _nullius_app/templates/compare/compare_picker.html +51 -0
  77. _nullius_app/templates/compare/compare_task.html +329 -0
  78. _nullius_app/templates/runs/_execution.html +131 -0
  79. _nullius_app/templates/runs/_runtime.html +5 -0
  80. _nullius_app/templates/runs/ascii-mark.html +485 -0
  81. _nullius_app/templates/runs/feasibility.html +127 -0
  82. _nullius_app/templates/runs/index.html +609 -0
  83. _nullius_app/templates/runs/job.html +446 -0
  84. _nullius_app/templates/runs/preparing.html +14 -0
  85. _nullius_app/templates/runs/reconcile.html +124 -0
  86. _nullius_app/templates/runs/setup.html +272 -0
  87. _nullius_app/templates/runs/start.html +51 -0
  88. _nullius_app/templates/settings/settings.html +508 -0
  89. _nullius_app/templates/traces/_charts.html +165 -0
  90. _nullius_app/templates/traces/_conversation.html +37 -0
  91. _nullius_app/templates/traces/_judgement.html +72 -0
  92. _nullius_app/templates/traces/artifact.html +15 -0
  93. _nullius_app/templates/traces/trial.html +838 -0
  94. _nullius_app/templates/workspaces/workspaces.html +54 -0
  95. _nullius_app/web/__init__.py +1 -0
  96. _nullius_app/web/agents.py +230 -0
  97. _nullius_app/web/builder.py +392 -0
  98. _nullius_app/web/catalogue.py +374 -0
  99. _nullius_app/web/compare.py +489 -0
  100. _nullius_app/web/core.py +17 -0
  101. _nullius_app/web/execute.py +205 -0
  102. _nullius_app/web/feasibility.py +60 -0
  103. _nullius_app/web/filters.py +224 -0
  104. _nullius_app/web/judge.py +623 -0
  105. _nullius_app/web/judge_tasks.py +33 -0
  106. _nullius_app/web/onboarding.py +20 -0
  107. _nullius_app/web/reconcile.py +47 -0
  108. _nullius_app/web/runs.py +461 -0
  109. _nullius_app/web/settings.py +210 -0
  110. _nullius_app/web/shared.py +468 -0
  111. _nullius_app/web/traces.py +306 -0
  112. _nullius_app/web/workspaces.py +84 -0
  113. nullius/__init__.py +32 -0
  114. nullius/__main__.py +5 -0
  115. nullius/catalogue/__init__.py +0 -0
  116. nullius/catalogue/agents/codex/agent.json +202 -0
  117. nullius/catalogue/agents/codex/config.toml +25 -0
  118. nullius/catalogue/agents/goose/agent.json +120 -0
  119. nullius/catalogue/agents/goose/config.yaml +20 -0
  120. nullius/catalogue/agents/jiuwenswarm/agent.json +115 -0
  121. nullius/catalogue/agents/jiuwenswarm/agent.py +316 -0
  122. nullius/catalogue/agents/mini-swe-agent/agent.json +68 -0
  123. nullius/catalogue/agents/mini-swe-agent/run.py +37 -0
  124. nullius/catalogue/agents/opencode/agent.json +124 -0
  125. nullius/catalogue/agents/opencode/opencode.json +32 -0
  126. nullius/catalogue/agents/reference/agent.json +89 -0
  127. nullius/catalogue/agents/reference/agent.py +209 -0
  128. nullius/catalogue/agents/terminus-2/agent.json +64 -0
  129. nullius/catalogue/agents/terminus-2/run.py +139 -0
  130. nullius/catalogue/benchmarks/gsm8k/benchmark.json +34 -0
  131. nullius/catalogue/benchmarks/gsm8k/driver.py +101 -0
  132. nullius/catalogue/benchmarks/gsm8k/standard.json +124 -0
  133. nullius/catalogue/benchmarks/gsm8k/upstream-settings.json +86 -0
  134. nullius/catalogue/benchmarks/humaneval/benchmark.json +37 -0
  135. nullius/catalogue/benchmarks/humaneval/driver.py +208 -0
  136. nullius/catalogue/benchmarks/humaneval/standard.json +114 -0
  137. nullius/catalogue/benchmarks/humaneval/upstream-settings.json +72 -0
  138. nullius/catalogue/benchmarks/locomo/benchmark.json +42 -0
  139. nullius/catalogue/benchmarks/locomo/driver.py +270 -0
  140. nullius/catalogue/benchmarks/locomo/standard.json +265 -0
  141. nullius/catalogue/benchmarks/locomo/upstream-settings.json +112 -0
  142. nullius/catalogue/benchmarks/longmemeval/benchmark.json +64 -0
  143. nullius/catalogue/benchmarks/longmemeval/driver.py +323 -0
  144. nullius/catalogue/benchmarks/longmemeval/standard.json +551 -0
  145. nullius/catalogue/benchmarks/longmemeval/upstream-settings.json +74 -0
  146. nullius/catalogue/benchmarks/swe-bench-verified/benchmark.json +87 -0
  147. nullius/catalogue/benchmarks/swe-bench-verified/driver.py +105 -0
  148. nullius/catalogue/benchmarks/swe-bench-verified/images.json +502 -0
  149. nullius/catalogue/benchmarks/swe-bench-verified/standard.json +108 -0
  150. nullius/catalogue/benchmarks/swe-bench-verified/upstream-settings.json +32 -0
  151. nullius/catalogue/benchmarks/tau3-bench/benchmark.json +49 -0
  152. nullius/catalogue/benchmarks/tau3-bench/driver.py +605 -0
  153. nullius/catalogue/benchmarks/tau3-bench/mcp_server.py +111 -0
  154. nullius/catalogue/benchmarks/tau3-bench/standard.json +495 -0
  155. nullius/catalogue/benchmarks/tau3-bench/upstream-settings.json +639 -0
  156. nullius/catalogue/benchmarks/terminal-bench/benchmark.json +70 -0
  157. nullius/catalogue/benchmarks/terminal-bench/driver.py +189 -0
  158. nullius/catalogue/benchmarks/terminal-bench/standard.json +160 -0
  159. nullius/catalogue/benchmarks/terminal-bench/upstream-settings.json +36 -0
  160. nullius/catalogue/capabilities/keyword-memory/capability.json +33 -0
  161. nullius/catalogue/capabilities/keyword-memory/capability.py +55 -0
  162. nullius/catalogue/capabilities/mem0/capability.json +135 -0
  163. nullius/catalogue/capabilities/mem0/capability.py +170 -0
  164. nullius/catalogue/catalog.py +413 -0
  165. nullius/catalogue/citation.py +116 -0
  166. nullius/catalogue/harbor_entry.py +367 -0
  167. nullius/catalogue/sources.py +85 -0
  168. nullius/catalogue/storage.py +125 -0
  169. nullius/cli.py +83 -0
  170. nullius/compare/__init__.py +0 -0
  171. nullius/compare/cli.py +265 -0
  172. nullius/compare/comparison.py +184 -0
  173. nullius/execution.py +1624 -0
  174. nullius/gitrefs.py +128 -0
  175. nullius/harbor/__init__.py +0 -0
  176. nullius/harbor/feed.py +228 -0
  177. nullius/harbor/source.py +582 -0
  178. nullius/hosts.py +339 -0
  179. nullius/importers/__init__.py +140 -0
  180. nullius/importers/atif.py +387 -0
  181. nullius/importers/cli.py +135 -0
  182. nullius/importers/otel.py +274 -0
  183. nullius/judge/__init__.py +14 -0
  184. nullius/judge/batch.py +122 -0
  185. nullius/judge/client.py +416 -0
  186. nullius/judge/floors.json +86 -0
  187. nullius/judge/lanes.py +89 -0
  188. nullius/judge/questions.py +309 -0
  189. nullius/judge/reconcile.py +172 -0
  190. nullius/judge/state.py +224 -0
  191. nullius/judge/store.py +167 -0
  192. nullius/migrate.py +268 -0
  193. nullius/onboarding.py +112 -0
  194. nullius/paths.py +84 -0
  195. nullius/prerequisites.py +111 -0
  196. nullius/progress.py +294 -0
  197. nullius/providers.py +115 -0
  198. nullius/recipes/__init__.py +0 -0
  199. nullius/recipes/launch.py +78 -0
  200. nullius/redact.py +72 -0
  201. nullius/runs/__init__.py +0 -0
  202. nullius/runs/artifacts.py +67 -0
  203. nullius/runs/classify.py +189 -0
  204. nullius/runs/cli.py +316 -0
  205. nullius/runs/feasibility.py +442 -0
  206. nullius/runs/launches.py +139 -0
  207. nullius/runs/live.py +705 -0
  208. nullius/runs/parse.py +991 -0
  209. nullius/runs/verifier.py +241 -0
  210. nullius/sandbox.py +146 -0
  211. nullius/secrets.py +192 -0
  212. nullius/settings.py +456 -0
  213. nullius/standard/__init__.py +15 -0
  214. nullius/standard/acp.py +301 -0
  215. nullius/standard/cancellation.py +19 -0
  216. nullius/standard/cli.py +650 -0
  217. nullius/standard/conform.py +149 -0
  218. nullius/standard/container.py +1381 -0
  219. nullius/standard/definitions.py +1577 -0
  220. nullius/standard/egress.py +192 -0
  221. nullius/standard/fidelity.py +255 -0
  222. nullius/standard/forward.py +92 -0
  223. nullius/standard/hostreq.py +65 -0
  224. nullius/standard/howto.py +220 -0
  225. nullius/standard/install.py +397 -0
  226. nullius/standard/job.py +541 -0
  227. nullius/standard/jsonl.py +129 -0
  228. nullius/standard/kits/agent-conversation-v1/driver.py +27 -0
  229. nullius/standard/kits/agent-conversation-v1/standard.json +26 -0
  230. nullius/standard/kits/agent-task-v1/driver.py +25 -0
  231. nullius/standard/kits/agent-task-v1/standard.json +100 -0
  232. nullius/standard/kits/agent-tools-v1/driver.py +206 -0
  233. nullius/standard/kits/agent-tools-v1/mcp_kit.py +209 -0
  234. nullius/standard/kits/agent-tools-v1/standard.json +119 -0
  235. nullius/standard/kits/agent-workspace-v1/driver.py +65 -0
  236. nullius/standard/kits/agent-workspace-v1/standard.json +95 -0
  237. nullius/standard/kits/cap-memory-v1/driver.py +39 -0
  238. nullius/standard/kits/cap-memory-v1/standard.json +91 -0
  239. nullius/standard/match.py +66 -0
  240. nullius/standard/mcp_bridge.py +62 -0
  241. nullius/standard/mcp_machine.py +193 -0
  242. nullius/standard/merge.py +209 -0
  243. nullius/standard/names.py +30 -0
  244. nullius/standard/payload.py +255 -0
  245. nullius/standard/ports.py +64 -0
  246. nullius/standard/prove.py +357 -0
  247. nullius/standard/recipe.py +663 -0
  248. nullius/standard/relay.py +629 -0
  249. nullius/standard/run.py +1367 -0
  250. nullius/standard/shard.py +71 -0
  251. nullius/traces/__init__.py +0 -0
  252. nullius/traces/behavior.py +131 -0
  253. nullius/traces/charts.py +898 -0
  254. nullius/traces/conversation.py +159 -0
  255. nullius/traces/otel.py +608 -0
  256. nullius/traces/trace.py +1477 -0
  257. nullius/traces/trajectory.py +586 -0
  258. nullius/workspace.py +409 -0
  259. nullius/workspace_cli.py +119 -0
  260. nullius_eval-0.1.0rc1.dist-info/METADATA +93 -0
  261. nullius_eval-0.1.0rc1.dist-info/RECORD +268 -0
  262. nullius_eval-0.1.0rc1.dist-info/WHEEL +5 -0
  263. nullius_eval-0.1.0rc1.dist-info/entry_points.txt +2 -0
  264. nullius_eval-0.1.0rc1.dist-info/licenses/LICENSE +202 -0
  265. nullius_eval-0.1.0rc1.dist-info/licenses/app/static/fonts/dmsans-OFL.txt +93 -0
  266. nullius_eval-0.1.0rc1.dist-info/licenses/app/static/fonts/ibmplexmono-OFL.txt +93 -0
  267. nullius_eval-0.1.0rc1.dist-info/licenses/app/static/fonts/instrumentserif-OFL.txt +93 -0
  268. nullius_eval-0.1.0rc1.dist-info/top_level.txt +2 -0
@@ -0,0 +1,994 @@
1
+ /* Builder page controller: edit recipes, resolve their dependencies, and start an explicit Run. */
2
+ (() => {
3
+ 'use strict';
4
+ const root = document.getElementById('nullius-builder');
5
+ if (!root) return;
6
+ const schema = JSON.parse(document.getElementById('nb-schema').textContent);
7
+ const C = window.NulliusRecipe(schema), $ = s => root.querySelector(s);
8
+ const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
9
+ const agentMarks = JSON.parse(root.dataset.agentMarks || '{}');
10
+ const agentMark = (key, label) => {
11
+ const source = agentMarks[String(key).split('@')[0]];
12
+ if (!source) return esc(label[0]);
13
+ return source.includes('#')
14
+ ? `<svg class="agent-logo" aria-hidden="true"><use href="/static/${esc(source)}"/></svg>`
15
+ : `<img class="agent-logo" src="/static/${esc(source)}" alt="" aria-hidden="true">`;
16
+ };
17
+ const steps = C.STEPS, S = C.STEP, REVIEW = S.review;
18
+ const query = Object.fromEntries(new URLSearchParams(location.search));
19
+ let recipe = C.prefill(query);
20
+ let step = C.openingStep(query, recipe), tab = 'select';
21
+ // What the page shows is kept in the browser as a draft on every change, so
22
+ // leaving for another page and coming back finds the recipe as it was left.
23
+ // A run's own recipe (?run=) or a prefill from a run's fields comes first.
24
+ // A draft comes back silently: the page simply is as it was left.
25
+ const draftKey = 'nullius.recipe-draft.v1';
26
+ let opened = '';
27
+ if (schema.loadRecipe) { try { recipe = C.fromJSON(schema.loadRecipe); step = REVIEW; opened = 'Opened the recipe of run “' + schema.loadRun + '”. Run gives it a new name.'; } catch (e) { opened = 'This run’s recipe cannot be read: ' + e.message; } }
28
+ else if (schema.loadLike) { const o = C.fromJob(schema.loadLike); recipe = o.recipe; step = REVIEW; opened = o.notes.join(' '); }
29
+ // An unsupported draft opens nothing; its rejection is shown as a toast.
30
+ else { let d = null; try { d = C.unpackDraft(localStorage.getItem(draftKey), query); } catch {} if (d && d.recipe) { recipe = d.recipe; step = d.step; tab = d.tab; } else if (d && d.gone) opened = d.gone; }
31
+ const saveDraft = () => { try { localStorage.setItem(draftKey, C.packDraft({recipe, step, tab})); } catch {} };
32
+ let compiled, pendingDirs, dirsSequence = 0;
33
+ const r = () => recipe;
34
+ const storageKey = 'nullius.recipes.v1'; // one list for this browser; a run may open another workspace and the recipes stay
35
+ // A message is a toast at the bottom right: a new one replaces it, its bar runs down and it goes, or its × closes it.
36
+ // Shown again on each message, so it lands above a dialog opened since.
37
+ const status = text => {
38
+ const t = $('#nb-status'), bar = t && t.querySelector('.nb-toast-bar');
39
+ if (!t) return;
40
+ const show = on => {
41
+ if (t.showPopover) { if (t.matches(':popover-open')) t.hidePopover(); if (on) t.showPopover(); }
42
+ else t.hidden = !on;
43
+ };
44
+ if (!t.dataset.wired) {
45
+ t.dataset.wired = '1';
46
+ t.querySelector('.nb-toast-close').addEventListener('click', () => show(false));
47
+ bar.addEventListener('animationend', () => show(false));
48
+ }
49
+ if (!text) { show(false); return; }
50
+ show(true);
51
+ t.querySelector('.nb-toast-text').textContent = text;
52
+ bar.style.animation = 'none'; void bar.offsetWidth; bar.style.animation = '';
53
+ };
54
+ const button = (label,attrs='',cls='nb-button') => `<button type="button" class="${cls}" ${attrs}>${label}</button>`;
55
+ // Which Harbor runs this recipe: the one it pins (Runner step), or a
56
+ // development checkout typed as a path (a field appears) - labelled as
57
+ // such; Run does not support them.
58
+ const harborExecutableFields = rec => {
59
+ const current = rec.harborDev ? 'dev' : 'path';
60
+ const opts = [['path', 'The Harbor this recipe pins (Runner step)'], ['dev', 'Development checkout · a path, not a release']];
61
+ return `<label class="nb-field">Harbor executable<select data-harbor-choice aria-label="Harbor executable">${opts.map(([v, t]) => `<option value="${esc(v)}" ${v === current ? 'selected' : ''}>${esc(t)}</option>`).join('')}</select></label>`
62
+ + (current === 'dev' ? field('Path to the development harbor', 'harborDev', rec.harborDev, {placeholder: '~/harbor-dev/.venv/bin/harbor', hint: 'Runs from it are labelled development, not acceptance evidence.'}) : '');
63
+ };
64
+ // The Harbor agents as cards, grouped by what they are for. Every selected
65
+ // agent becomes one run command; the line above the cards says how many.
66
+ const agentLabel = (id, rec = r()) => C.agentById(id, rec)?.label || id;
67
+ const chip = (id, label, on, extra = '') => `<button type="button" class="nb-agentchip" data-agent="${esc(id)}" aria-pressed="${on}" ${extra}>${esc(label)}${on ? ' <span aria-hidden="true">✓</span>' : ''}</button>`;
68
+ // The agent list: the vocabulary as chips, and custom agents as typed
69
+ // import paths (each one an agent under evaluation).
70
+ const agentCards = rec => {
71
+ const on = id => rec.agents.includes(id);
72
+ const n = rec.agents.length;
73
+ const published = (schema.benchmarks.find(b => b.key === rec.benchmark)?.published || {}).agent;
74
+ const vocab = C.agents().filter(a => !a.benchmarks || a.benchmarks.includes(rec.benchmark)).map(a => a.id === published ? {...a, kind:'reference'} : a);
75
+ let html = `<div class="nb-agentline"><strong>${n} selected${n ? ' · ' + rec.agents.map(id => agentLabel(id, rec)).map(esc).join(', ') : ''}</strong></div>`;
76
+ const ref = vocab.filter(a => a.kind === 'reference'), ctl = vocab.filter(a => a.kind === 'control');
77
+ if (ref.length) html += `<div class="nb-agentrow"><h4>Benchmark reference</h4><div class="nb-chips">${ref.map(a => chip(a.id, a.label, on(a.id), `title="${esc(a.summary || '')}"`)).join('')}</div></div>`;
78
+ html += `<div class="nb-agentrow"><h4>Under evaluation</h4><div class="nb-chips">${vocab.filter(a => a.kind === 'evaluated').map(a => chip(a.id, a.label, on(a.id), `title="${esc(a.summary || '')}"`)).join('')}`
79
+ + rec.customAgents.map((p, i) => `<span class="nb-customagent">${chip('custom-' + i, 'custom', on('custom-' + i))}<input data-custom-agent="${i}" value="${esc(p)}" placeholder="package.module:AgentClass" spellcheck="false" aria-label="Custom agent ${i + 1} import path">${button('×', `data-remove-custom-agent="${i}"`, 'nb-remove')}</span>`).join('')
80
+ + button('+ Custom agent', 'id="nb-add-custom-agent"', 'nb-subtab') + '</div></div>';
81
+ // Harbor's own agents: what the recipe's Harbor registers, once it has been scanned (Runner step).
82
+ const builtin = vocab.filter(a => a.kind === 'builtin');
83
+ html += builtin.length ? `<div class="nb-agentrow"><h4>Harbor built-in</h4><div class="nb-chips">${builtin.map(a => chip(a.id, a.label, on(a.id), `title="${esc(a.summary || '')}"`)).join('')}</div></div>`
84
+ : `<p class="nb-note">Harbor's own agents are offered once the Harbor this recipe pins has been scanned: Runner step, <em>Install</em>.</p>`;
85
+
86
+ html += `<div class="nb-agentrow"><h4>Controls</h4><div class="nb-chips">${ctl.map(a => chip(a.id, a.label, on(a.id), `title="${esc(a.summary || '')}"`)).join('')}</div></div>`;
87
+ return html;
88
+ };
89
+ // Harbor's per-trial settings, shared by every selected agent.
90
+ // Time limits per phase, in minutes, when the benchmark's declared
91
+ // timeouts are recorded; the multipliers Harbor takes are derived from them
92
+ // and kept out of sight. A benchmark with nothing recorded gets the multipliers.
93
+ const timeLimits = rec => {
94
+ const t = C.effectiveTimeouts(rec);
95
+ if (!t) return `<div class="nb-two">${field('Agent timeout multiplier','timeoutMultiplier',rec.timeoutMultiplier,{type:'number',min:0.01,hint:'This benchmark has no recorded timeouts, so only the multiplier can be set: 1 keeps what each task declares.'})}${field('Agent setup timeout multiplier', 'setupTimeoutMultiplier', rec.setupTimeoutMultiplier, {type: 'number', min: 0.01, placeholder: '1'})}</div>`
96
+ + `<div class="nb-two">${field('Verifier timeout multiplier', 'verifierTimeoutMultiplier', rec.verifierTimeoutMultiplier, {type: 'number', min: 0.01, placeholder: '1'})}${field('Environment build timeout multiplier', 'buildTimeoutMultiplier', rec.buildTimeoutMultiplier, {type: 'number', min: 0.01, placeholder: '1'})}</div>`;
97
+ const fmt=s=>s==null?'—':s>=3600?(s/3600).toFixed(s%3600?1:0)+' h':s>=60&&s%60===0?(s/60)+' min':s>=600?(s/60).toFixed(1)+' min':s+' s';
98
+ return `<div class="nb-note"><table class="nb-timeouts nb-timelimits"><thead><tr><th>Phase</th><th>Declared by the tasks</th><th>Time limit · minutes</th></tr></thead><tbody>${t.phases.map(p=>`<tr><td>${esc(p.label)}</td><td>${fmt(p.declared)}</td><td><input type="number" min="0.1" step="any" data-minutes="${p.key}" value="${p.minutes ?? ''}" aria-label="${esc(p.label)} time limit in minutes"></td></tr>`).join('')}</tbody></table></div>`;
99
+ };
100
+ const commonSettings = rec => `<div class="nb-categoryhead"><h3>Common settings</h3><p>Every trial, whichever agent runs it.</p></div>`
101
+ + `<div id="nb-timeouts">${timeLimits(rec)}</div>`
102
+ + `<div class="nb-two">${field('Repeats per task', 'attempts', rec.attempts, {type: 'number', min: 1, placeholder: '1', hint: 'Every task is run this many times, pass or fail (Harbor\'s --n-attempts). Retries after a failure are on Limits.'})}<span></span></div>`
103
+ ;
104
+ // One tab per selected agent: the parameters this catalogue knows for it,
105
+ // its extra --ak list, and what else it needs.
106
+ const agentTab = (rec, id) => {
107
+ const a = C.agentById(id, rec);
108
+ let html = `<div class="nb-categoryhead"><h3>${esc(agentLabel(id, rec))}</h3><p>${esc(a?.summary || (a?.custom ? 'Your own agent class, passed to Harbor by import path.' : ''))}</p></div>`;
109
+ if (id === 'tau3-llm-agent') html += parameterRows(id)
110
+ + field('Adapter directory · on the run target', 'adapterPath:' + id, C.adapterPath(rec, id), {list: 'nb-paths', hint: 'Harbor’s source tree holds this agent (adapters/tau3-bench). The run checks this directory before it starts; ~ is the run target’s home.'});
111
+ if (!a?.custom && id !== 'tau3-llm-agent') html += `<p class="nb-note">Harbor lists this agent\'s own options with <code>harbor agents schema ${esc(a?.arg || id)}</code>; this catalogue records none for it.</p>`;
112
+ html += `<div class="fl">Extra --ak for ${esc(agentLabel(id, rec))} only</div><div id="nb-parameters">${customRows(id)}</div>`;
113
+ return html;
114
+ };
115
+ // The standard's recipe as the server compiles it from the definitions (POST
116
+ // /new-run/runner). Nothing typed here is a command; Run sends the choices.
117
+ let runnerOut = null, runnerKey = '', runnerTimer;
118
+ // Switching runner keeps the recipe being edited, one per runner, for as long as the page is open: switching back finds it as it was.
119
+ const keptByRunner = {};
120
+ // Nullius's own mark for the standard; Harbor's for Harbor
121
+ const runnerMark = x => x.standard ? '<span class="brand-mark nb-nullius-mark" aria-hidden="true"></span>'
122
+ : '<svg aria-hidden="true"><use href="/static/brand/marks.svg#harbor"/></svg>';
123
+ // Two cards: Harbor, and Nullius (the standard) - a benchmark's own scripts run there, as its Original setup.
124
+ const runnerCard = (x, on, label, summary, mark) => tile({attr: 'runner', key: x.key, on, mark, title: label, tip: summary || ''});
125
+ const runnerStep = rec => {
126
+ const has = C.runnersOf(C.benchKey(rec)), list = C.runners().filter(x => x.builtin && has.includes(x.key));
127
+ const cards = list.length > 1 ? `<div class="nb-pick-grid">` + list.map(x => runnerCard(x, x.key === rec.harness, x.label, x.summary, runnerMark(x))).join('') + '</div>'
128
+ : `<label class="nb-field ui-field-row"><span class="ui-field-copy">Runner</span><span class="nb-fixed">${esc((C.runners().find(x => x.key === rec.harness) || {}).label || rec.harness)}</span></label>`;
129
+ return `<div class="nb-sectionhead"><h2>What runs it?</h2></div>` + cards + (rec.harness === 'harbor' ? harborPanel(rec) : '');
130
+ };
131
+ // Every benchmark of both runners in one list; picking one sets the runner that runs it (Nullius when both do).
132
+ const benchmarkStep = rec => {
133
+ const st = C.standard(), sb = C.standardBench(rec), on = C.benchKey(rec), seen = new Set(), tiles = [];
134
+ const add = (key, title, fam, kind, summary) => { if (seen.has(key)) return; seen.add(key); const c = catOf(key);
135
+ tiles.push({attr: 'bench', key, on: key === on, title: c.title || title,
136
+ mark: `<svg aria-hidden="true"><use href="/static/catalogue/marks.svg#bm-${esc(key)}"/></svg>`, cat: c.category, origin: c.origin,
137
+ fam, famLabel: fam === 'agent' ? 'Agents' : 'Capabilities · ' + kind, tip: c.domain || summary || '', meta: tasksOf(key),
138
+ find: [c.title || title, key, c.category, c.domain, kind].join(' ')}); };
139
+ st.benchmarks.forEach(x => add(x.key, x.label, x.family, x.kind, x.summary));
140
+ C.benchmarks().forEach(x => add(x.key, x.title, 'agent', '', x.domain));
141
+ tiles.sort((a, b) => a.title.localeCompare(b.title, 'en', {sensitivity: 'base'}));
142
+ const versions = C.isStandard(rec) && sb && (sb.versions || []).length > 1
143
+ ? `<label class="nb-field">Version of ${esc(sb.label)}<select data-std-version>${sb.versions.map(v => `<option value="${esc(v.ref)}" ${v.ref === rec.benchmark || (v.default && rec.benchmark === sb.key) ? 'selected' : ''}>${esc(v.version)}${v.default ? ' (the default)' : ''}</option>`).join('')}</select><small>Each version pins its own upstream, datasets and proofs.</small></label>` : '';
144
+ return `<div class="nb-sectionhead"><h2>Choose a benchmark.</h2></div>` + picker(tiles, [['agent', 'Agents'], ['capability', 'Capabilities']]) + versions;
145
+ };
146
+ // Put the recipe on a runner, keeping the one each runner had: the benchmark follows.
147
+ const toRunner = (target, key) => {
148
+ if (target !== r().harness) { keptByRunner[r().harness] = r(); recipe = keptByRunner[target] || (target === 'harbor' ? C.create() : C.createStandard(key)); runnerOut = null; runnerKey = ''; tab = 'select'; }
149
+ if (C.benchKey(r()) !== key) { if (C.isStandard(r())) C.setStandardBenchmark(r(), key); else C.setBenchmark(r(), key); }
150
+ };
151
+ // Branch, tag or commit first; then that kind's list, or the commit typed, for the
152
+ // repository a Harbor is pinned from: `o.kindAttr` and `o.refAttr` name the data
153
+ // attributes its two controls answer to.
154
+ const KIND_LABEL = {branch: 'Branch', tag: 'Tag', commit: 'Commit'};
155
+ const cap = s => s.charAt(0).toUpperCase() + s.slice(1);
156
+ const refPicker = o => {
157
+ const got = o.got || {loading: true}, kind = o.kind || 'commit';
158
+ const lists = {branch: got.branches || [], tag: got.tags || []}, totals = {branch: got.branches_total || 0, tag: got.tags_total || 0};
159
+ // A segmented control: one pill slides to the kind chosen (placeThumb), a kind with nothing to offer is dimmed.
160
+ const segments = ['branch', 'tag', 'commit'].map(k => {
161
+ const unknown = k !== 'commit' && (got.loading || got.error), none = k !== 'commit' && !unknown && !totals[k];
162
+ const count = k === 'commit' ? '' : `<span class="nb-seg-count" aria-label="${totals[k] || 'none'}">${totals[k] || '0'}</span>`;
163
+ return `<button type="button" class="nb-seg-btn" role="radio" aria-checked="${k === kind}" data-${o.kindAttr}="${k}" ${(unknown || none) && k !== kind ? 'disabled' : ''}>${KIND_LABEL[k]}${count}</button>`;
164
+ }).join('');
165
+ const said = got.loading ? 'Reading branches and tags…' : got.error ? cap(got.error) + '.' : '';
166
+ let body;
167
+ if (kind === 'commit') body = o.commitField;
168
+ else {
169
+ const list = lists[kind], extra = list.some(x => x.name === o.revision) ? [] : [{name: o.revision, date: '', commit: ''}];
170
+ const option = x => `<option value="${esc(x.name)}" ${x.name === o.revision ? 'selected' : ''}>${esc(x.name)}${kind === 'branch' && x.name === got.default_branch ? ' · default' : ''}${x.date ? ' · ' + esc(x.date) : ''}${x.commit ? ' · ' + esc(x.commit.slice(0, 12)) : ''}</option>`;
171
+ body = `<label class="nb-field">${KIND_LABEL[kind]}<select data-${o.refAttr} aria-label="${KIND_LABEL[kind]}">${extra.concat(list).map(option).join('')}</select>`
172
+ + `<small>${totals[kind] > list.length ? (kind === 'tag' ? 'The ' + list.length + ' newest of ' + totals[kind] + '. ' : 'The first ' + list.length + ' of ' + totals[kind] + ', the default first. ') : ''}${o.notes[kind]}</small></label>`;
173
+ }
174
+ return `<div class="nb-field"><span>Version of ${esc(o.source)}</span>${segmented(o.seg, 'Version kind', segments)}${said || o.after ? `<small>${esc(said)}${o.after || ''}</small>` : ''}</div>` + body;
175
+ };
176
+ // Which Harbor runs a Harbor recipe (C.harborPin): one of the five newest
177
+ // releases of the official package on PyPI, the newest preselected, or a repository
178
+ // - a private fork included - at a branch, tag or commit, listed with this
179
+ // machine's git credentials. Read after the page loads, never blocking it.
180
+ // Its agents are asked of it on an explicit choice (a release or a ref
181
+ // picked, or Install): the first ask builds a repository's commit
182
+ // here, later asks read what was kept. Nothing is polled.
183
+ const harbor = {releases: null, refs: {}, scans: {}, kept: {}};
184
+ const harborPanel = rec => {
185
+ const h = rec.harbor || {kind: 'release', version: '', extras: []};
186
+ const kinds = [['release', 'Release'], ['repo', 'Repository']].map(([k, t]) => `<button type="button" class="nb-seg-btn" role="radio" aria-checked="${h.kind === k}" data-harbor-kind="${k}">${t}</button>`).join('');
187
+ let body = '';
188
+ if (h.kind === 'repo') {
189
+ const url = C.harborRepoUrl(h.repo), got = url ? harbor.refs[url] : null;
190
+ body = `<label class="nb-field">Repository<input data-harbor-repo aria-label="Harbor repository" value="${esc(h.repo || '')}" autocomplete="off" spellcheck="false"><small>owner/name or a git URL</small></label>`;
191
+ if (url) {
192
+ const head = ((got && got.branches) || []).find(x => x.name === h.revision)?.commit;
193
+ body += refPicker({got, kind: h.revisionKind, revision: h.revision, source: C.repoLabel(url), seg: 'harbor-ref', kindAttr: 'harbor-ref-kind', refAttr: 'harbor-ref',
194
+ after: got && !got.loading ? ' ' + button('↻ List again', 'data-harbor-refs-fresh', 'nb-inlinebutton') : '',
195
+ commitField: `<label class="nb-field">Commit<input data-harbor-commit aria-label="Harbor commit" value="${esc(h.commit || '')}" autocomplete="off" spellcheck="false"><small>The full 40-character commit: it is the pin.</small></label>`,
196
+ notes: {branch: 'Pinned at the commit shown' + (h.commit ? ', ' + h.commit.slice(0, 12) : '') + ': the recipe keeps it, and a later push to the branch changes nothing until it is chosen again.' + (head && h.commit && head !== h.commit ? ' The branch has moved to ' + head.slice(0, 12) + ' since; choose it again to move the pin.' : ''),
197
+ tag: 'Pinned at the commit the tag names' + (h.commit ? ', ' + h.commit.slice(0, 12) : '') + '.'}});
198
+ }
199
+ } else {
200
+ const got = harbor.releases || {loading: true}, versions = got.versions || [];
201
+ if (got.loading) body = `<p class="nb-note">Reading Harbor's releases on PyPI…</p>`;
202
+ else if (!versions.length) body = `<label class="nb-field">Version<input data-harbor-version aria-label="Harbor version" value="${esc(h.version || '')}" autocomplete="off" spellcheck="false"><small>${esc(cap(got.error || 'PyPI lists no release'))}. Type a version of the harbor package on PyPI.</small></label>`;
203
+ else {
204
+ // the five newest, and the recipe's own version when it is older than them
205
+ const shown = versions.slice(0, 5), extra = !h.version || shown.some(v => v.version === h.version) ? [] : [{version: h.version, date: ''}];
206
+ body = `<label class="nb-field">Version<select data-harbor-version aria-label="Harbor version">${shown.concat(extra).map(v => `<option value="${esc(v.version)}" ${v.version === h.version ? 'selected' : ''}>${esc(v.version)}${v === versions[0] ? ' · newest' : ''}${v.date ? ' · ' + esc(v.date) : ''}</option>`).join('')}</select>`
207
+ + `<small>The five newest releases on PyPI.</small></label>`;
208
+ }
209
+ }
210
+ return `<div class="nb-harbor"><div class="nb-sectionhead"><h3>Which Harbor?</h3></div><div class="nb-field"><span>Harbor</span>${segmented('harbor-kind', 'Harbor source', kinds)}</div>${body}${harborScanLine(rec)}</div>`;
211
+ };
212
+ // The pinned Harbor: installed here once (a repository's commit built), then asked for the agents it registers.
213
+ const harborScanLine = rec => {
214
+ const pin = C.harborPin(rec);
215
+ if (!pin) return '';
216
+ const s = harbor.scans[C.harborKey(pin)] || {state: 'absent'}, ask = t => schema.local ? ' ' + button(t, 'data-harbor-scan', 'nb-inlinebutton') : '';
217
+ let html;
218
+ if (s.state === 'scanning') html = `<p class="nb-note nb-harbor-busy" role="status">${esc(pin.kind === 'repo' ? 'Building harbor from ' + C.repoLabel(pin.url) + ' at ' + pin.commit.slice(0, 12) + ' here, then asking it for its agents…' : 'Installing harbor ' + pin.version + ' and asking it for its agents…')} The first time takes a minute or two.</p>`;
219
+ else if (s.state === 'asking') html = `<p class="nb-note">Looking for what was kept of this Harbor…</p>`;
220
+ else if (s.state === 'failed') html = `<p class="nb-error">✕ ${esc(s.error || 'the scan failed')}</p><p class="nb-note">The builder offers its own agents until this Harbor answers.${ask('Try again')}</p>`;
221
+ else if (s.state === 'ready') {
222
+ const n = (s.agents || []).length;
223
+ html = `<p class="nb-note">✓ ${esc(C.harborLabel({...pin, extras: []}))} installed · ${n} agent${n === 1 ? '' : 's'} on the Agent step</p>`;
224
+ } else html = `<p class="nb-note">${esc(C.harborLabel({...pin, extras: []}))} is not installed here yet.${schema.local ? ask(pin.kind === 'repo' ? 'Build and install' : 'Install') : ' It is installed from a browser on the application host.'}</p>`;
225
+ return html;
226
+ };
227
+ // The scan for the recipe's pin, when there is one, is what the agent list is merged with.
228
+ const applyScan = () => {
229
+ const rec = r(), pin = rec.harness === 'harbor' ? C.harborPin(rec) : null, s = pin ? harbor.scans[C.harborKey(pin)] : null;
230
+ C.setScanned(s && s.state === 'ready' ? s.agents : null, pin && C.harborLabel({...pin, extras: []}));
231
+ };
232
+ const harborRedraw = () => { if (step === S.runner || step === S.agent || step === REVIEW) renderForm(); refreshPlan(); };
233
+ async function askScan(build) {
234
+ const rec = r(), pin = rec.harness === 'harbor' ? C.harborPin(rec) : null;
235
+ applyScan();
236
+ if (!pin) return;
237
+ const key = C.harborKey(pin), had = harbor.scans[key];
238
+ if (had && (['scanning', 'asking', 'ready'].includes(had.state) || !build)) return;
239
+ if (build && !schema.local) return;
240
+ harbor.scans[key] = {state: build ? 'scanning' : 'asking'};
241
+ harborRedraw();
242
+ let got;
243
+ try {
244
+ const res = build
245
+ ? await fetch('/new-run/harbor/agents', {method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRF-Token': schema.csrf}, body: JSON.stringify({harbor: pin})})
246
+ : await fetch('/new-run/harbor/agents?' + new URLSearchParams({kind: pin.kind, version: pin.version || '', repo: pin.repo || '', revisionKind: pin.revisionKind || '', revision: pin.revision || '', commit: pin.commit || ''}));
247
+ got = await res.json().catch(() => ({}));
248
+ if (!got.state) got = {state: build ? 'failed' : 'absent', error: got.error || 'HTTP ' + res.status};
249
+ if (!build && got.state === 'failed') got = {state: 'absent'};
250
+ } catch (e) { got = {state: build ? 'failed' : 'absent', error: String(e)}; }
251
+ harbor.scans[key] = got;
252
+ applyScan();
253
+ harborRedraw();
254
+ }
255
+ async function loadReleases() {
256
+ if (harbor.releases) return;
257
+ harbor.releases = {loading: true};
258
+ let got;
259
+ try { const res = await fetch('/new-run/harbor/releases'); got = await res.json(); } catch { got = {versions: [], error: 'PyPI could not be read'}; }
260
+ harbor.releases = got;
261
+ if (step === S.runner) { renderForm(); refreshPlan(); }
262
+ }
263
+ async function loadRefs(url, fresh = false) {
264
+ if (!url || (harbor.refs[url] && !fresh) || !schema.local) return;
265
+ harbor.refs[url] = {loading: true};
266
+ if (step === S.runner) renderForm();
267
+ let got;
268
+ try {
269
+ const res = await fetch('/new-run/harbor/refs?' + new URLSearchParams({repo: url, ...(fresh ? {fresh: '1'} : {})}));
270
+ got = await res.json();
271
+ } catch { got = {error: 'the branches and tags could not be read'}; }
272
+ harbor.refs[url] = got;
273
+ // a repository just named: its default branch, at its commit, to start with
274
+ const h = r().harbor;
275
+ if (h && h.kind === 'repo' && C.harborRepoUrl(h.repo) === url && !h.commit && h.revisionKind !== 'commit' && !got.error) {
276
+ const list = h.revisionKind === 'tag' ? got.tags || [] : got.branches || [], pick = list.find(x => x.name === (h.revision || got.default_branch)) || list[0];
277
+ if (pick) { h.revision = pick.name; h.commit = pick.commit; }
278
+ }
279
+ if (step === S.runner) renderForm();
280
+ refreshPlan();
281
+ askScan(false);
282
+ }
283
+ // On every render: what the recipe's Harbor needs read, each read once a page.
284
+ const harborFollow = () => {
285
+ const rec = r();
286
+ if (rec.harness !== 'harbor') return applyScan();
287
+ loadReleases();
288
+ if (rec.harbor && rec.harbor.kind === 'repo') loadRefs(C.harborRepoUrl(rec.harbor.repo));
289
+ askScan(false);
290
+ };
291
+ // A release not chosen yet becomes the newest, in front of the person: on the Runner step only.
292
+ const preselectRelease = () => {
293
+ const rec = r(), h = rec.harbor, versions = (harbor.releases && harbor.releases.versions) || [];
294
+ if (step === S.runner && rec.harness === 'harbor' && h && h.kind === 'release' && !h.version && versions.length) h.version = versions[0].version;
295
+ };
296
+ // A segmented control: the segments are buttons with role radio; one pill
297
+ // slides under the chosen one. A re-render draws a new control, so the pill
298
+ // starts where that control's last one was and slides from there.
299
+ // Harbor's own mark where Harbor fetches the tasks; a plain icon where no one's mark belongs. Square tiles, so
300
+ // a mark is never read as a second radio button.
301
+ const HARBOR_MARK = '<svg class="nb-radio-mark" aria-hidden="true"><use href="/static/brand/marks.svg#harbor"/></svg>';
302
+ const iconTile = d => `<span class="nb-radio-mark nb-radio-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="${d}"/></svg></span>`;
303
+ const SOURCE_MARK = { hub: HARBOR_MARK, registry: HARBOR_MARK,
304
+ local: iconTile('M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'),
305
+ generate: iconTile('M15 4V2M15 16v-2M8 9h2M20 9h2M17.8 11.8 19 13M15 9h.01M17.8 6.2 19 5M3 21l9-9M12.2 6.2 11 5') };
306
+ const SOURCE_HINT = { hub: 'Harbor fetches the tasks when the run starts.', registry: 'Harbor fetches the tasks when the run starts.',
307
+ local: 'Task folders already on disk. A run on a host is sent them.', generate: "Built first with the benchmark's own generator, into a folder you name." };
308
+ const segmented = (name, label, segments) => `<div class="nb-seg" role="radiogroup" aria-label="${esc(label)}" data-seg="${name}"><span class="nb-seg-thumb" aria-hidden="true"></span>${segments}</div>`;
309
+ const thumbAt = {};
310
+ const placeThumb = () => {
311
+ for (const seg of root.querySelectorAll('.nb-seg')) {
312
+ const th = seg.querySelector('.nb-seg-thumb'), on = seg.querySelector('[aria-checked="true"]'), was = thumbAt[seg.dataset.seg];
313
+ if (!th || !on) continue;
314
+ const to = {left: on.offsetLeft, width: on.offsetWidth};
315
+ if (was) { th.style.transition = 'none'; th.style.left = was.left + 'px'; th.style.width = was.width + 'px'; th.getBoundingClientRect(); th.style.transition = ''; }
316
+ th.style.left = to.left + 'px'; th.style.width = to.width + 'px'; thumbAt[seg.dataset.seg] = to;
317
+ }
318
+ };
319
+ // The provider is one whose key (a local endpoint: its URL) is set in Settings. One is said, nothing to choose;
320
+ // several are a select of those alone; none, every provider. A recipe naming one
321
+ // whose key is not set keeps it, marked, until another is chosen.
322
+ const providerField = (rec, offered) => {
323
+ const have = C.available().filter(p => offered.some(([x]) => x === p)), current = C.recipeProvider(rec);
324
+ if (have.length === 1 && current === have[0])
325
+ return `<div class="nb-field"><span>Provider</span><span class="nb-fixed">${esc(offered.find(([p]) => p === current)[1])}</span><small>The only one set in Settings.</small></div>`;
326
+ return select('Provider', 'provider', current, !have.length ? offered
327
+ : offered.filter(([p]) => have.includes(p) || p === current).map(([p, t]) => [p, have.includes(p) ? t : t + ' · not set in Settings']));
328
+ };
329
+ // Show only a missing-provider blocker; configured credentials need no confirmation line.
330
+ const keyLine = rec => {
331
+ const p = C.recipeProvider(rec), blocked = C.providerBlocker(rec), at = name => button('Settings', `data-href="/settings#${name}"`, 'nb-inlinebutton');
332
+ if (blocked) return note('Not set in Settings', esc(blocked) + ' ' + at(C.PROVIDER_NEEDS[p] || 'MODEL_API_URL'));
333
+ return '';
334
+ };
335
+ // The Nullius standard (C.isStandard): a benchmark, then an agent or a capability among every one there is - the
336
+ // ones that have not proved the ports it needs shown greyed, with the reasons - a model and a scope. The server
337
+ // compiles the choices (POST /new-run/runner, nullius/standard/recipe.py).
338
+ // what a unit is: the benchmark's, or a setup's own when only setups run (a conversation, where the paper batches its questions)
339
+ const unitsOf = rec => { const b = C.standardBench(rec) || {}, own = (b.setups || []).filter(x => C.chosenOf(rec).includes(x.key));
340
+ return own.length && own.length === C.chosenOf(rec).length ? own[0].units : b.units || {noun: 'unit', nouns: 'units'}; };
341
+ // the first clause of a long description, for a line; the whole goes in its title
342
+ // settings as sub-tabs, one a chosen way of running that has any: [key, label, html]; the open one kept while it is there
343
+ let setTab = '';
344
+ const settingsTabs = panes => { panes = panes.filter(([, , h]) => h); if (!panes.length) return '';
345
+ const open = panes.some(([k]) => k === setTab) ? setTab : panes[0][0];
346
+ return `<div class="nb-sectionhead std-controlshead std-sethead"><h3>Settings</h3></div><nav class="nb-subtabs" aria-label="Settings">${panes.map(([k, l]) => button(esc(l), `data-set-tab="${esc(k)}" aria-pressed="${k === open}"`, 'nb-subtab')).join('')}</nav>`
347
+ + panes.map(([k, , html]) => `<div data-settings-pane="${esc(k)}"${k === open ? '' : ' hidden'}>${html}</div>`).join(''); };
348
+ // an option's key read as words: reasoning_effort -> Reasoning effort
349
+ const words = k => { const t = String(k).replace(/[_-]+/g, ' ').trim(); return t.charAt(0).toUpperCase() + t.slice(1); };
350
+ // A control's proof on a dataset: ✓ with what passed (when, in its title), ✕ with the value the last try
351
+ // reached against its bound, or not run. Its source (nullius/standard/definitions.py, SOURCES) is in its title.
352
+ const SOURCE_SAYS = {official: 'from the authors', adapter: 'from Harbor\'s adapter', nullius: 'made by Nullius'};
353
+ const bound = e => { const [k, v] = Object.entries(e || {})[0] || ['at_least', 1]; return [k === 'at_most' ? '>' : '<', v]; };
354
+ function proofOf(proven, failed, expect) {
355
+ if (proven) return {state: 'ok', text: '✓ ' + (proven.passed || '') + (proven.limit ? ' · first ' + proven.limit : ''), title: 'proven on ' + (proven.on || '?') + (proven.shard ? ', shard ' + proven.shard : '')};
356
+ if (failed && failed.value !== undefined) { const [op, v] = bound(failed.expect || expect); return {state: 'no', text: '✕ ' + failed.value + ' ' + op + ' ' + v, title: 'not proven: ' + [failed.passed, failed.on, ...(failed.problems || [])].filter(Boolean).join(' · ')}; }
357
+ if (failed) return {state: 'no', text: '✕ not proven', title: (failed.problems || []).join(' · ')};
358
+ return {state: 'none', text: 'not run'};
359
+ }
360
+ const proofSpan = p => `<span class="std-proof std-proof-${p.state}"${p.title ? ` title="${esc(p.title)}"` : ''}>${esc(p.text)}</span>`;
361
+ // A control or a check as a plain chip: its name and its proof; where the control comes from is in its title.
362
+ const controlChip = (c, proof = true) => `<span class="std-ctl" title="${esc(c.key === 'nop' ? 'no answer at all: must score nothing' : c.key === 'oracle' ? 'the reference answers: must score everything' : '')} - ${esc(SOURCE_SAYS[c.source] || c.source)}: ${esc(c.from)}"><b>${esc(c.key)}</b>`
363
+ + (proof ? proofSpan(proofOf(c.proven, c.failed, c.expect)) : '') + '</span>';
364
+ const checkChip = (name, proven, failed, says) => { const p = proofOf(proven, failed); if (p.state === 'ok') { p.title = [says, proven.passed, p.title].filter(Boolean).join(' · '); p.text = '✓'; }
365
+ return `<span class="std-ctl std-checkchip"><b>${esc(name)}</b>${proofSpan(p)}</span>`; };
366
+ // The yes to an agent running as you: asked only for the local backend, where it is no sandbox.
367
+ const consentBox = rec => `<label class="nb-field nb-consent"><span><input type="checkbox" data-std-unsandboxed ${rec.unsandboxed ? 'checked' : ''}> Run it as me, not sandboxed</span></label>`;
368
+ // The standard's Where step: one machine or several (one shard each), and the backend on them.
369
+ function standardWhere(rec) {
370
+ const here = schema.standardHere || {}, list = C.whereList(rec), H = schema.hosts || [], b = C.standardBench(rec);
371
+ const backend = rec.backend || 'local';
372
+ const dockerWhy = list.includes('local') ? here.docker : null;
373
+ const agentRun = b && b.family === 'agent' && C.standardOthers(rec).some(o => C.chosenOf(rec).includes(o.key) && !o.control);
374
+ const machine = (v, t, sub) => machineTile('std-where', v, t, sub, list.includes(v));
375
+ const how = (v, t, sub, why) => tile({attr: 'std-backend', key: v, on: backend === v && !why, disabled: !!why, why, note: why ? 'Not usable here' : '', mark: v === 'local' ? '$' : '▣', title: t, tip: sub});
376
+ const dockerOnly = Object.entries((b || {}).environments || {}).filter(([, e]) => !e.local_ok).map(([n]) => n);
377
+ return '<div class="nb-sectionhead"><h2>Where does it run?</h2></div>'
378
+ + `<div class="nb-pick-grid nb-where">${machine('local', 'This machine', 'Nullius runs it here, in runs/' + rec.name + '.')}${H.map(h => machine(h.entry, h.label, 'Over ssh: the standard\'s code at this commit is sent there, uv put there if missing; its job comes back as it runs.')).join('')}</div>`
379
+ + (H.length ? (list.some(w => w !== 'local') ? button('Test connection', 'id="nb-test-host"') + ' <span id="nb-hosttest" class="nb-note"></span>' : '') : `<p class="nb-note">Hosts are named in ${button('Settings → Run hosts', 'data-href="/settings#HOSTS"', 'nb-inlinebutton')}; this machine is the only choice until then.</p>`)
380
+ + '<div class="nb-sectionhead std-wherehead"><h3>How it runs there</h3></div>'
381
+ + `<div class="nb-pick-grid std-backends">${how('local', 'Local processes', 'Its commands run as you, not sandboxed.', '')}`
382
+ + how('docker', 'Docker', 'Sandboxed: each unit in a container whose only way out is its relay.', dockerWhy ? 'Not on this machine: ' + dockerWhy : '') + '</div>'
383
+ + (agentRun && backend === 'local' ? consentBox(rec) : '')
384
+ + (dockerOnly.length && backend === 'local' && agentRun ? `<p class="nb-note nb-error">${esc(dockerOnly.join(', '))}: ${dockerOnly.length > 1 ? 'these environments need' : 'this environment needs'} docker - on local processes their units are recorded as not run.</p>` : '')
385
+ + hostSetup(rec)
386
+ + (b ? environmentsOf(b) : '');
387
+ }
388
+ // What the chosen options of the benchmark need: an embedding model, requirements of the machine (standard.json host).
389
+ function optionNeeds(rec) {
390
+ const b = C.standardBench(rec), out = {embeddings: [], host: []};
391
+ if (!b) return out;
392
+ for (const [n, o] of Object.entries(b.options || {})) {
393
+ if (o.datasets.length && !C.datasetsOf(rec).some(id => o.datasets.includes(id))) continue;
394
+ const v = (rec.bench_options || {})[n] ?? o.default, need = (o.needs || {})[v] || {};
395
+ if (need.embeddings && !out.embeddings.includes(need.embeddings)) out.embeddings.push(need.embeddings);
396
+ for (const h of need.host || []) if (!out.host.includes(h)) out.host.push(h);
397
+ }
398
+ return out;
399
+ }
400
+ // The machines' setup for those requirements: each chosen machine's state, a check, an install on an explicit
401
+ // click (sudo -n: a machine whose sudo asks for a password is told the commands instead), the commands to copy.
402
+ const hostState = {}; // entry -> {missing, error, said}
403
+ function hostSetup(rec) {
404
+ const b = C.standardBench(rec), need = optionNeeds(rec).host;
405
+ if (!b || !need.length) return '';
406
+ const reqs = need.map(n => [n, (b.host || {})[n]]).filter(([, r]) => r);
407
+ const local = ((schema.standardHere || {}).host || {})[b.key] || {};
408
+ // what installs them; none for a machine's own hardware (a GPU), which no package puts there
409
+ const lines = reqs.flatMap(([n]) => b.host[n].install).filter((x, i, a) => a.indexOf(x) === i);
410
+ const line = w => {
411
+ const st = hostState[w] || (w === 'local' ? {missing: Object.fromEntries(need.filter(n => local[n]).map(n => [n, local[n]]))} : null);
412
+ const gone = st && st.missing ? Object.entries(st.missing).filter(([n]) => need.includes(n)) : [];
413
+ const state = !st ? '<span class="nb-tick">not checked</span>' : st.error ? `<span class="nb-tick no">${esc(st.error)}</span>`
414
+ : gone.length ? `<span class="nb-tick no">missing ${esc(gone.map(([, ps]) => ps.join(', ')).join(', '))}</span>` : '<span class="nb-tick ok">ready ✓</span>';
415
+ return `<li><b>${esc(w === 'local' ? 'This machine' : C.machineLabel(w))}</b> ${state} ${button('Check', `data-hostreq-check="${esc(w)}"`, 'nb-inlinebutton')}${lines.length && (gone.length || (st && st.error)) ? ' ' + button('Install for me', `data-hostreq-install="${esc(w)}"`, 'nb-inlinebutton') : ''}${st && st.said ? ` <small>${esc(st.said)}</small>` : ''}</li>`;
416
+ };
417
+ return `<div class="nb-sectionhead std-wherehead"><h3>Machine setup</h3><small>Needed by the search you chose, on each machine it runs on</small></div>`
418
+ + reqs.map(([n, r]) => `<p class="nb-note"><b>${esc(n)}</b>: ${esc(r.summary)}</p>`).join('')
419
+ + `<ul class="nb-hostreq">${C.whereList(rec).map(line).join('')}</ul>`
420
+ + (lines.length ? `<div class="std-code"><div class="std-code-head"><span>or run it yourself, on each machine</span><button type="button" class="std-copy" data-copy-code>Copy</button></div><pre><code>${esc(lines.join('\n'))}</code></pre></div>` : '');
421
+ }
422
+ async function hostReq(entry, what) {
423
+ const rec = r(), b = C.standardBench(rec);
424
+ hostState[entry] = {...(hostState[entry] || {}), said: what === 'install' ? 'installing…' : 'checking…', error: ''};
425
+ renderForm();
426
+ try {
427
+ const res = await fetch('/new-run/host/' + what, {method: 'POST', headers: {'X-CSRF-Token': schema.csrf},
428
+ body: new URLSearchParams({entry, benchmark: b.key, requirements: optionNeeds(rec).host.join(',')})});
429
+ const j = await res.json();
430
+ if (what === 'install' && j.ok) return hostReq(entry, 'check');
431
+ hostState[entry] = j.ok ? {missing: j.missing || {}} : {...(hostState[entry] || {}), error: j.error || ('HTTP ' + res.status), said: j.manual ? 'run the commands below by hand' : ''};
432
+ } catch (e) { hostState[entry] = {error: String(e)}; }
433
+ renderForm();
434
+ }
435
+ // A benchmark's own options (a search, a mode), for the chosen datasets they apply to, and what a value needs of this
436
+ // machine. Those an agent's or capability's run takes ('yours') on the Agent step, with the agents; those only a setup
437
+ // takes (a retriever, a top-k of the paper's pipeline) in that setup's tab, once it is chosen.
438
+ function benchOptions(rec, b, scope = 'yours') {
439
+ const local = ((schema.standardHere || {}).host || {})[b.key] || {};
440
+ const chosen = C.chosenOf(rec);
441
+ return Object.entries(b.options || {}).filter(([, o]) => !o.datasets.length || C.datasetsOf(rec).some(id => o.datasets.includes(id)))
442
+ // one that applies only under another's values (a top-k, only with a retrieval) is left out otherwise
443
+ .filter(([, o]) => Object.entries(o.when || {}).every(([k, vs]) => vs.includes((rec.bench_options || {})[k] ?? (b.options[k] || {}).default)))
444
+ .filter(([, o]) => {
445
+ const on = o.setups || ['yours'];
446
+ const shared = on.includes('yours') && on.includes('original');
447
+ if (scope === 'shared') return shared;
448
+ if (shared) return false;
449
+ return scope === 'setup' ? !on.includes('yours') && on.some(k => chosen.includes(k)) : on.includes('yours');
450
+ })
451
+ .map(([n, o]) => {
452
+ const cur = (rec.bench_options || {})[n] ?? o.default;
453
+ if (o.pattern) return `<label class="nb-field std-optselect" title="${esc(o.summary)}">${esc(o.label)}<input data-bench-opt-select="${esc(n)}" value="${esc(cur === o.default ? '' : cur)}" placeholder="${esc(n === 'temperature' && o.default === 'default' ? 'Provider default' : o.default)}" aria-label="${esc(o.label)}" pattern="${esc(o.pattern)}" autocomplete="off" spellcheck="false"></label>`;
454
+ const tileOf = v => { const need = (o.needs || {})[v] || {};
455
+ const foot = [need.embeddings ? `<span class="nb-tick" title="its embedding calls go through the run's relay, with your OpenAI key">OpenAI key</span>` : '',
456
+ ...(need.host || []).filter(h => local[h]).map(h => `<span class="nb-tick no" title="${esc(((b.host || {})[h] || {}).summary || '')}">needs ${esc(h)}</span>`),
457
+ v === o.default ? '<span class="nb-tag">default</span>' : ''].join('');
458
+ return tile({attr: 'bench-opt', key: n, data: ` data-bench-val="${esc(v)}"`, on: v === cur, title: v, mark: '', tip: (o.about || {})[v] || '', foot}); };
459
+ return `<div class="nb-sectionhead std-wherehead"><h3 title="${esc(o.summary)}">${esc(o.label)}${o.datasets.length ? ' · ' + esc(o.datasets.join(', ')) : ''}</h3></div>`
460
+ // by the data: every value with its line (or a need) - cards of one size, the line whole; plain values - one small
461
+ // card each, all one size, or a select past five of them (a line some have is their tooltip)
462
+ + (o.values.some(v => ((o.needs || {})[v] || {}).embeddings || (((o.needs || {})[v] || {}).host || []).some(h => local[h]))
463
+ ? `<div class="nb-pick-grid std-optgrid" role="radiogroup" aria-label="${esc(o.label)}">${o.values.map(tileOf).join('')}</div>`
464
+ : o.values.length > 5
465
+ ? `<label class="nb-field std-optselect"><select data-bench-opt-select="${esc(n)}" aria-label="${esc(o.label)}">${o.values.map(v => `<option value="${esc(v)}"${v === cur ? ' selected' : ''} title="${esc((o.about || {})[v] || '')}">${esc(v === 'default' ? 'Default' : v + (v === o.default ? ' (default)' : ''))}</option>`).join('')}</select></label>`
466
+ : `<div class="std-valgrid" style="--w:${Math.max(7, ...o.values.map(v => String(v).length))}ch" role="radiogroup" aria-label="${esc(o.label)}">${o.values.map(v => `<button class="nb-tile std-val" data-bench-opt="${esc(n)}" data-bench-val="${esc(v)}" aria-pressed="${v === cur}" title="${esc((o.about || {})[v] || (v === o.default ? 'default' : v))}"><strong>${esc(v)}</strong>${v === o.default ? '<small>default</small>' : ''}</button>`).join('')}</div>`);
467
+ }).join('');
468
+ }
469
+ // A benchmark's licences, kept on its own page (never in Settings): what the store holds of each, by name - never a value.
470
+ const licenceState = (b, name) => (((schema.standardHere || {}).licences || {})[b.key] || {})[name] || null;
471
+ const KIND_WORD = {value: 'a key', file: 'a licence file', server: 'a licence server'};
472
+ const licencePage = b => button(`Set it on ${esc(b.label)}'s page`, `data-href="/benchmarks/${esc(b.key)}#licences"`, 'nb-inlinebutton');
473
+ function licenceLine(b, s) {
474
+ const st = licenceState(b, s.name), to = s.to === 'agent' ? 'the agent\'s container' : 'the driver';
475
+ if (!st) return `<small class="std-secret std-secret-missing">${esc(s.name)} (${KIND_WORD[s.kind] || 'a key'}) is missing: units needing it will be recorded as not run. ${licencePage(b)}</small>`;
476
+ return `<small class="std-secret${st.expired ? ' std-secret-missing' : ''}">${esc(s.name)} ✓ set ${esc(st.on || '')}${st.expires ? (st.expired ? ' · expired ' : ' · expires ') + esc(st.expires) : ''} · ${KIND_WORD[s.kind] || 'a key'}, sent to ${to}</small>`;
477
+ }
478
+ // A benchmark's per-task environments: what each is, whether it needs docker, the licences it needs.
479
+ function environmentsOf(b) {
480
+ const envs = Object.entries(b.environments || {});
481
+ if (!envs.length) return '';
482
+ return `<div class="std-envs"><h3>Environments</h3><small>Each unit runs in one of ${esc(b.label)}'s environments.</small><ul>` + envs.map(([n, e]) =>
483
+ `<li><b class="nb-mono">${esc(n)}</b> <span class="nb-tag">${e.local_ok ? 'docker or local processes' : 'needs docker'}</span><small>${esc(e.summary)}</small>`
484
+ + (e.needs_secrets || []).map(s => licenceLine(b, s)).join('') + '</li>').join('') + '</ul></div>';
485
+ }
486
+ // The Dataset step: the licences the chosen dataset's units may need. Which environment a unit uses is the
487
+ // driver's answer at its setup, unless the dataset names one: only then is it known before the run.
488
+ function datasetLicences(b, ds) {
489
+ const envs = Object.entries(b.environments || {}).filter(([, e]) => (e.needs_secrets || []).length);
490
+ if (!ds || !envs.length) return '';
491
+ const named = ds.environment ? envs.filter(([n]) => n === ds.environment) : [];
492
+ const shown = named.length ? named : (ds.environment ? [] : envs);
493
+ if (!shown.length) return '';
494
+ const missing = shown.some(([, e]) => (e.needs_secrets || []).some(s => { const st = licenceState(b, s.name); return !st; }));
495
+ return `<div class="std-envs std-dslicences"><h3>Licences</h3><small>${named.length
496
+ ? `${esc(ds.label || ds.id)} runs its ${esc((b.units || {}).nouns || 'units')} in the environment ${esc(ds.environment)}, unless a unit's setup names another.`
497
+ : `Which environment a unit uses is known only when it is set up: these may be needed by units using the environment named.`}</small><ul>`
498
+ + shown.map(([n, e]) => `<li><b class="nb-mono">${esc(n)}</b>${named.length ? '' : ' <span class="nb-tag">may be needed</span>'}`
499
+ + (e.needs_secrets || []).map(s => licenceLine(b, s)).join('') + '</li>').join('') + '</ul>'
500
+ + (missing ? `<p class="nb-note">Units needing a missing licence will be recorded as not run - no one's result. They cannot be left out beforehand: which units need it is known only at their setup.</p>` : '')
501
+ + '</div>';
502
+ }
503
+ // The benchmark step, both ways (Harbor's catalogue, the standard's benchmarks): a search, filter chips and a grid
504
+ // of tiles, as the Benchmarks page draws them. The filter hides tiles in place (applyPick), so typing keeps focus.
505
+ const picks = {}, pickOf = () => (picks[step] ||= {q: '', cat: '', fam: ''}); // each step its own search and filters
506
+ const catOf = key => (schema.benchmarks || []).find(b => b.key === key) || {};
507
+ const tasksOf = key => { const t = schema.datasets.filter(d => d.benchmark === key && d.tasks).map(d => d.tasks);
508
+ return !t.length ? '' : t.every(n => n === t[0]) && t.length > 1 ? `${t[0]} tasks each` : `${t.reduce((a, n) => a + n, 0)} tasks`; };
509
+ const pickChip = (attr, v, label, on) => `<button type="button" class="nb-pick-chip" data-${attr}="${esc(v)}" aria-pressed="${on}">${esc(label)}</button>`;
510
+ // one tile: {attr, key, on, title, mark, cat, origin, line, meta, foot, find, fam, data (more attributes), tip (its title)}
511
+ const tile = t => `<button class="nb-tile${t.disabled ? ' nb-tile-unfit' : ''}" data-${t.attr}="${esc(t.key)}" aria-pressed="${t.on}"${t.data || ''}${t.disabled ? ` disabled aria-disabled="true" title="${esc(t.why || '')}"` : t.tip ? ` title="${esc(t.tip)}"` : ''} data-cat="${esc(t.cat || '')}" data-fam="${esc(t.fam || '')}" data-find="${esc((t.find || t.title).toLowerCase())}">`
512
+ + `<span class="nb-tile-head">${t.mark ? `<span class="nb-mark">${t.mark}</span>` : ''}<strong>${esc(t.title)}</strong><span class="nb-tile-check" aria-hidden="true">${t.on ? '✓' : ''}</span></span>`
513
+ + (t.cat || t.origin || t.fam ? `<span class="nb-tile-tags">${t.cat ? `<span class="nb-tile-cat">${esc(t.cat)}</span>` : ''}${t.origin === 'experiment' ? '<span class="nb-tile-exp">Experiment</span>' : ''}${t.famLabel ? `<span class="nb-tile-fam">${esc(t.famLabel)}</span>` : ''}</span>` : '')
514
+ + (t.line ? `<span class="nb-tile-line">${esc(t.line)}</span>` : '') + (t.note ? `<span class="nb-tile-note">${esc(t.note)}</span>` : '')
515
+ + (t.meta || t.foot ? `<span class="nb-tile-foot">${t.meta ? `<span>${esc(t.meta)}</span>` : ''}${t.foot || ''}</span>` : '') + '</button>';
516
+ // a machine to run on: this one or a host, its connection state filled in by Test connection
517
+ const machineTile = (attr, v, t, sub, on) => tile({attr, key: v, on, mark: v === 'local' ? '⌂' : '⇄', title: t, tip: sub,
518
+ foot: v !== 'local' ? `<span class="nb-state nb-hoststate" data-host-state="${esc(v)}"></span>` : ''});
519
+ const picker = (tiles, fams, noun = 'benchmark') => {
520
+ const pick = pickOf(), cats = [...new Set(tiles.map(t => t.cat).filter(Boolean))].sort();
521
+ return `<div class="nb-pick"><div class="nb-pick-bar">`
522
+ + `<label class="nb-pick-find"><svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/></svg><input type="search" data-pick-find value="${esc(pick.q)}" placeholder="Search ${noun === 'capability' ? 'capabilities' : noun + 's'}" aria-label="Search ${noun === 'capability' ? 'capabilities' : noun + 's'}" autocomplete="off"></label>`
523
+ + (cats.length > 1 ? `<div class="nb-pick-chips" role="group" aria-label="Category">${pickChip('pick-cat', '', 'All', !pick.cat)}${cats.map(c => pickChip('pick-cat', c, c, pick.cat === c)).join('')}</div>` : '')
524
+ + (fams ? `<div class="nb-pick-chips" role="group" aria-label="Runs">${pickChip('pick-fam', '', 'Any', !pick.fam)}${fams.map(([v, l]) => pickChip('pick-fam', v, l, pick.fam === v)).join('')}</div>` : '')
525
+ + `</div><div class="nb-pick-grid">${tiles.map(tile).join('')}</div><p class="nb-pick-none" hidden>No ${noun} matches.</p></div>`;
526
+ };
527
+ function applyPick() {
528
+ const box = root.querySelector('.nb-pick'), pick = pickOf(); if (!box) return;
529
+ const words = pick.q.toLowerCase().split(/\s+/).filter(Boolean);
530
+ let shown = 0;
531
+ box.querySelectorAll('.nb-tile').forEach(t => {
532
+ const on = t.getAttribute('aria-pressed') === 'true';
533
+ const fits = (!pick.cat || t.dataset.cat === pick.cat) && (!pick.fam || t.dataset.fam === pick.fam) && words.every(w => t.dataset.find.includes(w));
534
+ t.hidden = !fits && !on; if (!t.hidden) shown++;
535
+ });
536
+ box.querySelectorAll('[data-pick-cat]').forEach(b => b.setAttribute('aria-pressed', b.dataset.pickCat === pick.cat));
537
+ box.querySelectorAll('[data-pick-fam]').forEach(b => b.setAttribute('aria-pressed', b.dataset.pickFam === pick.fam));
538
+ box.querySelector('.nb-pick-none').hidden = shown > 0;
539
+ }
540
+ function modelChoiceCards(rec) {
541
+ const hasPaper = C.paperOffered(rec), on = rec.model_choice || 'any';
542
+ return `<div class="nb-pick-grid std-optgrid" role="group" aria-label="Model choice">${tile({attr:'model-choice',key:'paper',title:'Like the paper',on:on==='paper',disabled:!hasPaper,why:'Paper models unavailable',note:hasPaper?'':'Paper models unavailable'})}`
543
+ + (C.leaderboard(rec) ? tile({attr:'model-choice',key:'leaderboard',title:'Like the leaderboard',on:on==='leaderboard'}) : '')
544
+ + `${tile({attr:'model-choice',key:'any',title:'Any of your choice',on:on==='any'})}</div>`;
545
+ }
546
+ function standardForm(rec) {
547
+ const st = C.standard(), b = C.standardBench(rec);
548
+ if (!b) return note('Choose a benchmark first', button('Benchmark step', `data-step="${S.benchmark}"`, 'nb-inlinebutton'));
549
+ const u = unitsOf(rec);
550
+ if (step === S.dataset)
551
+ return `<div class="nb-sectionhead"><h2>Which datasets?</h2></div>`
552
+ + `<div class="nb-pick-grid std-optgrid">${b.datasets.map(x => tile({attr: 'std-dataset', key: x.id, on: C.datasetsOf(rec).includes(x.id), title: x.label,
553
+ tip: x.summary || '', meta: x.units ? x.units + ' ' + u.nouns : '',
554
+ foot: (x.controls || []).map(c => controlChip(c)).join('') + checkChip('stable', (x.proofs || {}).units, (x.failed || {}).units, 'the same ids twice, each unique')
555
+ + ((b.controls || []).some(c => c.key === 'oracle') ? checkChip('no leak', (x.proofs || {}).leak, (x.failed || {}).leak, 'nothing of the reference shows before the run') : '')})).join('')}</div>`
556
+ + b.datasets.filter(x => C.datasetsOf(rec).includes(x.id)).map(x => datasetLicences(b, x)).join('');
557
+ if (step === S.agent) {
558
+ const agent = b.family === 'agent', all = C.standardOthers(rec), others = all.filter(o => !o.control && !o.setup);
559
+ const setups = all.filter(o => o.setup), controls = all.filter(o => o.control);
560
+ const ds = b.datasets.find(x => C.datasetsOf(rec).includes(x.id)) || b.datasets[0];
561
+ // an agent or a capability as a tile: its name, a skill it failed or a fidelity that differs as a tick; one that has not
562
+ // proved a port the benchmark needs greyed, the ports it lacks named (the reasons whole in its title)
563
+ const tileOf = o => {
564
+ const ok = !o.why.length, lacks = b.needs.filter(p => !o.proven[p]);
565
+ const skills = b.needs.flatMap(p => o.proven[p] ? o.proven[p].skills || [] : []).filter(s => !s.shown).map(s => `<span class="nb-tick no" title="${esc(s.says)}">${esc(s.id)} ✗</span>`).join('');
566
+ const fid = o.fidelity && o.fidelity.verdict !== 'same' ? `<span class="nb-tick ${o.fidelity.verdict === 'same' ? 'ok' : 'no'}" title="ACP ${o.fidelity.verdict === 'same' ? 'gives its model the same requests as its own CLI' : 'differs from its own CLI: ' + esc(o.fidelity.verdict)}">ACP ${o.fidelity.verdict === 'same' ? '= CLI ✓' : '≠ CLI'}</span>` : '';
567
+ const older = b.needs.some(p => o.proven[p] && o.proven[p].older) ? '<span class="nb-tick no" title="proven on an older kit: worth running again">older kit</span>' : '';
568
+ return {attr: 'std-other', key: o.key, on: ok && C.chosenOf(rec).includes(o.key), disabled: !ok, why: o.why.join('; '), title: o.label + (o.version && !o.label.includes(o.version) ? ' ' + o.version : ''),
569
+ mark: agent ? agentMark(o.key, o.label) : esc(o.label[0]), cat: o.protocol, fam: ok ? 'fit' : 'unfit', tip: o.summary, note: ok ? '' : 'Lacks ' + (lacks.map(p => p.replace(/^[^.]+\./, '').replace(/\/v\d+$/, '').replace(/[-_]/g, ' ')).join(', ') || 'a port it needs'),
570
+ foot: fid + skills + older, find: [o.label, o.key, o.version, o.protocol, o.summary].join(' ')};
571
+ };
572
+ // each chosen agent's options, at its vendor's default unless changed: {ref: {name: word}}
573
+ const chosen = others.filter(o => C.chosenOf(rec).includes(o.key) && !o.why.length);
574
+ const optionsOf = o => { const mine = (rec.options || {})[o.key] || {}, opts = Object.entries(o.options || {});
575
+ return !opts.length ? '' : `<div class="std-options">` + opts.map(([n, x]) => {
576
+ const cur = mine[n] ?? x.default;
577
+ return x.values
578
+ ? `<label class="nb-field std-optselect" title="${esc(x.summary)}">${esc(words(n))}<select data-std-option="${esc(n)}" data-std-option-of="${esc(o.key)}">${x.values.map(v => `<option value="${esc(v)}" ${v === cur ? 'selected' : ''}>${esc(v === 'default' ? 'Default' : v + (v === x.default ? ' (its default)' : ''))}</option>`).join('')}</select></label>`
579
+ : `<label class="nb-field std-optselect" title="${esc(x.summary)}">${esc(words(n))}<input data-std-option="${esc(n)}" data-std-option-of="${esc(o.key)}" value="${esc(mine[n] ?? '')}" placeholder="${esc(x.default ?? '')} (its default)" spellcheck="false" autocomplete="off"></label>`;
580
+ }).join('') + '</div>'; };
581
+ // the chosen ones' settings, one tab each: the benchmark's own way, the benchmark's settings every agent takes, each one's own
582
+ const yoursWord = agent ? 'agent' : (b.kind || 'capability');
583
+ // the benchmark's own way of running it (its reference, as published) is one more choice beside yours
584
+ const setupTile = o => ({attr: 'std-other', key: o.key, on: C.chosenOf(rec).includes(o.key), mark: o.key === 'original' ? '◆' : '◇',
585
+ title: o.reference_agent || (agent ? 'No agent · Original' : 'Original ' + (b.kind || 'capability')), cat: 'reference', fam: 'fit', tip: o.summary, find: [b.label, o.label, 'reference'].join(' ')});
586
+ const ds2 = ds;
587
+ const controlTile = o => { const c = ((ds2 || {}).controls || []).find(x => x.key === o.key) || {...o, from: o.summary};
588
+ return tile({attr: 'std-other', key: o.key, on: C.chosenOf(rec).includes(o.key), mark: o.key === 'nop' ? '∅' : '≡', title: o.label,
589
+ tip: o.summary + (b.judged ? ' The judge still runs.' : ''), foot: controlChip(c)}); };
590
+ const setupsNamed = ls => ls.filter(l => !ls.some(m => m !== l && l.startsWith(m))).join(' and ');
591
+ const onSetups = setups.filter(o => C.chosenOf(rec).includes(o.key));
592
+ return `<div class="nb-sectionhead"><h2>Who runs it?</h2></div>`
593
+ + picker([...setups.map(setupTile), ...others.map(tileOf)], [['fit', 'Can run it'], ['unfit', 'Cannot']], agent ? 'agent' : 'capability')
594
+ + (others.length || setups.length ? '' : note('None yet', 'Bring one in with the /import-standard skill, or by hand: docs/standard.md.'))
595
+ + settingsTabs([
596
+ ...(chosen.length || onSetups.length ? [['shared', 'Every ' + yoursWord, benchOptions(rec, b, 'shared')]] : []),
597
+ ...(onSetups.length ? [['setup', b.label + ' · ' + setupsNamed(onSetups.map(o => o.label)), benchOptions(rec, b, 'setup')]] : []),
598
+ ...(chosen.length ? [['yours', agent ? 'Selected agents' : 'Selected capabilities', benchOptions(rec, b)]] : []),
599
+ ...chosen.map(o => [o.key, o.label, optionsOf(o)])])
600
+ + (controls.length ? `<div class="nb-sectionhead std-controlshead std-sethead"><h3>Checks</h3></div><div class="nb-pick-grid">${controls.map(controlTile).join('')}</div>` : '')
601
+ ;
602
+ }
603
+ if (step === S.model && C.standardKeyless(rec))
604
+ return `<div class="nb-sectionhead"><h2>Choose the model.</h2></div>` + note('No model needed', 'A control calls no model, and its run is handed no key at all.');
605
+ if (step === S.model) {
606
+ const lb = rec.model_choice === 'leaderboard' ? C.leaderboard(rec) : null, paper = rec.model_choice === 'paper' || !!lb;
607
+ return `<div class="nb-sectionhead"><h2>Choose the model.</h2></div>` + modelChoiceCards(rec)
608
+ + providerField(rec, C.PROVIDERS.map(p => [p, C.PROVIDER_LABEL[p]]))
609
+ + field('Model', 'model', rec.model, {list:'nb-models', placeholder:paper && C.paperListed(rec) ? 'Choose a paper model' : 'Search or enter a model ID'})
610
+ // the benchmark's other models: the user simulator its conversations need, the judge that grades - each its official one
611
+ // unless named; like the paper, the official one; like the leaderboard, its own and the options it fixes
612
+ + (b.simulator ? (paper ? fixed('Model for the user simulator', lb && lb.simulator || b.simulator, lb && lb.simulator ? 'leaderboard' : 'official') : field('Model for the user simulator', 'simulator_model', rec.simulator_model || '', {list: 'nb-models', placeholder: b.simulator + ' (official)',
613
+ hint: 'Plays the user in every conversation. Empty: ' + esc(b.label) + "'s official one; another compares only with runs that used it."})) : '')
614
+ + (b.judge ? (paper ? fixed('Model for the judge', lb && lb.judge || b.judge, lb && lb.judge ? 'leaderboard' : 'official') : field('Model for the judge', 'judge_model', rec.judge_model || '', {list: 'nb-models', placeholder: b.judge + ' (official)',
615
+ hint: 'Grades the answers. Empty: ' + esc(b.label) + "'s official judge; another compares only with runs that used it."})) : '')
616
+ + (lb ? Object.entries(lb.bench_options || {}).map(([k, v]) => fixed((b.options[k] || {}).label || k, v, 'leaderboard')).join('') : '')
617
+ + keyLine(rec);
618
+ }
619
+ if (step === S.limits) {
620
+ const sets = b.datasets.filter(x => C.datasetsOf(rec).includes(x.id)), per = sets.length > 1 ? ' of each dataset' : '';
621
+ // empty is the default, shown as the placeholder: every unit, one at a time, one attempt
622
+ const ds = sets.length === 1 ? sets[0] : null, all = ds && ds.units ? String(ds.units) : 'all';
623
+ return '<div class="nb-sectionhead"><h2>Scope</h2></div><div class="nb-two">'
624
+ + field('Number of ' + u.nouns, 'limit', rec.limit, {type: 'number', min: 1, placeholder: all, hint: 'The first ones' + per + ', in its order.'})
625
+ + field('Concurrent ' + u.nouns, 'concurrency', rec.concurrency, {type: 'number', min: 1, max: 32, placeholder: '1'}) + '</div>'
626
+ + field('Attempts per ' + u.noun, 'repeat', rec.repeat || '', {type: 'number', min: 1, max: 32, placeholder: '1'});
627
+ }
628
+ return '';
629
+ }
630
+ function compileRunner() {
631
+ const rec = r(), key = JSON.stringify(rec);
632
+ if (key === runnerKey) return;
633
+ runnerKey = key;
634
+ clearTimeout(runnerTimer);
635
+ runnerTimer = setTimeout(async () => {
636
+ let out;
637
+ try {
638
+ const res = await fetch('/new-run/runner', {method: 'POST', headers: {'Content-Type': 'application/json', 'X-CSRF-Token': schema.csrf}, body: JSON.stringify({recipe: rec})});
639
+ out = await res.json();
640
+ } catch (e) { out = {errors: [{step: REVIEW, message: 'The recipe could not be compiled here: ' + e}], notes: [], review: []}; }
641
+ if (key !== runnerKey) return;
642
+ runnerOut = out;
643
+ if (step === REVIEW) renderForm();
644
+ refreshPlan();
645
+ }, 120);
646
+ }
647
+ const field = (label,key,value,{type='text',hint='',list='',min='',max='',placeholder=''}={}) => `<label class="nb-field">${label}<input aria-label="${esc(label)}" data-field="${key}" type="${type}" value="${esc(value)}" ${list?`list="${list}"`:''} ${min!==''?`min="${min}"`:''} ${max!==''?`max="${max}"`:''} ${type==='number'?'step="any"':''} placeholder="${esc(placeholder)}" autocomplete="off" spellcheck="false">${hint?`<small>${hint}</small>`:''}</label>`;
648
+ const select = (label,key,value,options) => `<label class="nb-field">${label}<select data-field="${key}">${options.map(([v,t])=>`<option value="${esc(v)}" ${v===value?'selected':''}>${esc(t)}</option>`).join('')}</select></label>`;
649
+ const fixed = (label,value,whose='official') => `<label class="nb-field ui-field-row"><span class="ui-field-copy">${esc(label)}</span><span class="nb-fixed">${esc(value)} (${whose})</span></label>`;
650
+ const note = (title,text) => `<div class="nb-notice"><strong>${title}</strong>${text}</div>`;
651
+
652
+ function customRows(agent = '') {
653
+ // '' lists the shared entries (every agent, and the other owners); an id lists that agent's own --ak.
654
+ const rows = r().custom.map((p, i) => [p, i]).filter(([p]) => agent ? p.scope === 'agent' && p.agent === agent : !p.agent);
655
+ return (agent ? '' : `<p class="nb-note">Name the parameter, choose its owner and type. An agent parameter here reaches every selected agent; one agent's own go on its tab. Unknown options remain marked for review.</p>`) + rows.map(([p,i])=>`<div class="nb-custom"><div class="nb-rowhead"><span class="nb-badge">Custom override${p.agent ? ' · ' + esc(agentLabel(p.agent)) : ''}</span>${button('Remove',`data-remove="${i}"`,'nb-remove')}</div><div class="nb-two"><label class="nb-field">Owner<select data-custom="${i}:scope" ${p.agent?'disabled':''}>${C.scopes().map(([v,t])=>`<option value="${v}" ${p.scope===v?'selected':''}>${t}</option>`).join('')}</select></label><label class="nb-field">Parameter name<input data-custom="${i}:key" value="${esc(p.key)}" placeholder="custom_setting" spellcheck="false"></label></div><div class="nb-two"><label class="nb-field">Type<select data-custom="${i}:type">${[['string','Text'],['number','Number'],['boolean','Boolean'],['JSON','JSON'],['flag','Flag without value']].map(([v,t])=>`<option value="${v}" ${p.type===v?'selected':''}>${t}</option>`).join('')}</select></label><label class="nb-field">Value<input data-custom="${i}:value" value="${esc(p.value)}" placeholder="${p.type==='boolean'?'true or false':'Value'}" ${p.type==='flag'?'disabled':''} spellcheck="false"></label></div></div>`).join('')+button('+ Add parameter',`id="nb-add" data-add-agent="${esc(agent)}"`);
656
+ }
657
+ // The parameters the launch vocabulary files under one agent (launch.py: a parameter's group is the agent it is sent to).
658
+ function parameterRows(agent) {
659
+ return C.parameters().filter(p=>p.group===agent).map(p=>{
660
+ const value=r().params[p.key];
661
+ const control=field(p.label,'param:'+p.key,value,{type:['number','integer'].includes(p.type)?'number':'text',min:p.min??'',max:p.max??'',hint:p.help,placeholder:p.default==null?'Use agent default':''});
662
+ return `<div class="nb-parameter">${control}</div>`;
663
+ }).join('');
664
+ }
665
+ function categoryContent(category) {
666
+ const rec=r(); let html='';
667
+ if(category==='Model'){
668
+ html='<div class="nb-categoryhead"><h3>Model</h3><p>The model as the provider lists it, e.g. <code>gpt-5.2</code>.</p></div>';
669
+ if(C.needsCredentials(rec)){
670
+ const controlOnly=!rec.agents.some(id=>!schema.agents.find(a=>a.id===id)?.control);
671
+ const tau3=rec.benchmark==='tau3-bench';
672
+ html+=providerField(rec,C.PROVIDERS.map(p=>[p,C.PROVIDER_LABEL[p]]));
673
+ if(tau3&&controlOnly)html+=`<div class="nb-two">${field('Model · customer','userModel',rec.userModel,{list:'nb-models',placeholder:'vendor/model, as the provider lists it'})}${field('Model · evaluator','evalModel',rec.evalModel,{list:'nb-models',placeholder:'same as the customer'})}</div>`;
674
+ else if(tau3)html+=field('Model · agent','model',rec.model,{list:'nb-models',placeholder:'vendor/model, as the provider lists it'})+`<div class="nb-two">${field('Model · customer','userModel',rec.userModel,{list:'nb-models',placeholder:'same as the agent'})}${field('Model · evaluator','evalModel',rec.evalModel,{list:'nb-models',placeholder:'same as the customer'})}</div>`;
675
+ else html+=field('Model','model',rec.model,{list:'nb-models',placeholder:'vendor/model, as the provider lists it'});
676
+ html+=keyLine(rec);
677
+ }else html+=note('No model connection needed','The selected control agents and benchmark do not require one.');
678
+ }
679
+ if(category==='Extra parameters')html='<div class="nb-categoryhead"><h3>Extra parameters</h3><p>Pass additional typed options to the agent, to Harbor, to the environment or to the verifier.</p></div>';
680
+ return html;
681
+ }
682
+ function renderForm() {
683
+ preselectRelease();
684
+ root.dataset.modelProvider = C.recipeProvider(r());
685
+ root.dataset.paperModels = JSON.stringify(r().model_choice === 'paper' && C.paperListed(r()) ? ((C.paperModels(r()).sent || {})[r().provider] || {}) : null);
686
+ root.dataset.standardModel = String(C.isStandard(r()));
687
+ const rec=r(), d=C.dataset(rec);
688
+ let html='';
689
+ const own=C.isStandard(rec);
690
+ if(step===S.benchmark)html=benchmarkStep(rec);
691
+ else if(step===S.runner)html=runnerStep(rec);
692
+ else if(own&&step<S.where)html=standardForm(rec);
693
+ if(!own&&step===S.dataset){
694
+ html='<div class="nb-sectionhead"><h2>Where do the tasks come from?</h2></div>';
695
+ if(C.sources(rec).length>1)html+=`<div class="nb-pick-grid" role="radiogroup" aria-label="Where the tasks come from">${C.sources(rec).map(([v,t])=>tile({attr:'harbor-source',key:v,on:v===rec.source,mark:SOURCE_MARK[v],title:t,tip:SOURCE_HINT[v]||''})).join('')}</div>`;
696
+ if(rec.source==='generate'){
697
+ const g=d?.generate||{};
698
+ html+=field(g.checkout||'Generator checkout','generatorRoot',rec.generatorRoot,{list:'nb-paths',placeholder:g.example||''})+field('Generated task destination','path',rec.path,{list:'nb-paths',placeholder:(d?.local)||''});
699
+ }else if(rec.source==='local')html+=field('Task folder','path',rec.path,{list:'nb-paths',placeholder:(d?.local)||'../harbor-datasets/my-tasks'});
700
+ else html+=field('Dataset reference','dataset',rec.dataset,{list:'nb-registry',placeholder:'name@version or org/name'})+button('Refresh Harbor catalogue','id="nb-refresh"');
701
+ }
702
+ if(!own&&step===S.agent){
703
+ const tabs=[['select','Select agents'],['common','Common settings'],...rec.agents.map(id=>[id,agentLabel(id,rec)]),['extra','Extra parameters'+(rec.custom.filter(p=>!p.agent).length?' · '+rec.custom.filter(p=>!p.agent).length:'')]];
704
+ if(!tabs.some(([t])=>t===tab))tab='select';
705
+ html=`<div class="nb-sectionhead"><h2>Configure your agents.</h2></div>`;
706
+ html+=`<nav class="nb-subtabs nb-categories" aria-label="Agent tabs">${tabs.map(([t,label])=>button(esc(label),`data-tab="${esc(t)}" aria-pressed="${tab===t}"`,'nb-subtab')).join('')}</nav>`;
707
+ if(tab==='select')html+=agentCards(rec);
708
+ else if(tab==='common')html+=commonSettings(rec);
709
+ else if(tab==='extra')html+=categoryContent('Extra parameters')+`<div id="nb-parameters">${customRows()}</div>`;
710
+ else html+=agentTab(rec,tab);
711
+ }
712
+ if(!own&&step===S.model){
713
+ html='<div class="nb-sectionhead"><h2>Choose your model.</h2></div>'+modelChoiceCards(rec)+categoryContent('Model');
714
+ }
715
+ if(!own&&step===S.limits){
716
+ html='<div class="nb-sectionhead"><h2>Scope & execution</h2></div>';
717
+ const allTasks=(()=>{const ds=schema.datasets.find(d=>d.benchmark===rec.benchmark);return ds&&ds.tasks?'all '+ds.tasks:'all';})();
718
+ html+=`<div class="nb-two">${field('Number of tasks','tasks',rec.tasks,{type:'number',min:1,placeholder:allTasks,hint:'Empty: '+allTasks+'.'})}${field('Concurrent trials','concurrency',rec.concurrency,{type:'number',min:1})}</div>`;
719
+ html+=`<div class="nb-two">${field('Retries per trial','retries',rec.retries,{type:'number',min:0,hint:'Run a trial again after an error, up to this many times.'})}${field('Include task names · optional glob','include',rec.include,{placeholder:'django*'})}</div>`
720
+ +harborExecutableFields(rec);
721
+ html+=field('Output directory','output',rec.output,{});
722
+ }
723
+ if(step===S.where&&C.isStandard(rec))html=standardWhere(rec);
724
+ else if(step===S.where){
725
+ // Where the recipe runs when Run is pressed: this machine, or a host from Settings.
726
+ const H=schema.hosts||[], rec2=r(), on=v=>rec2.where===v;
727
+ html='<div class="nb-sectionhead"><h2>Where does it run?</h2></div>'
728
+ +`<div class="nb-pick-grid nb-where">${[['local','This machine','Nullius runs the script here, in runs/'+esc(rec2.name)+'.'],...H.map(h=>[h.entry,h.label,own?'Over ssh. uv and a snapshot of this runner are put there if missing; results and proofs come back as it runs.':'Over ssh. The tasks are sent there, and a repository’s Harbor as the wheels built here; uv runs the Harbor the recipe pins; the job comes back as it runs.'])].map(([v,t,sub])=>machineTile('where',v,t,sub,on(v))).join('')}</div>`
729
+ +(H.length?button('Test connection','id="nb-test-host"'+(rec2.where==='local'?' disabled':''))+' <span id="nb-hosttest" class="nb-note"></span>':note('No host yet','Hosts are named in Settings → Run hosts; this machine is the only choice until then.'));
730
+ }
731
+ if(step===REVIEW){
732
+ // the standard's review names Where itself (recipe.py): its machines and its backend
733
+ const rows=own?[...((runnerOut&&runnerOut.review)||[]),...(C.isStandard(rec)?[]:[[S.where,'Where',C.whereLabel(rec)]])]:C.review(rec);
734
+ html='<div class="nb-sectionhead"><h2>Review the experiment.</h2></div>'+rows.map(([i,t,v])=>`<div class="nb-reviewrow"><div><small>${t}</small><strong>${esc(v)}</strong></div>${button('Edit',`data-step="${i}"`)}</div>`).join('')+'<div id="nb-errors" class="nb-errorlist" hidden></div><div id="nb-reviewnotes"></div>'+(schema.local?'<section id="nb-prereq" class="nb-prereq" aria-live="polite"></section>':'')+runPanel();
735
+ }
736
+ $('#nb-form').innerHTML=html+'<p id="nb-localerrors" class="nb-error" role="status"></p>';applyPick();
737
+ if(step===REVIEW&&schema.local){drawPrereq();checkPrereq();}
738
+ $('#nb-back').hidden=step===S.benchmark;
739
+ $('#nb-next').textContent=step===REVIEW?'Export recipe JSON':stepName(steps[nextShown(step,1)],nextShown(step,1))+' →';
740
+ placeThumb();
741
+ }
742
+ function refreshPlan() {
743
+ const rec=r();
744
+ if(C.isStandard(rec)){
745
+ compileRunner();
746
+ const out=runnerOut||{errors:[],notes:[]};
747
+ compiled={errors:out.errors||[],notes:out.notes||[]};
748
+ }else{compiled=C.compile(rec);}
749
+ $('#nb-localerrors').textContent=compiled.errors.filter(e=>e.step===step).map(e=>e.message).join(' ');
750
+ const errors=$('#nb-errors');
751
+ if(errors){
752
+ errors.hidden=!compiled.errors.length;
753
+ errors.innerHTML=compiled.errors.map(e=>button(esc(e.message),`data-step="${e.step}" ${e.step===S.agent&&!C.isStandard(rec)?`data-config-group="${esc(e.group||'')}"`:""}`,'')).join('');
754
+ }
755
+ $('#nb-next').disabled=step===REVIEW&&compiled.errors.length>0;
756
+ if($('#nb-reviewnotes'))$('#nb-reviewnotes').innerHTML=compiled.notes.map(t=>`<p class="nb-note">${esc(t)}</p>`).join('');
757
+ saveDraft();
758
+ }
759
+ // The underline under the active step is one element that slides to it. It follows the nav's own width, not
760
+ // the window's: the Getting started panel narrows the page without a resize event.
761
+ const moveUnderline=()=>{const nav=$('.nb-steps'),on=nav.querySelector('.nb-step[aria-pressed=true]'),bar=nav.querySelector('.nb-stepbar');if(!on||!bar)return;bar.style.left=on.offsetLeft+'px';bar.style.width=on.offsetWidth+'px';};
762
+ new ResizeObserver(moveUnderline).observe($('.nb-steps'));
763
+ function stepName(t,i){const rec=r(),b=C.isStandard(rec)&&C.standardBench(rec);
764
+ return i===S.agent&&b?(b.family==='agent'?'Agent':(b.kind||'capability').replace(/^./,c=>c.toUpperCase())):t;}
765
+ // Next and Back skip a step no recipe shows (Setup, its number kept for saved drafts)
766
+ const nextShown=(i,dir)=>{let j=i+dir;while(j>S.benchmark&&j<REVIEW&&!C.stepShown(r(),j))j+=dir;return Math.max(S.benchmark,Math.min(REVIEW,j));};
767
+ function render(focus=false) {
768
+ const nav=$('.nb-steps');
769
+ if(!nav.querySelector('.nb-stepbar'))nav.innerHTML='<span class="nb-stepbar" aria-hidden="true"></span>';
770
+ nav.querySelectorAll('.nb-step').forEach(b=>b.remove());
771
+ if(!C.stepShown(r(),step))step=nextShown(step,step>S.setup?-1:1);
772
+ const shown=steps.map((t,i)=>i).filter(i=>C.stepShown(r(),i));
773
+ nav.insertAdjacentHTML('afterbegin',shown.map((i,n)=>button(`<em>0${n+1}</em>${stepName(steps[i],i)}`,`data-step="${i}" aria-pressed="${step===i}"`,'nb-step')).join(''));
774
+ renderForm();refreshPlan();moveUnderline();saveDraft();harborFollow();
775
+ if(focus){const heading=$('#nb-form h2');if(heading){heading.tabIndex=-1;heading.focus({preventScroll:true});heading.scrollIntoView({block:'nearest'});}}
776
+ }
777
+ function readSaved(){
778
+ try{
779
+ const ok=list=>Array.isArray(list)?list.filter(x=>x&&x.recipe&&typeof x.id==='string'):[];
780
+ let list=ok(JSON.parse(localStorage.getItem(storageKey)||'[]'));
781
+ // Merge workspace-scoped recipe lists into this browser's shared list.
782
+ for(const k of Object.keys(localStorage))if(k.startsWith(storageKey+'.')){const old=ok(JSON.parse(localStorage.getItem(k)||'[]'));list=list.concat(old.filter(o=>!list.some(x=>x.id===o.id)));localStorage.removeItem(k);localStorage.setItem(storageKey,JSON.stringify(list));}
783
+ return list;
784
+ }catch{return [];}
785
+ }
786
+ const workspaceLabel = () => schema.workspace && schema.workspace!=='unassigned' ? 'Workspace: '+schema.workspace : 'Personal recipes · no workspace selected';
787
+ const recipeSlug = title => title.normalize('NFKD').replace(/[\u0300-\u036f]/g,'').toLowerCase().replace(/[^a-z0-9._-]+/g,'-').replace(/^[^a-z0-9]+|[-.]+$/g,'').slice(0,72) || 'recipe';
788
+ function savedState(recipe){try{return C.validate(C.fromJSON(recipe)).errors.length?' · Draft':'';}catch{return ' · Needs review';}}
789
+ function renderSaved(){
790
+ const saved=readSaved();
791
+ $('#nb-saved-list').innerHTML='<p class="nb-note">'+esc(workspaceLabel())+' · stored in this browser</p>'+(saved.length?saved.map(s=>`<div class="nb-savedrow"><span><strong>${esc(s.recipe.title||s.recipe.name)}</strong><small>${esc(s.recipe.harness)} · ${esc(s.updated)}${savedState(s.recipe)}</small></span><div>${button('Load',`data-load="${esc(s.id)}"`)} ${button('Delete',`data-delete="${esc(s.id)}"`)}</div></div>`).join(''):'<p class="nb-note">Save your first recipe to find it here.</p>');
792
+ }
793
+ function download(text,filename,type){const url=URL.createObjectURL(new Blob([text],{type})),link=document.createElement('a');link.href=url;link.download=filename;link.click();setTimeout(()=>URL.revokeObjectURL(url),1000);}
794
+ function updateSavePreview(){
795
+ const title=$('#nb-recipe-title').value.trim(),name=recipeSlug(title),existing=readSaved().find(s=>s.id===(r().harness||'harbor')+':'+name);
796
+ $('#nb-recipe-title').setCustomValidity(title?'':'Enter a name for this recipe.');
797
+ $('#nb-save-submit').textContent=existing?'Update recipe':'Save recipe';
798
+ $('#nb-save-message').textContent=existing?'A recipe with this name exists. Saving will update it.':workspaceLabel()+'. You can save unfinished recipes as drafts.';
799
+ }
800
+ function openSave(){
801
+ $('#nb-recipe-title').value=r().title||r().name.replace(/-/g,' ');
802
+ updateSavePreview();$('#nb-save-dialog').showModal();$('#nb-recipe-title').focus();$('#nb-recipe-title').select();
803
+ }
804
+ function save(){
805
+ const title=$('#nb-recipe-title').value.trim();if(!title){$('#nb-recipe-title').focus();return;}
806
+ const candidate={...C.copy(r()),title,name:recipeSlug(title)};
807
+ if(C.validate(candidate).errors.some(e=>/environment variable name|credentials; do not put/.test(e.message))){$('#nb-save-message').textContent='Use environment variable names for credentials before saving. Their values belong in your shell.';return;}
808
+ try{
809
+ const list=readSaved(),id=(candidate.harness||'harbor')+':'+candidate.name; // the harness prefix earlier versions wrote; a runner's key for its recipes
810
+ const saved={id,updated:new Date().toLocaleDateString(),recipe:candidate};
811
+ localStorage.setItem(storageKey,JSON.stringify([saved,...list.filter(s=>s.id!==id)].slice(0,50)));
812
+ recipe=candidate;$('#nb-save-dialog').close();render();renderSaved();
813
+ status('Saved “'+title+'”'+(compiled.errors.length?' as a draft.':'.'));
814
+ }catch{ $('#nb-save-message').textContent='Browser storage is unavailable. Close this dialog and export the recipe as JSON instead.'; }
815
+ }
816
+ root.addEventListener('submit',event=>{if(event.target.id==='nb-save-form'){event.preventDefault();save();}});
817
+ // Running from here: the runner script is posted with the target; the page follows the log until the run ends.
818
+ const runPanel=()=>{
819
+ const rec=r(), where=C.whereList(rec).map(w=>w==='local'?'this machine':C.machineLabel(w)).join(' + ');
820
+ if(!schema.local)return note('Run from the application host','Runs start from a browser on the machine Nullius runs on.');
821
+ // A provider not set in Settings: Run waits and says why.
822
+ const blocked=C.providerBlocker(rec);
823
+ if(blocked)return `<div class="nb-runbox" id="nb-runbox"><div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run" disabled data-held title="'+esc(blocked)+'"','nb-button nb-primary')}</div><p class="nb-note nb-error">${esc(blocked)} ${button('Model step','data-step="'+S.model+'"','nb-inlinebutton')} · ${button('Settings','data-href="/settings#'+(C.PROVIDER_NEEDS[C.recipeProvider(rec)]||'MODEL_API_URL')+'"','nb-inlinebutton')}</p></div>`;
824
+ if(C.isStandard(rec)){
825
+ const out=runnerOut||{errors:[{message:'Compiling the recipe…'}]}, noun=C.isStandard(rec)?unitsOf(rec).noun:'item';
826
+ return `<div class="nb-runbox" id="nb-runbox">${(out.errors||[]).length?out.errors.map(e=>`<p class="nb-note">${esc(e.message)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"','nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(out.confirm?`<p class="nb-note nb-nolimit">No ${esc(noun)} limit: ${esc(out.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
827
+ }
828
+ const plan=C.runnable(rec);
829
+ return `<div class="nb-runbox" id="nb-runbox">${plan.errors.length?plan.errors.map(e=>`<p class="nb-note">${esc(e)}</p>`).join(''):`<div class="nb-runline">${button('▶ Run on '+esc(where),'id="nb-run"'+(C.validate(rec).errors.length?' disabled data-held':''),'nb-button nb-primary')}<span id="nb-runstate" class="nb-note"></span></div>`+(plan.confirm?`<p class="nb-note nb-nolimit">No task limit: ${esc(plan.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.</p>`:'')}</div>`;
830
+ };
831
+ // Prerequisites: what the recipe needs of each machine it runs on, asked when Review opens and on Check again
832
+ // (/new-run/prerequisites, nullius/prerequisites.py). Run waits until every row is ready; the run asks again as it starts.
833
+ let prereq={sig:'',busy:false,out:null};
834
+ const prereqSig=rec=>JSON.stringify({...rec,name:'',title:''});
835
+ async function checkPrereq(force=false){
836
+ const rec=r(), sig=prereqSig(rec);
837
+ if(!force&&prereq.sig===sig)return;
838
+ prereq={sig,busy:true,out:null};drawPrereq();
839
+ let out;
840
+ try{const res=await fetch('/new-run/prerequisites',{method:'POST',headers:{'Content-Type':'application/json','X-CSRF-Token':schema.csrf},body:JSON.stringify({recipe:rec})});
841
+ out=res.ok?await res.json():{machines:[],ready:false,errors:['The machines could not be checked: HTTP '+res.status]};}
842
+ catch(e){out={machines:[],ready:false,errors:['The machines could not be checked: '+e]};}
843
+ if(prereq.sig!==sig)return; // the recipe changed while it was asked: the newer check stands
844
+ prereq={sig,busy:false,out};drawPrereq();
845
+ }
846
+ function drawPrereq(){
847
+ const el=$('#nb-prereq'); if(!el)return;
848
+ const out=prereq.out, mark={ok:'✓',missing:'✕',install:'↓'};
849
+ const rows=m=>m.rows.map(x=>`<li class="nb-prereq-${x.state}"><span class="nb-prereq-mark" aria-hidden="true">${mark[x.state]}</span><span><strong>${esc(x.label)}</strong>${x.detail?` <small>${esc(x.detail)}</small>`:''}${x.state==='missing'&&x.install.length?`<code class="nb-prereq-fix">${x.install.map(esc).join('<br>')}</code>`:''}</span></li>`).join('');
850
+ const head=prereq.busy?'<span class="nb-note">checking…</span>':out&&out.ready?'<span class="nb-note nb-ok">Ready</span>':out?'<span class="nb-note nb-error">Missing something: Run waits</span>':'';
851
+ el.innerHTML=`<div class="nb-prereq-head"><h3>Prerequisites</h3>${head}${button('Check again','id="nb-prereq-again"'+(prereq.busy?' disabled':''),'nb-inlinebutton')}</div>`
852
+ +(out?(out.errors||[]).map(e=>`<p class="nb-note nb-error">${esc(e)}</p>`).join('')
853
+ +out.machines.map(m=>`<div class="nb-prereq-machine">${out.machines.length>1?`<small>${esc(m.label)}</small>`:''}<ul>${rows(m)}</ul></div>`).join(''):'');
854
+ const b=$('#nb-run'); if(b&&!b.hasAttribute('data-held'))b.disabled=!(out&&out.ready&&!prereq.busy);
855
+ }
856
+ const say=(t,cls='')=>{const el=$('#nb-runstate');if(el){el.textContent=t;el.className='nb-note '+cls;}};
857
+ async function testHost(entry){
858
+ if(entry==='local')return;
859
+ const out=$('#nb-hosttest'), st=root.querySelector(`[data-host-state="${CSS.escape(entry)}"]`);
860
+ out.textContent='testing…';
861
+ try{const res=await fetch('/settings/hosts/test',{method:'POST',headers:{'X-CSRF-Token':schema.csrf},body:new URLSearchParams({entry})});const j=await res.json();
862
+ // only what can stop this recipe there: docker, for a Harbor run or the standard's docker backend (uv is installed when missing)
863
+ const rec=r(),needsDocker=rec.harness==='harbor'||(C.isStandard(rec)&&rec.backend==='docker'),dockerOk=j.docker&&j.docker_ok;
864
+ out.textContent=!j.ok?'✕ '+(j.error||('HTTP '+res.status)):needsDocker&&!dockerOk?'✓ Connected · ✕ docker '+(j.docker?'not usable by this user':'missing')+': this run needs it':'✓ Connected';
865
+ if(st){st.textContent=j.ok?'connected':'unreachable';st.className='nb-state nb-hoststate '+(j.ok?'':'warn');}
866
+ if(j.ok&&C.isStandard(r())&&optionNeeds(r()).host.length)hostReq(entry,'check'); // and what the chosen search needs of it
867
+ }catch(e){out.textContent='✕ '+e;}
868
+ }
869
+ async function startRun(){
870
+ // Each Run is a new job: the recipe's name plus the second, so a second press does not resume the first (Harbor refuses a job directory whose config differs and resumes one whose config matches).
871
+ const now=new Date(), pad=n=>String(n).padStart(2,'0'), stamp=pad(now.getMonth()+1)+pad(now.getDate())+'-'+pad(now.getHours())+pad(now.getMinutes())+pad(now.getSeconds());
872
+ const rec={...r(),name:r().name+'-'+stamp};
873
+ let body, ask;
874
+ if(C.providerBlocker(rec))return; // the button is disabled then; /run refuses the same
875
+ if(!(prereq.out&&prereq.out.ready))return; // Run waits for the prerequisites; the run asks again as it starts
876
+ // A runner of its own sends its choices only: /run compiles them again from the definition file.
877
+ if(C.isStandard(rec)){body={name:rec.name,where:rec.where,recipe:rec};ask=runnerOut&&runnerOut.confirm;}
878
+ else{const plan=C.runnable(rec); if(plan.errors.length)return; body={name:rec.name,script:plan.script,where:rec.where,tasks:plan.tasks,model:plan.model,jobs:plan.jobs,parts:plan.parts,recipe:rec}; ask=plan.confirm;} // the recipe travels with the run
879
+ if(ask&&!window.confirm(ask)){say('Not started.');return;} // the whole dataset is a decision, not a default
880
+ const b=$('#nb-run'); b.disabled=true; say('starting…');
881
+ try{
882
+ const res=await fetch('/run',{method:'POST',headers:{'Content-Type':'application/json','X-CSRF-Token':schema.csrf},body:JSON.stringify(body)});
883
+ const j=await res.json(); if(!j.ok){say('✕ '+(j.error||('HTTP '+res.status)),'nb-error');b.disabled=false;return;}
884
+ location.href=j.open||'/runs?view=launch'; // the Runs page, by launch: this launch's runs, each opening its job
885
+ }catch(e){say('✕ '+e,'nb-error');b.disabled=false;}
886
+ }
887
+ // The button says it is reading until the answer's toast replaces it: a toast alone would be gone before a slow answer.
888
+ async function refreshRegistry(){const b=$('#nb-refresh'),label=b.textContent;b.disabled=true;b.classList.add('nb-loading');b.setAttribute('aria-busy','true');b.textContent='Reading Harbor’s catalogue…';status('');try{const response=await fetch('/new-run/registry');if(!response.ok)throw Error();const data=await response.json(),names=[...new Set([...schema.datasets.map(d=>d.registry),...schema.seenRegistry,...(data.names||[]),...(data.hub||[])])].filter(Boolean);$('#nb-registry').innerHTML=names.map(n=>`<option value="${esc(n)}"></option>`).join('');status(names.length+' catalogue references available. You can also enter one directly.');}catch{status('Catalogue refresh unavailable. Existing references and custom entry still work.');}finally{if(b.isConnected){b.disabled=false;b.classList.remove('nb-loading');b.removeAttribute('aria-busy');b.textContent=label;}}}
889
+ function completeDirectory(value){clearTimeout(pendingDirs);const seq=++dirsSequence;pendingDirs=setTimeout(async()=>{try{const response=await fetch('/new-run/dirs?path='+encodeURIComponent(value));if(!response.ok)return;const data=await response.json();if(seq===dirsSequence)$('#nb-paths').innerHTML=(data.dirs||[]).map(p=>`<option value="${esc(p)}"></option>`).join('');}catch{}},180);}
890
+ // Saved recipes: a dialog that a click on its backdrop closes, as Esc does (a button's click, by key too, is not one)
891
+ $('#nb-saved').addEventListener('click',event=>{if(event.target!==event.currentTarget)return;const box=event.currentTarget.getBoundingClientRect();if(event.clientX<box.left||event.clientX>box.right||event.clientY<box.top||event.clientY>box.bottom)event.currentTarget.close();});
892
+ root.addEventListener('click',async event=>{
893
+ const b=event.target.closest('button');if(!b)return;const d=b.dataset;
894
+ if(d.modelChoice){C.setModelChoice(r(),d.modelChoice);renderForm();refreshPlan();return;}
895
+ if(d.benchOpt!==undefined){const rec=r(),o=((C.standardBench(rec)||{}).options||{})[d.benchOpt]||{};rec.bench_options={...(rec.bench_options||{})};if(d.benchVal===o.default)delete rec.bench_options[d.benchOpt];else rec.bench_options[d.benchOpt]=d.benchVal;renderForm();refreshPlan();return;}
896
+ if(d.hostreqCheck!==undefined){hostReq(d.hostreqCheck,'check');return;}
897
+ if(d.hostreqInstall!==undefined){hostReq(d.hostreqInstall,'install');return;}
898
+ if(d.copyCode!==undefined){const t=b.closest('.std-code').querySelector('code').textContent;try{await navigator.clipboard.writeText(t);b.textContent='Copied';}catch{b.textContent='Select it';}setTimeout(()=>{b.textContent='Copy';},1500);return;}
899
+ if(d.pickCat!==undefined){pickOf().cat=d.pickCat;applyPick();return;}
900
+ if(d.pickFam!==undefined){pickOf().fam=d.pickFam;applyPick();return;}
901
+ if(d.agent){const on=r().agents.includes(d.agent);r().agents=on?r().agents.filter(id=>id!==d.agent):[...r().agents,d.agent];renderForm();refreshPlan();return;}
902
+ else if(d.href){location.href=d.href;return;}
903
+ else if(b.id==='nb-add-custom-agent'){r().customAgents.push('');r().agents.push('custom-'+(r().customAgents.length-1));renderForm();refreshPlan();root.querySelector('[data-custom-agent="'+(r().customAgents.length-1)+'"]')?.focus();return;}
904
+ else if(d.removeCustomAgent!==undefined){const i=Number(d.removeCustomAgent),rec=r(),kept=rec.agents.filter(id=>id.startsWith('custom-')&&id!=='custom-'+i).map(id=>Number(id.slice(7)));rec.customAgents.splice(i,1);rec.agents=rec.agents.filter(id=>!id.startsWith('custom-')).concat(kept.map(k=>'custom-'+(k>i?k-1:k)));renderForm();refreshPlan();return;}
905
+ // The Harbor panel (Runner step): a release or a repository, a ref of it, installed and asked for its agents.
906
+ else if(d.harborKind){const rec=r(),h=rec.harbor||{},k=d.harborKind;if(k===h.kind)return;harbor.kept[h.kind]=h;rec.harbor=harbor.kept[k]||(k==='repo'?{kind:'repo',repo:'',revisionKind:'branch',revision:'',commit:'',extras:[]}:{kind:'release',version:'',extras:[]});applyScan();renderForm();refreshPlan();harborFollow();root.querySelector(k==='repo'?'[data-harbor-repo]':'[data-harbor-kind="release"]')?.focus();return;}
907
+ else if(d.harborRefKind){const h=r().harbor,got=harbor.refs[C.harborRepoUrl(h.repo)]||{},k=d.harborRefKind;if(k===h.revisionKind)return;h.revisionKind=k;const pick=k==='branch'?(got.branches||[]).find(x=>x.name===got.default_branch)||(got.branches||[])[0]:k==='tag'?(got.tags||[])[0]:null;if(pick){h.revision=pick.name;h.commit=pick.commit;}else if(k==='commit')h.revision=h.commit;else{h.revision='';h.commit='';}applyScan();renderForm();refreshPlan();askScan(false);root.querySelector(`[data-harbor-ref-kind="${k}"]`)?.focus();return;}
908
+ else if(d.harborScan!==undefined){askScan(true);return;}
909
+ else if(d.harborRefsFresh!==undefined){loadRefs(C.harborRepoUrl(r().harbor.repo),true);return;}
910
+ else if(d.runner){toRunner(d.runner,C.benchKey(r()));}
911
+ else if(d.bench){toRunner(C.runnerFor(r(),d.bench),d.bench);}
912
+ else if(d.stdBench){C.setStandardBenchmark(r(),d.stdBench);}
913
+ else if(d.stdDataset){const rec=r(),c=C.datasetsOf(rec);rec.datasets=c.includes(d.stdDataset)?(c.length>1?c.filter(k=>k!==d.stdDataset):c):[...c,d.stdDataset];delete rec.dataset;}
914
+ else if(d.stdOther){const rec=r(),c=C.chosenOf(rec);rec.others=c.includes(d.stdOther)?c.filter(k=>k!==d.stdOther):[...c,d.stdOther];delete rec.other;if(rec.options)delete rec.options[d.stdOther];}
915
+ // the standard's machines: each a toggle, one at least; several split the run into shards
916
+ else if(d.stdWhere){const rec=r(),list=C.whereList(rec),on=list.includes(d.stdWhere),next=on?list.filter(w=>w!==d.stdWhere):[...list,d.stdWhere];if(!next.length)return;rec.where=next.length>1?next:next[0];}
917
+ else if(d.stdBackend){r().backend=d.stdBackend;}
918
+ else if(d.harborSource){r().source=d.harborSource;}
919
+ else if(d.benchmark){C.setBenchmark(r(),d.benchmark);}
920
+ else if(d.where!==undefined){r().where=d.where;}
921
+ else if(b.id==='nb-test-host'){for(const w of C.whereList(r()))if(w!=='local')await testHost(w);return;}
922
+ else if(b.id==='nb-run'){await startRun();return;}
923
+ else if(b.id==='nb-prereq-again'){checkPrereq(true);return;}
924
+ else if(d.step!==undefined){step=Number(d.step);if(d.configGroup!==undefined){const g=d.configGroup;tab=g==='Extra parameters'?'extra':r().agents.includes(g)?g:'select';}}
925
+ else if(d.tab){tab=d.tab;step=S.agent;}
926
+ else if(d.setTab!==undefined){
927
+ setTab=d.setTab;
928
+ // Keep the surrounding form and focused tab in place when changing settings.
929
+ root.querySelectorAll('[data-set-tab]').forEach(t=>t.setAttribute('aria-pressed',t.dataset.setTab===setTab));
930
+ root.querySelectorAll('[data-settings-pane]').forEach(p=>{p.hidden=p.dataset.settingsPane!==setTab;});
931
+ return;
932
+ }
933
+ else if(d.remove!==undefined)r().custom.splice(Number(d.remove),1);
934
+ else if(d.load){try{const saved=readSaved().find(s=>s.id===d.load);recipe=C.fromJSON(saved.recipe);step=REVIEW;$('#nb-saved').close();status('Loaded “'+(recipe.title||recipe.name)+'”.');}catch(error){status('This saved recipe cannot be read: '+error.message);return;}}
935
+ else if(d.delete){try{localStorage.setItem(storageKey,JSON.stringify(readSaved().filter(s=>s.id!==d.delete)));renderSaved();status('Saved recipe deleted.');}catch{status('Browser storage is unavailable.');}return;}
936
+ else if(b.id==='nb-add'){r().custom.push({scope:'agent',key:'',type:'string',value:'',...(d.addAgent?{agent:d.addAgent}:{})});}
937
+ else if(b.id==='nb-next'){if(step===REVIEW){if(!compiled.errors.length)download(JSON.stringify(r(),null,2)+'\n',r().name+'.json','application/json');return;}step=nextShown(step,1);}
938
+ else if(b.id==='nb-back')step=nextShown(step,-1);
939
+ else if(b.id==='nb-save'){openSave();return;}
940
+ else if(b.id==='nb-startover'){try{localStorage.removeItem(draftKey);}catch{}recipe=C.prefill({});runnerOut=null;runnerKey='';step=S.benchmark;tab='select';status('Started over from the defaults.');}
941
+ else if(b.id==='nb-save-cancel'){$('#nb-save-dialog').close();return;}
942
+ else if(b.id==='nb-saved-toggle'){renderSaved();$('#nb-saved').showModal();return;}
943
+ else if(b.id==='nb-saved-close'){$('#nb-saved').close();return;}
944
+ else if(b.id==='nb-import'){$('#nb-import-file').click();return;}
945
+ else if(b.id==='nb-refresh'){await refreshRegistry();return;}
946
+ else return;
947
+ render(d.step!==undefined||['nb-next','nb-back'].includes(b.id));
948
+ });
949
+ root.addEventListener('input',event=>{
950
+ const el=event.target,d=el.dataset,rec=r();
951
+ if(el.id==='nb-recipe-title'){updateSavePreview();return;}
952
+ if(d.pickFind!==undefined){pickOf().q=el.value;applyPick();return;}
953
+ if(d.providerModel && rec.modelFormat !== 'provider-id'){for(const key of ['model','userModel','evalModel'])if(typeof rec[key]==='string')rec[key]=C.bareModel(rec[key]);rec.modelFormat='provider-id';}
954
+ if(d.field){const p=d.field.startsWith('param:')?C.parameters().find(p=>p.key===d.field.slice(6)):null;
955
+ const value=el.type==='number'?(el.value===''?'':Number(el.value)):el.value;
956
+ if(p)rec.params[p.key]=p.type==='optional-boolean'?(value==='__default__'?null:value==='true'):value;
957
+ else if(d.field==='timeoutMultiplier'){rec.timeoutMultiplier=value;rec.agentMinutes='';}
958
+ else if(d.field.startsWith('adapterPath:')){const id=d.field.slice(12);if(String(value).trim())rec.adapterPaths[id]=String(value).trim();else delete rec.adapterPaths[id];}
959
+ else if(!d.providerModel&&['model','userModel','evalModel'].includes(d.field)&&/^(openrouter|openai)\//.test(String(value))){rec.provider=C.providerOf(rec,value);rec[d.field]=C.bareModel(value);
960
+ renderForm();refreshPlan();const f=root.querySelector(`[data-field="${d.field}"]`);if(f){f.focus();f.setSelectionRange(f.value.length,f.value.length);}return;} // the provider the prefix named, and whether it is set
961
+ else{rec[d.field]=value;if(d.field==='provider'){renderForm();refreshPlan();return;}} // whether it is set in Settings, and the names a runner's models are sent as, follow the provider
962
+ if(el.list?.id==='nb-paths')completeDirectory(el.value);
963
+ }else if(d.minutes){C.setPhaseMinutes(rec,d.minutes,el.value===''?'':Number(el.value));const row=el.closest('tr');if(row){const m=row.querySelector('.nb-mono');const t=C.effectiveTimeouts(rec);const p=t&&t.phases.find(x=>x.key===d.minutes);if(m&&p)m.textContent='×'+p.multiplier;}refreshPlan();return;}
964
+ else if(d.customAgent!==undefined){rec.customAgents[Number(d.customAgent)]=el.value;refreshPlan();return;}
965
+ else if(d.harborRepo!==undefined){const h=rec.harbor;h.repo=el.value;h.commit='';h.revision='';applyScan();}
966
+ else if(d.harborCommit!==undefined){rec.harbor.commit=rec.harbor.revision=el.value.trim();applyScan();}
967
+ else if(d.harborVersion!==undefined){rec.harbor.version=el.value.trim();applyScan();}
968
+ else if(d.custom){const [i,k]=d.custom.split(':');rec.custom[i][k]=el.value;}
969
+ else return;
970
+ refreshPlan();
971
+ });
972
+ root.addEventListener('change',async event=>{
973
+ const el=event.target,d=el.dataset;
974
+ if(d.custom?.endsWith(':type')){$('#nb-parameters').innerHTML=customRows(!['common','extra'].includes(tab)?tab:'');}
975
+ else if(d.stdUnsandboxed!==undefined){r().unsandboxed=el.checked;refreshPlan();}
976
+ else if(d.stdVersion!==undefined){C.setStandardBenchmark(r(),el.value);render();}
977
+ // an option at its default is left out: the recipe names only what was changed
978
+ else if(d.benchOptSelect!==undefined){const rec=r(),o=((C.standardBench(rec)||{}).options||{})[d.benchOptSelect]||{};rec.bench_options={...(rec.bench_options||{})};const v=el.value.trim();if(!v||v===o.default)delete rec.bench_options[d.benchOptSelect];else rec.bench_options[d.benchOptSelect]=v;refreshPlan();}
979
+ else if(d.stdOption!==undefined){const rec=r(),k=d.stdOptionOf,o=(C.standardOthers(rec).find(x=>x.key===k)||{}).options||{},x=o[d.stdOption]||{},v=el.value.trim();rec.options={...(rec.options||{})};const mine={...(rec.options[k]||{})};if(v===''||v===x.default)delete mine[d.stdOption];else mine[d.stdOption]=v;if(Object.keys(mine).length)rec.options[k]=mine;else delete rec.options[k];refreshPlan();}
980
+ // a release or a ref picked, a commit typed: an explicit choice, so its agents are asked for (built here the first time)
981
+ else if(d.harborVersion!==undefined){r().harbor.version=el.value.trim();applyScan();renderForm();refreshPlan();askScan(true);}
982
+ else if(d.harborRef!==undefined){const h=r().harbor,got=harbor.refs[C.harborRepoUrl(h.repo)]||{},x=((h.revisionKind==='tag'?got.tags:got.branches)||[]).find(y=>y.name===el.value);h.revision=el.value;h.commit=x?x.commit:'';applyScan();renderForm();refreshPlan();askScan(true);}
983
+ else if(d.harborCommit!==undefined){const h=r().harbor;h.commit=h.revision=el.value.trim();applyScan();renderForm();refreshPlan();if(C.harborPin(r()))askScan(true);}
984
+ else if(d.harborRepo!==undefined){renderForm();refreshPlan();loadRefs(C.harborRepoUrl(r().harbor.repo));}
985
+ else if(d.harborChoice!==undefined){const rec=r(),v=el.value;if(v==='path')rec.harborDev='';else if(v==='dev')rec.harborDev=rec.harborDev||'~/harbor-dev/.venv/bin/harbor';renderForm();refreshPlan();if(v==='dev')root.querySelector('[data-field="harborDev"]')?.select();}
986
+ else if(el.id==='nb-import-file'){
987
+ const file=el.files[0];if(!file)return;
988
+ try{if(file.size>100000)throw Error('Recipe file is too large.');recipe=C.fromJSON(await file.text());step=REVIEW;render(true);status('Imported “'+(recipe.title||recipe.name)+'”. Review the recipe before copying commands.');}catch(error){status('Could not import recipe: '+error.message);}el.value='';
989
+ }
990
+ });
991
+ { const dl=document.getElementById('nb-models'); if(dl){const seen=new Set(); for(const o of [...dl.options]){const v=C.bareModel(o.value); if(!v||seen.has(v)){o.remove();continue;} seen.add(v); o.value=v;}} }
992
+ render();
993
+ status(opened||'');
994
+ })();