micro-models-agent 2.35.1 → 2.36.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 +24 -2
- package/dist/assets/app.js +1 -1
- package/dist/assets/js/core/store/feed.js +1 -1
- package/dist/assets/js/core/store/index.js +1 -1
- package/dist/assets/js/feed/core.js +1 -1
- package/dist/assets/js/feed/sidebar.js +1 -1
- package/dist/assets/js/feed/stream.js +1 -1
- package/dist/assets/js/feed/turn.js +4 -4
- package/dist/assets/js/loader.js +1 -1
- package/dist/assets/js/session/composer.js +1 -1
- package/dist/assets/js/session/tabs.js +1 -1
- package/dist/assets/js/settings/controls.js +1 -1
- package/dist/assets/js/settings/write.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 +226 -226
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ 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.36.0] - 2026-10-08
|
|
8
|
+
|
|
9
|
+
`mma web` fixes from a live two-tab session (a background session's stream
|
|
10
|
+
leaked into the active tab, Settings showed a stale value after slash-command
|
|
11
|
+
config writes, an interrupted turn reported success, the context probe compared
|
|
12
|
+
against the history budget instead of the window, open tabs were lost on
|
|
13
|
+
reload), a context selector that can take the window from the provider
|
|
14
|
+
(`contextAuto`, default on), and the agent's mascot: the loader face is now
|
|
15
|
+
named **MMART** (MMA + art), greets on click, and maps every tool and
|
|
16
|
+
agent-facing SSE event to a distinct face state.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **Context selector: `auto`** (`assets/js/settings/write.ts`, `config/registry-extra.ts`, `modules/webui/settings/context-auto.ts`, `core/agent.ts`, `core/bootstrap/provider-phase.ts`): the composer context dropdown gains an `auto` item (button reads `context: auto`) that takes the window from the provider for the active model. It is backed by the new `contextAuto` config key — default **on**, so the existing probe behaviour is unchanged; enabling it probes the provider immediately and applies the result (fail-open, the provider staying silent is announced with `web.selectors.auto_failed` instead of a plain "saved"). Writing a concrete `contextWindow` (selector, `/context`, `mma context`) pins the value: the probe no longer overrides it on start or on model/provider switch. Toggled from the selector menu, `/config contextAuto` or Settings → Context. Tests: `tests/config/context-auto.test.ts`, `tests/webui-config.test.ts`, guard in `tests/webui-assets.test.ts`.
|
|
21
|
+
- **MMART — the mascot** (`src/modules/webui/assets/js/loader.ts`, `assets/app.ts`, `assets/styles.css`, `src/i18n/{en,ru}.json`): the loader face gets a name (**MMART** = MMA + art). Clicking the face itself pops a localized greeting bubble (`web.loader.greet`) for 2.2s — a click anywhere else still only blinks it, so the greeting is not a page-wide easter egg; repeated clicks restart the timer. The bubble's font is floored (`max(12px, …)`), because scaling it by the face size produced unreadable ~4.6px text on the 22px face. The greeting text is injected via `setGreetResolver` from `app.ts` (so `loader.ts` stays import-safe under `bun test`) and is re-bound on locale switch. `TOOL_STATE` now gives every core tool a behavioural state instead of the generic `run`: `approve`/`question` → `ask`, `web_browse` → `web`, `load_skill`/`session_info` → `read`, `search_history` → `find`, `define_capability`/`remember` → `create`, `set_thinking` → `think`, `enable_tools` → `run`, `meet_done` → `done`. `loaderStateFor` covers the remaining agent-facing SSE (`retract` → error, `index` → find, `setup_done` → done); background broadcasts (`usage`/`state`/`config`/`files`/`sessions`/`plugins`/`log`) map to `idle` and are deliberately not wired to `faceEvent`, as they are not agent activity. Tests in `tests/webui-loader.test.ts`.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **Cross-tab stream bleed** (`src/modules/webui/assets/js/core/store/feed.ts`, `feed/stream.ts`, `feed/turn.ts`, `feed/core.ts`): streaming/turn/tool bookkeeping moved from one global cursor to a per-feed state (`streamStateFor(feed)`), keyed by the tab's feed element. With two sessions streaming at once, text, reasoning, the tool map (`pendingArgs`/`toolNodes`, where ids like `t1` collide across runners) and turn accumulators no longer bleed into the active tab. `finishMd`/`finishThink`/`flushRun`/`resetTurnText` are now session-scoped.
|
|
26
|
+
- **Stale Settings after slash-command config writes** (`src/modules/webui/chat/commands-shared.ts`, `settings/config-api.ts`, `assets/app.ts`): config writes now broadcast a `config` SSE event; the client re-reads `/api/config`, so the open Settings panel and composer selectors update immediately (`/verbose`, `/config`, `/reasoning`, …) instead of only after a reload.
|
|
27
|
+
- **Interrupted turn reported as "ok"** (`src/core/agent.ts`, `src/core/types.ts`, `src/modules/webui/session/run-agent.ts`): `AgentResult.interrupted` is set on `shutdown`/AbortError and forwarded in `turn_end`; the feed shows `stopped` (not `turn end · ok`) and success is no longer reported for an aborted turn.
|
|
28
|
+
- **Context probe label** (`src/modules/webui/assets/js/feed/sidebar.ts`): the probe's "configured" value now uses the true configured window (`h.contextWindow`) instead of the history budget (`h.contextLimit`, ~75%), which made a 1000K config read as "750.0K configured".
|
|
29
|
+
- **Tabs lost on reload** (`src/modules/webui/assets/js/session/tabs.ts`, `assets/app.ts`): the set of open session tabs and the active one are persisted to `localStorage` (`mma-open-tabs`) and restored on boot before `refresh()`; the URL `?session=` still wins as the active tab for deep links.
|
|
30
|
+
|
|
7
31
|
## [2.35.1] - 2026-10-08
|
|
8
32
|
|
|
9
33
|
Closing the last tab in `mma web` now resets the session instead of leaving a
|
|
@@ -511,8 +535,6 @@ background-process leaks. Harness fixes only (no model/task-specific tuning).
|
|
|
511
535
|
- **`resolve.ts`** — extracted npx→global-binary resolution (`findOnPath`, `resolveNpxLaunch`) shared by the client and the doctor.
|
|
512
536
|
- **Docs**: `docs/agents/tools.md` "LSP in locked-down networks" (PATH binaries, `lsp.servers.<lang>` overrides, registry mirror via `env`, `MMA_LSP_OFFLINE`, classes table).
|
|
513
537
|
|
|
514
|
-
## [Unreleased]
|
|
515
|
-
|
|
516
538
|
## [2.17.2] - 2026-10-04
|
|
517
539
|
|
|
518
540
|
### Changed
|
package/dist/assets/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as K,inp as S,connStatus as k,setIcon as _,icon as A}from"./js/dom.js";import{api as V,token as R}from"./js/api.js";import{I18N as X,t as a,loadI18n as Y}from"./js/i18n.js";import{tabs as l,session as u,settings as b,hooks as v}from"./js/store.js";import{routeState as Z,mergeUsage as $,storeSnapshot as q,applyCounters as P,shouldHydrateAutoOpen as ee}from"./js/state-sync.js";import{onText as te,onReasoning as se,onMeta as ne,onPhase as oe,onToolStart as ie,onToolEnd as ae,onTurnEnd as re,onErrorEvent as de,onCommandOutput as ce,onLog as le,onPlan as fe,onQuestion as ue,onRetract as pe,showEmptyFeed as y,renderPlan as be,renderUsage as B,renderEnvironment as me,renderWorkspace as he,feedHasContent as we,loadHistory as ge}from"./js/feed.js";import{openTab as F,updateTabName as Se,renderSessionsDropdown as I,reflectBusy as ve,loadSessions as H,loadCommands as ye,setTabStatus as w,reconcileTabStatuses as Ie}from"./js/session/tabs.js";import{renderSelectors as E,renderSettings as Ee,loadConfig as Le,loadModels as xe,loadProviders as Te,loadMemory as Ce,loadSkills as ke,loadPlugins as _e,applyTheme as Ae,currentTheme as Re,applyFontSize as qe,setConnStatus as L,setStaleBar as M}from"./js/settings.js";import{initRail as Pe,setPlan as N,railEvent as Be,applyRailI18n as Fe}from"./js/rail.js";import{initSidebar as He,sidebarSessionChanged as Me,sidebarMapState as Ne,sidebarTraceEvent as x,sidebarTurnEnd as Oe,sidebarBusy as O,sidebarMapIndicator as Ue,sidebarPullLog as We,sidebarSessionId as De,setSessionLoading as je,sidebarLspState as ze,sidebarLspEvent as Je,applySidebarI18n as U,initFiles as Qe,sidebarFilesState as Ge,sidebarFilesChanged as W,sidebarPluginsState as Ke,sidebarPluginsEvent as Ve,initSidebarDrawer as Xe}from"./js/sidebar.js";import{insertIntoDraft as Ye}from"./js/session/composer.js";import{initCursor as Ze,createFace as $e,setFaceState as D,loaderStateFor as et}from"./js/loader.js";let g=null,T=0;function m(s){T++,D(g,s)}function tt(){const s=document.getElementById("composerFace");s&&(g=$e("idle","sm"),s.replaceChildren(g))}document.querySelectorAll("[data-collapse]").forEach(s=>{const e=s.querySelector(".arrow");e&&(e.textContent="",e.appendChild(A("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 r=s.querySelector(".arrow");r&&(r.textContent="",r.appendChild(A(o?"chevron-right":"chevron-down")))})});let C=-1;function h(){const s=l.tabs.find(r=>r.id===l.activeTabId)||null,e=s&&s.state||{};u.host=e;const i=e.sessionId||s&&s.id||null;u.activeSessionId=i,l.tabs.length||y(),be(e.plan),N(u.busy&&e?e.plan:null),B(e),typeof e.contextWindow=="number"&&b.config&&b.config.contextWindow!==e.contextWindow&&(b.config.contextWindow=e.contextWindow,E()),me(e),Ne(e),Ue(e),ze(),Ge(e),Ke();const o=typeof e.filesRevision=="number"?e.filesRevision:void 0;if(o!==void 0&&o!==C){const r=C===-1;C=o,!r&&o>0&&W()}Me(i),he(e),I(),je(!1),M(!!e.i18nStale)}function st(s){const e=Z(s);ve(),Ie(),s.state&&typeof s.state.sessionId=="string"&&Se(s.state.sessionId,s.state.sessionName),e&&h()}async function j(s){const e=s?"/api/state?session="+encodeURIComponent(s):"/api/state",i=await V(e);return i.ok&&i.data?i.data:null}async function z(s){const e=l.tabs.find(o=>o.id===s);if(!e)return;if(e.state){l.activeTabId===s&&h();return}const i=await j(s);i&&(q(i.state),l.activeTabId===s&&(P(i),h()))}async function J(){const s=l.activeTabId,e=await j(s);if(!e||l.activeTabId!==s)return;const i=e.state;if(!s&&i&&i.sessionId&&!l.tabs.some(o=>o.id===i.sessionId)){const o=ee(u.sessions,i.sessionId);F(i.sessionId,i.sessionName||String(i.sessionId),"session",o)}q(i),P(e),h()}v.ensureTabState=z,v.renderActive=h;function nt(){for(const e of l.tabs)e.kind==="session"&&(e.state=null,z(e.id));J(),H();const s=l.tabs.find(e=>e.id===l.activeTabId);s&&s.kind==="session"&&!we(s.feed)&&(s.historyLoaded=!1,ge(s))}function ot(){const s="/events"+(R?"?token="+encodeURIComponent(R):""),e=new EventSource(s);let i=!1;e.onopen=()=>{i&&(i=!1,L(!1),nt())},e.onerror=t=>{t&&typeof t.data=="string"||(i=!0,L(!0))};const o=t=>{try{return JSON.parse(t.data)}catch{return null}},r=t=>!t.sessionId||t.sessionId===De(),c=[["text",t=>te(t.chunk||"",t.sessionId)],["meta",t=>ne(t.chunk||"",t.sessionId,t.kind)],["reasoning",t=>se(t.chunk||"",t.sessionId)],["phase",t=>oe(t.phase,t.sessionId)],["tool_start",ie],["tool_end",ae],["plan",fe],["question",ue],["turn_end",t=>{re(t),r(t)&&(Oe(t.turnSeq),O(!1),We())}],["log",le],["retract",t=>pe(t.reason||"",t.sessionId)]];for(const[t,n]of c)e.addEventListener(t,d=>{const p=o(d);p&&n(p)});for(const t of["tool_start","tool_end","text","plan"])e.addEventListener(t,n=>{const d=o(n);d&&(t==="plan"?N(d):Be(t,d.name))});const f=[["tool_start","tool_start"],["tool_end","tool_end"],["text","text"],["question","question"],["error","error"]];for(const[t,n]of f)e.addEventListener(t,d=>{const p=o(d);p&&m(et({type:n,name:typeof p.name=="string"?p.name:""}))});e.addEventListener("phase",t=>{const n=o(t),d=n&&typeof n.phase=="string"?n.phase:"";m(d==="composing"?"type":d==="tool"?"run":"think")}),e.addEventListener("reasoning",()=>m("think")),e.addEventListener("plan",()=>m("plan")),e.addEventListener("turn_end",t=>{const n=o(t);m(n&&n.success===!1?"error":"done");const d=T;window.setTimeout(()=>{d===T&&D(g,"idle")},1500)});for(const t of["text","reasoning","phase","tool_start","plan"])e.addEventListener(t,n=>{const d=o(n);d&&d.sessionId&&w(d.sessionId,"working")});e.addEventListener("question",t=>{const n=o(t);n&&n.sessionId&&w(n.sessionId,"waiting")}),e.addEventListener("turn_end",t=>{const n=o(t);n&&n.sessionId&&w(n.sessionId,n.success===!1?"failed":"idle")});for(const t of["tool_start","tool_end","phase","plan","question","meta","log","retract","index"])e.addEventListener(t,n=>{const d=o(n);d&&r(d)&&x(t,d)});e.addEventListener("text",t=>{const n=o(t);n&&r(n)&&x("text",n)}),e.addEventListener("lsp",t=>{const n=o(t);n&&Je(n)}),e.addEventListener("files",()=>W()),e.addEventListener("plugins",()=>Ve()),e.addEventListener("command",t=>{const n=o(t);n&&typeof n.text=="string"&&ce(n.text,n.sessionId)}),e.addEventListener("state",t=>{const n=o(t);n&&(O(!!n.busy),st(n))}),e.addEventListener("sessions",t=>{const n=o(t);n&&Array.isArray(n.sessions)&&(u.sessions=n.sessions,I())}),e.addEventListener("usage",t=>{const n=o(t);if(!n||!n.usage||typeof n.usage!="object")return;const d=n.usageSessionId||n.sessionId||null;$(d,n.usage)&&B(u.host)}),e.addEventListener("error",t=>{if(!t.data)return;const n=o(t);n&&(n.sessionId&&w(n.sessionId,"failed"),de(n),x("error",n))})}function Q(){document.documentElement.lang=X.locale;const s=(r,c)=>{const f=document.getElementById(r);f&&(f.textContent=c)};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"));const e={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(e).forEach(r=>{const c=document.getElementById(r);if(!c)return;const[f,t]=e[r];_(c,f,r==="closeSettings"||r==="sessNew"||r==="sessRefresh"?t:null),c.title=t,c.setAttribute("aria-label",t)});const i=document.getElementById("settingsIcon");i&&_(i,"settings",null),S&&(S.placeholder=a("web.input.placeholder"),S.setAttribute("aria-label",a("web.input.placeholder"))),document.querySelectorAll("#setMenu .mi").forEach(r=>{const c=r.dataset.p;c&&(r.textContent=a("web.settings."+c))});const o=document.getElementById("setSearch");o&&(o.setAttribute("placeholder",a("web.settings.search_placeholder")),o.setAttribute("aria-label",a("web.settings.search_placeholder"))),document.querySelectorAll(".content-col .panel").forEach(r=>{const c=r.querySelector("h3"),f=r.id.replace(/^p-/,"");c&&f&&(c.textContent=a("web.settings."+f))}),E(),I(),Fe(),U(),K.querySelector(".empty")&&y(),k&&!k.hidden&&L(!0),M(void 0,!0)}async function it(){Ze();const s=new URLSearchParams(location.search).get("session");if(window.MmaSetup)try{if(await window.MmaSetup.maybeOpen()){G();return}}catch{}try{await Y(),await ye(),Ae(Re()),qe(),Q(),y(),E(),Ee(),await Le(),Pe(b.config&&b.config.ui?b.config.ui.activityRail:void 0),tt(),He(),Xe(),U(),Qe({insertPath:e=>Ye("`"+e+"` ")}),await xe(),await Te(),await H(),await Ce(),await ke(),await _e();try{await J()}catch(e){console.error("initial refresh failed",e)}if(s){const e=u.sessions.find(i=>i.id===s);e&&F(s,e.name||String(s),"session",!0)}}finally{G()}ot()}function G(){const s=document.getElementById("bootSplash");!s||s.hidden||(s.classList.add("hide"),window.setTimeout(()=>{s.hidden=!0},500))}v.applyStaticI18n=Q,it();
|
|
1
|
+
import{msgs as V,inp as v,connStatus as _,setIcon as A,icon as R}from"./js/dom.js";import{api as X,token as q}from"./js/api.js";import{I18N as Y,t as a,loadI18n as Z}from"./js/i18n.js";import{tabs as f,session as u,settings as m,hooks as S}from"./js/store.js";import{routeState as $,mergeUsage as ee,storeSnapshot as P,applyCounters as B,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 y,renderPlan as me,renderUsage as F,renderEnvironment as he,renderWorkspace as ge,feedHasContent as we,loadHistory as ve}from"./js/feed.js";import{openTab as E,updateTabName as Se,renderSessionsDropdown as I,reflectBusy as ye,loadSessions as H,loadCommands as Ee,setTabStatus as w,reconcileTabStatuses as Ie,readSavedTabs as Le}from"./js/session/tabs.js";import{renderSelectors as L,renderSettings as xe,loadConfig as M,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 x,setStaleBar as N}from"./js/settings.js";import{initRail as Be,setPlan as O,railEvent as Fe,applyRailI18n as He}from"./js/rail.js";import{initSidebar as Me,sidebarSessionChanged as Ne,sidebarMapState as Oe,sidebarTraceEvent as T,sidebarTurnEnd as Ue,sidebarBusy as U,sidebarMapIndicator as We,sidebarPullLog as De,sidebarSessionId as je,setSessionLoading as ze,sidebarLspState as Ge,sidebarLspEvent as Je,applySidebarI18n as W,initFiles as Qe,sidebarFilesState as Ke,sidebarFilesChanged as D,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 j,loaderStateFor as tt,setGreetResolver as nt}from"./js/loader.js";let h=null,C=0;function p(n){C++,j(h,n)}function st(){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(R("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(R(o?"chevron-right":"chevron-down")))})});let k=-1;function g(){const n=f.tabs.find(l=>l.id===f.activeTabId)||null,e=n&&n.state||{};u.host=e;const i=e.sessionId||n&&n.id||null;u.activeSessionId=i,f.tabs.length||y(),me(e.plan),O(u.busy&&e?e.plan:null),F(e),typeof e.contextWindow=="number"&&m.config&&m.config.contextWindow!==e.contextWindow&&(m.config.contextWindow=e.contextWindow,L()),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!==k){const l=k===-1;k=o,!l&&o>0&&D()}Ne(i),ge(e),I(),ze(!1),N(!!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&&g()}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&&g();return}const i=await z(n);i&&(P(i.state),f.activeTabId===n&&(B(i),g()))}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(u.sessions,i.sessionId);E(i.sessionId,i.sessionName||String(i.sessionId),"session",o)}P(i),B(e),g()}S.ensureTabState=G,S.renderActive=g;function it(){for(const e of f.tabs)e.kind==="session"&&(e.state=null,G(e.id));J(),H();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"+(q?"?token="+encodeURIComponent(q):""),e=new EventSource(n);let i=!1;e.onopen=()=>{i&&(i=!1,x(!1),it())},e.onerror=t=>{t&&typeof t.data=="string"||(i=!0,x(!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),U(!1),De())}],["log",fe],["retract",t=>be(t.reason||"",t.sessionId)]];for(const[t,s]of d)e.addEventListener(t,c=>{const b=o(c);b&&s(b)});for(const t of["tool_start","tool_end","text","plan"])e.addEventListener(t,s=>{const c=o(s);c&&(t==="plan"?O(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 b=o(c);b&&p(tt({type:s,name:typeof b.name=="string"?b.name:""}))});e.addEventListener("phase",t=>{const s=o(t),c=s&&typeof s.phase=="string"?s.phase:"";p(c==="composing"?"type":c==="tool"?"run":"think")}),e.addEventListener("reasoning",()=>p("think")),e.addEventListener("plan",()=>p("plan")),e.addEventListener("turn_end",t=>{const s=o(t);p(s&&s.success===!1&&!s.interrupted?"error":"done");const c=C;window.setTimeout(()=>{c===C&&j(h,"idle")},1500)}),e.addEventListener("retract",()=>p("error")),e.addEventListener("index",()=>p("find")),e.addEventListener("setup_done",()=>p("done"));for(const t of["text","reasoning","phase","tool_start","plan"])e.addEventListener(t,s=>{const c=o(s);c&&c.sessionId&&w(c.sessionId,"working")});e.addEventListener("question",t=>{const s=o(t);s&&s.sessionId&&w(s.sessionId,"waiting")}),e.addEventListener("turn_end",t=>{const s=o(t);s&&s.sessionId&&w(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)&&T(t,c)});e.addEventListener("text",t=>{const s=o(t);s&&l(s)&&T("text",s)}),e.addEventListener("lsp",t=>{const s=o(t);s&&Je(s)}),e.addEventListener("files",()=>D()),e.addEventListener("plugins",()=>Xe()),e.addEventListener("config",()=>{M()}),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&&(U(!!s.busy),ot(s))}),e.addEventListener("sessions",t=>{const s=o(t);s&&Array.isArray(s.sessions)&&(u.sessions=s.sessions,I())}),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)&&F(u.host)}),e.addEventListener("error",t=>{if(!t.data)return;const s=o(t);s&&(s.sessionId&&w(s.sessionId,"failed"),ce(s),T("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")),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,s]=i[d];A(r,t,d==="closeSettings"||d==="sessNew"||d==="sessRefresh"?s:null),r.title=s,r.setAttribute("aria-label",s)});const o=document.getElementById("settingsIcon");o&&A(o,"settings",null),v&&(v.placeholder=a("web.input.placeholder"),v.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))}),L(),I(),He(),W(),V.querySelector(".empty")&&y(),_&&!_.hidden&&x(!0),N(void 0,!0)}function rt(n){const e=Le(),i=r=>u.sessions.some(t=>t.id===r),o=r=>{const t=u.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){E(d[0],o(d[0]),"session",!0);for(const r of d.slice(1))E(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(),y(),L(),xe(),await M(),Be(m.config&&m.config.ui?m.config.ui.activityRail:void 0),st(),Me(),Ye(),W(),Qe({insertPath:e=>Ze("`"+e+"` ")}),await Te(),await Ce(),await H(),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))}S.applyStaticI18n=Q,dt();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const feed={curText:null,curMd:null,turnMd:"",turnRoots:[],curThink:null,
|
|
1
|
+
export const feed={lastPlanSig:null,lastUsageSig:null,lastEnvSig:null};const e=new WeakMap;function u(){return{curText:null,curMd:null,turnMd:"",turnRoots:[],curThink:null,runCount:0,runFails:0,runReconOnly:!0,runNodes:[],runDuration:0,busyTimer:null,pendingArgs:new Map,toolNodes:new Map,pendingText:"",textScheduled:!1}}export function streamStateFor(t){let n=e.get(t);return n||(n=u(),e.set(t,n)),n}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feed as s}from"./feed.js";import{tabs as
|
|
1
|
+
import{feed as s}from"./feed.js";import{tabs as f}from"./tabs.js";import{settings as c}from"./settings.js";import{session as i}from"./session.js";export{s as feed,f as tabs,c as settings,i as session};export{streamStateFor}from"./feed.js";export const THEME_KEY="mma-theme",MAX_IMAGES=10,MAX_IMAGE_BYTES=50*1024*1024,hooks={applyStaticI18n:null};export function setPath(r,n,p){const t=n.split(".");let o=r;for(let e=0;e<t.length-1;e++)(o[t[e]]==null||typeof o[t[e]]!="object")&&(o[t[e]]={}),o=o[t[e]];o[t[t.length-1]]=p}export function getPath(r,n){const p=n.split(".");let t=r;for(const o of p){if(t==null||typeof t!="object")return;t=t[o]}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as
|
|
1
|
+
import{msgs as i,el as r,setIcon as C}from"../dom.js";import{t as s,pluralCount as w}from"../i18n.js";import{streamStateFor as f,tabs as a}from"../store.js";import{formatMs as x,verbosity as T}from"../format.js";import{copyText as v}from"../../md.js";import{createFace as g}from"../loader.js";export function mdOpts(t){return{copyLabel:s("web.code.copy"),copiedLabel:s("web.code.copied"),copyFailedLabel:s("web.code.copy_failed"),animate:t===!0}}export function buildThinkBlock(t,e){const n=r("div","think"+(e===!1?"":" live")),o=r("button","think-h");o.type="button",o.setAttribute("aria-expanded","false"),o.appendChild(r("span","g","✦")),o.appendChild(r("span","lab",s("web.action.thinking"))),t&&o.appendChild(r("span","dur",""));const c=r("span","tog");C(c,"chevron-right",s("web.action.show")),o.appendChild(c);const l=r("div","think-body hidden");return n.appendChild(o),n.appendChild(l),{wrap:n,head:o,body:l}}export function copyAction(t,e){const n=r("button","act-btn",s(e));return n.type="button",n.addEventListener("click",()=>{v(t).then(o=>{n.textContent=o?"✓ "+s("web.code.copied"):"⚠ "+s("web.code.copy_failed"),window.setTimeout(()=>{n.textContent=s(e)},1400)})}),n}export function appendActionsRow(t,e,n){const o=String(e??""),c=String(n??"");if(!t||!o.trim()&&!c.trim())return;const l=r("div","msg-actions");o.trim()&&l.appendChild(copyAction(o,"web.msg.copy")),c.trim()&&l.appendChild(copyAction(c,"web.msg.copy_md")),appendTo(t,l)}export function insertAfter(t,e){t&&t.parentNode?t.parentNode.insertBefore(e,t.nextSibling):appendTo(liveFeed(),e)}function b(){const t=r("div","empty");return t.appendChild(r("span","g","✦")),t.appendChild(document.createTextNode(" "+s("web.empty.title"))),t.appendChild(document.createElement("br")),t.appendChild(r("span","hint",s("web.empty.hint"))),t}export function makeFeed(){const t=r("div","feed");return t.appendChild(b()),t}export function showEmptyFeed(){i.replaceChildren(b()),p=!0,d(),syncUrl()}export function clearFeed(t){if(!t)return;t.replaceChildren(b()),p=!0,d();const e=a.tabs.find(n=>n.feed===t);e&&(e.planCard=null),t===activeFeed()&&scroll()}export function activeFeed(){const t=a.tabs.find(e=>e.id===a.activeTabId);return t?t.feed:null}export function liveFeed(){const t=a.tabs.find(e=>e.id===a.liveTabId)||a.tabs.find(e=>e.id===a.activeTabId);return t?t.feed:null}export function feedForEvent(t){if(t){const e=a.tabs.find(n=>n.id===t);if(e)return e.feed}return liveFeed()}function h(){return i.scrollHeight-i.scrollTop-i.clientHeight<140}let p=!0;export function scroll(t){t||p||h()?(i.scrollTop=i.scrollHeight,p=!0,d()):m()}export function scrollToBottom(t){if(p=!0,d(),t&&typeof i.scrollTo=="function")try{i.scrollTo({top:i.scrollHeight,behavior:"smooth"});return}catch{}i.scrollTop=i.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=a.tabs.find(n=>n.id===a.activeTabId);e&&e.kind==="session"?t.searchParams.set("session",e.id):t.searchParams.delete("session"),history.replaceState(null,"",t)}let u=null;function L(){if(u)return u;const t=document.querySelector(".chat");return t?(u=r("button","to-latest"),u.type="button",u.hidden=!0,u.addEventListener("click",()=>scrollToBottom(!0)),t.appendChild(u),u):null}function m(){const t=L();t&&(t.textContent="↓ "+s("web.scroll.latest"),t.hidden=!1,i.classList.add("unfollowed"))}function d(){u&&(u.hidden=!0),i.classList.remove("unfollowed")}i?.addEventListener("scroll",()=>{const t=h();p=t,i.classList.toggle("scrolled",i.scrollTop>24),t?d():liveFeed()&&feedHasContent(liveFeed())&&m()});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=r("div","busy");n.appendChild(g("think","sm")),n.appendChild(r("span","lab",s("web.action.thinking")));const o=r("span","busytime","· 0s");n.appendChild(o),n.appendChild(r("span","","· "+s("web.input.esc"))),appendTo(t,n);const c=Date.now();e.busyTimer=setInterval(()=>{if(!n.parentNode){clearInterval(e.busyTimer),e.busyTimer=null;return}o.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(l=>l.classList.add("fold-out")),window.setTimeout(()=>n.forEach(l=>l.remove()),160);const o=r("div","grouped");o.appendChild(r("span","pipe","│"));const c=x(e.runDuration);o.appendChild(document.createTextNode(" "+w("web.action.actions",e.runCount)+" ✓"+(c?" · "+c:""))),appendTo(t,o)}y(e)}function y(t){t.runCount=0,t.runFails=0,t.runReconOnly=!0,t.runNodes=[],t.runDuration=0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{usageEl as c,envEl as x,wsLine as
|
|
1
|
+
import{usageEl as c,envEl as x,wsLine as A,el as s,icon as C,attachTooltip as h}from"../dom.js";import{I18N as k,t as a,pluralCount as v}from"../i18n.js";import{feed as g,settings as B}from"../store.js";import{renderFooter as E}from"../footer.js";import{fmtTokens as b}from"../format.js";import{copyText as L}from"../../md.js";function f(e,i,n){const t=s("div","kv");return t.appendChild(s("span","",e)),t.appendChild(s("b",n||"",i)),t}function S(e){return[["seg-system","web.usage.part_system",e.system],["seg-tools","web.usage.part_tools",e.tools],["seg-history","web.usage.part_history",e.history],["seg-reserve","web.usage.part_reserve",e.reserve],["seg-free","web.usage.part_free",e.free]]}function _(e,i,n,t){const o=document.createDocumentFragment();return o.appendChild(s("i","ctip-dot "+e)),o.appendChild(s("span","ctip-label",a(i))),o.appendChild(s("b","",b(n))),o.appendChild(s("span","ctip-pct",Math.round(n/t*100)+"%")),o}const M=new Map;function W(e,i,n){const t=M.get(i);if(M.set(i,n),t===void 0||t===n){e.style.flexGrow=String(n);return}e.style.flexGrow=String(t);const o=()=>{e.style.flexGrow=String(n)};typeof requestAnimationFrame=="function"?requestAnimationFrame(o):o()}function F(e,i,n){const t=s("div","bar segbar"),o=e.contextBreakdown;if(!o||typeof o.window!="number"||o.window<=0){const l=s("i");return l.style.flex="0 0 "+Math.min(100,Math.round(i/n*100))+"%",t.appendChild(l),t}const d=Math.max(o.window,o.used+o.reserve);for(const[l,r,p]of S(o)){if(!p||p<=0)continue;const u=s("i",l);u.style.flexBasis="0",W(u,l,p),u.tabIndex=0,u.setAttribute("aria-label",[a(r),b(p),Math.round(p/d*100)+"%"].join(" · ")),h(u,()=>_(l,r,p,d)),t.appendChild(u)}return t}function I(e){const i=s("div","seglegend"),n=e.contextBreakdown;if(!n)return i;const t=Math.max(n.window,n.used+n.reserve);for(const[o,d,l]of S(n)){if(!l||l<=0)continue;const r=s("span","segl-item");r.tabIndex=0,r.setAttribute("aria-label",[a(d),b(l),Math.round(l/t*100)+"%"].join(" · ")),r.appendChild(s("i","segl-dot "+o)),r.appendChild(s("span","segl-label",a(d))),r.appendChild(s("b","",b(l))),h(r,()=>_(o,d,l,t)),i.appendChild(r)}return i}function R(e){const i=s("div","kv");i.appendChild(s("span","",a("web.usage.session")));const n=s("span","kv-val");if(!e)n.appendChild(s("b","","—"));else{n.appendChild(s("b","",e));const t=s("button","copy-btn");t.type="button",t.title=a("web.usage.copy_id"),t.setAttribute("aria-label",a("web.usage.copy_id")),t.appendChild(C("copy")),t.addEventListener("click",()=>{L(e).then(o=>{t.replaceChildren(C(o?"check":"copy")),setTimeout(()=>t.replaceChildren(C("copy")),1500)})}),n.appendChild(t)}return i.appendChild(n),i}export function renderUsage(e){const i=B.config||{},n=JSON.stringify([e.sessionId,e.model,e.contextUsed,e.contextLimit,e.contextWindow,e.cacheHitRate,e.costUsd,e.compactionCount,e.contextQuality,e.contextProbe,e.contextBreakdown,i.model,i.contextWindow,k.locale]);if(n===g.lastUsageSig)return;g.lastUsageSig=n,c.textContent="";const t=e.sessionId?String(e.sessionId):"";c.appendChild(R(t)),c.appendChild(f(a("web.usage.model"),e.model||i.model||"—"));const o=typeof e.contextUsed=="number"?e.contextUsed:null,d=typeof e.contextLimit=="number"?e.contextLimit:i.contextWindow||null;c.appendChild(f(a("web.usage.context"),o!=null&&d?b(o)+" / "+b(d):"—")),o!=null&&d&&(c.appendChild(F(e,o,d)),c.appendChild(I(e)));const l=typeof e.cacheHitRate=="number"?e.cacheHitRate:null;c.appendChild(f(a("web.usage.cache"),l!=null?Math.round(l*100)+"%":"—",l!=null?"":"dim")),c.appendChild(f(a("web.usage.cost"),typeof e.costUsd=="number"?"$"+e.costUsd.toFixed(4):"—")),c.appendChild(f(a("web.usage.compactions"),"⟳ "+(e.compactionCount||0),e.compactionCount?"wn":"dim"));const r=typeof e.contextQuality=="number"?e.contextQuality:null;c.appendChild(f(a("web.usage.quality"),r!=null?Math.round(r)+"%":"—",r!=null?"":"dim"));let p="—",u="dim";const m=e.contextProbe;if(m&&typeof m.actual=="number"){const y=b(m.actual),w=e.contextWindow||i.contextWindow||null;w&&m.actual<w?(p=a("web.usage.probe_low",{actual:y,configured:b(w)}),u="wn"):(p=a("web.usage.probe_loaded",{actual:y}),u="")}c.appendChild(f(a("web.usage.probe"),p,u))}export function renderWorkspace(e){E(A,{workspace:e.workspace,version:e.version,moeActive:e.moeActive===!0,dirLabel:a("web.env.dir")},s)}function U(e,i){const n=s("div","env-item");return n.appendChild(s("div","env-k",e)),i.forEach(t=>{const o=s("div","env-v",t);o.title=t,n.appendChild(o)}),n}export function renderEnvironment(e){const i=!!(e.instructions&&e.instructions.disabled),n=e.instructions&&!i?e.instructions.files||[]:[],t=e.projectMap||null,o=JSON.stringify([i,n,t,k.locale]);o!==g.lastEnvSig&&(g.lastEnvSig=o,x.textContent="",x.appendChild(U(a("web.env.agents"),i?[a("web.env.agents_disabled")]:n.length?n:[a("web.env.agents_none")])),x.appendChild(U(a("web.env.map"),t&&t.indexed?[[v("web.env.files",t.files),v("web.env.symbols",t.symbols),v("web.env.tokens",t.tokens)].join(" · ")]:[a("web.env.map_not_indexed")])))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as g,el as
|
|
1
|
+
import{msgs as g,el as p,setIcon as w}from"../dom.js";import{t as M}from"../i18n.js";import{streamStateFor as c}from"../store.js";import{verbosity as k}from"../format.js";import{mountMarkdown as v}from"../../md.js";import{activeFeed as f,feedForEvent as u,clearBusy as s,clearEmpty as l,flushRun as T,showBusy as y,appendTo as h,scroll as a,mdOpts as b,buildThinkBlock as R}from"./core.js";function x(r){const n=c(r);if(n.textScheduled=!1,!n.pendingText||!n.curMd){n.pendingText="";return}const t=n.pendingText;n.pendingText="",n.curMd.write(t),r===f()&&a()}function S(r){const n=c(r);n.textScheduled||(n.textScheduled=!0,typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>x(r)):x(r))}export function finishMd(r){if(!r)return;const n=c(r);x(r),n.curMd&&(n.curMd.root.classList.remove("streaming"),n.curMd.end(),n.curMd=null),n.curText=null}export function onText(r,n){const t=u(n);if(s(t),!t)return;l(t);const e=c(t);e.curThink&&finishThink(t),e.curText==null&&(T(t),e.curText="",e.curMd=v(t,b(!0)),e.curMd.root.classList.add("streaming"),e.turnRoots.push(e.curMd.root)),e.curText+=r,e.turnMd+=r,e.pendingText+=r,S(t)}export function finishThink(r){if(!r)return;const n=c(r);if(n.curThink&&(n.curThink.wrap&&n.curThink.wrap.classList.remove("live"),n.curThink.startedAt)){const t=n.curThink.head.querySelector(".dur");t&&(t.textContent="· "+((Date.now()-n.curThink.startedAt)/1e3).toFixed(1)+"s")}n.curThink=null}export function onReasoning(r,n){const t=u(n);if(s(t),!t)return;l(t),finishMd(t);const e=c(t);if(!e.curThink){T(t);const{wrap:o,head:i,body:d}=R(!0);h(t,o),e.curThink={wrap:o,head:i,body:d,startedAt:Date.now()}}e.curThink.body.textContent+=r,t===f()&&a()}export function onMeta(r,n,t){if(t==="tool"&&k()==="quiet")return;const e=u(n);s(e);const o=(r||"").trim();if(!e||!o)return;l(e),finishMd(e);const i=o.indexOf("⚠")!==-1||o.indexOf("✗")!==-1;h(e,p("div",i?"metaln warn":"metaln",o)),e===f()&&a()}export function onRetract(r,n){const t=u(n);if(!t)return;s(t);const e=c(t),o=e.curMd?e.curMd.root:null,i=!!o||e.curText!=null&&e.curText!=="",d=e.curText?e.curText.length:0;if(finishMd(t),finishThink(t),o){const m=e.turnRoots.indexOf(o);m!==-1&&e.turnRoots.splice(m,1),o.remove()}d>0&&(e.turnMd=e.turnMd.slice(0,Math.max(0,e.turnMd.length-d))),i&&(r&&h(t,p("div","metaln",r)),t===f()&&a())}export function onPhase(r,n){const t=u(n);r==="thinking"?y(t):s(t)}g?.addEventListener("click",r=>{const t=r.target.closest(".think-h");if(!t)return;const e=t.nextElementSibling;if(!e)return;const o=e.classList.toggle("hidden");t.setAttribute("aria-expanded",o?"false":"true");const i=t.querySelector(".tog");i&&w(i,o?"chevron-right":"chevron-down",M(o?"web.action.show":"web.action.hide"))});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{msgs as A,el as
|
|
2
|
-
`).length>12){o.classList.add("collapsed");const
|
|
1
|
+
import{msgs as A,el as i,icon as w,announce as a}from"../dom.js";import{t as f,pluralCount as _}from"../i18n.js";import{streamStateFor as C,tabs as k,session as g}from"../store.js";import{FILE_TOOLS as x,OPENABLE_TOOLS as F,LINK_TOOLS as B,categoryOf as y,labelOf as I,argText as U,formatMs as S,verbosity as b,firstOutputLine as L}from"../format.js";import{copyText as q}from"../../md.js";import{imageCard as P}from"./image-card.js";import{activeFeed as j,liveFeed as D,feedForEvent as h,clearBusy as O,clearEmpty as T,appendTo as d,insertAfter as N,appendActionsRow as $,flushRun as K,scrollToBottom as z}from"./core.js";import{finishMd as E,finishThink as M}from"./stream.js";export function onToolStart(e){const n=h(e.sessionId);if(O(n),!n)return;T(n),E(n),M(n);const o=C(n);o.pendingArgs.set(e.toolCallId,e.args||{});const s=i("div","act "+y(e.name));s.appendChild(i("span","g","◇")),s.appendChild(i("span","lab",I(e.name)));const l=U(e.args);l&&(s.appendChild(i("span","sep","·")),s.appendChild(i("span","args",l)));const t=i("span","ok","");s.appendChild(t),s.classList.add("running"),d(n,s),o.toolNodes.set(e.toolCallId,{status:t,line:s}),y(e.name)!=="recon"&&(o.runReconOnly=!1),o.runCount++}function R(e,n){if(typeof n!="string"||!n)return;const o=i("div","toolout"),s=i("div","code");if(s.textContent=n,o.appendChild(s),n.length>600||n.split(`
|
|
2
|
+
`).length>12){o.classList.add("collapsed");const u="▸ "+_("web.tool.output",n.length),r=i("span","more",u);r.addEventListener("click",()=>{const c=o.classList.toggle("collapsed");r.textContent=c?u:"▾ "+f("web.tool.collapse")}),o.appendChild(r)}const t=e&&e.parentNode?null:D();e&&e.parentNode?e.parentNode.insertBefore(o,e.nextSibling):d(t,o)}function G(e){if(typeof e!="string"||!e)return null;try{const n=new URL(e,location.href);if(n.protocol==="http:"||n.protocol==="https:"||n.protocol==="file:")return n.href}catch{return null}return null}function H(e){const n=String(e??"").replace(/\\/g,"/");try{const o=g&&g.host&&g.host.workspace?String(g.host.workspace).replace(/\\/g,"/").replace(/\/+$/,""):"";if(o&&(n===o||n.indexOf(o+"/")===0)){const s=n===o?"":n.slice(o.length+1);if(s)return s}}catch{}return n}function m(e,n,o,s){const l=h(o);if(!l)return null;if(x.indexOf(e)!==-1){const t=n.path||n.file||n.dir;if(!t)return null;const u=H(t),r=i("div","filerow "+y(e));if(r.appendChild(i("span","g","◇")),r.appendChild(i("span","lab",I(e))),r.appendChild(i("span","sep"," · ")),F.indexOf(e)!==-1){const p=i("a","path",u||String(t));p.href="/api/file?path="+encodeURIComponent(String(t)),p.target="_blank",p.rel="noopener noreferrer",p.title=f("web.card.open_title")+" · "+String(t),r.appendChild(p)}else{const p=i("span","tail",u||String(t));p.title=String(t),r.appendChild(p)}const c=i("button","copy-btn");return c.type="button",c.title=f("web.card.copy_title"),c.setAttribute("aria-label",f("web.card.copy_title")),c.appendChild(w("copy")),c.addEventListener("click",()=>{q(String(t)).then(p=>{if(c.replaceChildren(w(p?"check":"copy")),!p){const v=r.querySelector(".st");v&&(v.textContent=" ⚠")}window.setTimeout(()=>c.replaceChildren(w("copy")),1400)})}),r.appendChild(c),r.appendChild(i("span","st",s===!1?" ✗":s===!0?" ✓":"")),s===!1&&(r.dataset.fail="1"),/\.drawio(\.xml)?$/i.test(String(t))&&b()==="verbose"&&r.appendChild(i("span","detail","↳ "+f("web.card.drawio_hint"))),d(l,r),r}if(B.indexOf(e)!==-1&&n.url){const t=i("div","linkline");t.appendChild(document.createTextNode("↳ "));const u=G(n.url);if(u){const r=i("a","",n.url);r.href=u,r.target="_blank",r.rel="noopener noreferrer",t.appendChild(r);try{const c=new URL(u).hostname;c&&t.appendChild(i("span","dom"," · "+c))}catch{}}else t.appendChild(i("span","",n.url));return d(l,t),t}return null}function J(e){if(!e.success||!Array.isArray(e.images)||!e.images.length)return;const n=h(e.sessionId);if(n)for(const o of e.images){const s=P(String(e.name||""),String(o));s&&d(n,s)}}export function onToolEnd(e){Q(e),J(e)}function Q(e){const n=h(e.sessionId),o=n?C(n):null,s=o?o.toolNodes.get(e.toolCallId):void 0,l=s?s.line:null;if(s&&o){s.line.classList.remove("running");const r=S(e.durationMs);s.status.textContent=e.success?" ✓"+(r?" "+r:""):" ✗"+(r?" "+r:""),e.success||(s.status.classList.add("fail"),o.runFails++,o.runReconOnly=!1),o.toolNodes.delete(e.toolCallId)}const t=(o?o.pendingArgs.get(e.toolCallId):void 0)||{};o&&o.pendingArgs.delete(e.toolCallId);const u=t.path||t.file||t.dir;if(x.indexOf(e.name)!==-1&&u){if(l&&l.parentNode&&l.remove(),b()==="quiet"){if(e.success){const c=m(e.name,t,e.sessionId,e.success);c&&o&&o.runNodes.push(c),o&&(o.runDuration+=typeof e.durationMs=="number"?e.durationMs:0)}else{const c=m(e.name,t,e.sessionId,e.success),p=L(e.output);p&&N(c||l,i("div","detail","↳ "+p)),c&&o&&o.runNodes.push(c)}return}const r=m(e.name,t,e.sessionId,e.success);R(r||l,e.output);return}if(b()==="quiet"){if(e.success){l&&o&&o.runNodes.push(l);const r=m(e.name,t,e.sessionId,e.success);r&&o&&o.runNodes.push(r),o&&(o.runDuration+=typeof e.durationMs=="number"?e.durationMs:0)}else{const r=L(e.output);r&&N(l,i("div","detail","↳ "+r))}return}e.success&&m(e.name,t,e.sessionId,e.success),R(l,e.output)}export function onTurnEnd(e){g.busy=!1;const n=h(e.sessionId);O(n),M(n),E(n),K(n);const o=n?C(n):null;o&&o.toolNodes.forEach(t=>{t&&t.line&&n&&t.line.parentNode===n&&t.line.classList.remove("running")});const s=k.tabs.find(t=>t.id===e.sessionId);if(s&&(s.planCard=null),!n||!o){resetTurnText(n);return}if(e.success===!1)e.interrupted?(d(n,i("div","warnline","⚠ "+f("web.turn.stopped"))),a(f("web.turn.stopped"))):(d(n,i("div","errline","✗ "+f("web.turn.failed"))),a(f("web.turn.failed")));else{const t=[];typeof e.toolCalls=="number"&&e.toolCalls>0&&t.push(f("web.turn.tools",{count:e.toolCalls})),typeof e.durationMs=="number"&&t.push(S(e.durationMs)),t.length&&d(n,i("div","metric","⟡ "+t.join(" · "))),a(f("web.turn.end",{count:e.toolCalls||0}))}const l=o.turnRoots.map(t=>t.innerText||t.textContent||"").join(`
|
|
3
3
|
|
|
4
|
-
`);$(n,
|
|
5
|
-
`).forEach(s=>
|
|
4
|
+
`);$(n,l,o.turnMd),resetTurnText(n)}export function resetTurnText(e){if(!e)return;const n=C(e);n.turnMd="",n.turnRoots=[]}export function onErrorEvent(e){if(!e||!e.error)return;const n=h(e.sessionId);n&&d(n,i("div","errline","✗ "+e.error)),a(String(e.error))}export function onCommandOutput(e,n){const o=h(n)||A;T(o),String(e).split(`
|
|
5
|
+
`).forEach(s=>d(o,i("div","cmdout",s))),z()}export function onLog(e){if(!e||typeof e.text!="string"||!e.text||e.diagnostic&&b()!=="verbose")return;const n=h(e.sessionId)||j();if(!n)return;const o=e.level,s=o==="error"?"errline":o==="warn"?"warnline":"detail",l=o==="error"?"✗ ":o==="warn"?"⚠ ":"↳ ",t=i("div",s);t.textContent=l+e.text,d(n,t),(o==="error"||o==="warn")&&a(e.text)}
|
package/dist/assets/js/loader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const m={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"},_={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:"plan",set_thinking:"think",approve:"ask",question:"ask",meet_done:"done"};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":return toolState(e.name||"");case"index":return"find";case"setup_done":return"done";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 w=()=>`Привет! Я ${MMART_NAME}`;export function setGreetResolver(e){w=e}function r(e,n,t){const s=document.createElement(e);return n&&(s.className=n),t!=null&&(s.textContent=t),s}export function createFace(e="think",n=null){const t=r("span");t.setAttribute("aria-hidden","true"),t.dataset.size=n||"";const s=r("span","eyes");s.appendChild(r("i","eye left")),s.appendChild(r("i","eye right"));const o=r("span","orb");o.appendChild(r("i"));const a=r("span","keys");for(let i=0;i<4;i++)a.appendChild(r("i"));const c=r("span","dust");for(let i=0;i<3;i++)c.appendChild(r("i"));return t.append(s,o,a,r("span","grow"),r("span","fly"),c,r("span","q","?"),r("span","spark","✦"),r("span","star"),r("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:"")+" "+m[n],e.dataset.state=n,m[n].includes("track")||(e.style.setProperty("--ex","0px"),e.style.setProperty("--ey","0px"),e.style.setProperty("--tilt","0deg"))}const p=new WeakMap;function b(e){const n=e.querySelector(".mdl-tip");if(!n)return;n.textContent=w(),e.classList.add("show-tip");const t=p.get(e);t!==void 0&&window.clearTimeout(t),p.set(e,window.setTimeout(()=>{e.classList.remove("show-tip"),p.delete(e)},2200))}function u(e){return Array.from(document.querySelectorAll(e))}function x(e,n){for(const t of u(".mdl.track")){const s=t.getBoundingClientRect(),o=s.left+s.width/2,a=s.top+s.height/2,c=e-o,i=n-a,l=Math.hypot(c,i)||1,f=s.width*.16,d=Math.min(1,l/140),y=c/l,k=i/l;t.style.setProperty("--ex",(y*f*d).toFixed(1)+"px"),t.style.setProperty("--ey",(k*f*d).toFixed(1)+"px"),t.style.setProperty("--tilt",(y*6*d).toFixed(2)+"deg")}}function g(){for(const e of u(".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 h=!1;export function initCursor(){if(h||typeof window>"u")return;h=!0,window.addEventListener("mousemove",n=>x(n.clientX,n.clientY)),window.addEventListener("mouseleave",g);let e=null;window.addEventListener("click",n=>{const t=u(".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 s=v(n);s&&b(s)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inp as i,imgPicker as g,attachStrip as B,attachErr as k,sendBtn as p,el as f,icon as _}from"../dom.js";import{api as S}from"../api.js";import{t as c}from"../i18n.js";import{tabs as o,session as m,settings as T,MAX_IMAGES as C,MAX_IMAGE_BYTES as W}from"../store.js";import{contextLabel as z}from"../format.js";import{clearEmpty as N,activeFeed as Y,liveFeed as j,appendTo as v,scrollToBottom as P,clearFeed as J,finishMd as Q,resetTurnText as V,finishThink as Z,showBusy as $}from"../feed.js";import{setBusy as tt}from"../rail.js";import"../core/menus.js";import{openSessionsMenu as et}from"./sessions-menu.js";import{closeCmdk as F,updateCmdk as nt,cmdkKeydown as at,initCmdk as st}from"./cmdk.js";let r={activeTab:()=>null,setTabStatus:()=>{},newChatTab:async()=>{},markTabDead:()=>{},openTab:()=>{},closeTab:()=>{},statusTitle:()=>""};export function initComposer(t){r={...r,...t}}st({autogrow:w});const it=200;function w(){i&&(i.style.height="auto",i.style.height=Math.min(i.scrollHeight,it)+"px")}function ot(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=f("div","thumb"),s=document.createElement("img");s.alt="",s.src=e,a.appendChild(s);const d=f("button","rm");d.type="button",d.title=c("web.attach.remove"),d.setAttribute("aria-label",c("web.attach.remove")),d.appendChild(_("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 rt(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>W){e=c("web.attach.too_large");continue}try{const a=await rt(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&&ot(e)}function ct(t,e){const n=f("div","u",t);return(e||[]).forEach(a=>{const s=document.createElement("img");s.className="uimg",s.alt="",s.src=a,n.appendChild(s)}),n}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(),F())}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"),O=document.getElementById("sessTools"),q=document.getElementById("sessDD"),y=document.querySelector(".bar-top"),E=document.getElementById("newChat"),M=document.createComment("top-tools");y&&E&&y.insertBefore(M,E);function X(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 U(){!y||!O||!E||!q||(window.matchMedia("(max-width: 760px)").matches?O.append(E,q):(y.insertBefore(E,M),y.insertBefore(q,M)))}if(L&&L.addEventListener("click",()=>X(-1)),A&&A.addEventListener("click",()=>X(1)),D&&D.addEventListener("click",()=>{o.activeTabId&&r.closeTab(o.activeTabId)}),I&&I.addEventListener("click",t=>{t.stopPropagation(),et()}),typeof window.matchMedia=="function"){const t=window.matchMedia("(max-width: 760px)");typeof t.addEventListener=="function"&&t.addEventListener("change",U),U()}g&&g.addEventListener("change",()=>{x(Array.from(g.files||[])),g.value=""});const G=document.getElementById("attachBtn");G&&g&&G.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 H(){i.value="",w(),F()}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(),nt()});async function K(){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()||Y();if(n&&n.dead){N(s),r.markTabDead(n.id);return}if(N(s),Q(),V(),Z(),t.startsWith("/")){v(s,f("div","u",t)),P(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),H();const u=t.slice(1).split(/\s+/)[0].toLowerCase();if(u==="clear"){J(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,f("div","detail","↳ "+c("web.misc.command_unavailable")));return}if(s&&s.querySelector(".startbanner")===null&&s.querySelector(".u")===null){const u=f("div","startbanner");u.appendChild(document.createTextNode(c("web.start.label")+" ")),u.appendChild(f("b","",T.config&&T.config.model||m.host.model||"—"));const b=m.host.sessionId?" · "+c("web.start.session")+" "+String(m.host.sessionId):"";u.appendChild(document.createTextNode(" · "+(m.host.provider||T.config&&T.config.provider&&T.config.provider.active||"—")+" · "+z()+b)),s.insertBefore(u,s.firstChild)}v(s,ct(t,e)),P(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),H(),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,f("div","detail",String(l.data.notice)));else if(l.data&&l.data.queued){const u=l.data.queuedForSession||l.data.queued;v(s,f("div","detail","↳ "+c("web.input.queued",{n:u}))),a&&r.setTabStatus(a,"queued")}else window.setTimeout(()=>$(s),180);else{const u=l.data&&l.data.error||l.status,b=u==="queue_full"?c("web.input.queue_full"):u;v(s,f("div","warnline","⚠ "+b)),a&&r.setTabStatus(a,"failed")}}async function R(){const t=r.activeTab(),e=t&&t.kind==="session"?t.id:null,n=m.runningSessionIds||[];e&&!n.includes(e)||!e&&!m.busy||await S("/api/interrupt",{method:"POST",body:e?{sessionId:e}:{}})}i.addEventListener("keydown",t=>{t.isComposing||t.keyCode===229||at(t)||(t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),K()):t.key==="Escape"&&(t.preventDefault(),R()))}),p&&p.addEventListener("click",()=>{const t=r.activeTab();t&&t.kind==="session"&&m.runningSessionIds.includes(t.id)?R():K()});export function reflectBusy(){const t=r.activeTab(),e=m.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),p){const d=n?c("web.input.stop"):c("web.input.send");p.textContent="",p.appendChild(_(n?"square":"arrow-up")),p.classList.toggle("busy",n),p.title=d,p.setAttribute("aria-label",d)}const s=document.getElementById("hintEsc");s&&(s.hidden=!n),tt(m.busy)}
|
|
1
|
+
import{inp as i,imgPicker as g,attachStrip as B,attachErr as k,sendBtn as p,el as f,icon as _}from"../dom.js";import{api as S}from"../api.js";import{t as c}from"../i18n.js";import{tabs as o,session as m,settings as T,MAX_IMAGES as C,MAX_IMAGE_BYTES as W}from"../store.js";import{contextLabel as z}from"../format.js";import{clearEmpty as N,activeFeed as Y,liveFeed as j,appendTo as v,scrollToBottom as P,clearFeed as J,finishMd as Q,resetTurnText as V,finishThink as Z,showBusy as $}from"../feed.js";import{setBusy as tt}from"../rail.js";import"../core/menus.js";import{openSessionsMenu as et}from"./sessions-menu.js";import{closeCmdk as F,updateCmdk as nt,cmdkKeydown as at,initCmdk as st}from"./cmdk.js";let r={activeTab:()=>null,setTabStatus:()=>{},newChatTab:async()=>{},markTabDead:()=>{},openTab:()=>{},closeTab:()=>{},statusTitle:()=>""};export function initComposer(t){r={...r,...t}}st({autogrow:w});const it=200;function w(){i&&(i.style.height="auto",i.style.height=Math.min(i.scrollHeight,it)+"px")}function ot(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=f("div","thumb"),s=document.createElement("img");s.alt="",s.src=e,a.appendChild(s);const d=f("button","rm");d.type="button",d.title=c("web.attach.remove"),d.setAttribute("aria-label",c("web.attach.remove")),d.appendChild(_("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 rt(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>W){e=c("web.attach.too_large");continue}try{const a=await rt(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&&ot(e)}function ct(t,e){const n=f("div","u",t);return(e||[]).forEach(a=>{const s=document.createElement("img");s.className="uimg",s.alt="",s.src=a,n.appendChild(s)}),n}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(),F())}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"),O=document.getElementById("sessTools"),q=document.getElementById("sessDD"),y=document.querySelector(".bar-top"),E=document.getElementById("newChat"),M=document.createComment("top-tools");y&&E&&y.insertBefore(M,E);function X(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 U(){!y||!O||!E||!q||(window.matchMedia("(max-width: 760px)").matches?O.append(E,q):(y.insertBefore(E,M),y.insertBefore(q,M)))}if(L&&L.addEventListener("click",()=>X(-1)),A&&A.addEventListener("click",()=>X(1)),D&&D.addEventListener("click",()=>{o.activeTabId&&r.closeTab(o.activeTabId)}),I&&I.addEventListener("click",t=>{t.stopPropagation(),et()}),typeof window.matchMedia=="function"){const t=window.matchMedia("(max-width: 760px)");typeof t.addEventListener=="function"&&t.addEventListener("change",U),U()}g&&g.addEventListener("change",()=>{x(Array.from(g.files||[])),g.value=""});const G=document.getElementById("attachBtn");G&&g&&G.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 H(){i.value="",w(),F()}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(),nt()});async function K(){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()||Y();if(n&&n.dead){N(s),r.markTabDead(n.id);return}if(N(s),Q(s),V(s),Z(s),t.startsWith("/")){v(s,f("div","u",t)),P(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),H();const u=t.slice(1).split(/\s+/)[0].toLowerCase();if(u==="clear"){J(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,f("div","detail","↳ "+c("web.misc.command_unavailable")));return}if(s&&s.querySelector(".startbanner")===null&&s.querySelector(".u")===null){const u=f("div","startbanner");u.appendChild(document.createTextNode(c("web.start.label")+" ")),u.appendChild(f("b","",T.config&&T.config.model||m.host.model||"—"));const b=m.host.sessionId?" · "+c("web.start.session")+" "+String(m.host.sessionId):"";u.appendChild(document.createTextNode(" · "+(m.host.provider||T.config&&T.config.provider&&T.config.provider.active||"—")+" · "+z()+b)),s.insertBefore(u,s.firstChild)}v(s,ct(t,e)),P(),n&&(n.draft="",n.attachments=[]),o.attachments=[],renderAttachments(),H(),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,f("div","detail",String(l.data.notice)));else if(l.data&&l.data.queued){const u=l.data.queuedForSession||l.data.queued;v(s,f("div","detail","↳ "+c("web.input.queued",{n:u}))),a&&r.setTabStatus(a,"queued")}else window.setTimeout(()=>$(s),180);else{const u=l.data&&l.data.error||l.status,b=u==="queue_full"?c("web.input.queue_full"):u;v(s,f("div","warnline","⚠ "+b)),a&&r.setTabStatus(a,"failed")}}async function R(){const t=r.activeTab(),e=t&&t.kind==="session"?t.id:null,n=m.runningSessionIds||[];e&&!n.includes(e)||!e&&!m.busy||await S("/api/interrupt",{method:"POST",body:e?{sessionId:e}:{}})}i.addEventListener("keydown",t=>{t.isComposing||t.keyCode===229||at(t)||(t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),K()):t.key==="Escape"&&(t.preventDefault(),R()))}),p&&p.addEventListener("click",()=>{const t=r.activeTab();t&&t.kind==="session"&&m.runningSessionIds.includes(t.id)?R():K()});export function reflectBusy(){const t=r.activeTab(),e=m.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),p){const d=n?c("web.input.stop"):c("web.input.send");p.textContent="",p.appendChild(_(n?"square":"arrow-up")),p.classList.toggle("busy",n),p.title=d,p.setAttribute("aria-label",d)}const s=document.getElementById("hintEsc");s&&(s.hidden=!n),tt(m.busy)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{msgs as
|
|
1
|
+
import{msgs as x,inp as C,tabstripEl as c,el as p,icon as O,link as B}from"../dom.js";import{api as b}from"../api.js";import{t as d}from"../i18n.js";import{tabs as i,session as f,hooks as v}from"../store.js";import{makeFeed as D,showEmptyFeed as F,activeFeed as P,appendTo as I,feedHasContent as N,loadHistory as _,syncUrl as y,scrollToBottom as w}from"../feed.js";import{setIndicator as M}from"../dialog.js";import{sidebarSessionChanged as L,setSessionLoading as S}from"../sidebar.js";import{setSessOpen as Y}from"../core/menus.js";import{closeCmdk as H}from"./cmdk.js";import{saveComposer as A,restoreComposer as E,renderAttachments as J,renderSessBar as W,initComposer as K}from"./composer.js";import{renderSessionsDropdown as m,initSessionsMenu as U}from"./sessions-menu.js";export{reflectBusy}from"./composer.js";export{loadCommands}from"./cmdk.js";export{renderSessionsDropdown}from"./sessions-menu.js";const V={working:"●",waiting:"◉",queued:"○",failed:"✗",dead:"✗"},q="mma-open-tabs";function h(){try{const e=i.tabs.filter(s=>s.kind==="session"&&!s.dead).map(s=>String(s.id)),t=i.tabs.find(s=>s.id===i.activeTabId),n={ids:e,active:t&&t.kind==="session"&&!t.dead?String(t.id):null};localStorage.setItem(q,JSON.stringify(n))}catch{}}export function readSavedTabs(){try{const e=localStorage.getItem(q);if(!e)return{ids:[],active:null};const t=JSON.parse(e),n=Array.isArray(t.ids)?t.ids.filter(a=>typeof a=="string"):[],s=typeof t.active=="string"?t.active:null;return{ids:n,active:s}}catch{return{ids:[],active:null}}}function T(e){return e==="working"?d("web.tab.working"):e==="waiting"?d("web.tab.waiting"):e==="queued"?d("web.tab.queued"):e==="failed"?d("web.tab.failed"):e==="dead"?d("web.tab.gone"):""}export function activeTab(){return i.tabs.find(e=>e.id===i.activeTabId)||null}export function setTabStatus(e,t){if(!e)return;const n=i.tabs.find(s=>s.id===e);!n||n.status===t||n.dead||(n.status=t,u())}export function markTabDead(e){const t=i.tabs.find(a=>a.id===e);if(!t||t.dead)return;t.dead=!0,t.status="dead",t.historyLoaded=!0,t.historyFailed=!1,t.planCard=null,S(!1),t.feed.replaceChildren();const n=p("div","warnline","✗ "+d("web.session.gone"));I(t.feed,n);const s=B(d("web.topbar.close"),"",()=>closeTab(e));I(t.feed,s),t.feed===P()&&w(),u()}function u(){c.textContent="",i.tabs.forEach(e=>{const t=e.id===i.activeTabId,n=e.name||e.id,s=e.kind==="session"?String(e.id):n,a=p("div","stab"+(t?" on":""));if(a.setAttribute("role","tab"),a.setAttribute("tabindex",t?"0":"-1"),a.setAttribute("aria-selected",t?"true":"false"),a.setAttribute("aria-label",n),a.title=s,e.status&&e.status!=="idle"){const l=p("span","dot st-"+e.status,V[e.status]||"●");l.title=T(e.status),l.setAttribute("aria-label",T(e.status)),a.appendChild(l)}const o=p("span","name",n);o.title=s,a.appendChild(o);const r=p("button","stab-x");r.type="button",r.title=d("web.topbar.close"),r.setAttribute("aria-label",d("web.topbar.close")+": "+n),r.appendChild(O("x")),r.addEventListener("click",l=>{l.stopPropagation(),closeTab(e.id)}),a.appendChild(r);const k=()=>openTab(e.id,e.name,e.kind,!0);a.addEventListener("click",k),a.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),k())}),c.appendChild(a)}),j(),W()}function j(){const e=c.querySelector(".stab.on");if(!e)return;const t=Math.max(0,e.offsetLeft-4);(t<c.scrollLeft||t+e.offsetWidth>c.scrollLeft+c.clientWidth)&&(c.scrollLeft=t)}c.addEventListener("wheel",e=>{e.deltaY!==0&&(e.preventDefault(),c.scrollLeft+=e.deltaY)},{passive:!1});export function updateTabName(e,t){if(!e||!t)return;const n=i.tabs.find(a=>a.id===e);n&&n.name!==t&&(n.name=t,u());const s=f.sessions.find(a=>a.id===e);s&&s.name!==t&&(s.name=t,m())}export function openTab(e,t,n,s,a=!0){a&&A();let o=i.tabs.find(r=>r.id===e);if(o?t&&(o.name=t):(o={id:e,name:t||e,kind:n||"session",feed:D(),historyLoaded:!1,historyLoading:!1,historyFailed:!1,dead:!1,planCard:null,draft:"",attachments:[],status:"idle"},i.tabs.push(o)),!a){u(),m(),h();return}if(i.activeTabId=e,i.liveTabId=e,(n||"session")==="session"&&(f.activeSessionId=e,L(e),v.ensureTabState?.(e)),x.replaceChildren(o.feed),E(o),u(),m(),w(),o.kind==="session"&&!s&&(o.historyLoaded=!0),s&&o.kind==="session"){if(o.dead){y(),h();return}(!N(o.feed)||o.historyFailed)&&(o.historyLoaded=!1),S(!0),b("/api/sessions/activate",{method:"POST",body:{id:e}}).then(r=>{if(r.status===404){markTabDead(e),loadSessions();return}loadSessions()}),_(o).then(r=>{r&&r.gone&&markTabDead(o.id)})}y(),h()}export function closeTab(e){const t=i.tabs.findIndex(s=>s.id===e);if(t===-1)return;const n=i.activeTabId===e;if(n&&A(),i.tabs=i.tabs.filter(s=>s.id!==e),n){const s=i.tabs[Math.min(t,i.tabs.length-1)];s?(i.activeTabId=s.id,i.liveTabId=s.id,x.replaceChildren(s.feed),E(s),s.kind==="session"&&(f.activeSessionId=s.id,L(s.id),v.ensureTabState?.(s.id),b("/api/sessions/activate",{method:"POST",body:{id:s.id}})),w()):z()}u(),m(),y(),h()}function z(){i.activeTabId=null,i.liveTabId=null,f.activeSessionId=null,f.host={},C&&(C.value=""),i.attachments=[],J(),v.renderActive?.(),F(),h(),b("/api/sessions/deactivate",{method:"POST",body:{}})}async function g(){const e=await b("/api/sessions",{method:"POST",body:{}});if(e.ok&&e.data&&e.data.session&&e.data.session.id){const t=e.data.session;openTab(t.id,t.name||String(t.id),"session",!1),await loadSessions(),S(!0);return}i.newSeq++,openTab("new"+i.newSeq,d("web.empty.title"),"new",!1),M(d("web.sessions.create_failed"),!0)}document.getElementById("newChat")?.addEventListener("click",()=>{g()});export function reconcileTabStatuses(){const e=f.runningSessionIds||[],t=f.queued||{};let n=!1;i.tabs.forEach(s=>{if(s.kind!=="session"||s.status==="waiting"||s.status==="failed"||s.status==="dead")return;const a=e.includes(s.id)?"working":t[s.id]>0?"queued":"idle";s.status!==a&&(s.status=a,n=!0)}),n&&u()}export async function loadSessions(){const e=await b("/api/sessions");!e.ok||!e.data||(f.sessions=Array.isArray(e.data.sessions)?e.data.sessions:[],m())}document.addEventListener("click",()=>{document.querySelectorAll("[data-sel]").forEach(e=>e.classList.remove("open")),Y(!1),H()}),K({activeTab,setTabStatus,newChatTab:g,markTabDead,openTab,closeTab,statusTitle:T}),U({openTab,closeTab,loadSessions,newChatTab:g});
|
|
@@ -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","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.checkOnStart","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(s){return{ok:!1,error:s instanceof Error?s.message:"invalid JSON"}}}function u(i,e){const s=a("input");return s.setAttribute("aria-label",i),s.value=e,s}function m(i,e,s){const l=s.optionsSource==="providers"?e.providerOptions||[]:e.modelOptions||[],t=typeof i=="string"?i:"";if(!l.length){const o=u(e.label,t);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===t&&(y.selected=!0),n.appendChild(y)}),t&&!d.has(t)){const o=a("option","",t);o.value=t,o.selected=!0,n.appendChild(o)}return n.value=t||"",n.addEventListener("change",()=>e.post(n.value)),n}export function controlFor(i,e,s){if(i.readOnly){const t=a("span","val dim",e==null?"—":String(e));return e!=null&&(t.title=String(e)),t}if(i.valueType==="bool")return g(!!e,t=>(s.post(t),!0));if(i.valueType==="enum"){const t=a("select");return t.setAttribute("aria-label",s.label),(i.enum||[]).forEach(n=>{const c=a("option","",s.enumLabel(n));c.value=n,n===e&&(c.selected=!0),t.appendChild(c)}),t.addEventListener("change",()=>s.post(t.value)),t}if(i.valueType==="int"){const t=u(s.label,e==null?"":String(e));return t.type="number",i.min!=null&&(t.min=String(i.min)),i.max!=null&&(t.max=String(i.max)),i.step!=null&&(t.step=String(i.step)),t.addEventListener("change",()=>s.post(t.value)),t}if(i.valueType==="share"){const t=u(s.label,e==null?"":Math.round(Number(e)*100)+"%");return t.addEventListener("change",()=>s.post(t.value)),t}const r=i.editor;if(r&&r.kind==="select")return m(e,s,r);if(r&&r.kind==="tags"&&(i.valueType==="list"||i.valueType==="json"))return b(e,s,r);if(r&&r.kind==="checkboxes")return p(e,s,r);if(r&&r.kind==="table")return w(e,s,r);if(i.valueType==="list"){const t=Array.isArray(e)?e.join(", "):e==null?"":String(e),n=u(s.label,t);return n.placeholder="a, b, c",n.addEventListener("change",()=>s.post(n.value)),n}if(i.valueType==="json"){const t=a("div","jsonctl"),n=a("textarea");n.setAttribute("aria-label",s.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?s.post(n.value.trim()):n.focus()}),t.appendChild(n),t.appendChild(c),t}const l=u(s.label,e==null?"":String(e));return l.addEventListener("change",()=>s.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.checkOnStart","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,s]of Object.entries(PANEL_SECTIONS))for(const r of s)for(const l of r.keys)i.set(l,e);return i}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{el as l,icon as
|
|
1
|
+
import{el as l,icon as B,link as q,connStatus as k,staleBar as y}from"../dom.js";import{api as I}from"../api.js";import{t as s,loadI18n as z}from"../i18n.js";import{settings as c,session as R,setPath as W,getPath as F,hooks as O}from"../store.js";import{contextLabel as T,matchesQuery as K}from"../format.js";import{closeAllMenus as v,setSessOpen as G}from"../core/menus.js";import{setIndicator as L}from"../dialog.js";import{setLayout as H}from"../rail.js";function S(e,n,o){e&&(e.textContent=n+":",e.appendChild(l("b","",o)),e.appendChild(B("chevron-down")))}function x(e,n,o,t){const i=l("button","mi"+(o?" on":""));return i.type="button",i.setAttribute("aria-pressed",o?"true":"false"),i.appendChild(l("span","",e)),n&&i.appendChild(l("span","sub",n)),i.addEventListener("click",r=>{r.stopPropagation(),t(),v()}),i}function D(e,n,o){const t=l("button","mi row-mi");return t.type="button",n&&t.appendChild(B(n)),t.appendChild(l("span","",e)),t.addEventListener("click",i=>{i.stopPropagation(),v(),o()}),t}let C="";export function renderSelectors(){const e=c.config||{},n=e.provider||{};S(document.getElementById("selModelBtn"),s("web.selectors.model"),e.model||"—");const o=document.getElementById("selModelMenu");o.textContent="";const t=document.createElement("input");t.id="selModelSearch",t.className="searchbox",t.type="search",t.autocomplete="off",t.spellcheck=!1,t.placeholder=s("web.selectors.search_models"),t.setAttribute("aria-label",s("web.selectors.search_models")),t.value=C,t.addEventListener("click",d=>d.stopPropagation()),o.appendChild(t);const i=l("div","model-menu-list");o.appendChild(i);const r=()=>{i.textContent="";const d=c.models.filter(a=>K(a,C));if(!d.length){i.appendChild(l("div","mi dim",c.models.length?s("web.settings.no_matches"):s("web.selectors.no_models")));return}d.forEach(a=>{const p=x(String(a),"",a===e.model,()=>{C="",postConfig("model",a,!0)});p.addEventListener("keydown",g=>{g.key==="ArrowUp"&&p===i.querySelector(".mi:not(.dim)")&&(g.preventDefault(),g.stopPropagation(),t.focus())}),i.appendChild(p)})};t.addEventListener("input",()=>{C=t.value,r()}),t.addEventListener("keydown",d=>{if(d.stopPropagation(),d.key==="ArrowDown"){d.preventDefault();const a=i.querySelector(".mi:not(.dim)");a&&a.focus()}else if(d.key==="Enter"){d.preventDefault();const a=i.querySelector(".mi:not(.dim)");a&&a.click()}else d.key==="Escape"&&(t.value?(d.preventDefault(),t.value="",C="",r()):v())}),r(),o.appendChild(l("div","sep")),o.appendChild(D(s("web.selectors.refresh_list"),"refresh",()=>{loadModels().then(renderSelectors)})),S(document.getElementById("selProviderBtn"),s("web.selectors.provider"),n.active||n.type||"—");const u=document.getElementById("selProviderMenu");u.textContent="",(Array.isArray(n.entries)&&n.entries.length?n.entries:[{label:n.active||n.type,type:n.type}]).forEach(d=>{const a=d.label||d.type;a&&u.appendChild(x(a,d.type||"",a===(n.active||n.type),()=>{postConfig("provider.active",a,!0)}))});const A=!!c.config&&e.contextAuto!==!1;S(document.getElementById("selContextBtn"),s("web.selectors.context"),A?s("web.selectors.auto"):T());const m=document.getElementById("selContextMenu");m.textContent="",m.appendChild(x(s("web.selectors.auto"),A?T():"",A,()=>{postConfig("contextAuto",!0,!1)})),m.appendChild(l("div","sep")),[8192,16384,32768,65536,131072].forEach(d=>{const a=!A&&d===e.contextWindow;m.appendChild(x(Math.round(d/1024)+"K",a?s("web.selectors.current"):"",a,()=>{postConfig("contextWindow",d,!1)}))}),m.appendChild(l("div","sep"));const w=l("button","mi row-mi");w.type="button",w.appendChild(B("settings")),w.appendChild(l("span","",s("web.selectors.custom"))),w.addEventListener("click",d=>{if(d.stopPropagation(),m.querySelector(".ctx-custom"))return;const a=l("div","ctx-custom"),p=l("input");p.type="number",p.min="1024",p.step="1024",p.value=String(e.contextWindow||32768),p.placeholder=s("web.selectors.context_prompt"),p.setAttribute("aria-label",s("web.selectors.context_prompt"));const g=()=>{const f=Number(p.value.trim());Number.isFinite(f)&&f>=1024?(v(),postConfig("contextWindow",f,!1)):p.focus()};p.addEventListener("click",f=>f.stopPropagation()),p.addEventListener("keydown",f=>{f.stopPropagation(),f.key==="Enter"?(f.preventDefault(),g()):f.key==="Escape"&&a.remove()});const N=q(s("web.settings.save"),"",g);a.appendChild(p),a.appendChild(N),m.appendChild(a),setTimeout(()=>p.focus(),0)}),m.appendChild(w),j(),_()}const U=["auto","default","none","low","medium","high","max"],V=["auto","default","none","low","high"];function j(){const e=document.querySelector('[data-sel="reasoning"]'),n=document.getElementById("selReasoningBtn"),o=document.getElementById("selReasoningMenu");if(!e||!n||!o)return;const t=R.reasoning;if(!t||t.strategy==="none"){e.hidden=!0;return}if(e.hidden=!1,t.supported===!1){S(n,s("web.selectors.reasoning"),s("web.selectors.reasoning_off")),o.textContent="",o.appendChild(l("div","mi dim",s("reasoning.probe_failed"))),o.appendChild(l("div","sep")),o.appendChild(D(s("web.settings.reasoning"),"settings",()=>b.openSettingsAt?.("reasoning")));return}const i=c.config&&F(c.config,"reasoning.mode")||t.mode||"auto";S(n,s("web.selectors.reasoning"),String(i)),o.textContent="",(t.strategy==="openai-effort"?U:V).forEach(u=>{o.appendChild(x(u,u===i?s("web.selectors.current"):"",u===i,()=>{postConfig("reasoning.mode",u,!1)}))})}document.querySelectorAll("[data-sel]").forEach(e=>{const n=e.querySelector("button");n&&(n.setAttribute("aria-haspopup","menu"),n.setAttribute("aria-expanded","false"),n.addEventListener("click",o=>{o.stopPropagation(),G(!1),document.querySelectorAll("[data-sel]").forEach(i=>{if(i!==e){i.classList.remove("open");const r=i.querySelector("button");r&&r.setAttribute("aria-expanded","false")}});const t=e.classList.toggle("open");if(n.setAttribute("aria-expanded",t?"true":"false"),t&&e.dataset&&e.dataset.sel==="model"){const i=document.getElementById("selModelSearch");i&&setTimeout(()=>i.focus(),0)}}))});const Q=["provider.active","model","contextWindow","contextAuto","reasoning.mode"];let P=0,E=null,b={renderSettings:null,openSettingsAt:null};export function setWriteHooks(e){b={...b,...e}}function _(){const e=E!==null||!c.config,n=document.querySelector(".selectors");n&&(e?n.setAttribute("data-pending",E||"boot"):n.removeAttribute("data-pending")),["selProviderBtn","selModelBtn","selContextBtn","selReasoningBtn"].forEach(o=>{const t=document.getElementById(o);t&&(t.classList.toggle("pending",e),t.setAttribute("aria-busy",e?"true":"false"))})}export async function postConfig(e,n,o){const t=Q.indexOf(e)!==-1;if(t&&E!==null)return L(s("web.selectors.switch_busy"),!0),!1;let i=0;t&&(i=++P,E=e,v(),_());try{const r=await I("/api/config",{method:"POST",body:{key:e,value:n}});if(!r.ok||!r.data||!r.data.ok){const M=r.data&&(r.data.error||r.data.reason)||r.status||s("web.settings.save_failed");return L(String(M),!0),!1}const u=r.data.persisted!==!1;return e==="contextAuto"&&r.data.probed===!1?L(s("web.selectors.auto_failed"),!0):L(u?s("web.settings.saved"):r.data.warning||"not persisted",!u),c.config&&r.data.value!==void 0&&W(c.config,e,r.data.value),e==="contextAuto"&&c.config&&typeof r.data.contextWindow=="number"&&W(c.config,"contextWindow",r.data.contextWindow),e==="ui.activityRail"&&H(String(r.data.value)),e==="ui.fontSize"&&applyFontSize(String(r.data.value)),e==="locale"&&(await z(),O.applyStaticI18n&&O.applyStaticI18n(),b.renderSettings?.()),e==="provider.active"||e==="model"?await Promise.all([loadConfig(),loadModels()]):t&&await loadConfig(),t&&i!==P||(renderSelectors(),o&&b.renderSettings?.()),!0}finally{t&&i===P&&(E=null,_())}}export async function loadConfig(){const e=await I("/api/config");!e.ok||!e.data||(c.config=e.data.config||{},c.registry=Array.isArray(e.data.registry)?e.data.registry:[],c.webToken=typeof e.data.webToken=="string"?e.data.webToken:null,applyFontSize(),renderSelectors(),b.renderSettings?.())}export async function loadModels(){const e=await I("/api/models");!e.ok||!e.data||(c.models=Array.isArray(e.data.models)?e.data.models:[],e.data.reasoning&&typeof e.data.reasoning=="object"&&(R.reasoning=e.data.reasoning),renderSelectors())}export function setConnStatus(e){k&&(k.hidden=!e,k.textContent=e?"⋯ "+s("web.conn.reconnecting"):"")}let h=null;export function setStaleBar(e,n){if(!y)return null;const o=e===void 0?!!h:!!e;return!n&&o===h||(h=o,y.hidden=!o,y.textContent="",!o)||(y.appendChild(l("span","","⚠ "+s("web.i18n.stale")+" ")),y.appendChild(q(s("web.i18n.reload"),"",()=>location.reload()))),h}export function applyFontSize(e){const n=e||c.config&&c.config.ui&&c.config.ui.fontSize||"comfortable",o=n==="compact"||n==="large"?n:"comfortable";o==="comfortable"?document.body.removeAttribute("data-font"):document.body.setAttribute("data-font",o)}
|