micro-models-agent 2.5.0 → 2.8.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.
@@ -9,6 +9,8 @@
9
9
  </head>
10
10
  <body>
11
11
 
12
+ <div class="setup-gate" id="setupGate" hidden></div>
13
+
12
14
  <div class="bar-top">
13
15
  <button class="icon-btn primary" id="newChat" title="new chat" aria-label="new chat">+</button>
14
16
  <div class="dd" id="sessDD">
@@ -24,6 +26,7 @@
24
26
  </div>
25
27
  </div>
26
28
  <div class="tabstrip" id="tabstrip"></div>
29
+ <button class="icon-btn" id="toggleSidebar" title="sidebar" aria-label="sidebar" aria-expanded="false">▤</button>
27
30
  <button class="icon-btn" id="openSettings" title="settings" aria-label="settings" aria-haspopup="dialog" aria-expanded="false">⚙</button>
28
31
  <span class="conn" id="connStatus" role="status" aria-live="polite" hidden></span>
29
32
  </div>
@@ -90,6 +93,7 @@
90
93
  <div class="mi" data-p="model">Model &amp; Provider</div>
91
94
  <div class="mi" data-p="context">Context</div>
92
95
  <div class="mi" data-p="reasoning">Reasoning</div>
96
+ <div class="mi" data-p="agent">Agent</div>
93
97
  <div class="mi" data-p="ui">UI &amp; Theme</div>
94
98
  <div class="mi" data-p="memory">Memory</div>
95
99
  <div class="mi" data-p="skills">Skills</div>
@@ -102,6 +106,7 @@
102
106
  <div class="panel" id="p-model"><h3>Model &amp; Provider</h3><div class="rows" data-panel="model"></div></div>
103
107
  <div class="panel" id="p-context"><h3>Context</h3><div class="rows" data-panel="context"></div></div>
104
108
  <div class="panel" id="p-reasoning"><h3>Reasoning</h3><div class="rows" data-panel="reasoning"></div></div>
109
+ <div class="panel" id="p-agent"><h3>Agent</h3><div class="rows" data-panel="agent"></div></div>
105
110
  <div class="panel" id="p-ui"><h3>UI &amp; Theme</h3><div class="rows" data-panel="ui"></div></div>
106
111
  <div class="panel" id="p-memory"><h3>Memory</h3><div class="rows" data-panel="memory"></div></div>
107
112
  <div class="panel" id="p-skills"><h3>Skills</h3><div class="rows" data-panel="skills"></div></div>
@@ -126,6 +131,15 @@
126
131
  </div>
127
132
  </div>
128
133
 
129
- <script src="/app.js"></script>
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>
138
+ </div>
139
+ </div>
140
+
141
+ <script defer src="/hljs.js"></script>
142
+ <script src="/setup.js"></script>
143
+ <script type="module" src="/app.js"></script>
130
144
  </body>
131
145
  </html>
@@ -0,0 +1,28 @@
1
+ // REST helper for the `mma web` frontend. The `?token=` query carries auth
2
+ // for non-loopback binds (EventSource and fetch share it); same-origin POSTs
3
+ // additionally rely on the `mma_web_auth` cookie the server sets.
4
+
5
+ export const token = new URLSearchParams(location.search).get("token") || "";
6
+
7
+ export async function api(path, opts = {}) {
8
+ const headers = Object.assign({}, opts.headers || {});
9
+ if (opts.body !== undefined) headers["content-type"] = "application/json";
10
+ if (token) headers["x-mma-token"] = token;
11
+ let res;
12
+ try {
13
+ res = await fetch(path, {
14
+ method: opts.method || "GET",
15
+ headers,
16
+ body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,
17
+ });
18
+ } catch (err) {
19
+ return { ok: false, status: 0, data: null };
20
+ }
21
+ let data = null;
22
+ try {
23
+ data = await res.json();
24
+ } catch (err) {
25
+ data = null;
26
+ }
27
+ return { ok: res.ok, status: res.status, data };
28
+ }
@@ -0,0 +1,105 @@
1
+ // Chrome primitives: save toast + generic confirmation dialog.
2
+ // Leaf module (dom + i18n only) so tabs and settings can both use it.
3
+ import { saveIndicator } from "./dom.js";
4
+ import { t } from "./i18n.js";
5
+
6
+ let indicatorTimer = null;
7
+ const indicatorQueue = [];
8
+ let indicatorShowing = false;
9
+
10
+ function showNextIndicator() {
11
+ if (!saveIndicator) return;
12
+ const next = indicatorQueue.shift();
13
+ if (next === undefined) {
14
+ indicatorShowing = false;
15
+ return;
16
+ }
17
+ indicatorShowing = true;
18
+ saveIndicator.textContent = next.msg;
19
+ saveIndicator.classList.toggle("fail", !!next.fail);
20
+ saveIndicator.classList.add("show");
21
+ clearTimeout(indicatorTimer);
22
+ indicatorTimer = setTimeout(() => {
23
+ saveIndicator.classList.remove("show");
24
+ // Brief gap so a repeated message visibly re-appears instead of blending.
25
+ setTimeout(showNextIndicator, 150);
26
+ }, 2400);
27
+ }
28
+
29
+ // Save toast. Overlapping messages queue (cap 3) instead of overwriting —
30
+ // a single message behaves exactly as before (2.4s, then hide).
31
+ export function setIndicator(msg, fail) {
32
+ if (!saveIndicator) return;
33
+ indicatorQueue.push({ msg, fail });
34
+ if (indicatorQueue.length > 3) indicatorQueue.splice(0, indicatorQueue.length - 3);
35
+ if (!indicatorShowing) showNextIndicator();
36
+ }
37
+
38
+ // Keep Tab cycling inside an open overlay dialog (focus trap). The confirm
39
+ // dialog keeps its own two-button variant below — it always traps, even with
40
+ // a single visible action.
41
+ export function trapTab(container, e) {
42
+ if (e.key !== "Tab") return;
43
+ const items = Array.from(
44
+ container.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])'),
45
+ ).filter((node) => node.offsetParent !== null);
46
+ if (!items.length) return;
47
+ const first = items[0];
48
+ const last = items[items.length - 1];
49
+ if (e.shiftKey && document.activeElement === first) {
50
+ e.preventDefault();
51
+ last.focus();
52
+ } else if (!e.shiftKey && document.activeElement === last) {
53
+ e.preventDefault();
54
+ first.focus();
55
+ }
56
+ }
57
+
58
+ export const confirmOverlay = document.getElementById("confirmOverlay");
59
+ const confirmTitle = document.getElementById("confirmTitle");
60
+ const confirmMsg = document.getElementById("confirmMsg");
61
+ const confirmAccept = document.getElementById("confirmAccept");
62
+ const confirmCancel = document.getElementById("confirmCancel");
63
+ let confirmOnAccept = null;
64
+ let confirmReturnFocus = null;
65
+
66
+ export function openConfirm(opts) {
67
+ if (!confirmOverlay) return;
68
+ confirmReturnFocus = document.activeElement;
69
+ confirmTitle.textContent = opts.title || "";
70
+ confirmMsg.textContent = opts.body || "";
71
+ confirmAccept.textContent = opts.acceptLabel || t("web.sessions.delete");
72
+ confirmCancel.textContent = opts.cancelLabel || t("web.action.cancel");
73
+ confirmOnAccept = opts.onAccept || null;
74
+ confirmOverlay.classList.add("open");
75
+ setTimeout(() => confirmCancel.focus(), 0);
76
+ }
77
+
78
+ export function closeConfirm() {
79
+ if (!confirmOverlay || !confirmOverlay.classList.contains("open")) return;
80
+ confirmOverlay.classList.remove("open");
81
+ confirmOnAccept = null;
82
+ if (confirmReturnFocus && confirmReturnFocus.focus) confirmReturnFocus.focus();
83
+ confirmReturnFocus = null;
84
+ }
85
+
86
+ if (confirmOverlay) {
87
+ confirmCancel.addEventListener("click", closeConfirm);
88
+ confirmAccept.addEventListener("click", () => {
89
+ const fn = confirmOnAccept;
90
+ closeConfirm();
91
+ if (fn) fn();
92
+ });
93
+ confirmOverlay.addEventListener("click", (e) => {
94
+ // Keep clicks inside the dialog from reaching the global handler, so the
95
+ // sessions dropdown stays open behind it.
96
+ e.stopPropagation();
97
+ if (e.target === confirmOverlay) closeConfirm();
98
+ });
99
+ // Keep Tab between the two actions while the dialog is open.
100
+ confirmOverlay.addEventListener("keydown", (e) => {
101
+ if (e.key !== "Tab") return;
102
+ e.preventDefault();
103
+ (document.activeElement === confirmAccept ? confirmCancel : confirmAccept).focus();
104
+ });
105
+ }
@@ -0,0 +1,157 @@
1
+ // DOM refs + tiny element builders for the `mma web` frontend.
2
+ // No dependencies: every other module builds on these.
3
+
4
+ export const msgs = document.getElementById("msgs");
5
+ export const inp = document.getElementById("inp");
6
+ export const tabstripEl = document.getElementById("tabstrip");
7
+ export const planEl = document.getElementById("plan");
8
+ export const planCountEl = document.getElementById("planCount");
9
+ export const usageEl = document.getElementById("usage");
10
+ export const envEl = document.getElementById("env");
11
+ export const wsLine = document.getElementById("wsLine");
12
+ export const saveIndicator = document.getElementById("saveIndicator");
13
+ export const attachStrip = document.getElementById("attachStrip");
14
+ export const attachErr = document.getElementById("attachErr");
15
+ export const imgPicker = document.getElementById("imgPicker");
16
+ export const connStatus = document.getElementById("connStatus");
17
+ export const liveEl = document.getElementById("live");
18
+ export const sendBtn = document.getElementById("sendBtn");
19
+
20
+ // Announce a short status line to assistive tech (turn end, warnings/errors).
21
+ // Clearing first forces repeats to be re-announced.
22
+ export function announce(text) {
23
+ if (!liveEl || !text) return;
24
+ liveEl.textContent = "";
25
+ setTimeout(() => {
26
+ liveEl.textContent = text;
27
+ }, 30);
28
+ }
29
+
30
+ export function el(tag, cls, text) {
31
+ const node = document.createElement(tag);
32
+ if (cls) node.className = cls;
33
+ if (text != null) node.textContent = text;
34
+ return node;
35
+ }
36
+
37
+ // --- Lucide icons (MIT), inlined: chrome only. Chat status glyphs (◇ ✓ ✗ ✦ ⟡ …)
38
+ // stay textual per docs/design/ui/STYLE.md; icons replace emoji/gear chrome.
39
+ export const SVG_NS = "http://www.w3.org/2000/svg";
40
+ export const ICONS = {
41
+ plus: [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]],
42
+ menu: [
43
+ ["line", { x1: 4, y1: 6, x2: 20, y2: 6 }],
44
+ ["line", { x1: 4, y1: 12, x2: 20, y2: 12 }],
45
+ ["line", { x1: 4, y1: 18, x2: 20, y2: 18 }],
46
+ ],
47
+ settings: [
48
+ ["path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }],
49
+ ["circle", { cx: 12, cy: 12, r: 3 }],
50
+ ],
51
+ image: [
52
+ ["rect", { width: 18, height: 18, x: 3, y: 3, rx: 2, ry: 2 }],
53
+ ["circle", { cx: 9, cy: 9, r: 2 }],
54
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }],
55
+ ],
56
+ x: [["path", { d: "M18 6 6 18" }], ["path", { d: "m6 6 12 12" }]],
57
+ trash: [
58
+ ["path", { d: "M3 6h18" }],
59
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }],
60
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }],
61
+ ["line", { x1: 10, y1: 11, x2: 10, y2: 17 }],
62
+ ["line", { x1: 14, y1: 11, x2: 14, y2: 17 }],
63
+ ],
64
+ refresh: [
65
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }],
66
+ ["path", { d: "M21 3v5h-5" }],
67
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }],
68
+ ["path", { d: "M8 21H3v-5" }],
69
+ ],
70
+ "chevron-down": [["path", { d: "m6 9 6 6 6-6" }]],
71
+ "chevron-right": [["path", { d: "m9 18 6-6-6-6" }]],
72
+ "arrow-up": [["path", { d: "M12 19V5" }], ["path", { d: "m5 12 7-7 7 7" }]],
73
+ panel: [
74
+ ["rect", { width: 18, height: 18, x: 3, y: 3, rx: 2, ry: 2 }],
75
+ ["line", { x1: 15, y1: 3, x2: 15, y2: 21 }],
76
+ ],
77
+ square: [["rect", { width: 14, height: 14, x: 5, y: 5, rx: 2 }]],
78
+ copy: [
79
+ ["rect", { width: 14, height: 14, x: 8, y: 8, rx: 2, ry: 2 }],
80
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }],
81
+ ],
82
+ check: [["path", { d: "M20 6 9 17l-5-5" }]],
83
+ };
84
+
85
+ export function icon(name, cls) {
86
+ const svg = document.createElementNS(SVG_NS, "svg");
87
+ svg.setAttribute("viewBox", "0 0 24 24");
88
+ svg.setAttribute("fill", "none");
89
+ svg.setAttribute("stroke", "currentColor");
90
+ svg.setAttribute("stroke-width", "2");
91
+ svg.setAttribute("stroke-linecap", "round");
92
+ svg.setAttribute("stroke-linejoin", "round");
93
+ svg.setAttribute("aria-hidden", "true");
94
+ svg.setAttribute("focusable", "false");
95
+ svg.setAttribute("class", "svg-icon" + (cls ? " " + cls : ""));
96
+ (ICONS[name] || []).forEach(([tag, attrs]) => {
97
+ const child = document.createElementNS(SVG_NS, tag);
98
+ Object.keys(attrs).forEach((k) => child.setAttribute(k, String(attrs[k])));
99
+ svg.appendChild(child);
100
+ });
101
+ return svg;
102
+ }
103
+
104
+ // Replace a node's contents with an icon + optional label, keeping it a real
105
+ // control. Returns the label node so callers can preserve text-only updates.
106
+ export function setIcon(button, name, label) {
107
+ if (!button) return null;
108
+ button.textContent = "";
109
+ button.appendChild(icon(name));
110
+ if (label != null) button.appendChild(el("span", "", label));
111
+ return button;
112
+ }
113
+
114
+ // Accessible on/off switch (`role=switch`). `onFlip(next)` runs on click; the
115
+ // switch flips itself only when `onFlip` returns truthy — async callers that
116
+ // re-render instead (MCP list) return nothing and keep server truth.
117
+ export function makeToggle(on, onFlip) {
118
+ const b = el("button", "toggle" + (on ? " on" : ""));
119
+ b.type = "button";
120
+ b.setAttribute("role", "switch");
121
+ b.setAttribute("aria-checked", on ? "true" : "false");
122
+ b.addEventListener("click", () => {
123
+ const next = !b.classList.contains("on");
124
+ if (onFlip(next)) {
125
+ b.classList.toggle("on", next);
126
+ b.setAttribute("aria-checked", next ? "true" : "false");
127
+ }
128
+ });
129
+ return b;
130
+ }
131
+
132
+ // Text action control (`edit`, `forget`, `add`, …) as a focusable <button>.
133
+ export function link(label, cls, onClick) {
134
+ const b = el("button", "linkbtn" + (cls ? " " + cls : ""), label);
135
+ b.type = "button";
136
+ b.addEventListener("click", onClick);
137
+ return b;
138
+ }
139
+
140
+ // Render raw memory text (`- **date** -- **pattern:** body`) as safe DOM nodes:
141
+ // `**…**` spans become <b>, everything else stays a text node. Never uses
142
+ // innerHTML, so untrusted/model-written content cannot inject markup.
143
+ export function inlineTextNodes(text) {
144
+ const frag = document.createDocumentFragment();
145
+ const raw = String(text == null ? "" : text).replace(/^-\s*/, "");
146
+ raw.split("**").forEach((part, i) => {
147
+ if (part === "") return;
148
+ if (i % 2 === 1) {
149
+ const b = document.createElement("b");
150
+ b.textContent = part;
151
+ frag.appendChild(b);
152
+ } else {
153
+ frag.appendChild(document.createTextNode(part));
154
+ }
155
+ });
156
+ return frag;
157
+ }