micro-models-agent 2.9.0 → 2.10.0

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ All notable changes to Micro Models Agent (MMA) will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.10.0] - 2026-09-27
8
+
9
+ ### Added
10
+
11
+ - **Config registry expansion** (`src/config/registry.ts`, `src/config/registry-extra.ts`): ~110 keys now editable via `/config`, `mma config set` and web Settings; new value types `json` (objects, 20K limit, `JSON.parse`) and `list` (string arrays, comma-separated in REPL). `registry.ts` stays frozen (grandfathered over 300 lines) — new defs live in `registry-extra.ts`, merged into `DEFINITIONS` by concat.
12
+ - **`mma config set` validation + `--force`** (`src/cli/commands.ts`): writes go through `setConfigValue` by default (bad value → `cli.config_invalid`, nothing persisted); `--force` is a raw dotted-path escape hatch without validation.
13
+ - **`/security status` (REPL + web)** (`src/cli/repl-commands.ts`, `src/modules/webui/commands-settings.ts`): read-only summary (`security · on/off`, `↳` lines per STYLE.md) plus `/security <key> [value]` registry writes; handler maps per rule #17, automatic in web `/api/commands` HELP.
14
+ - **Provider form fields** (`src/modules/webui/providers-api.ts`): `maxCompletionTokens` (512–128000), `cache` (mechanism/report selects + 6 bool flags), `retry{maxRetries,baseDelay,maxDelay}`; mirrored to legacy when active, validation failure keeps the existing `400 invalid-provider`.
15
+ - **Web MCP CRUD** (`src/modules/webui/settings-api.ts`, `server.ts` route table): `POST /api/mcp` (create) + `PUT /api/mcp/:id` (full edit, `stdio→command` / `sse|http→url` required), `restartRequired: true`.
16
+ - **Web LSP read/edit** (`src/modules/webui/settings-api.ts`): `GET /api/lsp` table + `PUT /api/lsp/:lang` (`enabled/timeout/command/args` only; add/remove stays JSON-only), `restartRequired: true`.
17
+ - **Generic web settings controls** (`src/modules/webui/assets/js/settings-controls.js`): `controlFor` renders bool/enum/int/share/list/json per registry type.
18
+ - **Settings information architecture** (`src/modules/webui/assets/js/settings-controls.js`, `index.html`, `settings.js`): `PANEL_SECTIONS` is the single source of truth mapping each panel to *named* sections, so a section title always describes the keys under it and no key sits in an "Advanced" bucket. Sidebar grew to 14 intent-named sections (network/browser/sessions split out; `advanced` keeps only diagnostics/retry/service), each panel renders titled cards with a one-line explanation, and the per-group count badges are gone.
19
+ - **Settings search** (`src/modules/webui/assets/js/settings.js`, `index.html`, `styles.css`): a search box over the same `PANEL_SECTIONS` table plus i18n labels; results show label + owning panel + dotted key, selection switches the panel and flashes the row (`Esc` clears).
20
+ - **Structured editors for list/JSON keys** (`src/config/registry.ts` `ConfigKeyDef.editor`, `src/config/registry-extra.ts`, `src/modules/webui/assets/js/settings-controls.js`): registry metadata now tells the GUI how to render a value. `tags` = removable chips with an inline adder (bash/path/network rule lists, `tools.defaultTags`, `contentScan.dangerousPatterns`), `checkboxes` = multiselect over a fixed set (`auditNotifier.eventTypes`), `table` = typed record rows (`pricing.overrides`, `experts`, `modelCapabilities`). Tables validate the record client-side and never post a half-filled row; editors post JSON, and `parseConfigValue` accepts a JSON array for `list` keys so values containing commas (regexes like `a{1,3}`) survive.
21
+ - **Memory add dialog** (`src/modules/webui/assets/js/settings.js`): adding a memory entry uses the shared nested dialog (category + multi-line note) instead of the cramped inline row.
22
+
23
+ ### Changed
24
+
25
+ - **Provider upsert semantics** (`src/modules/webui/providers-api.ts`): a create-POST naming the only entry of a virgin legacy config updates it in place instead of `409 name-conflict`; genuine collisions in multi-entry configs still return `name-conflict`.
26
+ - **One nested settings dialog** (`src/modules/webui/assets/js/settings.js`, `index.html`, `styles.css`): provider, MCP-server and LSP-server edits all open in the shared `#subOverlay` (`openSubDialog`/`closeSubDialog`) above the settings modal, with focus trap, focus return and Esc/backdrop close; the inline MCP/LSP forms and the provider-only overlay are gone.
27
+
28
+ ### Fixed
29
+
30
+ - **Audit event checkboxes** (`src/modules/webui/assets/styles.css`, `src/i18n/*.json`): `.row input` (a right-aligned 120px field) was inherited by checkboxes, so the label drifted away from the box; checkboxes now reset width/alignment and lay out in an even grid, and every option has a human label (`security block`, `bash command`, …) instead of a raw id.
31
+ - **Settings reported a stale MMA version** (`src/config/registry.ts`): the `version` key returned `config.version` — the config-schema version written at first launch (`2.0.0`), which never matched a release. It now reports the installed package version (`readMmaVersion()`, read at call time), so the web Settings panel and `/config version` show the real release; the description no longer claims "(read-only)".
32
+
7
33
  ## [2.9.0] - 2026-09-26
8
34
 
9
35
  ### Added
@@ -210,6 +210,11 @@ function applyStaticI18n() {
210
210
  const p = mi.dataset.p;
211
211
  if (p) mi.textContent = t("web.settings." + p);
212
212
  });
213
+ const settingsSearch = document.getElementById("setSearch");
214
+ if (settingsSearch) {
215
+ settingsSearch.placeholder = t("web.settings.search_placeholder");
216
+ settingsSearch.setAttribute("aria-label", t("web.settings.search_placeholder"));
217
+ }
213
218
  document.querySelectorAll(".content-col .panel").forEach((panel) => {
214
219
  const h3 = panel.querySelector("h3");
215
220
  const name = panel.id.replace(/^p-/, "");
@@ -88,18 +88,29 @@
88
88
  <div class="modal" role="dialog" aria-modal="true" aria-labelledby="settingsTitle">
89
89
  <div class="modal-top"><span class="modal-top-icon" id="settingsIcon" aria-hidden="true"></span> <span id="settingsTitle">settings</span> <span class="saved" id="saveIndicator" role="status" aria-live="polite"></span> <button class="x linkbtn" id="closeSettings" type="button">✕ close</button></div>
90
90
  <div class="modal-body">
91
- <div class="menu-col" id="setMenu" role="tablist" aria-label="settings sections">
92
- <div class="mi on" data-p="general">General</div>
93
- <div class="mi" data-p="model">Model &amp; Provider</div>
94
- <div class="mi" data-p="context">Context</div>
95
- <div class="mi" data-p="reasoning">Reasoning</div>
96
- <div class="mi" data-p="agent">Agent</div>
97
- <div class="mi" data-p="ui">UI &amp; Theme</div>
98
- <div class="mi" data-p="memory">Memory</div>
99
- <div class="mi" data-p="skills">Skills</div>
100
- <div class="mi" data-p="plugins">Plugins · MCP</div>
101
- <div class="mi" data-p="security">Security</div>
102
- <div class="mi" data-p="advanced">Advanced</div>
91
+ <div class="menu-col">
92
+ <div class="set-search">
93
+ <span class="set-search-icon" id="setSearchIcon" aria-hidden="true"></span>
94
+ <input id="setSearch" type="search" autocomplete="off" spellcheck="false" placeholder="search settings" aria-label="search settings">
95
+ <button class="set-search-clear linkbtn" id="setSearchClear" type="button" hidden>✕</button>
96
+ </div>
97
+ <div id="setMenu" role="tablist" aria-label="settings sections">
98
+ <div class="mi on" data-p="general">General</div>
99
+ <div class="mi" data-p="model">Model &amp; Provider</div>
100
+ <div class="mi" data-p="context">Context</div>
101
+ <div class="mi" data-p="reasoning">Reasoning</div>
102
+ <div class="mi" data-p="agent">Agent</div>
103
+ <div class="mi" data-p="network">Network</div>
104
+ <div class="mi" data-p="browser">Browser</div>
105
+ <div class="mi" data-p="sessions">Sessions</div>
106
+ <div class="mi" data-p="ui">UI &amp; Theme</div>
107
+ <div class="mi" data-p="memory">Memory</div>
108
+ <div class="mi" data-p="skills">Skills</div>
109
+ <div class="mi" data-p="plugins">Plugins · MCP</div>
110
+ <div class="mi" data-p="security">Security</div>
111
+ <div class="mi" data-p="advanced">Advanced</div>
112
+ </div>
113
+ <div class="set-results" id="setResults" role="listbox" aria-label="search results" hidden></div>
103
114
  </div>
104
115
  <div class="content-col">
105
116
  <div class="panel on" id="p-general"><h3>General</h3><div class="rows" data-panel="general"></div></div>
@@ -107,6 +118,9 @@
107
118
  <div class="panel" id="p-context"><h3>Context</h3><div class="rows" data-panel="context"></div></div>
108
119
  <div class="panel" id="p-reasoning"><h3>Reasoning</h3><div class="rows" data-panel="reasoning"></div></div>
109
120
  <div class="panel" id="p-agent"><h3>Agent</h3><div class="rows" data-panel="agent"></div></div>
121
+ <div class="panel" id="p-network"><h3>Network</h3><div class="rows" data-panel="network"></div></div>
122
+ <div class="panel" id="p-browser"><h3>Browser</h3><div class="rows" data-panel="browser"></div></div>
123
+ <div class="panel" id="p-sessions"><h3>Sessions</h3><div class="rows" data-panel="sessions"></div></div>
110
124
  <div class="panel" id="p-ui"><h3>UI &amp; Theme</h3><div class="rows" data-panel="ui"></div></div>
111
125
  <div class="panel" id="p-memory"><h3>Memory</h3><div class="rows" data-panel="memory"></div></div>
112
126
  <div class="panel" id="p-skills"><h3>Skills</h3><div class="rows" data-panel="skills"></div></div>
@@ -131,10 +145,10 @@
131
145
  </div>
132
146
  </div>
133
147
 
134
- <div class="overlay overlay-nested" id="providerOverlay">
135
- <div class="modal modal-provider" role="dialog" aria-modal="true" aria-labelledby="providerFormTitle">
136
- <div class="modal-top"><span id="providerFormTitle">provider</span><button class="x linkbtn" id="closeProvider" type="button">✕ close</button></div>
137
- <div class="modal-body provider-body" id="providerFormHost"></div>
148
+ <div class="overlay overlay-nested" id="subOverlay">
149
+ <div class="modal modal-sub" role="dialog" aria-modal="true" aria-labelledby="subTitle">
150
+ <div class="modal-top"><span id="subTitle"></span><button class="x linkbtn" id="closeSub" type="button">✕ close</button></div>
151
+ <div class="modal-body provider-body" id="subHost"></div>
138
152
  </div>
139
153
  </div>
140
154
 
@@ -69,6 +69,10 @@ refresh: [
69
69
  ],
70
70
  "chevron-down": [["path", { d: "m6 9 6 6 6-6" }]],
71
71
  "chevron-right": [["path", { d: "m9 18 6-6-6-6" }]],
72
+ search: [
73
+ ["circle", { cx: 11, cy: 11, r: 8 }],
74
+ ["path", { d: "m21 21-4.3-4.3" }],
75
+ ],
72
76
  "arrow-up": [["path", { d: "M12 19V5" }], ["path", { d: "m5 12 7-7 7 7" }]],
73
77
  panel: [
74
78
  ["rect", { width: 18, height: 18, x: 3, y: 3, rx: 2, ry: 2 }],
@@ -0,0 +1,452 @@
1
+ // Generic settings controls for the `mma web` settings modal (`settings.js`).
2
+ // One renderer per registry `valueType`; rows, labels and descriptions stay in
3
+ // `settings.js` (same `row`/`el` styling). Never uses innerHTML — all user or
4
+ // config data goes through `textContent` (XSS rule).
5
+ import { el, makeToggle } from "./dom.js";
6
+ import { t } from "./i18n.js";
7
+
8
+ // Validate raw JSON text without posting. Empty input is invalid (the backend
9
+ // would reject it too); the caller shows `error` inline and skips the POST.
10
+ export function validateJson(text) {
11
+ const raw = String(text == null ? "" : text).trim();
12
+ if (!raw) return { ok: false, error: "required" };
13
+ try {
14
+ JSON.parse(raw);
15
+ return { ok: true };
16
+ } catch (e) {
17
+ return { ok: false, error: e instanceof Error ? e.message : "invalid JSON" };
18
+ }
19
+ }
20
+
21
+ function textInput(label, value) {
22
+ const input = el("input");
23
+ input.setAttribute("aria-label", label);
24
+ input.value = value;
25
+ return input;
26
+ }
27
+
28
+ // `def`: registry entry ({valueType, enum, min, max, step, readOnly}).
29
+ // `value`: current config value at the key (`getPath` result).
30
+ // `ctx`: { label, enumLabel(v), post(rawValue) } — `post` is `settings.js`
31
+ // `postConfig`, injected so this module never touches the API directly.
32
+ export function controlFor(def, value, ctx) {
33
+ if (def.readOnly) {
34
+ const ro = el("span", "val dim", value == null ? "—" : String(value));
35
+ if (value != null) ro.title = String(value);
36
+ return ro;
37
+ }
38
+ if (def.valueType === "bool") {
39
+ return makeToggle(!!value, (next) => {
40
+ ctx.post(next);
41
+ return true;
42
+ });
43
+ }
44
+ if (def.valueType === "enum") {
45
+ const sel = el("select");
46
+ sel.setAttribute("aria-label", ctx.label);
47
+ (def.enum || []).forEach((v) => {
48
+ const o = el("option", "", ctx.enumLabel(v));
49
+ o.value = v;
50
+ if (v === value) o.selected = true;
51
+ sel.appendChild(o);
52
+ });
53
+ sel.addEventListener("change", () => ctx.post(sel.value));
54
+ return sel;
55
+ }
56
+ if (def.valueType === "int") {
57
+ const input = textInput(ctx.label, value == null ? "" : String(value));
58
+ input.type = "number";
59
+ if (def.min != null) input.min = String(def.min);
60
+ if (def.max != null) input.max = String(def.max);
61
+ if (def.step != null) input.step = String(def.step);
62
+ input.addEventListener("change", () => ctx.post(input.value));
63
+ return input;
64
+ }
65
+ if (def.valueType === "share") {
66
+ const input = textInput(ctx.label, value == null ? "" : Math.round(Number(value) * 100) + "%");
67
+ input.addEventListener("change", () => ctx.post(input.value));
68
+ return input;
69
+ }
70
+ const editor = def.editor;
71
+ if (editor && editor.kind === "tags" && (def.valueType === "list" || def.valueType === "json")) {
72
+ return tagsEditor(value, ctx, editor);
73
+ }
74
+ if (editor && editor.kind === "checkboxes") {
75
+ return checkboxEditor(value, ctx, editor);
76
+ }
77
+ if (editor && editor.kind === "table") {
78
+ return tableEditor(value, ctx, editor);
79
+ }
80
+ if (def.valueType === "list") {
81
+ const shown = Array.isArray(value) ? value.join(", ") : value == null ? "" : String(value);
82
+ const input = textInput(ctx.label, shown);
83
+ input.placeholder = "a, b, c";
84
+ // The backend splits the raw comma string — post it verbatim.
85
+ input.addEventListener("change", () => ctx.post(input.value));
86
+ return input;
87
+ }
88
+ if (def.valueType === "json") {
89
+ const wrap = el("div", "jsonctl");
90
+ const area = el("textarea");
91
+ area.setAttribute("aria-label", ctx.label);
92
+ area.rows = 3;
93
+ area.value = value == null ? "" : JSON.stringify(value, null, 2);
94
+ const err = el("div", "json-err");
95
+ err.hidden = true;
96
+ area.addEventListener("input", () => {
97
+ const r = validateJson(area.value);
98
+ err.hidden = r.ok;
99
+ err.textContent = r.ok ? "" : String(r.error || "invalid JSON");
100
+ });
101
+ // Post only when valid — an invalid draft stays editable, no error toast.
102
+ area.addEventListener("change", () => {
103
+ if (validateJson(area.value).ok) ctx.post(area.value.trim());
104
+ else area.focus();
105
+ });
106
+ wrap.appendChild(area);
107
+ wrap.appendChild(err);
108
+ return wrap;
109
+ }
110
+ const input = textInput(ctx.label, value == null ? "" : String(value));
111
+ input.addEventListener("change", () => ctx.post(input.value));
112
+ return input;
113
+ }
114
+
115
+ // --- structured editors for list/json keys --------------------------------
116
+ // Each posts a JSON string; `parseConfigValue` accepts a JSON array for `list`
117
+ // and JSON.parse for `json`, so values containing commas (regexes, tags) survive.
118
+
119
+ /** String chips with per-item remove and an inline "add" field. */
120
+ function tagsEditor(value, ctx, editor) {
121
+ const items = Array.isArray(value) ? value.map(String) : [];
122
+ const wrap = el("div", "tagsctl ctl-block");
123
+ const list = el("div", "tags-list");
124
+ const commit = () => ctx.post(JSON.stringify(items));
125
+ const draw = () => {
126
+ list.textContent = "";
127
+ items.forEach((tag, i) => {
128
+ const chip = el("span", "tag-chip");
129
+ const text = el("span", "tag-text", tag);
130
+ text.title = tag;
131
+ chip.appendChild(text);
132
+ const rm = el("button", "tag-rm linkbtn", "✕");
133
+ rm.type = "button";
134
+ rm.setAttribute("aria-label", `${ctx.label}: remove ${tag}`);
135
+ rm.addEventListener("click", () => {
136
+ items.splice(i, 1);
137
+ commit();
138
+ draw();
139
+ });
140
+ chip.appendChild(rm);
141
+ list.appendChild(chip);
142
+ });
143
+ if (!items.length) list.appendChild(el("span", "tags-empty", ctx.emptyLabel || "—"));
144
+ };
145
+ draw();
146
+ wrap.appendChild(list);
147
+ const adder = el("div", "tags-add");
148
+ const inp = el("input");
149
+ inp.type = "text";
150
+ inp.placeholder = editor.placeholder || "…";
151
+ inp.setAttribute("aria-label", ctx.label);
152
+ const submit = () => {
153
+ const v = inp.value.trim();
154
+ if (!v || items.includes(v)) {
155
+ inp.select();
156
+ return;
157
+ }
158
+ items.push(v);
159
+ commit();
160
+ draw();
161
+ inp.value = "";
162
+ inp.focus();
163
+ };
164
+ inp.addEventListener("keydown", (e) => {
165
+ if (e.key === "Enter") {
166
+ e.preventDefault();
167
+ submit();
168
+ }
169
+ });
170
+ adder.appendChild(inp);
171
+ const plus = el("button", "tags-plus linkbtn", "+");
172
+ plus.type = "button";
173
+ plus.setAttribute("aria-label", `${ctx.label}: add`);
174
+ plus.addEventListener("click", submit);
175
+ adder.appendChild(plus);
176
+ wrap.appendChild(adder);
177
+ return wrap;
178
+ }
179
+
180
+ /** Multiselect over a fixed option list (an empty selection = all). */
181
+ function checkboxEditor(value, ctx, editor) {
182
+ const selected = new Set(Array.isArray(value) ? value.map(String) : []);
183
+ const wrap = el("div", "checksctl ctl-block");
184
+ (editor.options || []).forEach((opt) => {
185
+ const label = el("label", "check-line");
186
+ const box = el("input");
187
+ box.type = "checkbox";
188
+ box.checked = selected.has(opt);
189
+ box.addEventListener("change", () => {
190
+ if (box.checked) selected.add(opt);
191
+ else selected.delete(opt);
192
+ ctx.post(JSON.stringify([...selected]));
193
+ });
194
+ label.appendChild(box);
195
+ label.appendChild(el("span", "", ctx.enumLabel ? ctx.enumLabel(opt) : opt));
196
+ wrap.appendChild(label);
197
+ });
198
+ return wrap;
199
+ }
200
+
201
+ /** Record editor: one row per key, typed columns, add/remove.
202
+ *
203
+ * Rows are held locally and the whole record is validated client-side before
204
+ * posting, so a half-filled new row never round-trips to the server (which
205
+ * would reject the object with a generic "invalid"). Nothing is posted until
206
+ * the record satisfies the required columns. */
207
+ function tableEditor(value, ctx, editor) {
208
+ const columns = editor.columns || [];
209
+ const keyCol = columns[0];
210
+ const rest = columns.slice(1);
211
+ const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
212
+ const rows = Object.entries(source).map(([name, val]) => ({
213
+ name,
214
+ val: val && typeof val === "object" ? { ...val } : {},
215
+ error: "",
216
+ }));
217
+ const wrap = el("div", "tablectl ctl-block");
218
+ const head = el("div", "table-head");
219
+ columns.forEach((c) => head.appendChild(el("span", "table-th", ctx.fieldLabel(c.key))));
220
+ wrap.appendChild(head);
221
+ const body = el("div", "table-body");
222
+ const error = el("div", "json-err");
223
+ error.hidden = true;
224
+
225
+ const colIsArray = (col) => col.array === true;
226
+ const isBlank = (v) => v === undefined || v === "" || (Array.isArray(v) && v.length === 0);
227
+
228
+ /** Build the record; empty optional values are dropped. Returns null + reason. */
229
+ const build = () => {
230
+ const out = {};
231
+ for (const row of rows) {
232
+ if (!row.name) return { ok: false, reason: "empty name" };
233
+ if (out[row.name] !== undefined) return { ok: false, reason: `duplicate: ${row.name}` };
234
+ const entry = {};
235
+ for (const col of rest) {
236
+ const v = row.val[col.key];
237
+ if (col.optional && isBlank(v)) continue;
238
+ if (!col.optional && isBlank(v)) return { ok: false, reason: `${row.name}: ${ctx.fieldLabel(col.key)}` };
239
+ if (col.type === "number") {
240
+ const n = Number(v);
241
+ if (!Number.isFinite(n) || n < 0) return { ok: false, reason: `${row.name}: ${ctx.fieldLabel(col.key)}` };
242
+ entry[col.key] = n;
243
+ } else if (col.type === "bool") {
244
+ if (v === true) entry[col.key] = true;
245
+ } else {
246
+ entry[col.key] = colIsArray(col) ? v : String(v);
247
+ }
248
+ }
249
+ out[row.name] = entry;
250
+ }
251
+ return { ok: true, value: out };
252
+ };
253
+
254
+ const sync = () => {
255
+ const built = build();
256
+ if (!built.ok) {
257
+ error.hidden = false;
258
+ error.textContent = t("web.settings.table_invalid", { field: built.reason });
259
+ return false;
260
+ }
261
+ error.hidden = true;
262
+ error.textContent = "";
263
+ ctx.post(JSON.stringify(built.value));
264
+ return true;
265
+ };
266
+
267
+ const writeValue = (row, col, input) => {
268
+ if (col.type === "bool") {
269
+ if (input.checked) row.val[col.key] = true;
270
+ else delete row.val[col.key];
271
+ } else if (col.type === "number") {
272
+ const raw = input.value.trim();
273
+ if (raw === "") delete row.val[col.key];
274
+ else row.val[col.key] = Number(raw);
275
+ } else {
276
+ const raw = input.value.trim();
277
+ if (raw === "") delete row.val[col.key];
278
+ else row.val[col.key] = colIsArray(col) ? raw.split(",").map((s) => s.trim()).filter(Boolean) : raw;
279
+ }
280
+ };
281
+
282
+ const inputFor = (row, col) => {
283
+ const input = el("input");
284
+ const v = row.val[col.key];
285
+ if (col.type === "bool") {
286
+ input.type = "checkbox";
287
+ input.checked = v === true;
288
+ } else if (col.type === "number") {
289
+ input.type = "number";
290
+ input.value = v == null ? "" : String(v);
291
+ } else {
292
+ input.type = "text";
293
+ input.value = Array.isArray(v) ? v.join(", ") : v == null ? "" : String(v);
294
+ }
295
+ input.setAttribute("aria-label", `${row.name}: ${ctx.fieldLabel(col.key)}`);
296
+ input.addEventListener("change", () => {
297
+ writeValue(row, col, input);
298
+ sync();
299
+ });
300
+ return input;
301
+ };
302
+
303
+ const draw = () => {
304
+ body.textContent = "";
305
+ rows.forEach((row) => {
306
+ const elRow = el("div", "table-row");
307
+ elRow.dataset.key = row.name;
308
+ const keyInput = el("input");
309
+ keyInput.type = "text";
310
+ keyInput.value = row.name;
311
+ keyInput.placeholder = ctx.fieldLabel(keyCol.key);
312
+ keyInput.setAttribute("aria-label", ctx.fieldLabel(keyCol.key));
313
+ keyInput.addEventListener("change", () => {
314
+ row.name = keyInput.value.trim();
315
+ if (sync()) {
316
+ elRow.dataset.key = row.name;
317
+ }
318
+ });
319
+ elRow.appendChild(keyInput);
320
+ rest.forEach((col) => elRow.appendChild(inputFor(row, col)));
321
+ const rm = el("button", "table-rm linkbtn", "✕");
322
+ rm.type = "button";
323
+ rm.setAttribute("aria-label", `${ctx.label}: remove ${row.name}`);
324
+ rm.addEventListener("click", () => {
325
+ rows.splice(rows.indexOf(row), 1);
326
+ if (sync()) draw();
327
+ });
328
+ elRow.appendChild(rm);
329
+ body.appendChild(elRow);
330
+ });
331
+ };
332
+ draw();
333
+ wrap.appendChild(body);
334
+ wrap.appendChild(error);
335
+
336
+ const adder = el("div", "table-add");
337
+ const nameInput = el("input");
338
+ nameInput.type = "text";
339
+ nameInput.placeholder = ctx.fieldLabel(keyCol.key);
340
+ nameInput.setAttribute("aria-label", `${ctx.label}: new ${ctx.fieldLabel(keyCol.key)}`);
341
+ // A new row is local until it satisfies the required columns — no POST yet.
342
+ const submit = () => {
343
+ const name = nameInput.value.trim();
344
+ if (!name || rows.some((r) => r.name === name)) {
345
+ nameInput.select();
346
+ return;
347
+ }
348
+ const seed = {};
349
+ rows.push({ name, val: seed, error: "" });
350
+ nameInput.value = "";
351
+ draw();
352
+ const last = body.lastElementChild;
353
+ const first = last && last.querySelectorAll("input")[1];
354
+ if (first) first.focus();
355
+ };
356
+ nameInput.addEventListener("keydown", (e) => {
357
+ if (e.key === "Enter") {
358
+ e.preventDefault();
359
+ submit();
360
+ }
361
+ });
362
+ adder.appendChild(nameInput);
363
+ const plus = el("button", "table-plus linkbtn", "+");
364
+ plus.type = "button";
365
+ plus.setAttribute("aria-label", `${ctx.label}: add`);
366
+ plus.addEventListener("click", submit);
367
+ adder.appendChild(plus);
368
+ wrap.appendChild(adder);
369
+ return wrap;
370
+ }
371
+
372
+ // Single source of truth for the settings information architecture.
373
+ //
374
+ // Every panel is a list of *named sections* — the title must describe exactly
375
+ // what is inside (research: settings fail when category names do not match the
376
+ // controls under them, and when an "Advanced" bucket collects unrelated keys).
377
+ // `search` (settings.js) indexes the same table, so a key can never be
378
+ // reachable but unfindable.
379
+ //
380
+ // Panel ids match `data-p` / `data-panel` in index.html. Panels with custom
381
+ // bodies (model, ui, memory, skills, plugins) render their own content first
382
+ // and then these sections.
383
+ export const PANEL_SECTIONS = {
384
+ general: [
385
+ { id: "general.interface", titleKey: "web.settings.sec.general.interface", keys: ["locale", "ui.verbosity"] },
386
+ { id: "general.agent", titleKey: "web.settings.sec.general.agent", descKey: "web.settings.sec.general.agent.desc", keys: ["maxToolIterations", "stuckThreshold", "autoPlan"] },
387
+ { id: "general.provider", titleKey: "web.settings.sec.general.provider", keys: ["provider.fallback"] },
388
+ ],
389
+ model: [
390
+ { id: "model.tuning", titleKey: "web.settings.sec.model.tuning", descKey: "web.settings.sec.model.tuning.desc", keys: ["provider.maxCompletionTokens", "modelLoad.autoLoad", "modelLoad.flashAttention", "modelLoad.evalBatchSize", "modelLoad.offloadKvCacheToGpu"] },
391
+ { id: "model.capabilities", titleKey: "web.settings.sec.model.capabilities", descKey: "web.settings.sec.model.capabilities.desc", keys: ["modelCapabilities"] },
392
+ ],
393
+ context: [
394
+ { id: "context.window", titleKey: "web.settings.sec.context.window", descKey: "web.settings.sec.context.window.desc", keys: ["contextWindow", "contextBudget.systemPrompt", "contextBudget.responseReserve"] },
395
+ { id: "context.compaction", titleKey: "web.settings.sec.context.compaction", descKey: "web.settings.sec.context.compaction.desc", keys: ["contextBudget.compactionThreshold", "contextBudget.compactionMinLoad"] },
396
+ { id: "context.instructions", titleKey: "web.settings.sec.context.instructions", descKey: "web.settings.sec.context.instructions.desc", keys: ["instructions.summarize"] },
397
+ { id: "context.log", titleKey: "web.settings.sec.context.log", descKey: "web.settings.sec.context.log.desc", keys: ["contextLog.enabled", "contextLog.redact"] },
398
+ ],
399
+ reasoning: [
400
+ { id: "reasoning.display", titleKey: "web.settings.sec.reasoning.display", keys: ["showReasoning"] },
401
+ { id: "reasoning.effort", titleKey: "web.settings.sec.reasoning.effort", descKey: "web.settings.sec.reasoning.effort.desc", keys: ["reasoning.mode", "reasoning.min", "reasoning.max", "reasoning.baseline", "reasoning.overrideCooldown"] },
402
+ ],
403
+ agent: [
404
+ { id: "agent.moe", titleKey: "web.settings.sec.agent.moe", descKey: "web.settings.sec.agent.moe.desc", keys: ["moe.enabled", "moe.maxReplanCycles", "experts"] },
405
+ { id: "agent.critic", titleKey: "web.settings.sec.agent.critic", descKey: "web.settings.sec.agent.critic.desc", keys: ["critic.enabled", "critic.maxCalls", "critic.maxRepairCycles", "critic.timeoutMs"] },
406
+ { id: "agent.tools", titleKey: "web.settings.sec.agent.tools", descKey: "web.settings.sec.agent.tools.desc", keys: ["tools.enableOnDemand", "tools.defaultTags", "skills.budget"] },
407
+ { id: "agent.subagent", titleKey: "web.settings.sec.agent.subagent", descKey: "web.settings.sec.agent.subagent.desc", keys: ["subagent.resultMode", "subagent.maxSummaryChars", "subagent.maxParallelChunkQueries", "subagent.stableSystemPrompt"] },
408
+ { id: "agent.hallucination", titleKey: "web.settings.sec.agent.hallucination", descKey: "web.settings.sec.agent.hallucination.desc", keys: ["hallucination.judge.enabled"] },
409
+ ],
410
+ network: [
411
+ { id: "network.web", titleKey: "web.settings.sec.network.web", descKey: "web.settings.sec.network.web.desc", keys: ["webSearch.enabled"] },
412
+ { id: "network.error", titleKey: "web.settings.sec.network.error", descKey: "web.settings.sec.network.error.desc", keys: ["errorWebSearch.enabled", "errorWebSearch.threshold", "errorWebSearch.maxResults", "errorWebSearch.maxQueryChars", "errorWebSearch.maxSearchesPerSession", "errorWebSearch.requestTimeoutMs"] },
413
+ ],
414
+ browser: [
415
+ { id: "browser.main", titleKey: "web.settings.sec.browser.main", keys: ["browser.enabled", "browser.headless"] },
416
+ { id: "browser.limits", titleKey: "web.settings.sec.browser.limits", descKey: "web.settings.sec.browser.limits.desc", keys: ["browser.maxElements", "browser.maxContentChars", "browser.maxConsoleEntries", "browser.maxConsoleLineChars"] },
417
+ { id: "browser.viewport", titleKey: "web.settings.sec.browser.viewport", keys: ["browser.viewportWidth", "browser.viewportHeight", "browser.navigationTimeout"] },
418
+ ],
419
+ sessions: [
420
+ { id: "sessions.main", titleKey: "web.settings.sec.sessions.main", descKey: "web.settings.sec.sessions.main.desc", keys: ["session.autoSave", "session.autoName", "session.maxSessions", "session.isolateMemory"] },
421
+ { id: "sessions.isolation", titleKey: "web.settings.sec.sessions.isolation", descKey: "web.settings.sec.sessions.isolation.desc", keys: ["sessionIsolation.enabled", "sessionIsolation.isolatePlugins", "sessionIsolation.isolateTempFiles"] },
422
+ ],
423
+ ui: [
424
+ { id: "ui.chat", titleKey: "web.settings.sec.ui.chat", descKey: "web.settings.sec.ui.chat.desc", keys: ["ui.spinner", "ui.showContextStats", "ui.showCompaction"] },
425
+ ],
426
+ security: [
427
+ { id: "security.switches", titleKey: "web.settings.sec.security.switches", descKey: "web.settings.sec.security.switches.desc", keys: ["security.enabled", "security.bash.enabled", "security.bash.blockDangerousFlags", "security.paths.enabled", "security.contentScan.enabled", "security.network.enabled", "security.sessionEncryption.enabled"] },
428
+ { id: "security.limits", titleKey: "web.settings.sec.security.limits", descKey: "web.settings.sec.security.limits.desc", keys: ["security.maxRecursionDepth", "security.maxFileOperations", "security.rateLimits.maxRequestsPerMinute", "security.rateLimits.maxParallelTasks", "security.network.requestTimeout", "security.network.maxResponseSize"] },
429
+ { id: "security.bash", titleKey: "web.settings.sec.security.bash", descKey: "web.settings.sec.security.bash.desc", keys: ["security.bash.blacklist", "security.bash.whitelist", "security.bash.dangerousFlags", "security.bash.dangerousOperators"] },
430
+ { id: "security.paths", titleKey: "web.settings.sec.security.paths", descKey: "web.settings.sec.security.paths.desc", keys: ["security.paths.denied", "security.paths.allowed"] },
431
+ { id: "security.network", titleKey: "web.settings.sec.security.network", descKey: "web.settings.sec.security.network.desc", keys: ["security.network.deniedDomains", "security.network.allowedDomains"] },
432
+ { id: "security.scan", titleKey: "web.settings.sec.security.scan", descKey: "web.settings.sec.security.scan.desc", keys: ["security.contentScan.dangerousPatterns"] },
433
+ { id: "security.audit", titleKey: "web.settings.sec.security.audit", descKey: "web.settings.sec.security.audit.desc", keys: ["security.auditNotifier.enabled", "security.auditNotifier.filePath", "security.auditNotifier.webhookUrl", "security.auditNotifier.webhookTimeout", "security.auditNotifier.minSeverity", "security.auditNotifier.maxRetries", "security.auditNotifier.eventTypes"] },
434
+ { id: "security.encryption", titleKey: "web.settings.sec.security.encryption", descKey: "web.settings.sec.security.encryption.desc", keys: ["security.sessionEncryption.encryptHistory", "security.sessionEncryption.encryptSessionLog", "security.sessionEncryption.keyPath"] },
435
+ ],
436
+ advanced: [
437
+ { id: "advanced.diagnostics", titleKey: "web.settings.sec.advanced.diagnostics", descKey: "web.settings.sec.advanced.diagnostics.desc", keys: ["logLevel", "version"] },
438
+ { id: "advanced.retry", titleKey: "web.settings.sec.advanced.retry", descKey: "web.settings.sec.advanced.retry.desc", keys: ["retry.maxRetries", "retry.baseDelay", "retry.maxDelay", "retry.maxStreamRetries", "retry.noDataTimeoutMs"] },
439
+ { id: "advanced.service", titleKey: "web.settings.sec.advanced.service", descKey: "web.settings.sec.advanced.service.desc", keys: ["pricing.enabled", "pricing.overrides", "updater.enabled", "updater.checkOnStart", "updater.autoInstall", "updater.intervalMs"] },
440
+ ],
441
+ };
442
+
443
+ /** Flat `key -> panelId` index (search + "where does this setting live"). */
444
+ export function keyToPanel() {
445
+ const map = new Map();
446
+ for (const [panel, sections] of Object.entries(PANEL_SECTIONS)) {
447
+ for (const section of sections) {
448
+ for (const key of section.keys) map.set(key, panel);
449
+ }
450
+ }
451
+ return map;
452
+ }