micro-models-agent 2.38.0 → 2.40.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 +48 -0
- package/dist/assets/app.js +1 -1
- package/dist/assets/js/feed/core.js +1 -1
- package/dist/assets/js/feed/history.js +1 -1
- package/dist/assets/js/loader.js +1 -1
- package/dist/assets/js/session/composer.js +1 -1
- package/dist/assets/js/settings/controls.js +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/i18n/en.json +1 -1
- package/dist/i18n/ru.json +1 -1
- package/dist/main.js +335 -337
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,54 @@ 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.40.0] - 2026-10-09
|
|
8
|
+
|
|
9
|
+
The web chat's work process steps back and the finished answer steps forward: answers get a
|
|
10
|
+
quiet translucent backdrop, reasoning stops shouting, the "jump to latest" pill sits where it
|
|
11
|
+
belongs, and user attachments are rendered properly and survive a page reload.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Answer backdrop** (`src/modules/webui/assets/styles.css`): `.feed > .md/.ans` now carry a muted, translucent accent fill (`--ans-bg`, both themes) next to the existing accent rail, so a finished answer reads instantly apart from the dim work process (think/tool/meta rows stay flat).
|
|
16
|
+
- **User attachments render properly** (`assets/js/feed/core.ts`, `assets/js/session/composer.ts`, `assets/js/feed/history.ts`): one shared `userBlock()` builder. Attachments form a `.u-attach` strip **above** the text (the `> ` prompt marker moves onto the text line); images become lazy `.uimg` thumbnails, other sources (file paths, non-image data URLs) become `.u-file` chips. Any number of attachments, live send / history replay / slash commands all use it.
|
|
17
|
+
- **User images persist** (`src/core/session-logger.ts`, `src/core/agent.ts`, `src/modules/webui/session/history-api.ts`): attached images are written into `<sessionDir>/images/` with the shared `images.maxCount`/`images.maxBytes` rotation; refs land on the `user` `session.jsonl` entry and the history API serves them as `/api/sessions/:id/images/:name` URLs, so previews come back after reload. Encrypted sessions behave like tool images (live inline, no history). `image-store` EXT gains `bmp`/`svg`/`avif`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **Reasoning is quieter** (`assets/styles.css`): `.think` renders at `.72` opacity (hover / live restore full weight) and its header uses `--dim-b` instead of the much brighter `--think`, so "thinking" no longer competes with the answer.
|
|
22
|
+
- **Jump-to-latest pill** (`assets/js/feed/core.ts`, `assets/styles.css`): anchored to `.input-area` (`bottom: calc(100% + 10px)`, same as `.menu`/`.cmdk`) instead of a hardcoded `bottom: 148px` on `.chat`, which drifted as the rail/textarea changed the composer height. Its entrance animation uses a new `popCenter` keyframe that keeps `translateX(-50%)` — plain `pop` ended at `transform: none` and made the pill flash in off-center before snapping to the middle.
|
|
23
|
+
- **`images.*` settings** are no longer tool-only: config labels and the Settings → UI section were reworded from "tool images" to cover tool outputs *and* user attachments (en + ru).
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **User message layout**: attachments used to append inline after the text (`> текст [img]`); they now stack above it.
|
|
28
|
+
|
|
29
|
+
## [2.39.0] - 2026-10-09
|
|
30
|
+
|
|
31
|
+
LSP is now a real language-server client instead of a one-shot linter: one warm server
|
|
32
|
+
process per `(server, project root)` with document sync, spec-correct diagnostics and a
|
|
33
|
+
tested JSON-RPC transport. The mascot reacts to LSP, and a native TypeScript engine
|
|
34
|
+
(`tsgo`) is one config key away.
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- **Persistent LSP client** (`src/modules/lsp/{connection,pool,client}.ts`): one server process per `(server, project root)`, kept warm for the session and reused across checks. Documents are synced with `didOpen`/`didChange` (full) / `didClose`; diagnostics are tracked per document version. Before, every `checkFile` (every `write_file`/`edit_file`, every file of `lsp_check`, 5 files of the startup check) spawned `npx -> node -> tsserver` and killed it after one push. The pool is LRU-capped (`LSP_MAX_SERVERS`), reaps idle connections (`LSP_SERVER_IDLE_MS`) and restarts a server that dies on its own; both are internal constants (`src/config/timeouts.ts`).
|
|
39
|
+
- **Spec-correct transport** (`src/modules/lsp/framing.ts`, `uri.ts`, `language.ts`): `Content-Length` framing accepts CRLF **and** LF separators; URIs are percent-encoded/decoded symmetrically (spaces, `#`, `%`, non-ASCII, Windows drives); one language-id table for both the protocol `languageId` and the `lsp.servers` key; client capabilities negotiate `general.positionEncodings`, `publishDiagnostics.versionSupport/relatedInformation`, pull diagnostics (`textDocument/diagnostic`) and `clientInfo`; server->client requests (`workspace/configuration`, `client/registerCapability`) are answered instead of leaving the server hanging.
|
|
40
|
+
- **Native TypeScript engine** (`src/modules/lsp/config.ts`, `src/config/registry-extra.ts`): `lsp.typescriptEngine: "typescript-language-server" | "tsgo"` selects the native TS7 preview (`tsgo --lsp --stdio`, `@typescript/native-preview`) for TS/JS; default stays classic. Surfaced in `/config`, Settings -> Plugins - LSP, and `/lsp status`.
|
|
41
|
+
- **LSP reactions for MMART** (`src/modules/webui/assets/js/loader.ts`, `assets/app.ts`, `styles.css`): new `check` and `warn` face states; `lsp_check` shows `check`, a completed check that found errors (or a `write_file`/`edit_file` with `[LSP errors]`) shows `warn`, and a failed/disabled server shows `error`.
|
|
42
|
+
- **`bun test` coverage for the transport**: `tests/modules/lsp/{framing,uri,language,connection,pool,client}.test.ts` plus `tests/helpers/fake-lsp-server.ts` (an in-memory server: real framing, correlation and timeouts, no child processes).
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **`LspClient.checkFile` returns `CheckResult`** (`{ diagnostics, inconclusive }`): a timeout no longer returns an empty list indistinguishable from "clean". `lsp_check` and the post-write hook say so explicitly; the model is not told "no errors" when the server stayed silent.
|
|
47
|
+
- **`LspModule` reports pool status** in `/lsp status` (warm servers / closed / restarts) and closes every server on `onSessionEnd`.
|
|
48
|
+
- **`severity` is optional per spec** (`src/modules/lsp/types.ts`): an absent severity is treated as an error (`isErrorDiagnostic`), so servers that omit it (or emit `0`, like clangd) are no longer silently dropped.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- **Leaked start timer** (`src/modules/lsp/connection.ts`): the per-spawn start-timeout timer is cleared; previously every check left a pending timeout of up to 30 s.
|
|
53
|
+
- **Structural `KillableProcess` type** (`src/modules/processes/kill-tree.ts`): the parameter accepts any `{ pid?, kill() }`, so the connection passes its own process wrapper without an unsafe cast. `ChildProcess` still satisfies it, so all callers are unchanged.
|
|
54
|
+
|
|
7
55
|
## [2.38.0] - 2026-10-09
|
|
8
56
|
|
|
9
57
|
Harness honesty for read-only work: the loop guard no longer treats "no mutation" as
|
package/dist/assets/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as V,inp as S,connStatus as A,setIcon as R,icon as q}from"./js/dom.js";import{api as X,token as P}from"./js/api.js";import{I18N as Y,t as a,loadI18n as Z}from"./js/i18n.js";import{tabs as f,session as p,settings as m,hooks as y}from"./js/store.js";import{routeState as $,mergeUsage as ee,storeSnapshot as B,applyCounters as F,shouldHydrateAutoOpen as te}from"./js/state-sync.js";import{onText as ne,onReasoning as se,onMeta as oe,onPhase as ie,onToolStart as ae,onToolEnd as re,onTurnEnd as de,onErrorEvent as ce,onCommandOutput as le,onLog as fe,onPlan as ue,onQuestion as pe,onRetract as be,showEmptyFeed as E,renderPlan as me,renderUsage as H,renderEnvironment as he,renderWorkspace as we,feedHasContent as ge,loadHistory as ve}from"./js/feed.js";import{openTab as I,updateTabName as Se,renderSessionsDropdown as L,reflectBusy as ye,loadSessions as M,loadCommands as Ee,setTabStatus as v,reconcileTabStatuses as Ie,readSavedTabs as Le}from"./js/session/tabs.js";import{renderSelectors as x,renderSettings as xe,loadConfig as N,loadModels as Te,loadProviders as Ce,loadMemory as ke,loadSkills as _e,loadPlugins as Ae,applyTheme as Re,currentTheme as qe,applyFontSize as Pe,setConnStatus as T,setStaleBar as O}from"./js/settings.js";import{initRail as Be,setPlan as U,railEvent as Fe,applyRailI18n as He}from"./js/rail.js";import{initSidebar as Me,sidebarSessionChanged as Ne,sidebarMapState as Oe,sidebarTraceEvent as C,sidebarTurnEnd as Ue,sidebarBusy as W,sidebarMapIndicator as We,sidebarPullLog as De,sidebarSessionId as je,setSessionLoading as ze,sidebarLspState as Ge,sidebarLspEvent as Je,applySidebarI18n as D,initFiles as Qe,sidebarFilesState as Ke,sidebarFilesChanged as j,sidebarPluginsState as Ve,sidebarPluginsEvent as Xe,initSidebarDrawer as Ye}from"./js/sidebar.js";import{insertIntoDraft as Ze}from"./js/session/composer.js";import{initCursor as $e,createFace as et,setFaceState as k,loaderStateFor as tt,setGreetResolver as nt}from"./js/loader.js";let h=null,w=0;function u(s){w++,k(h,s)}function st(){const s=document.getElementById("composerFace");s&&(h=et("idle","sm"),s.replaceChildren(h))}document.querySelectorAll("[data-collapse]").forEach(s=>{const e=s.querySelector(".arrow");e&&(e.textContent="",e.appendChild(q("chevron-down"))),s.addEventListener("click",()=>{const i=s.nextElementSibling;if(!i)return;const o=i.classList.toggle("collapsed");s.setAttribute("aria-expanded",o?"false":"true");const l=s.querySelector(".arrow");l&&(l.textContent="",l.appendChild(q(o?"chevron-right":"chevron-down")))})});let _=-1;function g(){const s=f.tabs.find(l=>l.id===f.activeTabId)||null,e=s&&s.state||{};p.host=e;const i=e.sessionId||s&&s.id||null;p.activeSessionId=i,f.tabs.length||E(),me(e.plan),U(p.busy&&e?e.plan:null),H(e),typeof e.contextWindow=="number"&&m.config&&m.config.contextWindow!==e.contextWindow&&(m.config.contextWindow=e.contextWindow,x()),he(e),Oe(e),We(e),Ge(),Ke(e),Ve();const o=typeof e.filesRevision=="number"?e.filesRevision:void 0;if(o!==void 0&&o!==_){const l=_===-1;_=o,!l&&o>0&&j()}Ne(i),we(e),L(),ze(!1),O(!!e.i18nStale)}function ot(s){const e=$(s);ye(),Ie(),s.state&&typeof s.state.sessionId=="string"&&Se(s.state.sessionId,s.state.sessionName),e&&g()}async function z(s){const e=s?"/api/state?session="+encodeURIComponent(s):"/api/state",i=await X(e);return i.ok&&i.data?i.data:null}async function G(s){const e=f.tabs.find(o=>o.id===s);if(!e)return;if(e.state){f.activeTabId===s&&g();return}const i=await z(s);i&&(B(i.state),f.activeTabId===s&&(F(i),g()))}async function J(){const s=f.activeTabId,e=await z(s);if(!e||f.activeTabId!==s)return;const i=e.state;if(!s&&i&&i.sessionId&&!f.tabs.some(o=>o.id===i.sessionId)){const o=te(p.sessions,i.sessionId);I(i.sessionId,i.sessionName||String(i.sessionId),"session",o)}B(i),F(e),g()}y.ensureTabState=G,y.renderActive=g;function it(){for(const e of f.tabs)e.kind==="session"&&(e.state=null,G(e.id));J(),M();const s=f.tabs.find(e=>e.id===f.activeTabId);s&&s.kind==="session"&&!ge(s.feed)&&(s.historyLoaded=!1,ve(s))}function at(){const s="/events"+(P?"?token="+encodeURIComponent(P):""),e=new EventSource(s);let i=!1;e.onopen=()=>{i&&(i=!1,T(!1),it())},e.onerror=t=>{t&&typeof t.data=="string"||(i=!0,T(!0))};const o=t=>{try{return JSON.parse(t.data)}catch{return null}},l=t=>!t.sessionId||t.sessionId===je(),d=[["text",t=>ne(t.chunk||"",t.sessionId)],["meta",t=>oe(t.chunk||"",t.sessionId,t.kind)],["reasoning",t=>se(t.chunk||"",t.sessionId)],["phase",t=>ie(t.phase,t.sessionId)],["tool_start",ae],["tool_end",re],["plan",ue],["question",pe],["turn_end",t=>{de(t),l(t)&&(Ue(t.turnSeq),W(!1),De())}],["log",fe],["retract",t=>be(t.reason||"",t.sessionId)]];for(const[t,n]of d)e.addEventListener(t,c=>{const b=o(c);b&&n(b)});for(const t of["tool_start","tool_end","text","plan"])e.addEventListener(t,n=>{const c=o(n);c&&(t==="plan"?U(c):Fe(t,c.name))});const r=[["tool_start","tool_start"],["tool_end","tool_end"],["text","text"],["question","question"],["error","error"]];for(const[t,n]of r)e.addEventListener(t,c=>{const b=o(c);b&&u(tt({type:n,name:typeof b.name=="string"?b.name:""}))});e.addEventListener("phase",t=>{const n=o(t),c=n&&typeof n.phase=="string"?n.phase:"";u(c==="composing"?"type":c==="tool"?"run":"think")}),e.addEventListener("reasoning",()=>u("think")),e.addEventListener("plan",()=>u("plan")),e.addEventListener("turn_end",t=>{const n=o(t);u(n&&n.success===!1&&!n.interrupted?"error":"done");const c=w;window.setTimeout(()=>{c===w&&k(h,"idle")},1500)}),e.addEventListener("retract",()=>u("error")),e.addEventListener("index",()=>u("find")),e.addEventListener("setup_done",()=>u("done")),e.addEventListener("update",t=>{const n=o(t);if(n&&n.phase==="failed"){u("error");return}u("update");const c=w;window.setTimeout(()=>{c===w&&k(h,"idle")},4e3)});for(const t of["text","reasoning","phase","tool_start","plan"])e.addEventListener(t,n=>{const c=o(n);c&&c.sessionId&&v(c.sessionId,"working")});e.addEventListener("question",t=>{const n=o(t);n&&n.sessionId&&v(n.sessionId,"waiting")}),e.addEventListener("turn_end",t=>{const n=o(t);n&&n.sessionId&&v(n.sessionId,n.success===!1&&!n.interrupted?"failed":"idle")});for(const t of["tool_start","tool_end","phase","plan","question","meta","log","retract","index"])e.addEventListener(t,n=>{const c=o(n);c&&l(c)&&C(t,c)});e.addEventListener("text",t=>{const n=o(t);n&&l(n)&&C("text",n)}),e.addEventListener("lsp",t=>{const n=o(t);n&&Je(n)}),e.addEventListener("files",()=>j()),e.addEventListener("plugins",()=>Xe()),e.addEventListener("config",()=>{N()}),e.addEventListener("command",t=>{const n=o(t);n&&typeof n.text=="string"&&le(n.text,n.sessionId)}),e.addEventListener("state",t=>{const n=o(t);n&&(W(!!n.busy),ot(n))}),e.addEventListener("sessions",t=>{const n=o(t);n&&Array.isArray(n.sessions)&&(p.sessions=n.sessions,L())}),e.addEventListener("usage",t=>{const n=o(t);if(!n||!n.usage||typeof n.usage!="object")return;const c=n.usageSessionId||n.sessionId||null;ee(c,n.usage)&&H(p.host)}),e.addEventListener("error",t=>{if(!t.data)return;const n=o(t);n&&(n.sessionId&&v(n.sessionId,"failed"),ce(n),C("error",n))})}function Q(){document.documentElement.lang=Y.locale;const s=(d,r)=>{const t=document.getElementById(d);t&&(t.textContent=r)};s("planHeaderLabel",a("web.sidebar.plan")),s("usageHeaderLabel",a("web.sidebar.session")+" · "+a("web.sidebar.usage")),s("envHeaderLabel",a("web.sidebar.env")),s("settingsTitle",a("web.settings.title")),s("sessActiveHeader",a("web.sessions.active")),s("sessRecentHeader",a("web.sessions.recent")),s("hintEnter",a("web.input.enter")),s("hintShift",a("web.input.shift_enter")),s("hintEsc",a("web.input.esc")),s("hintAttach",a("web.input.attach")),s("bootCap",a("web.loader.boot")),nt(()=>a("web.loader.greet"));const e=h?.querySelector(".mdl-tip");e&&(e.textContent=a("web.loader.greet"));const i={newChat:["plus",a("web.topbar.new_chat")],sessBtn:["menu",a("web.topbar.all_sessions")],toggleSidebar:["panel",a("web.topbar.sidebar")],openSettings:["settings",a("web.topbar.settings")],attachBtn:["image",a("web.attach.title")],closeSettings:["x",a("web.topbar.close")],sessNew:["plus",a("web.sessions.new")],sessRefresh:["refresh",a("web.sessions.refresh")],sessPrev:["chevron-left",a("web.sessbar.prev")],sessNext:["chevron-right",a("web.sessbar.next")],sessClose:["x",a("web.topbar.close")]};Object.keys(i).forEach(d=>{const r=document.getElementById(d);if(!r)return;const[t,n]=i[d];R(r,t,d==="closeSettings"||d==="sessNew"||d==="sessRefresh"?n:null),r.title=n,r.setAttribute("aria-label",n)});const o=document.getElementById("settingsIcon");o&&R(o,"settings",null),S&&(S.placeholder=a("web.input.placeholder"),S.setAttribute("aria-label",a("web.input.placeholder"))),document.querySelectorAll("#setMenu .mi").forEach(d=>{const r=d.dataset.p;r&&(d.textContent=a("web.settings."+r))});const l=document.getElementById("setSearch");l&&(l.setAttribute("placeholder",a("web.settings.search_placeholder")),l.setAttribute("aria-label",a("web.settings.search_placeholder"))),document.querySelectorAll(".content-col .panel").forEach(d=>{const r=d.querySelector("h3"),t=d.id.replace(/^p-/,"");r&&t&&(r.textContent=a("web.settings."+t))}),x(),L(),He(),D(),V.querySelector(".empty")&&E(),A&&!A.hidden&&T(!0),O(void 0,!0)}function rt(s){const e=Le(),i=r=>p.sessions.some(t=>t.id===r),o=r=>{const t=p.sessions.find(n=>n.id===r);return t&&t.name?String(t.name):r},l=(s&&i(s)?s:e.active&&i(e.active)?e.active:e.ids.find(i))||null,d=[];s&&i(s)&&d.push(s),l&&!d.includes(l)&&d.push(l);for(const r of e.ids)i(r)&&!d.includes(r)&&d.push(r);if(d.length){I(d[0],o(d[0]),"session",!0);for(const r of d.slice(1))I(r,o(r),"session",!1,!1)}}async function dt(){$e();const s=new URLSearchParams(location.search).get("session");if(window.MmaSetup)try{if(await window.MmaSetup.maybeOpen()){K();return}}catch{}try{await Z(),await Ee(),Re(qe()),Pe(),Q(),E(),x(),xe(),await N(),Be(m.config&&m.config.ui?m.config.ui.activityRail:void 0),st(),Me(),Ye(),D(),Qe({insertPath:e=>Ze("`"+e+"` ")}),await Te(),await Ce(),await M(),await ke(),await _e(),await Ae(),rt(s);try{await J()}catch(e){console.error("initial refresh failed",e)}}finally{K()}at()}function K(){const s=document.getElementById("bootSplash");!s||s.hidden||(s.classList.add("hide"),window.setTimeout(()=>{s.hidden=!0},500))}y.applyStaticI18n=Q,dt();
|
|
1
|
+
import{msgs as V,inp as S,connStatus as A,setIcon as R,icon as q}from"./js/dom.js";import{api as X,token as P}from"./js/api.js";import{I18N as Y,t as a,loadI18n as Z}from"./js/i18n.js";import{tabs as f,session as b,settings as m,hooks as y}from"./js/store.js";import{routeState as $,mergeUsage as ee,storeSnapshot as B,applyCounters as F,shouldHydrateAutoOpen as te}from"./js/state-sync.js";import{onText as se,onReasoning as ne,onMeta as oe,onPhase as ie,onToolStart as ae,onToolEnd as re,onTurnEnd as de,onErrorEvent as ce,onCommandOutput as le,onLog as fe,onPlan as ue,onQuestion as pe,onRetract as be,showEmptyFeed as E,renderPlan as me,renderUsage as H,renderEnvironment as he,renderWorkspace as ge,feedHasContent as we,loadHistory as ve}from"./js/feed.js";import{openTab as I,updateTabName as Se,renderSessionsDropdown as L,reflectBusy as ye,loadSessions as M,loadCommands as Ee,setTabStatus as v,reconcileTabStatuses as Ie,readSavedTabs as Le}from"./js/session/tabs.js";import{renderSelectors as x,renderSettings as xe,loadConfig as N,loadModels as Te,loadProviders as Ce,loadMemory as ke,loadSkills as _e,loadPlugins as Ae,applyTheme as Re,currentTheme as qe,applyFontSize as Pe,setConnStatus as T,setStaleBar as O}from"./js/settings.js";import{initRail as Be,setPlan as U,railEvent as Fe,applyRailI18n as He}from"./js/rail.js";import{initSidebar as Me,sidebarSessionChanged as Ne,sidebarMapState as Oe,sidebarTraceEvent as C,sidebarTurnEnd as Ue,sidebarBusy as W,sidebarMapIndicator as We,sidebarPullLog as De,sidebarSessionId as je,setSessionLoading as ze,sidebarLspState as Ge,sidebarLspEvent as Je,applySidebarI18n as D,initFiles as Qe,sidebarFilesState as Ke,sidebarFilesChanged as j,sidebarPluginsState as Ve,sidebarPluginsEvent as Xe,initSidebarDrawer as Ye}from"./js/sidebar.js";import{insertIntoDraft as Ze}from"./js/session/composer.js";import{initCursor as $e,createFace as et,setFaceState as k,loaderStateFor as tt,setGreetResolver as st}from"./js/loader.js";let h=null,g=0;function u(n){g++,k(h,n)}function nt(){const n=document.getElementById("composerFace");n&&(h=et("idle","sm"),n.replaceChildren(h))}document.querySelectorAll("[data-collapse]").forEach(n=>{const e=n.querySelector(".arrow");e&&(e.textContent="",e.appendChild(q("chevron-down"))),n.addEventListener("click",()=>{const i=n.nextElementSibling;if(!i)return;const o=i.classList.toggle("collapsed");n.setAttribute("aria-expanded",o?"false":"true");const l=n.querySelector(".arrow");l&&(l.textContent="",l.appendChild(q(o?"chevron-right":"chevron-down")))})});let _=-1;function w(){const n=f.tabs.find(l=>l.id===f.activeTabId)||null,e=n&&n.state||{};b.host=e;const i=e.sessionId||n&&n.id||null;b.activeSessionId=i,f.tabs.length||E(),me(e.plan),U(b.busy&&e?e.plan:null),H(e),typeof e.contextWindow=="number"&&m.config&&m.config.contextWindow!==e.contextWindow&&(m.config.contextWindow=e.contextWindow,x()),he(e),Oe(e),We(e),Ge(),Ke(e),Ve();const o=typeof e.filesRevision=="number"?e.filesRevision:void 0;if(o!==void 0&&o!==_){const l=_===-1;_=o,!l&&o>0&&j()}Ne(i),ge(e),L(),ze(!1),O(!!e.i18nStale)}function ot(n){const e=$(n);ye(),Ie(),n.state&&typeof n.state.sessionId=="string"&&Se(n.state.sessionId,n.state.sessionName),e&&w()}async function z(n){const e=n?"/api/state?session="+encodeURIComponent(n):"/api/state",i=await X(e);return i.ok&&i.data?i.data:null}async function G(n){const e=f.tabs.find(o=>o.id===n);if(!e)return;if(e.state){f.activeTabId===n&&w();return}const i=await z(n);i&&(B(i.state),f.activeTabId===n&&(F(i),w()))}async function J(){const n=f.activeTabId,e=await z(n);if(!e||f.activeTabId!==n)return;const i=e.state;if(!n&&i&&i.sessionId&&!f.tabs.some(o=>o.id===i.sessionId)){const o=te(b.sessions,i.sessionId);I(i.sessionId,i.sessionName||String(i.sessionId),"session",o)}B(i),F(e),w()}y.ensureTabState=G,y.renderActive=w;function it(){for(const e of f.tabs)e.kind==="session"&&(e.state=null,G(e.id));J(),M();const n=f.tabs.find(e=>e.id===f.activeTabId);n&&n.kind==="session"&&!we(n.feed)&&(n.historyLoaded=!1,ve(n))}function at(){const n="/events"+(P?"?token="+encodeURIComponent(P):""),e=new EventSource(n);let i=!1;e.onopen=()=>{i&&(i=!1,T(!1),it())},e.onerror=t=>{t&&typeof t.data=="string"||(i=!0,T(!0))};const o=t=>{try{return JSON.parse(t.data)}catch{return null}},l=t=>!t.sessionId||t.sessionId===je(),d=[["text",t=>se(t.chunk||"",t.sessionId)],["meta",t=>oe(t.chunk||"",t.sessionId,t.kind)],["reasoning",t=>ne(t.chunk||"",t.sessionId)],["phase",t=>ie(t.phase,t.sessionId)],["tool_start",ae],["tool_end",re],["plan",ue],["question",pe],["turn_end",t=>{de(t),l(t)&&(Ue(t.turnSeq),W(!1),De())}],["log",fe],["retract",t=>be(t.reason||"",t.sessionId)]];for(const[t,s]of d)e.addEventListener(t,c=>{const p=o(c);p&&s(p)});for(const t of["tool_start","tool_end","text","plan"])e.addEventListener(t,s=>{const c=o(s);c&&(t==="plan"?U(c):Fe(t,c.name))});const r=[["tool_start","tool_start"],["tool_end","tool_end"],["text","text"],["question","question"],["error","error"]];for(const[t,s]of r)e.addEventListener(t,c=>{const p=o(c);p&&u(tt({type:s,name:typeof p.name=="string"?p.name:"",success:p.success!==!1,...s==="tool_end"&&typeof p.output=="string"?{output:p.output}:{}}))});e.addEventListener("phase",t=>{const s=o(t),c=s&&typeof s.phase=="string"?s.phase:"";u(c==="composing"?"type":c==="tool"?"run":"think")}),e.addEventListener("reasoning",()=>u("think")),e.addEventListener("plan",()=>u("plan")),e.addEventListener("turn_end",t=>{const s=o(t);u(s&&s.success===!1&&!s.interrupted?"error":"done");const c=g;window.setTimeout(()=>{c===g&&k(h,"idle")},1500)}),e.addEventListener("retract",()=>u("error")),e.addEventListener("index",()=>u("find")),e.addEventListener("setup_done",()=>u("done")),e.addEventListener("update",t=>{const s=o(t);if(s&&s.phase==="failed"){u("error");return}u("update");const c=g;window.setTimeout(()=>{c===g&&k(h,"idle")},4e3)});for(const t of["text","reasoning","phase","tool_start","plan"])e.addEventListener(t,s=>{const c=o(s);c&&c.sessionId&&v(c.sessionId,"working")});e.addEventListener("question",t=>{const s=o(t);s&&s.sessionId&&v(s.sessionId,"waiting")}),e.addEventListener("turn_end",t=>{const s=o(t);s&&s.sessionId&&v(s.sessionId,s.success===!1&&!s.interrupted?"failed":"idle")});for(const t of["tool_start","tool_end","phase","plan","question","meta","log","retract","index"])e.addEventListener(t,s=>{const c=o(s);c&&l(c)&&C(t,c)});e.addEventListener("text",t=>{const s=o(t);s&&l(s)&&C("text",s)}),e.addEventListener("lsp",t=>{const s=o(t);s&&Je(s)}),e.addEventListener("files",()=>j()),e.addEventListener("plugins",()=>Xe()),e.addEventListener("config",()=>{N()}),e.addEventListener("command",t=>{const s=o(t);s&&typeof s.text=="string"&&le(s.text,s.sessionId)}),e.addEventListener("state",t=>{const s=o(t);s&&(W(!!s.busy),ot(s))}),e.addEventListener("sessions",t=>{const s=o(t);s&&Array.isArray(s.sessions)&&(b.sessions=s.sessions,L())}),e.addEventListener("usage",t=>{const s=o(t);if(!s||!s.usage||typeof s.usage!="object")return;const c=s.usageSessionId||s.sessionId||null;ee(c,s.usage)&&H(b.host)}),e.addEventListener("error",t=>{if(!t.data)return;const s=o(t);s&&(s.sessionId&&v(s.sessionId,"failed"),ce(s),C("error",s))})}function Q(){document.documentElement.lang=Y.locale;const n=(d,r)=>{const t=document.getElementById(d);t&&(t.textContent=r)};n("planHeaderLabel",a("web.sidebar.plan")),n("usageHeaderLabel",a("web.sidebar.session")+" · "+a("web.sidebar.usage")),n("envHeaderLabel",a("web.sidebar.env")),n("settingsTitle",a("web.settings.title")),n("sessActiveHeader",a("web.sessions.active")),n("sessRecentHeader",a("web.sessions.recent")),n("hintEnter",a("web.input.enter")),n("hintShift",a("web.input.shift_enter")),n("hintEsc",a("web.input.esc")),n("hintAttach",a("web.input.attach")),n("bootCap",a("web.loader.boot")),st(()=>a("web.loader.greet"));const e=h?.querySelector(".mdl-tip");e&&(e.textContent=a("web.loader.greet"));const i={newChat:["plus",a("web.topbar.new_chat")],sessBtn:["menu",a("web.topbar.all_sessions")],toggleSidebar:["panel",a("web.topbar.sidebar")],openSettings:["settings",a("web.topbar.settings")],attachBtn:["image",a("web.attach.title")],closeSettings:["x",a("web.topbar.close")],sessNew:["plus",a("web.sessions.new")],sessRefresh:["refresh",a("web.sessions.refresh")],sessPrev:["chevron-left",a("web.sessbar.prev")],sessNext:["chevron-right",a("web.sessbar.next")],sessClose:["x",a("web.topbar.close")]};Object.keys(i).forEach(d=>{const r=document.getElementById(d);if(!r)return;const[t,s]=i[d];R(r,t,d==="closeSettings"||d==="sessNew"||d==="sessRefresh"?s:null),r.title=s,r.setAttribute("aria-label",s)});const o=document.getElementById("settingsIcon");o&&R(o,"settings",null),S&&(S.placeholder=a("web.input.placeholder"),S.setAttribute("aria-label",a("web.input.placeholder"))),document.querySelectorAll("#setMenu .mi").forEach(d=>{const r=d.dataset.p;r&&(d.textContent=a("web.settings."+r))});const l=document.getElementById("setSearch");l&&(l.setAttribute("placeholder",a("web.settings.search_placeholder")),l.setAttribute("aria-label",a("web.settings.search_placeholder"))),document.querySelectorAll(".content-col .panel").forEach(d=>{const r=d.querySelector("h3"),t=d.id.replace(/^p-/,"");r&&t&&(r.textContent=a("web.settings."+t))}),x(),L(),He(),D(),V.querySelector(".empty")&&E(),A&&!A.hidden&&T(!0),O(void 0,!0)}function rt(n){const e=Le(),i=r=>b.sessions.some(t=>t.id===r),o=r=>{const t=b.sessions.find(s=>s.id===r);return t&&t.name?String(t.name):r},l=(n&&i(n)?n:e.active&&i(e.active)?e.active:e.ids.find(i))||null,d=[];n&&i(n)&&d.push(n),l&&!d.includes(l)&&d.push(l);for(const r of e.ids)i(r)&&!d.includes(r)&&d.push(r);if(d.length){I(d[0],o(d[0]),"session",!0);for(const r of d.slice(1))I(r,o(r),"session",!1,!1)}}async function dt(){$e();const n=new URLSearchParams(location.search).get("session");if(window.MmaSetup)try{if(await window.MmaSetup.maybeOpen()){K();return}}catch{}try{await Z(),await Ee(),Re(qe()),Pe(),Q(),E(),x(),xe(),await N(),Be(m.config&&m.config.ui?m.config.ui.activityRail:void 0),nt(),Me(),Ye(),D(),Qe({insertPath:e=>Ze("`"+e+"` ")}),await Te(),await Ce(),await M(),await ke(),await _e(),await Ae(),rt(n);try{await J()}catch(e){console.error("initial refresh failed",e)}}finally{K()}at()}function K(){const n=document.getElementById("bootSplash");!n||n.hidden||(n.classList.add("hide"),window.setTimeout(()=>{n.hidden=!0},500))}y.applyStaticI18n=Q,dt();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as
|
|
1
|
+
import{msgs as a,el as o,icon as g,setIcon as v}from"../dom.js";import{t as l,pluralCount as x}from"../i18n.js";import{streamStateFor as f,tabs as s}from"../store.js";import{formatMs as w,verbosity as T}from"../format.js";import{copyText as L}from"../../md.js";import{createFace as k}from"../loader.js";export function mdOpts(t){return{copyLabel:l("web.code.copy"),copiedLabel:l("web.code.copied"),copyFailedLabel:l("web.code.copy_failed"),animate:t===!0}}export function buildThinkBlock(t,e){const n=o("div","think"+(e===!1?"":" live")),i=o("button","think-h");i.type="button",i.setAttribute("aria-expanded","false"),i.appendChild(o("span","g","✦")),i.appendChild(o("span","lab",l("web.action.thinking"))),t&&i.appendChild(o("span","dur",""));const c=o("span","tog");v(c,"chevron-right",l("web.action.show")),i.appendChild(c);const r=o("div","think-body hidden");return n.appendChild(i),n.appendChild(r),{wrap:n,head:i,body:r}}export function userBlock(t,e){const n=o("div","u"),i=(e||[]).filter(r=>typeof r=="string"&&r.length>0);if(i.length){const r=o("div","u-attach");for(const C of i)r.appendChild(S(C));n.appendChild(r)}const c=o("div","u-text");return c.textContent=t||"",n.appendChild(c),n}function S(t){if(F(t)){const n=document.createElement("img");return n.className="uimg",n.alt="",n.loading="lazy",n.src=t,n}const e=o("div","u-file");return e.appendChild(g("file","u-file-ico")),e.appendChild(o("span","u-file-name",E(t))),e}function F(t){return/^data:/i.test(t)?/^data:image\//i.test(t):/\.(png|jpe?g|gif|webp|bmp|svg|avif|tiff?)(\?|#|$)/i.test(t)}function E(t){const e=/^data:([^;,]+)/i.exec(t);return e?e[1]:t.split(/[?#]/)[0].split(/[\\/]/).pop()||t}export function copyAction(t,e){const n=o("button","act-btn",l(e));return n.type="button",n.addEventListener("click",()=>{L(t).then(i=>{n.textContent=i?"✓ "+l("web.code.copied"):"⚠ "+l("web.code.copy_failed"),window.setTimeout(()=>{n.textContent=l(e)},1400)})}),n}export function appendActionsRow(t,e,n){const i=String(e??""),c=String(n??"");if(!t||!i.trim()&&!c.trim())return;const r=o("div","msg-actions");i.trim()&&r.appendChild(copyAction(i,"web.msg.copy")),c.trim()&&r.appendChild(copyAction(c,"web.msg.copy_md")),appendTo(t,r)}export function insertAfter(t,e){t&&t.parentNode?t.parentNode.insertBefore(e,t.nextSibling):appendTo(liveFeed(),e)}function m(){const t=o("div","empty");return t.appendChild(o("span","g","✦")),t.appendChild(document.createTextNode(" "+l("web.empty.title"))),t.appendChild(document.createElement("br")),t.appendChild(o("span","hint",l("web.empty.hint"))),t}export function makeFeed(){const t=o("div","feed");return t.appendChild(m()),t}export function showEmptyFeed(){a.replaceChildren(m()),p=!0,d(),syncUrl()}export function clearFeed(t){if(!t)return;t.replaceChildren(m()),p=!0,d();const e=s.tabs.find(n=>n.feed===t);e&&(e.planCard=null),t===activeFeed()&&scroll()}export function activeFeed(){const t=s.tabs.find(e=>e.id===s.activeTabId);return t?t.feed:null}export function liveFeed(){const t=s.tabs.find(e=>e.id===s.liveTabId)||s.tabs.find(e=>e.id===s.activeTabId);return t?t.feed:null}export function feedForEvent(t){if(t){const e=s.tabs.find(n=>n.id===t);if(e)return e.feed}return liveFeed()}function h(){return a.scrollHeight-a.scrollTop-a.clientHeight<140}let p=!0;export function scroll(t){t||p||h()?(a.scrollTop=a.scrollHeight,p=!0,d()):b()}export function scrollToBottom(t){if(p=!0,d(),t&&typeof a.scrollTo=="function")try{a.scrollTo({top:a.scrollHeight,behavior:"smooth"});return}catch{}a.scrollTop=a.scrollHeight}export function isFollowing(){return p}export function feedHasContent(t){return!!t.querySelector(".u, .md, .ans, .code, .act, .think, .metaln, .errline, .sysline, .detail")}export function syncUrl(){const t=new URL(location.href),e=s.tabs.find(n=>n.id===s.activeTabId);e&&e.kind==="session"?t.searchParams.set("session",e.id):t.searchParams.delete("session"),history.replaceState(null,"",t)}let u=null;function I(){if(u)return u;const t=document.querySelector(".input-area")||document.querySelector(".chat");return t?(u=o("button","to-latest"),u.type="button",u.hidden=!0,u.addEventListener("click",()=>scrollToBottom(!0)),t.appendChild(u),u):null}function b(){const t=I();t&&(t.textContent="↓ "+l("web.scroll.latest"),t.hidden=!1,a.classList.add("unfollowed"))}function d(){u&&(u.hidden=!0),a.classList.remove("unfollowed")}a?.addEventListener("scroll",()=>{const t=h();p=t,a.classList.toggle("scrolled",a.scrollTop>24),t?d():liveFeed()&&feedHasContent(liveFeed())&&b()});export function appendTo(t,e){return t&&(t.appendChild(e),t===activeFeed()&&scroll()),e}export function clearEmpty(t){const e=t&&t.querySelector(".empty");e&&e.remove()}export function clearBusy(t){if(t=t||liveFeed(),!t)return;const e=f(t);e.busyTimer&&(clearInterval(e.busyTimer),e.busyTimer=null);const n=t.querySelector(".busy");n&&n.remove()}export function showBusy(t){if(t=t||liveFeed(),!t)return;const e=f(t);if(e.curMd||e.curThink||(clearEmpty(t),t.querySelector(".busy")))return;e.busyTimer&&(clearInterval(e.busyTimer),e.busyTimer=null);const n=o("div","busy");n.appendChild(k("think","sm")),n.appendChild(o("span","lab",l("web.action.thinking")));const i=o("span","busytime","· 0s");n.appendChild(i),n.appendChild(o("span","","· "+l("web.input.esc"))),appendTo(t,n);const c=Date.now();e.busyTimer=setInterval(()=>{if(!n.parentNode){clearInterval(e.busyTimer),e.busyTimer=null;return}i.textContent="· "+Math.round((Date.now()-c)/1e3)+"s"},1e3)}export function flushRun(t){if(t=t||liveFeed(),!t)return;const e=f(t);if(e.runCount<=0){y(e);return}if(T()==="quiet"&&e.runReconOnly&&e.runFails===0&&e.runCount>1){const n=e.runNodes.slice();n.forEach(r=>r.classList.add("fold-out")),window.setTimeout(()=>n.forEach(r=>r.remove()),160);const i=o("div","grouped");i.appendChild(o("span","pipe","│"));const c=w(e.runDuration);i.appendChild(document.createTextNode(" "+x("web.action.actions",e.runCount)+" ✓"+(c?" · "+c:""))),appendTo(t,i)}y(e)}function y(t){t.runCount=0,t.runFails=0,t.runReconOnly=!0,t.runNodes=[],t.runDuration=0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{el as a}from"../dom.js";import{t as n}from"../i18n.js";import{categoryOf as c,labelOf as f,argText as u,formatMs as
|
|
1
|
+
import{el as a}from"../dom.js";import{t as n}from"../i18n.js";import{categoryOf as c,labelOf as f,argText as u,formatMs as m}from"../format.js";import{renderMarkdown as C}from"../../md.js";import{api as g}from"../api.js";import{imageCard as k}from"./image-card.js";import{feedHasContent as r,clearEmpty as x,scrollToBottom as h,activeFeed as v,liveFeed as w,mdOpts as A,buildThinkBlock as I,appendActionsRow as L,userBlock as T}from"./core.js";function H(i,e){const s=String(e??"");if(!s.trim())return;const o=C(i,s,A());L(i,o.innerText||o.textContent||"",s)}function B(i,e){const{wrap:s,body:o}=I(!1,!1);o.textContent=e==null?"":String(e),i.appendChild(s)}function F(i,e,s){const o=a("div","act "+c(e.name));o.appendChild(a("span","g","◇")),o.appendChild(a("span","lab",f(e.name)));const l=u(e.args);l&&(o.appendChild(a("span","sep","·")),o.appendChild(a("span","args",l)));const t=a("span","ok","");o.appendChild(t),i.appendChild(o),e.toolCallId&&s.set(e.toolCallId,t)}function S(i,e,s){const o=m(e.duration),l=(e.success?" ✓":" ✗")+(o?" "+o:""),t=e.toolCallId?s.get(e.toolCallId):null;if(t)t.textContent=l,e.success||t.classList.add("fail"),s.delete(e.toolCallId);else{const d=a("div","act "+c(e.tool));d.appendChild(a("span","g","↳")),d.appendChild(a("span","lab",f(e.tool))),d.appendChild(a("span","ok"+(e.success?"":" fail"),l)),i.appendChild(d)}if(e.success&&Array.isArray(e.images)&&e.images.length)for(const d of e.images){const p=k(String(e.tool||""),String(d));p&&i.appendChild(p)}}function M(i,e){const s=new Map;e.forEach(o=>{if(!(!o||typeof o.kind!="string"))switch(o.kind){case"user":i.appendChild(T(o.text||"",o.images));break;case"assistant":H(i,o.text||"");break;case"reasoning":B(i,o.text||"");break;case"tool_call":F(i,o,s);break;case"tool_result":S(i,o,s);break;case"plan":o.text&&i.appendChild(a("div","sysline","▸ "+o.text));break;case"context":o.text&&i.appendChild(a("div","detail","↳ "+o.text));break;case"error":i.appendChild(a("div","errline","✗ "+(o.text||"")));break;case"system":o.text&&i.appendChild(a("div","sysline",o.text));break}})}export async function loadHistory(i){if(!i||i.historyLoaded||i.historyLoading)return{gone:!!i.dead};i.historyLoading=!0;const e=a("div","detail",n("web.history.loading"));r(i.feed)||(x(i.feed),i.feed.appendChild(e));const s=await g("/api/sessions/"+encodeURIComponent(i.id)+"/history");if(i.historyLoading=!1,e.remove(),i.historyLoaded=!0,i.historyFailed=!1,!s.ok||!s.data||!Array.isArray(s.data.history))return s.status===404?{gone:!0}:(i.historyFailed=!0,r(i.feed)||i.feed.appendChild(a("div","detail",n("web.history.unavailable"))),{gone:!1});r(i.feed)||(M(i.feed,s.data.history),s.data.history.length||i.feed.appendChild(a("div","detail",n("web.history.empty"))),i.feed===v()?h():i.feed===w()&&h())}
|
package/dist/assets/js/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const w={idle:"c-dim track poke blink",think:"c-active st-think blink",read:"c-recon st-read",find:"c-recon st-find squint",web:"c-recon st-web squint",edit:"c-mutate st-edit narrow",type:"c-active st-type narrow",create:"c-mutate st-create",run:"c-exec st-run",tests:"c-exec st-tests",compact:"c-active st-compact",plan:"c-active st-plan",ask:"c-warn st-ask wide",done:"c-ok st-done happy celebrate",error:"c-err st-error sad",stop:"c-dim st-stop sleep",queued:"c-dim st-queued blink",boot:"c-dim st-boot",load:"c-dim st-load",update:"c-ok st-update happy",check:"c-recon st-check squint",warn:"c-warn st-warn squint"},_={read_file:"read",list_dir:"read",file_info:"read",load_skill:"read",session_info:"read",grep:"find",glob:"find",project_map:"find",chunk_query:"find",history:"find",recall:"find",search_history:"find",web_search:"web",web_fetch:"web",download_file:"web",web_browse:"web",write_file:"create",create_dir:"create",define_capability:"create",remember:"create",edit_file:"edit",move_file:"edit",delete_file:"edit",attach_image:"edit",bash:"run",pipeline_run:"run",process_wait:"run",process_kill:"run",browser:"run",subagent:"run",mcp_call:"run",enable_tools:"run",plan:"plan",todo:"plan",verify:"plan",lsp_check:"check",set_thinking:"think",approve:"ask",question:"ask",meet_done:"done"};export function lspOutputSignal(e){return e?e.includes("[LSP check failed")||e.includes("[LSP disabled")?"failed":e.includes("[LSP errors]")?"errors":null:null}export function toolState(e){return _[e]||"run"}export function loaderStateFor(e){switch(e.type){case"turn_end":return e.success===!1?"error":"done";case"error":case"retract":return"error";case"question":return"ask";case"text":return"type";case"tool_start":case"tool_end":{const n=e.name||"";if(n==="lsp_check"&&e.type==="tool_end"&&e.success===!1)return"warn";const t=lspOutputSignal(e.output);if(e.type==="tool_end"){if(t==="errors")return"warn";if(t==="failed")return"error"}return toolState(n)}case"index":return"find";case"setup_done":return"done";case"update":return"update";case"usage":case"state":case"config":case"files":case"sessions":case"plugins":case"log":return"idle";default:return"think"}}export const MMART_NAME="MMART";let h=()=>`Привет! Я ${MMART_NAME}`;export function setGreetResolver(e){h=e}function s(e,n,t){const r=document.createElement(e);return n&&(r.className=n),t!=null&&(r.textContent=t),r}export function createFace(e="think",n=null){const t=s("span");t.setAttribute("aria-hidden","true"),t.dataset.size=n||"";const r=s("span","eyes");r.appendChild(s("i","eye left")),r.appendChild(s("i","eye right"));const o=s("span","orb");o.appendChild(s("i"));const a=s("span","keys");for(let i=0;i<4;i++)a.appendChild(s("i"));const c=s("span","dust");for(let i=0;i<3;i++)c.appendChild(s("i"));return t.append(r,o,a,s("span","grow"),s("span","fly"),c,s("span","q","?"),s("span","spark","✦"),s("span","star"),s("span","mdl-tip")),setFaceState(t,e),t}export function setFaceState(e,n){if(!e)return;const t=e.dataset.size||"";e.className="mdl"+(t?" "+t:"")+" "+w[n],e.dataset.state=n,w[n].includes("track")||(e.style.setProperty("--ex","0px"),e.style.setProperty("--ey","0px"),e.style.setProperty("--tilt","0deg"))}const u=new WeakMap;function b(e){const n=e.querySelector(".mdl-tip");if(!n)return;n.textContent=h(),e.classList.add("show-tip");const t=u.get(e);t!==void 0&&window.clearTimeout(t),u.set(e,window.setTimeout(()=>{e.classList.remove("show-tip"),u.delete(e)},2200))}function p(e){return Array.from(document.querySelectorAll(e))}function x(e,n){for(const t of p(".mdl.track")){const r=t.getBoundingClientRect(),o=r.left+r.width/2,a=r.top+r.height/2,c=e-o,i=n-a,l=Math.hypot(c,i)||1,f=r.width*.16,d=Math.min(1,l/140),y=c/l,m=i/l;t.style.setProperty("--ex",(y*f*d).toFixed(1)+"px"),t.style.setProperty("--ey",(m*f*d).toFixed(1)+"px"),t.style.setProperty("--tilt",(y*6*d).toFixed(2)+"deg")}}function g(){for(const e of p(".mdl.track"))e.style.setProperty("--ex","0px"),e.style.setProperty("--ey","0px"),e.style.setProperty("--tilt","0deg")}function v(e){const n=e.target;return!n||typeof n.closest!="function"?null:n.closest(".mdl.poke")}let k=!1;export function initCursor(){if(k||typeof window>"u")return;k=!0,window.addEventListener("mousemove",n=>x(n.clientX,n.clientY)),window.addEventListener("mouseleave",g);let e=null;window.addEventListener("click",n=>{const t=p(".mdl.poke");if(t.length){for(const o of t)o.classList.remove("blink-once"),o.offsetWidth,o.classList.add("blink-once");e!==null&&window.clearTimeout(e),e=window.setTimeout(()=>{for(const o of t)o.classList.remove("blink-once");e=null},130)}const r=v(n);r&&b(r)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inp as i,imgPicker as g,attachStrip as B,attachErr as k,sendBtn as
|
|
1
|
+
import{inp as i,imgPicker as g,attachStrip as B,attachErr as k,sendBtn as m,el as p,icon as M}from"../dom.js";import{api as S}from"../api.js";import{t as c}from"../i18n.js";import{tabs as o,session as f,settings as T,MAX_IMAGES as C,MAX_IMAGE_BYTES as z}from"../store.js";import{contextLabel as Y}from"../format.js";import{clearEmpty as P,activeFeed as j,liveFeed as J,appendTo as v,scrollToBottom as N,clearFeed as Q,finishMd as V,resetTurnText as Z,finishThink as $,showBusy as tt,userBlock as F}from"../feed.js";import{setBusy as et}from"../rail.js";import"../core/menus.js";import{openSessionsMenu as nt}from"./sessions-menu.js";import{closeCmdk as O,updateCmdk as at,cmdkKeydown as st,initCmdk as it}from"./cmdk.js";let r={activeTab:()=>null,setTabStatus:()=>{},newChatTab:async()=>{},markTabDead:()=>{},openTab:()=>{},closeTab:()=>{},statusTitle:()=>""};export function initComposer(t){r={...r,...t}}it({autogrow:w});const ot=200;function w(){i&&(i.style.height="auto",i.style.height=Math.min(i.scrollHeight,ot)+"px")}function rt(t){k&&(k.textContent=t,k.hidden=!1,clearTimeout(o.attachErrTimer),o.attachErrTimer=setTimeout(()=>{k.hidden=!0},4e3))}export function renderAttachments(){if(!B)return;B.textContent="",B.hidden=o.attachments.length===0,o.attachments.forEach((e,n)=>{const a=p("div","thumb"),s=document.createElement("img");s.alt="",s.src=e,a.appendChild(s);const d=p("button","rm");d.type="button",d.title=c("web.attach.remove"),d.setAttribute("aria-label",c("web.attach.remove")),d.appendChild(M("x")),d.addEventListener("click",()=>{o.attachments.splice(n,1),renderAttachments()}),a.appendChild(d),B.appendChild(a)});const t=r.activeTab();t&&(t.attachments=o.attachments.slice())}function ct(t){return new Promise((e,n)=>{const a=new FileReader;a.onload=()=>e(String(a.result)),a.onerror=()=>n(a.error||new Error("read failed")),a.readAsDataURL(t)})}async function x(t){let e="";for(const n of t){if(!n||typeof n.type!="string"||n.type.indexOf("image/")!==0){e=c("web.attach.only_images");continue}if(o.attachments.length>=C){e=c("web.attach.too_many",{max:C});break}if(n.size>z){e=c("web.attach.too_large");continue}try{const a=await ct(n);if(a.indexOf("data:image/")!==0){e=c("web.attach.invalid");continue}if(o.attachments.length>=C){e=c("web.attach.too_many",{max:C});break}o.attachments.push(a)}catch{e=c("web.attach.read_failed")}}renderAttachments(),e&&rt(e)}export function saveComposer(){const t=r.activeTab();!t||!i||(t.draft=i.value,t.attachments=o.attachments.slice())}export function restoreComposer(t){!t||!i||(i.value=t.draft||"",o.attachments=(t.attachments||[]).slice(),renderAttachments(),w(),O())}const dt=document.getElementById("sessBar"),I=document.getElementById("sessNameBtn"),lt=document.getElementById("sessName"),L=document.getElementById("sessPrev"),A=document.getElementById("sessNext"),D=document.getElementById("sessClose"),X=document.getElementById("sessTools"),q=document.getElementById("sessDD"),y=document.querySelector(".bar-top"),E=document.getElementById("newChat"),_=document.createComment("top-tools");y&&E&&y.insertBefore(_,E);function U(t){if(o.tabs.length<2)return;const e=o.tabs.findIndex(s=>s.id===o.activeTabId),n=e===-1?0:(e+t+o.tabs.length)%o.tabs.length,a=o.tabs[n];a&&r.openTab(a.id,a.name,a.kind,!0)}export function renderSessBar(){if(!dt)return;const t=o.tabs.find(a=>a.id===o.activeTabId),e=t?t.name||String(t.id):"—";lt.textContent=e,I.title=e+(t&&t.status&&t.status!=="idle"?" · "+r.statusTitle(t.status):"");const n=o.tabs.length>0;L.disabled=o.tabs.length<2,A.disabled=o.tabs.length<2,D.disabled=!n,I.disabled=!n}function G(){!y||!X||!E||!q||(window.matchMedia("(max-width: 760px)").matches?X.append(E,q):(y.insertBefore(E,_),y.insertBefore(q,_)))}if(L&&L.addEventListener("click",()=>U(-1)),A&&A.addEventListener("click",()=>U(1)),D&&D.addEventListener("click",()=>{o.activeTabId&&r.closeTab(o.activeTabId)}),I&&I.addEventListener("click",t=>{t.stopPropagation(),nt()}),typeof window.matchMedia=="function"){const t=window.matchMedia("(max-width: 760px)");typeof t.addEventListener=="function"&&t.addEventListener("change",G),G()}g&&g.addEventListener("change",()=>{x(Array.from(g.files||[])),g.value=""});const H=document.getElementById("attachBtn");H&&g&&H.addEventListener("click",()=>g.click()),i.addEventListener("paste",t=>{const e=t.clipboardData&&t.clipboardData.items;if(!e)return;const n=[];for(const a of e)if(a.kind==="file"&&a.type&&a.type.indexOf("image/")===0){const s=a.getAsFile();s&&n.push(s)}n.length&&(t.preventDefault(),x(n))});const h=document.querySelector(".input-area");h&&(["dragenter","dragover"].forEach(t=>{h.addEventListener(t,e=>{e.preventDefault(),h.classList.add("dragover")})}),h.addEventListener("dragleave",t=>{const e=t;e.relatedTarget&&h.contains(e.relatedTarget)||h.classList.remove("dragover")}),h.addEventListener("drop",t=>{t.preventDefault(),h.classList.remove("dragover");const e=t.dataTransfer;e&&e.files&&e.files.length&&x(Array.from(e.files))}));function K(){i.value="",w(),O()}export function insertIntoDraft(t){if(!i||!t)return;const e=i.selectionStart??i.value.length,n=i.selectionEnd??e;i.value=i.value.slice(0,e)+t+i.value.slice(n);const a=e+t.length;i.selectionStart=i.selectionEnd=a;const s=r.activeTab();s&&(s.draft=i.value),w(),i.focus()}i&&i.addEventListener("input",()=>{const t=r.activeTab();t&&(t.draft=i.value),w(),at()});async function R(){const t=i.value.trim(),e=o.attachments.slice();if(!t&&!e.length)return;!r.activeTab()&&!t.startsWith("/")&&await r.newChatTab();const n=r.activeTab(),a=n&&n.kind==="session"?n.id:null,s=J()||j();if(n&&n.dead){P(s),r.markTabDead(n.id);return}if(P(s),V(s),Z(s),$(s),t.startsWith("/")){v(s,F(t)),N(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),K();const u=t.slice(1).split(/\s+/)[0].toLowerCase();if(u==="clear"){Q(s);return}if(u==="new"){r.newChatTab();return}const b={line:t};a&&(b.sessionId=a),(await S("/api/command",{method:"POST",body:b})).ok||v(s,p("div","detail","↳ "+c("web.misc.command_unavailable")));return}if(s&&s.querySelector(".startbanner")===null&&s.querySelector(".u")===null){const u=p("div","startbanner");u.appendChild(document.createTextNode(c("web.start.label")+" ")),u.appendChild(p("b","",T.config&&T.config.model||f.host.model||"—"));const b=f.host.sessionId?" · "+c("web.start.session")+" "+String(f.host.sessionId):"";u.appendChild(document.createTextNode(" · "+(f.host.provider||T.config&&T.config.provider&&T.config.provider.active||"—")+" · "+Y()+b)),s.insertBefore(u,s.firstChild)}v(s,F(t,e)),N(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),K(),a&&r.setTabStatus(a,"working");const d={text:t};e.length&&(d.images=e),a&&(d.sessionId=a);const l=await S("/api/message",{method:"POST",body:d});if(l.ok)if(l.data&&l.data.noop)l.data.notice&&v(s,p("div","detail",String(l.data.notice)));else if(l.data&&l.data.queued){const u=l.data.queuedForSession||l.data.queued;v(s,p("div","detail","↳ "+c("web.input.queued",{n:u}))),a&&r.setTabStatus(a,"queued")}else window.setTimeout(()=>tt(s),180);else{const u=l.data&&l.data.error||l.status,b=u==="queue_full"?c("web.input.queue_full"):u;v(s,p("div","warnline","⚠ "+b)),a&&r.setTabStatus(a,"failed")}}async function W(){const t=r.activeTab(),e=t&&t.kind==="session"?t.id:null,n=f.runningSessionIds||[];e&&!n.includes(e)||!e&&!f.busy||await S("/api/interrupt",{method:"POST",body:e?{sessionId:e}:{}})}i.addEventListener("keydown",t=>{t.isComposing||t.keyCode===229||st(t)||(t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),R()):t.key==="Escape"&&(t.preventDefault(),W()))}),m&&m.addEventListener("click",()=>{const t=r.activeTab();t&&t.kind==="session"&&f.runningSessionIds.includes(t.id)?W():R()});export function reflectBusy(){const t=r.activeTab(),e=f.runningSessionIds||[],n=!!(t&&t.kind==="session"&&e.includes(t.id));i&&i.setAttribute("aria-busy",n?"true":"false");const a=document.querySelector(".input-area");if(a&&a.classList.toggle("busy",n),m){const d=n?c("web.input.stop"):c("web.input.send");m.textContent="",m.appendChild(M(n?"square":"arrow-up")),m.classList.toggle("busy",n),m.title=d,m.setAttribute("aria-label",d)}const s=document.getElementById("hintEsc");s&&(s.hidden=!n),et(f.busy)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{el as a,makeToggle as g}from"../dom.js";import{tagsEditor as b,checkboxEditor as p,tableEditor as w}from"./editors.js";export function validateJson(i){const e=String(i??"").trim();if(!e)return{ok:!1,error:"required"};try{return JSON.parse(e),{ok:!0}}catch(t){return{ok:!1,error:t instanceof Error?t.message:"invalid JSON"}}}function u(i,e){const t=a("input");return t.setAttribute("aria-label",i),t.value=e,t}function m(i,e,t){const l=t.optionsSource==="providers"?e.providerOptions||[]:e.modelOptions||[],s=typeof i=="string"?i:"";if(!l.length){const o=u(e.label,s);return o.addEventListener("change",()=>e.post(o.value)),o}const n=a("select");n.setAttribute("aria-label",e.label);const c=a("option","",e.emptyLabel||"—");c.value="",n.appendChild(c);const d=new Set([""]);if(l.forEach(o=>{if(d.has(o))return;d.add(o);const y=a("option","",o);y.value=o,o===s&&(y.selected=!0),n.appendChild(y)}),s&&!d.has(s)){const o=a("option","",s);o.value=s,o.selected=!0,n.appendChild(o)}return n.value=s||"",n.addEventListener("change",()=>e.post(n.value)),n}export function controlFor(i,e,t){if(i.readOnly){const s=a("span","val dim",e==null?"—":String(e));return e!=null&&(s.title=String(e)),s}if(i.valueType==="bool")return g(!!e,s=>(t.post(s),!0));if(i.valueType==="enum"){const s=a("select");return s.setAttribute("aria-label",t.label),(i.enum||[]).forEach(n=>{const c=a("option","",t.enumLabel(n));c.value=n,n===e&&(c.selected=!0),s.appendChild(c)}),s.addEventListener("change",()=>t.post(s.value)),s}if(i.valueType==="int"){const s=u(t.label,e==null?"":String(e));return s.type="number",i.min!=null&&(s.min=String(i.min)),i.max!=null&&(s.max=String(i.max)),i.step!=null&&(s.step=String(i.step)),s.addEventListener("change",()=>t.post(s.value)),s}if(i.valueType==="share"){const s=u(t.label,e==null?"":Math.round(Number(e)*100)+"%");return s.addEventListener("change",()=>t.post(s.value)),s}const r=i.editor;if(r&&r.kind==="select")return m(e,t,r);if(r&&r.kind==="tags"&&(i.valueType==="list"||i.valueType==="json"))return b(e,t,r);if(r&&r.kind==="checkboxes")return p(e,t,r);if(r&&r.kind==="table")return w(e,t,r);if(i.valueType==="list"){const s=Array.isArray(e)?e.join(", "):e==null?"":String(e),n=u(t.label,s);return n.placeholder="a, b, c",n.addEventListener("change",()=>t.post(n.value)),n}if(i.valueType==="json"){const s=a("div","jsonctl"),n=a("textarea");n.setAttribute("aria-label",t.label),n.rows=3,n.value=e==null?"":JSON.stringify(e,null,2);const c=a("div","json-err");return c.hidden=!0,n.addEventListener("input",()=>{const d=validateJson(n.value);c.hidden=d.ok,c.textContent=d.ok?"":String(d.error||"invalid JSON")}),n.addEventListener("change",()=>{validateJson(n.value).ok?t.post(n.value.trim()):n.focus()}),s.appendChild(n),s.appendChild(c),s}const l=u(t.label,e==null?"":String(e));return l.addEventListener("change",()=>t.post(l.value)),l}export const PANEL_SECTIONS={general:[{id:"general.interface",titleKey:"web.settings.sec.general.interface",keys:["locale","ui.verbosity"]},{id:"general.agent",titleKey:"web.settings.sec.general.agent",descKey:"web.settings.sec.general.agent.desc",keys:["maxToolIterations","stuckThreshold","autoPlan","execution.autoAdvance"]},{id:"general.provider",titleKey:"web.settings.sec.general.provider",keys:["provider.fallback"]}],model:[{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"]},{id:"model.capabilities",titleKey:"web.settings.sec.model.capabilities",descKey:"web.settings.sec.model.capabilities.desc",keys:["modelCapabilities"]}],context:[{id:"context.window",titleKey:"web.settings.sec.context.window",descKey:"web.settings.sec.context.window.desc",keys:["contextWindow","contextAuto","contextBudget.systemPrompt","contextBudget.responseReserve"]},{id:"context.compaction",titleKey:"web.settings.sec.context.compaction",descKey:"web.settings.sec.context.compaction.desc",keys:["contextBudget.compactionThreshold","contextBudget.compactionMinLoad","contextBudget.policy","contextBudget.compactionSummary","contextBudget.overflowCooldown","contextBudget.toolResultKeep","contextBudget.calibrationWarmup","contextBudget.ratioFloor"]},{id:"context.instructions",titleKey:"web.settings.sec.context.instructions",descKey:"web.settings.sec.context.instructions.desc",keys:["instructions.summarize"]},{id:"context.indexer",titleKey:"web.settings.sec.context.indexer",descKey:"web.settings.sec.context.indexer.desc",keys:["indexer.maxFiles","indexer.respectGitignore","indexer.mapTokenBudget"]},{id:"context.log",titleKey:"web.settings.sec.context.log",descKey:"web.settings.sec.context.log.desc",keys:["contextLog.enabled","contextLog.redact"]}],reasoning:[{id:"reasoning.display",titleKey:"web.settings.sec.reasoning.display",keys:["showReasoning"]},{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"]}],agent:[{id:"agent.moe",titleKey:"web.settings.sec.agent.moe",descKey:"web.settings.sec.agent.moe.desc",keys:["moe.enabled","moe.maxReplanCycles","moe.parallelSubtasks","orchestrator.model","orchestrator.provider","orchestrator.contextWindow","experts"]},{id:"agent.critic",titleKey:"web.settings.sec.agent.critic",descKey:"web.settings.sec.agent.critic.desc",keys:["critic.enabled","critic.model","critic.provider","critic.tools","critic.maxCalls","critic.maxRepairCycles","critic.timeoutMs"]},{id:"agent.tools",titleKey:"web.settings.sec.agent.tools",descKey:"web.settings.sec.agent.tools.desc",keys:["tools.enableOnDemand","tools.defaultTags","tools.grepEngine","skills.budget"]},{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","subagent.timeoutMs"]},{id:"agent.hallucination",titleKey:"web.settings.sec.agent.hallucination",descKey:"web.settings.sec.agent.hallucination.desc",keys:["hallucination.judge.enabled"]}],network:[{id:"network.web",titleKey:"web.settings.sec.network.web",descKey:"web.settings.sec.network.web.desc",keys:["webSearch.enabled"]},{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"]},{id:"network.service",titleKey:"web.settings.sec.network.service",descKey:"web.settings.sec.network.service.desc",keys:["service.port","service.host","service.token","service.resultRetentionDays","service.idempotencyTtlHours","service.syncWaitMs","service.maxQueueLength","service.callbackTimeoutMs","service.webhookSecret"]}],browser:[{id:"browser.main",titleKey:"web.settings.sec.browser.main",keys:["browser.enabled","browser.headless"]},{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"]},{id:"browser.viewport",titleKey:"web.settings.sec.browser.viewport",keys:["browser.viewportWidth","browser.viewportHeight","browser.navigationTimeout"]}],sessions:[{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"]},{id:"sessions.isolation",titleKey:"web.settings.sec.sessions.isolation",descKey:"web.settings.sec.sessions.isolation.desc",keys:["sessionIsolation.enabled","sessionIsolation.isolatePlugins","sessionIsolation.isolateTempFiles"]}],ui:[{id:"ui.chat",titleKey:"web.settings.sec.ui.chat",descKey:"web.settings.sec.ui.chat.desc",keys:["ui.fontSize","ui.activityRail","ui.spinner","ui.showContextStats","ui.showCompaction"]},{id:"ui.images",titleKey:"web.settings.sec.ui.images",descKey:"web.settings.sec.ui.images.desc",keys:["images.maxCount","images.maxBytes"]}],security:[{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"]},{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"]},{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"]},{id:"security.paths",titleKey:"web.settings.sec.security.paths",descKey:"web.settings.sec.security.paths.desc",keys:["security.paths.denied","security.paths.allowed"]},{id:"security.network",titleKey:"web.settings.sec.security.network",descKey:"web.settings.sec.security.network.desc",keys:["security.network.deniedDomains","security.network.allowedDomains"]},{id:"security.scan",titleKey:"web.settings.sec.security.scan",descKey:"web.settings.sec.security.scan.desc",keys:["security.contentScan.dangerousPatterns"]},{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"]},{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"]}],advanced:[{id:"advanced.diagnostics",titleKey:"web.settings.sec.advanced.diagnostics",descKey:"web.settings.sec.advanced.diagnostics.desc",keys:["logLevel","version"]},{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"]},{id:"advanced.service",titleKey:"web.settings.sec.advanced.service",descKey:"web.settings.sec.advanced.service.desc",keys:["pricing.enabled","pricing.overrides","updater.enabled","updater.autoInstall","updater.intervalMs"]}],plugins:[{id:"plugins.registry",titleKey:"web.settings.sec.plugins.registry",descKey:"web.settings.sec.plugins.registry.desc",keys:["plugins.disabled","plugins.maxDrafts"]},{id:"plugins.lsp",titleKey:"web.settings.sec.plugins.lsp",descKey:"web.settings.sec.plugins.lsp.desc",keys:["lsp.enabled","lsp.offline"]}]};export function keyToPanel(){const i=new Map;for(const[e,t]of Object.entries(PANEL_SECTIONS))for(const r of t)for(const l of r.keys)i.set(l,e);return i}
|
|
1
|
+
import{el as a,makeToggle as g}from"../dom.js";import{tagsEditor as b,checkboxEditor as p,tableEditor as w}from"./editors.js";export function validateJson(i){const e=String(i??"").trim();if(!e)return{ok:!1,error:"required"};try{return JSON.parse(e),{ok:!0}}catch(t){return{ok:!1,error:t instanceof Error?t.message:"invalid JSON"}}}function u(i,e){const t=a("input");return t.setAttribute("aria-label",i),t.value=e,t}function m(i,e,t){const l=t.optionsSource==="providers"?e.providerOptions||[]:e.modelOptions||[],s=typeof i=="string"?i:"";if(!l.length){const o=u(e.label,s);return o.addEventListener("change",()=>e.post(o.value)),o}const n=a("select");n.setAttribute("aria-label",e.label);const c=a("option","",e.emptyLabel||"—");c.value="",n.appendChild(c);const d=new Set([""]);if(l.forEach(o=>{if(d.has(o))return;d.add(o);const y=a("option","",o);y.value=o,o===s&&(y.selected=!0),n.appendChild(y)}),s&&!d.has(s)){const o=a("option","",s);o.value=s,o.selected=!0,n.appendChild(o)}return n.value=s||"",n.addEventListener("change",()=>e.post(n.value)),n}export function controlFor(i,e,t){if(i.readOnly){const s=a("span","val dim",e==null?"—":String(e));return e!=null&&(s.title=String(e)),s}if(i.valueType==="bool")return g(!!e,s=>(t.post(s),!0));if(i.valueType==="enum"){const s=a("select");return s.setAttribute("aria-label",t.label),(i.enum||[]).forEach(n=>{const c=a("option","",t.enumLabel(n));c.value=n,n===e&&(c.selected=!0),s.appendChild(c)}),s.addEventListener("change",()=>t.post(s.value)),s}if(i.valueType==="int"){const s=u(t.label,e==null?"":String(e));return s.type="number",i.min!=null&&(s.min=String(i.min)),i.max!=null&&(s.max=String(i.max)),i.step!=null&&(s.step=String(i.step)),s.addEventListener("change",()=>t.post(s.value)),s}if(i.valueType==="share"){const s=u(t.label,e==null?"":Math.round(Number(e)*100)+"%");return s.addEventListener("change",()=>t.post(s.value)),s}const r=i.editor;if(r&&r.kind==="select")return m(e,t,r);if(r&&r.kind==="tags"&&(i.valueType==="list"||i.valueType==="json"))return b(e,t,r);if(r&&r.kind==="checkboxes")return p(e,t,r);if(r&&r.kind==="table")return w(e,t,r);if(i.valueType==="list"){const s=Array.isArray(e)?e.join(", "):e==null?"":String(e),n=u(t.label,s);return n.placeholder="a, b, c",n.addEventListener("change",()=>t.post(n.value)),n}if(i.valueType==="json"){const s=a("div","jsonctl"),n=a("textarea");n.setAttribute("aria-label",t.label),n.rows=3,n.value=e==null?"":JSON.stringify(e,null,2);const c=a("div","json-err");return c.hidden=!0,n.addEventListener("input",()=>{const d=validateJson(n.value);c.hidden=d.ok,c.textContent=d.ok?"":String(d.error||"invalid JSON")}),n.addEventListener("change",()=>{validateJson(n.value).ok?t.post(n.value.trim()):n.focus()}),s.appendChild(n),s.appendChild(c),s}const l=u(t.label,e==null?"":String(e));return l.addEventListener("change",()=>t.post(l.value)),l}export const PANEL_SECTIONS={general:[{id:"general.interface",titleKey:"web.settings.sec.general.interface",keys:["locale","ui.verbosity"]},{id:"general.agent",titleKey:"web.settings.sec.general.agent",descKey:"web.settings.sec.general.agent.desc",keys:["maxToolIterations","stuckThreshold","autoPlan","execution.autoAdvance"]},{id:"general.provider",titleKey:"web.settings.sec.general.provider",keys:["provider.fallback"]}],model:[{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"]},{id:"model.capabilities",titleKey:"web.settings.sec.model.capabilities",descKey:"web.settings.sec.model.capabilities.desc",keys:["modelCapabilities"]}],context:[{id:"context.window",titleKey:"web.settings.sec.context.window",descKey:"web.settings.sec.context.window.desc",keys:["contextWindow","contextAuto","contextBudget.systemPrompt","contextBudget.responseReserve"]},{id:"context.compaction",titleKey:"web.settings.sec.context.compaction",descKey:"web.settings.sec.context.compaction.desc",keys:["contextBudget.compactionThreshold","contextBudget.compactionMinLoad","contextBudget.policy","contextBudget.compactionSummary","contextBudget.overflowCooldown","contextBudget.toolResultKeep","contextBudget.calibrationWarmup","contextBudget.ratioFloor"]},{id:"context.instructions",titleKey:"web.settings.sec.context.instructions",descKey:"web.settings.sec.context.instructions.desc",keys:["instructions.summarize"]},{id:"context.indexer",titleKey:"web.settings.sec.context.indexer",descKey:"web.settings.sec.context.indexer.desc",keys:["indexer.maxFiles","indexer.respectGitignore","indexer.mapTokenBudget"]},{id:"context.log",titleKey:"web.settings.sec.context.log",descKey:"web.settings.sec.context.log.desc",keys:["contextLog.enabled","contextLog.redact"]}],reasoning:[{id:"reasoning.display",titleKey:"web.settings.sec.reasoning.display",keys:["showReasoning"]},{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"]}],agent:[{id:"agent.moe",titleKey:"web.settings.sec.agent.moe",descKey:"web.settings.sec.agent.moe.desc",keys:["moe.enabled","moe.maxReplanCycles","moe.parallelSubtasks","orchestrator.model","orchestrator.provider","orchestrator.contextWindow","experts"]},{id:"agent.critic",titleKey:"web.settings.sec.agent.critic",descKey:"web.settings.sec.agent.critic.desc",keys:["critic.enabled","critic.model","critic.provider","critic.tools","critic.maxCalls","critic.maxRepairCycles","critic.timeoutMs"]},{id:"agent.tools",titleKey:"web.settings.sec.agent.tools",descKey:"web.settings.sec.agent.tools.desc",keys:["tools.enableOnDemand","tools.defaultTags","tools.grepEngine","skills.budget"]},{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","subagent.timeoutMs"]},{id:"agent.hallucination",titleKey:"web.settings.sec.agent.hallucination",descKey:"web.settings.sec.agent.hallucination.desc",keys:["hallucination.judge.enabled"]}],network:[{id:"network.web",titleKey:"web.settings.sec.network.web",descKey:"web.settings.sec.network.web.desc",keys:["webSearch.enabled"]},{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"]},{id:"network.service",titleKey:"web.settings.sec.network.service",descKey:"web.settings.sec.network.service.desc",keys:["service.port","service.host","service.token","service.resultRetentionDays","service.idempotencyTtlHours","service.syncWaitMs","service.maxQueueLength","service.callbackTimeoutMs","service.webhookSecret"]}],browser:[{id:"browser.main",titleKey:"web.settings.sec.browser.main",keys:["browser.enabled","browser.headless"]},{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"]},{id:"browser.viewport",titleKey:"web.settings.sec.browser.viewport",keys:["browser.viewportWidth","browser.viewportHeight","browser.navigationTimeout"]}],sessions:[{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"]},{id:"sessions.isolation",titleKey:"web.settings.sec.sessions.isolation",descKey:"web.settings.sec.sessions.isolation.desc",keys:["sessionIsolation.enabled","sessionIsolation.isolatePlugins","sessionIsolation.isolateTempFiles"]}],ui:[{id:"ui.chat",titleKey:"web.settings.sec.ui.chat",descKey:"web.settings.sec.ui.chat.desc",keys:["ui.fontSize","ui.activityRail","ui.spinner","ui.showContextStats","ui.showCompaction"]},{id:"ui.images",titleKey:"web.settings.sec.ui.images",descKey:"web.settings.sec.ui.images.desc",keys:["images.maxCount","images.maxBytes"]}],security:[{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"]},{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"]},{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"]},{id:"security.paths",titleKey:"web.settings.sec.security.paths",descKey:"web.settings.sec.security.paths.desc",keys:["security.paths.denied","security.paths.allowed"]},{id:"security.network",titleKey:"web.settings.sec.security.network",descKey:"web.settings.sec.security.network.desc",keys:["security.network.deniedDomains","security.network.allowedDomains"]},{id:"security.scan",titleKey:"web.settings.sec.security.scan",descKey:"web.settings.sec.security.scan.desc",keys:["security.contentScan.dangerousPatterns"]},{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"]},{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"]}],advanced:[{id:"advanced.diagnostics",titleKey:"web.settings.sec.advanced.diagnostics",descKey:"web.settings.sec.advanced.diagnostics.desc",keys:["logLevel","version"]},{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"]},{id:"advanced.service",titleKey:"web.settings.sec.advanced.service",descKey:"web.settings.sec.advanced.service.desc",keys:["pricing.enabled","pricing.overrides","updater.enabled","updater.autoInstall","updater.intervalMs"]}],plugins:[{id:"plugins.registry",titleKey:"web.settings.sec.plugins.registry",descKey:"web.settings.sec.plugins.registry.desc",keys:["plugins.disabled","plugins.maxDrafts"]},{id:"plugins.lsp",titleKey:"web.settings.sec.plugins.lsp",descKey:"web.settings.sec.plugins.lsp.desc",keys:["lsp.enabled","lsp.offline","lsp.typescriptEngine"]}]};export function keyToPanel(){const i=new Map;for(const[e,t]of Object.entries(PANEL_SECTIONS))for(const r of t)for(const l of r.keys)i.set(l,e);return i}
|