nullius-eval 0.1.0__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 (291) hide show
  1. _nullius_app/.env.example +55 -0
  2. _nullius_app/app.py +96 -0
  3. _nullius_app/requirements.txt +1 -0
  4. _nullius_app/static/brand/README.md +20 -0
  5. _nullius_app/static/brand/docker.svg +1 -0
  6. _nullius_app/static/brand/favicon.svg +1 -0
  7. _nullius_app/static/brand/huggingface.svg +37 -0
  8. _nullius_app/static/brand/mark-dark.svg +1 -0
  9. _nullius_app/static/brand/marks.svg +34 -0
  10. _nullius_app/static/brand/tokens.json +51 -0
  11. _nullius_app/static/brand/typesafe.png +0 -0
  12. _nullius_app/static/brand/wordmark-dark.svg +1 -0
  13. _nullius_app/static/builder/command-builder-core.js +763 -0
  14. _nullius_app/static/builder/command-builder.css +248 -0
  15. _nullius_app/static/builder/command-builder.js +997 -0
  16. _nullius_app/static/builder/model-picker.js +113 -0
  17. _nullius_app/static/catalogue/add.js +46 -0
  18. _nullius_app/static/catalogue/agents/README.md +19 -0
  19. _nullius_app/static/catalogue/agents/goose.svg +1 -0
  20. _nullius_app/static/catalogue/agents/jiuwenswarm.svg +33 -0
  21. _nullius_app/static/catalogue/agents/marks.json +8 -0
  22. _nullius_app/static/catalogue/agents/mini-swe-agent.svg +7 -0
  23. _nullius_app/static/catalogue/agents/opencode.svg +7 -0
  24. _nullius_app/static/catalogue/catalogue.css +436 -0
  25. _nullius_app/static/catalogue/catalogue.js +87 -0
  26. _nullius_app/static/catalogue/marks.svg +29 -0
  27. _nullius_app/static/catalogue/new.js +78 -0
  28. _nullius_app/static/catalogue/versions.js +27 -0
  29. _nullius_app/static/compare/comparison.css +117 -0
  30. _nullius_app/static/controls.js +117 -0
  31. _nullius_app/static/disclosures.js +70 -0
  32. _nullius_app/static/fonts/0569c822cab6c510.ttf +0 -0
  33. _nullius_app/static/fonts/DMSans-Medium.woff2 +0 -0
  34. _nullius_app/static/fonts/DMSans-Regular.woff2 +0 -0
  35. _nullius_app/static/fonts/IBMPlexMono-Medium.woff2 +0 -0
  36. _nullius_app/static/fonts/IBMPlexMono-Regular.woff2 +0 -0
  37. _nullius_app/static/fonts/InstrumentSerif-Italic.woff2 +0 -0
  38. _nullius_app/static/fonts/InstrumentSerif-Regular.woff2 +0 -0
  39. _nullius_app/static/fonts/README.md +11 -0
  40. _nullius_app/static/fonts/c1e7453ea26a1d1e.ttf +0 -0
  41. _nullius_app/static/fonts/dmsans-OFL.txt +93 -0
  42. _nullius_app/static/fonts/ibmplexmono-OFL.txt +93 -0
  43. _nullius_app/static/fonts/instrumentserif-OFL.txt +93 -0
  44. _nullius_app/static/fonts.css +49 -0
  45. _nullius_app/static/notifications.js +49 -0
  46. _nullius_app/static/onboarding.css +78 -0
  47. _nullius_app/static/onboarding.js +158 -0
  48. _nullius_app/static/runs/board.css +358 -0
  49. _nullius_app/static/runs/board.js +127 -0
  50. _nullius_app/static/runs/launches.css +88 -0
  51. _nullius_app/static/runs/live-board.css +186 -0
  52. _nullius_app/static/runs/live-board.js +394 -0
  53. _nullius_app/static/runs/path-suggestions.js +119 -0
  54. _nullius_app/static/runs/start.css +38 -0
  55. _nullius_app/static/settings/autosave.js +162 -0
  56. _nullius_app/static/settings/custom-keys.js +100 -0
  57. _nullius_app/static/settings/data-providers.js +88 -0
  58. _nullius_app/static/settings/judges.js +61 -0
  59. _nullius_app/static/settings/modal.css +32 -0
  60. _nullius_app/static/settings/modal.js +91 -0
  61. _nullius_app/static/settings/navigation.js +55 -0
  62. _nullius_app/static/settings/prices.js +68 -0
  63. _nullius_app/static/settings/providers.js +134 -0
  64. _nullius_app/static/settings/sandbox.js +20 -0
  65. _nullius_app/static/settings/settings.css +288 -0
  66. _nullius_app/static/style.css +1752 -0
  67. _nullius_app/static/traces/conversation.css +49 -0
  68. _nullius_app/static/traces/conversation.js +215 -0
  69. _nullius_app/templates/agents/entry.html +145 -0
  70. _nullius_app/templates/agents/kits.html +55 -0
  71. _nullius_app/templates/agents/standard.html +58 -0
  72. _nullius_app/templates/base.html +479 -0
  73. _nullius_app/templates/builder/new_run.html +55 -0
  74. _nullius_app/templates/catalogue/add_dialog.html +32 -0
  75. _nullius_app/templates/catalogue/benchmark.html +270 -0
  76. _nullius_app/templates/catalogue/benchmarks.html +91 -0
  77. _nullius_app/templates/catalogue/new.html +141 -0
  78. _nullius_app/templates/catalogue/use_bundle.html +11 -0
  79. _nullius_app/templates/compare/_detail.html +37 -0
  80. _nullius_app/templates/compare/compare.html +298 -0
  81. _nullius_app/templates/compare/compare_picker.html +51 -0
  82. _nullius_app/templates/compare/compare_task.html +329 -0
  83. _nullius_app/templates/runs/_execution.html +131 -0
  84. _nullius_app/templates/runs/_runtime.html +5 -0
  85. _nullius_app/templates/runs/ascii-mark.html +485 -0
  86. _nullius_app/templates/runs/feasibility.html +127 -0
  87. _nullius_app/templates/runs/index.html +609 -0
  88. _nullius_app/templates/runs/job.html +460 -0
  89. _nullius_app/templates/runs/preparing.html +14 -0
  90. _nullius_app/templates/runs/reconcile.html +124 -0
  91. _nullius_app/templates/runs/setup.html +272 -0
  92. _nullius_app/templates/runs/start.html +51 -0
  93. _nullius_app/templates/settings/custom_keys.html +82 -0
  94. _nullius_app/templates/settings/data_providers.html +27 -0
  95. _nullius_app/templates/settings/settings.html +564 -0
  96. _nullius_app/templates/traces/_charts.html +165 -0
  97. _nullius_app/templates/traces/_conversation.html +37 -0
  98. _nullius_app/templates/traces/_judgement.html +72 -0
  99. _nullius_app/templates/traces/artifact.html +15 -0
  100. _nullius_app/templates/traces/trial.html +838 -0
  101. _nullius_app/templates/workspaces/workspaces.html +54 -0
  102. _nullius_app/web/__init__.py +1 -0
  103. _nullius_app/web/agents.py +230 -0
  104. _nullius_app/web/builder.py +406 -0
  105. _nullius_app/web/catalogue.py +370 -0
  106. _nullius_app/web/compare.py +489 -0
  107. _nullius_app/web/core.py +17 -0
  108. _nullius_app/web/execute.py +223 -0
  109. _nullius_app/web/feasibility.py +60 -0
  110. _nullius_app/web/filters.py +231 -0
  111. _nullius_app/web/judge.py +623 -0
  112. _nullius_app/web/judge_tasks.py +33 -0
  113. _nullius_app/web/onboarding.py +20 -0
  114. _nullius_app/web/reconcile.py +47 -0
  115. _nullius_app/web/runs.py +464 -0
  116. _nullius_app/web/settings.py +324 -0
  117. _nullius_app/web/shared.py +507 -0
  118. _nullius_app/web/traces.py +306 -0
  119. _nullius_app/web/workspaces.py +84 -0
  120. nullius/__init__.py +32 -0
  121. nullius/__main__.py +5 -0
  122. nullius/catalogue/__init__.py +0 -0
  123. nullius/catalogue/agents/codex/agent.json +222 -0
  124. nullius/catalogue/agents/codex/config.toml +25 -0
  125. nullius/catalogue/agents/goose/agent.json +131 -0
  126. nullius/catalogue/agents/goose/config.yaml +20 -0
  127. nullius/catalogue/agents/jiuwenswarm/agent.json +197 -0
  128. nullius/catalogue/agents/jiuwenswarm/agent.py +355 -0
  129. nullius/catalogue/agents/mini-swe-agent/agent.json +68 -0
  130. nullius/catalogue/agents/mini-swe-agent/run.py +37 -0
  131. nullius/catalogue/agents/opencode/agent.json +135 -0
  132. nullius/catalogue/agents/opencode/opencode.json +32 -0
  133. nullius/catalogue/agents/reference/agent.json +89 -0
  134. nullius/catalogue/agents/reference/agent.py +209 -0
  135. nullius/catalogue/agents/terminus-2/agent.json +64 -0
  136. nullius/catalogue/agents/terminus-2/run.py +139 -0
  137. nullius/catalogue/benchmarks/gaia/benchmark.json +72 -0
  138. nullius/catalogue/benchmarks/gaia/data-source.json +29 -0
  139. nullius/catalogue/benchmarks/gaia/driver.py +188 -0
  140. nullius/catalogue/benchmarks/gaia/env/data.Dockerfile +1 -0
  141. nullius/catalogue/benchmarks/gaia/standard.json +278 -0
  142. nullius/catalogue/benchmarks/gaia/upstream-settings.json +275 -0
  143. nullius/catalogue/benchmarks/gsm8k/benchmark.json +34 -0
  144. nullius/catalogue/benchmarks/gsm8k/driver.py +101 -0
  145. nullius/catalogue/benchmarks/gsm8k/standard.json +124 -0
  146. nullius/catalogue/benchmarks/gsm8k/upstream-settings.json +86 -0
  147. nullius/catalogue/benchmarks/humaneval/benchmark.json +36 -0
  148. nullius/catalogue/benchmarks/humaneval/driver.py +243 -0
  149. nullius/catalogue/benchmarks/humaneval/standard.json +115 -0
  150. nullius/catalogue/benchmarks/humaneval/upstream-settings.json +72 -0
  151. nullius/catalogue/benchmarks/locomo/benchmark.json +43 -0
  152. nullius/catalogue/benchmarks/locomo/driver.py +270 -0
  153. nullius/catalogue/benchmarks/locomo/standard.json +265 -0
  154. nullius/catalogue/benchmarks/locomo/upstream-settings.json +112 -0
  155. nullius/catalogue/benchmarks/longmemeval/benchmark.json +65 -0
  156. nullius/catalogue/benchmarks/longmemeval/driver.py +379 -0
  157. nullius/catalogue/benchmarks/longmemeval/standard.json +733 -0
  158. nullius/catalogue/benchmarks/longmemeval/upstream-settings.json +76 -0
  159. nullius/catalogue/benchmarks/swe-bench-verified/benchmark.json +87 -0
  160. nullius/catalogue/benchmarks/swe-bench-verified/driver.py +116 -0
  161. nullius/catalogue/benchmarks/swe-bench-verified/images.json +502 -0
  162. nullius/catalogue/benchmarks/swe-bench-verified/standard.json +108 -0
  163. nullius/catalogue/benchmarks/swe-bench-verified/upstream-settings.json +32 -0
  164. nullius/catalogue/benchmarks/tau3-bench/benchmark.json +49 -0
  165. nullius/catalogue/benchmarks/tau3-bench/driver.py +608 -0
  166. nullius/catalogue/benchmarks/tau3-bench/mcp_server.py +114 -0
  167. nullius/catalogue/benchmarks/tau3-bench/search_relay.py +19 -0
  168. nullius/catalogue/benchmarks/tau3-bench/standard.json +547 -0
  169. nullius/catalogue/benchmarks/tau3-bench/upstream-settings.json +639 -0
  170. nullius/catalogue/benchmarks/terminal-bench/benchmark.json +69 -0
  171. nullius/catalogue/benchmarks/terminal-bench/driver.py +267 -0
  172. nullius/catalogue/benchmarks/terminal-bench/standard.json +166 -0
  173. nullius/catalogue/benchmarks/terminal-bench/upstream-settings.json +36 -0
  174. nullius/catalogue/capabilities/keyword-memory/capability.json +33 -0
  175. nullius/catalogue/capabilities/keyword-memory/capability.py +55 -0
  176. nullius/catalogue/capabilities/mem0/capability.json +135 -0
  177. nullius/catalogue/capabilities/mem0/capability.py +173 -0
  178. nullius/catalogue/catalog.py +426 -0
  179. nullius/catalogue/citation.py +116 -0
  180. nullius/catalogue/harbor_entry.py +367 -0
  181. nullius/catalogue/sources.py +107 -0
  182. nullius/catalogue/storage.py +125 -0
  183. nullius/cli.py +85 -0
  184. nullius/compare/__init__.py +0 -0
  185. nullius/compare/cli.py +265 -0
  186. nullius/compare/comparison.py +184 -0
  187. nullius/execution.py +1653 -0
  188. nullius/gitrefs.py +128 -0
  189. nullius/harbor/__init__.py +0 -0
  190. nullius/harbor/feed.py +228 -0
  191. nullius/harbor/source.py +582 -0
  192. nullius/hosts.py +368 -0
  193. nullius/importers/__init__.py +140 -0
  194. nullius/importers/atif.py +387 -0
  195. nullius/importers/cli.py +135 -0
  196. nullius/importers/otel.py +274 -0
  197. nullius/judge/__init__.py +14 -0
  198. nullius/judge/batch.py +122 -0
  199. nullius/judge/client.py +433 -0
  200. nullius/judge/floors.json +86 -0
  201. nullius/judge/lanes.py +89 -0
  202. nullius/judge/questions.py +309 -0
  203. nullius/judge/reconcile.py +176 -0
  204. nullius/judge/state.py +224 -0
  205. nullius/judge/store.py +167 -0
  206. nullius/migrate.py +268 -0
  207. nullius/onboarding.py +116 -0
  208. nullius/paths.py +89 -0
  209. nullius/prerequisites.py +129 -0
  210. nullius/prices.py +283 -0
  211. nullius/progress.py +294 -0
  212. nullius/providers.py +335 -0
  213. nullius/recipes/__init__.py +0 -0
  214. nullius/recipes/launch.py +78 -0
  215. nullius/redact.py +72 -0
  216. nullius/runs/__init__.py +0 -0
  217. nullius/runs/artifacts.py +67 -0
  218. nullius/runs/classify.py +216 -0
  219. nullius/runs/cli.py +316 -0
  220. nullius/runs/feasibility.py +442 -0
  221. nullius/runs/launches.py +149 -0
  222. nullius/runs/live.py +715 -0
  223. nullius/runs/parse.py +1016 -0
  224. nullius/runs/verifier.py +241 -0
  225. nullius/sandbox.py +109 -0
  226. nullius/secrets.py +218 -0
  227. nullius/settings.py +544 -0
  228. nullius/standard/__init__.py +15 -0
  229. nullius/standard/acp.py +305 -0
  230. nullius/standard/cancellation.py +19 -0
  231. nullius/standard/cli.py +703 -0
  232. nullius/standard/conform.py +149 -0
  233. nullius/standard/container.py +1870 -0
  234. nullius/standard/definitions.py +1651 -0
  235. nullius/standard/egress.py +192 -0
  236. nullius/standard/fidelity.py +256 -0
  237. nullius/standard/forward.py +139 -0
  238. nullius/standard/hostreq.py +105 -0
  239. nullius/standard/howto.py +220 -0
  240. nullius/standard/install.py +428 -0
  241. nullius/standard/job.py +551 -0
  242. nullius/standard/jsonl.py +129 -0
  243. nullius/standard/kits/agent-conversation-v1/driver.py +27 -0
  244. nullius/standard/kits/agent-conversation-v1/standard.json +26 -0
  245. nullius/standard/kits/agent-search-v1/driver.py +171 -0
  246. nullius/standard/kits/agent-search-v1/standard.json +99 -0
  247. nullius/standard/kits/agent-task-v1/driver.py +25 -0
  248. nullius/standard/kits/agent-task-v1/standard.json +100 -0
  249. nullius/standard/kits/agent-tools-v1/driver.py +206 -0
  250. nullius/standard/kits/agent-tools-v1/mcp_kit.py +209 -0
  251. nullius/standard/kits/agent-tools-v1/standard.json +119 -0
  252. nullius/standard/kits/agent-workspace-v1/driver.py +65 -0
  253. nullius/standard/kits/agent-workspace-v1/standard.json +95 -0
  254. nullius/standard/kits/cap-memory-v1/driver.py +39 -0
  255. nullius/standard/kits/cap-memory-v1/standard.json +91 -0
  256. nullius/standard/ledger.py +326 -0
  257. nullius/standard/match.py +66 -0
  258. nullius/standard/mcp_bridge.py +62 -0
  259. nullius/standard/mcp_machine.py +193 -0
  260. nullius/standard/merge.py +239 -0
  261. nullius/standard/names.py +37 -0
  262. nullius/standard/network_requirements.py +44 -0
  263. nullius/standard/pace.py +53 -0
  264. nullius/standard/payload.py +278 -0
  265. nullius/standard/pins.py +130 -0
  266. nullius/standard/ports.py +70 -0
  267. nullius/standard/prove.py +373 -0
  268. nullius/standard/recipe.py +746 -0
  269. nullius/standard/relay.py +785 -0
  270. nullius/standard/run.py +1781 -0
  271. nullius/standard/setup_container.py +208 -0
  272. nullius/standard/shard.py +71 -0
  273. nullius/standard/web_services.py +30 -0
  274. nullius/traces/__init__.py +0 -0
  275. nullius/traces/behavior.py +131 -0
  276. nullius/traces/charts.py +898 -0
  277. nullius/traces/conversation.py +159 -0
  278. nullius/traces/otel.py +608 -0
  279. nullius/traces/trace.py +1477 -0
  280. nullius/traces/trajectory.py +586 -0
  281. nullius/workspace.py +417 -0
  282. nullius/workspace_cli.py +119 -0
  283. nullius_eval-0.1.0.dist-info/METADATA +93 -0
  284. nullius_eval-0.1.0.dist-info/RECORD +291 -0
  285. nullius_eval-0.1.0.dist-info/WHEEL +5 -0
  286. nullius_eval-0.1.0.dist-info/entry_points.txt +2 -0
  287. nullius_eval-0.1.0.dist-info/licenses/LICENSE +202 -0
  288. nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/dmsans-OFL.txt +93 -0
  289. nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/ibmplexmono-OFL.txt +93 -0
  290. nullius_eval-0.1.0.dist-info/licenses/app/static/fonts/instrumentserif-OFL.txt +93 -0
  291. nullius_eval-0.1.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,91 @@
1
+ (() => {
2
+ const modal = document.getElementById('settings-modal');
3
+ const frame = document.getElementById('settings-frame');
4
+ const closeButton = modal.querySelector('[data-settings-close]');
5
+ let opener, baseline = '', closing = false;
6
+ const values = () => {
7
+ const form = frame.contentDocument?.getElementById('settings-form');
8
+ return form ? JSON.stringify([...new FormData(form)]) : '';
9
+ };
10
+ async function close() {
11
+ if (closing) return;
12
+ closing = true;
13
+ try {
14
+ const doc = frame.contentDocument;
15
+ const hostDraft = doc?.querySelector('#add-host[open]');
16
+ if (hostDraft) { hostDraft.close(); return; }
17
+ const autosave = frame.contentWindow?.nulliusSettings;
18
+ if (autosave && !await autosave.flush()) return;
19
+ if ((!autosave && values() !== baseline) && !window.confirm('Discard unsaved settings changes?')) return;
20
+ modal.close();
21
+ } finally { closing = false; }
22
+ }
23
+ modal.addEventListener('click', event => {
24
+ const box = modal.getBoundingClientRect();
25
+ if (event.target === modal && (event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom)) void close();
26
+ });
27
+ closeButton.addEventListener('click', close);
28
+ modal.addEventListener('cancel', event => { event.preventDefault(); close(); });
29
+ modal.addEventListener('close', () => {
30
+ frame.removeAttribute('data-ready');
31
+ frame.removeAttribute('src');
32
+ baseline = '';
33
+ opener?.focus();
34
+ });
35
+ frame.addEventListener('load', () => {
36
+ const doc = frame.contentDocument;
37
+ if (!doc?.body.classList.contains('settings-embedded')) return;
38
+ doc.documentElement.dataset.theme = document.documentElement.dataset.theme;
39
+ doc.documentElement.dataset.palette = document.documentElement.dataset.palette;
40
+ // Reveal only after the document and its styles have loaded in our theme.
41
+ frame.dataset.ready = 'true';
42
+ let onboarding = {};
43
+ try { onboarding = JSON.parse(localStorage.getItem('nullius-onboarding')) || {}; } catch {}
44
+ const restore = doc.getElementById('onb-restore');
45
+ if (restore) restore.hidden = !onboarding.dismissed;
46
+ const state = doc.getElementById('onb-state');
47
+ if (state) state.textContent = onboarding.dismissed ? 'Removed from the rail.' : !onboarding.asked ? 'Not started yet.' : onboarding.open ? 'Open on the right.' : 'In the rail.';
48
+ doc.addEventListener('nullius-theme-change', event => {
49
+ document.dispatchEvent(new CustomEvent('nullius-theme-change', {detail: event.detail}));
50
+ });
51
+ baseline = values();
52
+ closing = false;
53
+ closeButton.disabled = false;
54
+ doc.addEventListener('keydown', event => {
55
+ if (event.key === 'Escape' && !doc.querySelector('dialog[open]')) {
56
+ event.preventDefault();
57
+ close();
58
+ }
59
+ });
60
+ // Onboarding belongs to the page beneath Settings, not the embedded document.
61
+ doc.addEventListener('click', async event => {
62
+ const control = event.target.closest('[data-onb]');
63
+ if (!control) return;
64
+ event.preventDefault();
65
+ await close();
66
+ if (modal.open) return;
67
+ const proxy = document.createElement('button');
68
+ proxy.dataset.onb = control.dataset.onb;
69
+ proxy.hidden = true;
70
+ document.body.append(proxy);
71
+ proxy.click();
72
+ proxy.remove();
73
+ });
74
+ });
75
+ document.addEventListener('click', event => {
76
+ const link = event.target.closest('a[href]');
77
+ if (!link || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || link.target || link.download) return;
78
+ const url = new URL(link.href, location.href);
79
+ if (url.origin !== location.origin || url.pathname !== '/settings' || location.pathname === '/settings') return;
80
+ event.preventDefault();
81
+ opener = link;
82
+ baseline = '';
83
+ closing = false;
84
+ closeButton.disabled = false;
85
+ url.searchParams.set('embedded', '1');
86
+ frame.removeAttribute('data-ready');
87
+ frame.src = url.href;
88
+ modal.showModal();
89
+ document.getElementById('settings-modal-title').focus();
90
+ });
91
+ })();
@@ -0,0 +1,55 @@
1
+ // Category search never inspects field values or credentials.
2
+ (() => {
3
+ const sections = [...document.querySelectorAll('.st-section')];
4
+ const links = [...document.querySelectorAll('.st-index [data-section]')];
5
+ const search = document.getElementById('settings-search');
6
+ function show(id) {
7
+ sections.forEach(section => { section.hidden = section.id !== id; });
8
+ links.forEach(link => link.setAttribute('aria-current', link.dataset.section === id ? 'page' : 'false'));
9
+ }
10
+ function fromHash() {
11
+ let id;
12
+ try { id = decodeURIComponent(location.hash.slice(1)); } catch { id = ''; }
13
+ id = {other: 'general', file: 'storage', 'other-vars': 'providers', 'agent-keys': 'custom-keys', 'benchmark-access': 'custom-keys'}[id] || id;
14
+ const target = document.getElementById(id);
15
+ const section = target?.closest('.st-section');
16
+ show(section?.id || 'providers');
17
+ if (target && target !== section) target.scrollIntoView({block: 'center'});
18
+ }
19
+ search.addEventListener('input', () => {
20
+ const words = search.value.trim().toLowerCase().split(/\s+/);
21
+ links.forEach(link => {
22
+ const haystack = (link.textContent + ' ' + link.dataset.search).toLowerCase();
23
+ link.hidden = !words.every(word => haystack.includes(word));
24
+ });
25
+ document.querySelectorAll('.st-nav-group').forEach(group => {
26
+ group.hidden = [...group.querySelectorAll('[data-section]')].every(link => link.hidden);
27
+ });
28
+ document.querySelector('.st-search-empty').hidden = links.some(link => !link.hidden);
29
+ });
30
+ search.addEventListener('keydown', event => {
31
+ if (event.key === 'Enter') {
32
+ event.preventDefault();
33
+ const first = links.find(link => !link.hidden);
34
+ first?.click();
35
+ first?.focus();
36
+ }
37
+ });
38
+ window.addEventListener('hashchange', fromHash);
39
+ fromHash();
40
+
41
+ const choices = [...document.querySelectorAll('[data-theme-choice]')];
42
+ function themeState() {
43
+ let saved;
44
+ try { saved = localStorage.getItem('theme'); } catch {}
45
+ const selected = saved === 'dark' ? 'charcoal' : ['light', 'charcoal', 'graphite', 'midnight'].includes(saved) ? saved : 'system';
46
+ choices.forEach(button => button.setAttribute('aria-pressed', String(button.dataset.themeChoice === selected)));
47
+ }
48
+ choices.forEach(button => button.addEventListener('click', () => {
49
+ document.dispatchEvent(new CustomEvent('nullius-theme-change', {detail: button.dataset.themeChoice}));
50
+ themeState();
51
+ }));
52
+ document.addEventListener('nullius-theme-updated', themeState);
53
+ window.addEventListener('storage', themeState);
54
+ themeState();
55
+ })();
@@ -0,0 +1,68 @@
1
+ // The Model prices section: the price list's state, its Update, and the user's own prices.
2
+ // The server sends the state with the page and again after each change; this draws it.
3
+ (() => {
4
+ const section = document.getElementById('prices');
5
+ if (!section) return;
6
+ const $ = sel => section.querySelector(sel);
7
+ const csrf = section.dataset.csrf;
8
+ const tell = (message, error = false) => window.nulliusNotify ? window.nulliusNotify(message, {error}) : null;
9
+ const post = async (url, fields) => {
10
+ try {
11
+ const r = await nulliusFetch(url, {method: 'POST', headers: {'X-CSRF-Token': csrf}, body: new URLSearchParams(fields)});
12
+ const j = await r.json();
13
+ return j.ok ? j : {ok: false, error: j.error || 'HTTP ' + r.status};
14
+ } catch (err) { return {ok: false, error: String(err)}; }
15
+ };
16
+ const rate = v => String(Number(v));
17
+
18
+ const show = state => {
19
+ $('[data-prices-state]').textContent = state.n
20
+ ? `${state.n.toLocaleString('en-US')} models · ${state.on}` : 'No price list yet';
21
+ const own = Object.entries(state.own || {}).sort(([a], [b]) => a.localeCompare(b));
22
+ $('[data-own-rows]').replaceChildren(...own.map(([model, r]) => {
23
+ const row = document.createElement('div'); row.className = 'st-row';
24
+ const name = document.createElement('span'); name.className = 'st-row-label mono'; name.textContent = model;
25
+ const value = document.createElement('span'); value.className = 'st-row-value st-value';
26
+ value.append(`input ${rate(r.input)} · output ${rate(r.output)}` + (r.cached === undefined ? '' : ` · cached ${rate(r.cached)}`));
27
+ for (const [key, label] of [['cache_write', 'cache write'], ['cache_write_1h', 'cache write 1h']]) {
28
+ if (r[key] !== undefined) value.append(` · ${label} ${rate(r[key])}`);
29
+ }
30
+ if (csrf) {
31
+ const button = document.createElement('button'); button.type = 'button'; button.className = 'btn sm ghost'; button.textContent = 'Remove';
32
+ button.setAttribute('aria-label', `Remove the price of ${model}`);
33
+ button.addEventListener('click', async () => {
34
+ button.disabled = true;
35
+ const got = await post(section.dataset.remove, {model});
36
+ if (got.ok) show(got); else { button.disabled = false; tell(got.error, true); }
37
+ });
38
+ value.append(' ', button);
39
+ }
40
+ row.append(name, value);
41
+ return row;
42
+ }));
43
+ $('[data-own-none]').hidden = own.length > 0;
44
+ };
45
+
46
+ const update = $('[data-prices-update]');
47
+ if (update) update.addEventListener('click', async () => {
48
+ const label = update.querySelector('span');
49
+ update.disabled = true; update.classList.add('busy'); label.textContent = 'Updating…';
50
+ const got = await post(section.dataset.update, {});
51
+ update.disabled = false; update.classList.remove('busy'); label.textContent = 'Update';
52
+ tell(got.ok ? `${got.n.toLocaleString('en-US')} models priced` : got.error, !got.ok);
53
+ if (got.ok) show(got);
54
+ });
55
+
56
+ const form = $('[data-own-add]');
57
+ if (form) form.addEventListener('submit', async e => {
58
+ e.preventDefault();
59
+ const f = new FormData(form), button = form.querySelector('[type=submit]');
60
+ button.disabled = true;
61
+ const got = await post(section.dataset.set, {model: f.get('model'), input: f.get('input'), output: f.get('output'), cached: f.get('cached'),
62
+ cache_write: f.get('cache_write'), cache_write_1h: f.get('cache_write_1h')});
63
+ button.disabled = false;
64
+ if (got.ok) { form.reset(); show(got); } else tell(got.error, true);
65
+ });
66
+
67
+ try { show(JSON.parse(section.dataset.state)); } catch (err) { show({n: 0, own: {}}); }
68
+ })();
@@ -0,0 +1,134 @@
1
+ // The catalogue and configured list share the existing settings fields and save path.
2
+ (() => {
3
+ const section = document.getElementById('providers');
4
+ if (!section) return;
5
+ const cards = [...section.querySelectorAll('[data-provider-card]')];
6
+ const catalogue = section.querySelector('.st-provider-catalogue');
7
+ const add = section.querySelector('[data-provider-add]');
8
+ const back = section.querySelector('[data-provider-back]');
9
+ const search = section.querySelector('[data-provider-search]');
10
+ const writable = !!document.getElementById('settings-form');
11
+ const testAll = section.querySelector('[data-provider-test-all]');
12
+ const testable = card => card.dataset.ready === 'true' && card.querySelector('[data-provider-test]');
13
+ let mode = 'list', selected = null;
14
+ function render() {
15
+ catalogue.hidden = mode !== 'catalogue';
16
+ add.hidden = !writable || mode !== 'list';
17
+ if (testAll) testAll.hidden = mode !== 'list' || !cards.some(testable);
18
+ back.hidden = mode === 'list';
19
+ section.querySelector('[data-provider-empty]').hidden = mode !== 'list' || cards.some(c => c.dataset.configured === 'true');
20
+ cards.forEach(card => {
21
+ card.hidden = mode === 'catalogue' || (mode === 'editor' ? card !== selected : card.dataset.configured !== 'true');
22
+ card.querySelector('.st-provider-fields').hidden = mode !== 'editor';
23
+ card.querySelector('[data-provider-edit]').hidden = mode !== 'list';
24
+ card.querySelector('[data-provider-done]').hidden = mode !== 'editor';
25
+ const test = card.querySelector('[data-provider-test]');
26
+ if (test) test.hidden = mode !== 'list' || !testable(card);
27
+ const remove = card.querySelector('[data-provider-remove-ask]'), ask = card.querySelector('.st-provider-ask');
28
+ if (remove) remove.hidden = mode !== 'list';
29
+ if (ask && mode !== 'list') { ask.hidden = true; remove.setAttribute('aria-expanded', 'false'); }
30
+ });
31
+ }
32
+ async function leave() {
33
+ if (window.nulliusSettings && !await window.nulliusSettings.flush()) return;
34
+ mode = 'list';
35
+ render();
36
+ (selected && !selected.hidden ? selected.querySelector('[data-provider-edit]') : add).focus({preventScroll: true});
37
+ }
38
+ function edit(key) {
39
+ selected = cards.find(card => card.dataset.providerCard === key);
40
+ if (!selected) return;
41
+ mode = 'editor';
42
+ render();
43
+ const input = selected.querySelector('input.st-input:not([hidden])');
44
+ (input || selected.querySelector('[data-replace]') || back).focus({preventScroll: true});
45
+ }
46
+ // Test: the saved settings asked at no cost (/settings/providers/test); only on a click, the result kept for the card.
47
+ async function test(button) {
48
+ const out = button.closest('[data-provider-card]').querySelector('[data-provider-test-state]');
49
+ const busy = document.createElement('span');
50
+ busy.className = 'sr'; busy.textContent = 'Testing';
51
+ button.disabled = true; out.classList.add('busy'); out.prepend(busy);
52
+ let got;
53
+ try {
54
+ const response = await nulliusFetch(section.dataset.test, {method: 'POST', headers: {'X-CSRF-Token': document.querySelector('#settings-form [name=csrf]').value},
55
+ body: new URLSearchParams({provider: button.dataset.providerTest})});
56
+ got = await response.json().catch(() => ({error: 'HTTP ' + response.status}));
57
+ } catch (error) { got = {error: 'Not tested: ' + error.message}; }
58
+ out.classList.remove('busy'); button.disabled = false;
59
+ out.textContent = got.said || got.error || 'Not tested';
60
+ out.dataset.state = got.mark || 'bad';
61
+ }
62
+ if (testAll) testAll.addEventListener('click', async () => {
63
+ testAll.disabled = true;
64
+ await Promise.all(cards.filter(card => !card.hidden && testable(card)).map(card => test(card.querySelector('[data-provider-test]'))));
65
+ testAll.disabled = false;
66
+ });
67
+ add.addEventListener('click', () => {
68
+ mode = 'catalogue'; render(); search.value = ''; search.dispatchEvent(new Event('input')); search.focus();
69
+ });
70
+ back.addEventListener('click', leave);
71
+ // Remove asks first, in place: Yes saves the removal, Keep it or Escape closes the question.
72
+ const setAsk = (card, open) => {
73
+ const button = card.querySelector('[data-provider-remove-ask]');
74
+ card.querySelector('.st-provider-ask').hidden = !open;
75
+ button.setAttribute('aria-expanded', String(open));
76
+ (open ? card.querySelector('[data-provider-remove-keep]') : button).focus({preventScroll: true});
77
+ };
78
+ section.addEventListener('keydown', event => {
79
+ const card = event.target.closest('[data-provider-card]'), ask = card?.querySelector('.st-provider-ask');
80
+ if (event.key === 'Escape' && ask && !ask.hidden) { event.preventDefault(); event.stopPropagation(); setAsk(card, false); }
81
+ });
82
+ section.addEventListener('click', event => {
83
+ const ask = event.target.closest('[data-provider-remove-ask]');
84
+ if (ask) { setAsk(ask.closest('[data-provider-card]'), ask.getAttribute('aria-expanded') !== 'true'); return; }
85
+ const keep = event.target.closest('[data-provider-remove-keep]');
86
+ if (keep) { setAsk(keep.closest('[data-provider-card]'), false); return; }
87
+ const yes = event.target.closest('[data-provider-remove-yes]');
88
+ if (yes) {
89
+ const field = document.querySelector('[name="remove_provider"]');
90
+ field.value = yes.dataset.providerRemoveYes;
91
+ field.dispatchEvent(new Event('change', {bubbles: true}));
92
+ return;
93
+ }
94
+ const tester = event.target.closest('[data-provider-test]');
95
+ if (tester) { void test(tester); return; }
96
+ const pick = event.target.closest('[data-provider-select], [data-provider-edit]');
97
+ if (pick) edit(pick.dataset.providerSelect || pick.dataset.providerEdit);
98
+ if (event.target.closest('[data-provider-done]')) void leave();
99
+ });
100
+ search.addEventListener('input', () => {
101
+ const choices = [...catalogue.querySelectorAll('[data-provider-select]')];
102
+ choices.forEach(choice => { choice.hidden = !choice.dataset.providerName.toLowerCase().includes(search.value.trim().toLowerCase()); });
103
+ catalogue.querySelector('[data-provider-no-results]').hidden = choices.some(choice => !choice.hidden);
104
+ });
105
+ document.addEventListener('nullius-settings-saved', event => {
106
+ const removedSelectedKey = mode === 'editor' && (event.detail?.removedKeys || []).some(name => selected?.contains(document.getElementById(name)));
107
+ for (const state of event.detail?.providers || []) {
108
+ const card = cards.find(c => c.dataset.providerCard === state.key);
109
+ if (!card) continue;
110
+ card.dataset.configured = state.configured;
111
+ card.dataset.ready = state.ready;
112
+ const said = card.querySelector('[data-provider-state]');
113
+ if (said) said.textContent = state.label;
114
+ const tested = card.querySelector('[data-provider-test-state]');
115
+ if (tested && state.tested !== undefined) { tested.textContent = state.tested; tested.dataset.state = state.mark; }
116
+ }
117
+ if (removedSelectedKey) mode = 'list';
118
+ render();
119
+ if (removedSelectedKey) (selected && !selected.hidden ? selected.querySelector('[data-provider-edit]') : add).focus({preventScroll: true});
120
+ });
121
+ function fromHash() {
122
+ let id;
123
+ try { id = decodeURIComponent(location.hash.slice(1)); } catch { return; }
124
+ const target = document.getElementById(id);
125
+ const card = target?.closest('[data-provider-card]');
126
+ if (card) {
127
+ edit(card.dataset.providerCard);
128
+ target.scrollIntoView({block: 'nearest'});
129
+ }
130
+ }
131
+ window.addEventListener('hashchange', fromHash);
132
+ render();
133
+ fromHash();
134
+ })();
@@ -0,0 +1,20 @@
1
+ // The Sandbox section: docker's state, asked once when the section is first shown.
2
+ (() => {
3
+ const section = document.getElementById('sandbox');
4
+ if (!section) return;
5
+
6
+ let asked = false;
7
+ const load = async () => {
8
+ asked = true;
9
+ let j;
10
+ try { j = await (await nulliusFetch(section.dataset.sandbox)).json(); } catch (err) { j = {docker: {ok: false, error: String(err)}}; }
11
+ const state = section.querySelector('[data-docker-state]');
12
+ state.textContent = j.docker.ok ? '✓ ' + j.docker.version : '✕ ' + j.docker.error;
13
+ state.className = 'st-row-value ' + (j.docker.ok ? 'ok' : 'bad');
14
+ };
15
+
16
+ // Asked the first time the section is shown, not on every visit to Settings.
17
+ const ask = () => { if (!asked && !section.hidden) load(); };
18
+ new MutationObserver(ask).observe(section, {attributes: true, attributeFilter: ['hidden']});
19
+ ask();
20
+ })();