@amd-gaia/agent-ui 0.25.4 → 0.26.0-rc.2

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.
@@ -1 +1 @@
1
- import{q as e}from"./useT-CtECS-vp.js";var t={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};t.node;var n=e(t),r={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};r.node;var i=e(r);export{n,i as t};
1
+ import{q as e}from"./useT-C0ow1Kps.js";var t={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};t.node;var n=e(t),r={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};r.node;var i=e(r);export{n,i as t};
package/dist/index.html CHANGED
@@ -12,11 +12,11 @@
12
12
  <meta name="apple-mobile-web-app-capable" content="yes" />
13
13
  <meta name="apple-mobile-web-app-title" content="GAIA" />
14
14
  <title>GAIA Agent UI</title>
15
- <script type="module" crossorigin src="./assets/index-CsgZhHsw.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-D8wu2yy4.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
17
- <link rel="modulepreload" crossorigin href="./assets/useT-CtECS-vp.js">
18
- <link rel="modulepreload" crossorigin href="./assets/api-D5mTAXjB.js">
19
- <link rel="stylesheet" crossorigin href="./assets/index-B7tI0eKR.css">
17
+ <link rel="modulepreload" crossorigin href="./assets/useT-C0ow1Kps.js">
18
+ <link rel="modulepreload" crossorigin href="./assets/api-9RdlUJAP.js">
19
+ <link rel="stylesheet" crossorigin href="./assets/index-LLooEbjq.css">
20
20
  </head>
21
21
  <body>
22
22
  <div id="root"></div>
package/dist/sw.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // never sees a stale UI or stale data.
10
10
 
11
11
  const CACHE_PREFIX = 'gaia-assets-';
12
- const CACHE_NAME = CACHE_PREFIX + '0.25.4-f9c04029eab871f5';
12
+ const CACHE_NAME = CACHE_PREFIX + '0.26.0rc2-c6932d3e03cf42c5';
13
13
  const ASSETS_PATH = new URL('assets/', self.registration.scope).pathname;
14
14
 
15
15
  self.addEventListener('install', () => {
package/main.cjs CHANGED
@@ -733,11 +733,10 @@ function createWindow() {
733
733
  platform: process.platform,
734
734
  reportNoticeError: (err) => {
735
735
  console.error("[main] First-close notice failed:", err.message);
736
- const where = process.platform === "darwin" ? "menu bar" : "tray";
736
+ const { message, detail } = trayManager.closeNoticeText();
737
737
  dialog.showErrorBox(
738
738
  "GAIA is still running",
739
- `GAIA is still running in the ${where}. Quit from the ${where} menu to stop it.\n\n` +
740
- `(The usual notice failed: ${err.message})`
739
+ `${message} ${detail}\n\n(The usual notice failed: ${err.message})`
741
740
  );
742
741
  },
743
742
  });
@@ -1396,14 +1395,20 @@ function workCanBeLost() {
1396
1395
  return Boolean(trayManager && backendProcess);
1397
1396
  }
1398
1397
 
1399
- /** Ask about losing work in front of the window, even when it was hidden in the tray. */
1398
+ /** Ask about losing work in front of the window, even when it was hidden or minimized. */
1400
1399
  function askAboutRunningWork(action) {
1401
1400
  return confirmQuit({
1402
1401
  action,
1403
1402
  getWork: () => fetchWorkInProgress(backendPort),
1404
1403
  showMessageBox: (opts) => {
1405
1404
  if (!mainWindow || mainWindow.isDestroyed()) return dialog.showMessageBox(opts);
1405
+ const wasMinimized = mainWindow.isMinimized();
1406
+ if (wasMinimized) mainWindow.restore();
1406
1407
  if (!mainWindow.isVisible()) mainWindow.show();
1408
+ // Wayland can't un-minimize a window, and a modal would stay minimized with it.
1409
+ if (process.platform === "linux" && wasMinimized && !mainWindow.isFocused()) {
1410
+ return dialog.showMessageBox(opts);
1411
+ }
1407
1412
  return dialog.showMessageBox(mainWindow, opts);
1408
1413
  },
1409
1414
  });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@amd-gaia/agent-ui",
3
- "version": "0.25.4",
3
+ "version": "0.26.0-rc.2",
4
4
  "type": "module",
5
5
  "productName": "GAIA Agent UI",
6
+ "desktopName": "gaia-desktop.desktop",
6
7
  "description": "Chat with the GAIA agent - local and private by default on AMD Ryzen AI, cloud models when you choose them",
7
8
  "author": "AMD AI Group",
8
9
  "license": "MIT",
@@ -197,9 +197,11 @@ function installQuitGuard({ app, updater, shouldAsk, confirm, onQuitting, onErro
197
197
  }
198
198
 
199
199
  /**
200
- * What closing the window does: hide it to the tray (telling the user once),
201
- * or, when closing quits, run the quit guard first and keep the window open
202
- * until it agrees. An OS sign-out (Windows' session-end) never waits on it.
200
+ * What closing the window does: hide it to the tray, or minimize it where
201
+ * there is no tray (telling the user once either way), or, when closing quits,
202
+ * run the quit guard first and keep the window open until it agrees. A close
203
+ * while GAIA sits minimized is a dock Quit, so it quits. An OS sign-out
204
+ * (Windows' session-end) never waits on the guard.
203
205
  *
204
206
  * @param {Electron.BrowserWindow} win
205
207
  * @param {{app: Electron.App, guard: ReturnType<typeof installQuitGuard>,
@@ -207,13 +209,30 @@ function installQuitGuard({ app, updater, shouldAsk, confirm, onQuitting, onErro
207
209
  * reportNoticeError: (err: Error) => void}} deps
208
210
  */
209
211
  function attachWindowGuards(win, { app, guard, getTray, isQuitting, platform, reportNoticeError }) {
212
+ let minimizedByClose = false;
213
+ // On Wayland a restore from the dock may arrive only as focus, so that counts too.
214
+ for (const back of ["restore", "focus", "show"]) {
215
+ win.on(back, () => {
216
+ minimizedByClose = false;
217
+ });
218
+ }
210
219
  win.on("close", (event) => {
211
220
  if (isQuitting()) return;
212
221
  const tray = getTray();
213
- if (tray && tray.minimizeToTray) {
222
+ const action = tray ? tray.closeAction : "quit";
223
+ // Focus wins over isMinimized(), which Wayland can leave stale after a dock restore.
224
+ const dockQuit =
225
+ action === "minimize" && !win.isFocused() && (minimizedByClose || win.isMinimized());
226
+ if (action === "hide" || (action === "minimize" && !dockQuit)) {
214
227
  event.preventDefault();
215
- win.hide();
216
- console.log("[main] Window hidden to tray");
228
+ if (action === "hide") {
229
+ win.hide();
230
+ console.log("[main] Window hidden to tray");
231
+ } else {
232
+ win.minimize();
233
+ minimizedByClose = true;
234
+ console.log("[main] Window minimized; no tray to hide it in");
235
+ }
217
236
  if (tray.closeNoticeDue) {
218
237
  Promise.resolve()
219
238
  .then(() => tray.showCloseNotice())
@@ -8,7 +8,7 @@
8
8
  * StatusNotifierItem, which shows only when a host owns the
9
9
  * `org.kde.StatusNotifierWatcher` name on the session bus. Stock GNOME has
10
10
  * none (its AppIndicator extension adds one), so hiding the window there
11
- * leaves GAIA running with no way back to it.
11
+ * would leave GAIA running with no way back to it; GAIA minimizes instead.
12
12
  */
13
13
 
14
14
  const { execFile } = require("child_process");
@@ -338,6 +338,16 @@ class TrayManager {
338
338
  return this.config.tray.minimizeToTray && this.trayHost.available;
339
339
  }
340
340
 
341
+ /**
342
+ * What closing the window does. With no tray to find a hidden window in,
343
+ * GAIA minimizes instead, so the dock still shows it and offers Quit.
344
+ * @returns {"hide" | "minimize" | "quit"}
345
+ */
346
+ get closeAction() {
347
+ if (!this.config.tray.minimizeToTray) return "quit";
348
+ return this.trayHost.available ? "hide" : "minimize";
349
+ }
350
+
341
351
  /** @returns {boolean} Whether app should start minimized, which also needs a tray. */
342
352
  get startMinimized() {
343
353
  return this.config.tray.startMinimized && this.trayHost.available;
@@ -356,7 +366,7 @@ class TrayManager {
356
366
  this._host = { available: host.available, reason: host.available ? null : host.reason };
357
367
  if (!host.available) {
358
368
  console.log(
359
- `[tray] No tray icon host (${host.reason}: ${host.detail || "no detail"}); closing the window quits GAIA`
369
+ `[tray] No tray icon host (${host.reason}: ${host.detail || "no detail"}); closing the window minimizes GAIA`
360
370
  );
361
371
  }
362
372
  }
@@ -373,7 +383,8 @@ class TrayManager {
373
383
 
374
384
  /** @returns {boolean} Whether the one-time "still running in the tray" notice is still due. */
375
385
  get closeNoticeDue() {
376
- return !this.config.notices.firstClose;
386
+ // Held while the tray check runs, so a dock notice never uses up the tray one.
387
+ return !this.config.notices.firstClose && this.trayHost.reason !== "checking";
377
388
  }
378
389
 
379
390
  /**
@@ -386,12 +397,12 @@ class TrayManager {
386
397
  const next = { ...this.config, notices: { ...this.config.notices, firstClose: true } };
387
398
  this._saveConfig(next);
388
399
  this.config = next;
389
- const where = process.platform === "darwin" ? "menu bar" : "tray";
400
+ const { message, detail } = this.closeNoticeText();
390
401
  const { response } = await dialog.showMessageBox({
391
402
  type: "info",
392
403
  title: "GAIA is still running",
393
- message: `GAIA is still running in the ${where}.`,
394
- detail: `Quit from the ${where} menu to stop it. Closing the window keeps your model loaded, so the next chat starts quickly.`,
404
+ message,
405
+ detail,
395
406
  buttons: ["OK", "Quit GAIA"],
396
407
  defaultId: 0,
397
408
  cancelId: 0,
@@ -400,6 +411,22 @@ class TrayManager {
400
411
  return response === 1;
401
412
  }
402
413
 
414
+ /** @returns {{message: string, detail: string}} Where the closed window went and how to quit. */
415
+ closeNoticeText() {
416
+ const loaded = "Closing the window keeps your model loaded, so the next chat starts quickly.";
417
+ if (this.closeAction === "minimize") {
418
+ return {
419
+ message: "GAIA is still running in the dock.",
420
+ detail: `${loaded} Click GAIA in the dock to bring it back. To stop it, right-click GAIA there and choose Quit.`,
421
+ };
422
+ }
423
+ const where = process.platform === "darwin" ? "menu bar" : "tray";
424
+ return {
425
+ message: `GAIA is still running in the ${where}.`,
426
+ detail: `Quit from the ${where} menu to stop it. ${loaded}`,
427
+ };
428
+ }
429
+
403
430
  // ── Private: Rendering ───────────────────────────────────────────────
404
431
 
405
432
  _render() {
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{I as t,J as n,a as r,c as i,f as a,l as o,u as s}from"./useT-CtECS-vp.js";import{At as c,Bt as l,I as u,R as d,V as f,Y as p,jt as m,q as h,ut as g}from"./api-D5mTAXjB.js";import{Ft as _,Lt as v,Vt as y,Z as b,a as x,c as S,d as C,et as w,f as T,l as E,o as D,r as O,s as k,vt as A}from"./index-CsgZhHsw.js";var j=e(n(),1);function M(){let e=r(),t=a(e=>e.runSetupAgain),n=a(e=>e.closeSettings),[l,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(null),[m,h]=(0,j.useState)(``),[g,_]=(0,j.useState)(``),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)(null),[w,T]=(0,j.useState)(!1);(0,j.useEffect)(()=>{u().then(e=>{d(e),h(e.saved_base_url??e.base_url??``)}).catch(e=>p(e instanceof Error?e.message:String(e)))},[]);let E=(0,j.useCallback)(async e=>{b(!0),S(null);try{let r=await c(e);d(r),_(``),T(!1),r.mode===`gaia`&&!r.gaia_installed&&(n(),t(!0))}catch(e){T(C(e)),S(e instanceof Error?e.message:String(e))}finally{b(!1)}},[n,t]),D=()=>void E({mode:`external`,base_url:m.trim(),api_key:g.trim()||void 0});if(f)return s(`section`,{className:`settings-section`,children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),s(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),s(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:e(`settings.server.readFailed`)}),o(`p`,{children:f})]})]})]});if(!l)return null;let O=l.mode===`external`,k=l.source===`env`;return s(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(`p`,{className:`model-override-desc`,role:`status`,children:k?e(`settings.server.usesEnv`,{url:l.base_url??``}):O?e(`settings.server.usesYours`,{url:l.base_url??``}):e(`settings.server.usesOwn`)}),!k&&l.env_url_ignored&&o(`p`,{className:`model-status-hint`,children:e(`settings.server.envIgnored`,{url:l.env_url_ignored})}),k?o(`p`,{className:`model-status-hint`,children:e(`settings.server.envUseOwn`)}):s(i.Fragment,{children:[s(`p`,{className:`model-status-hint`,children:[e(`settings.server.useYours`),` `,o(`bdi`,{children:l.what_gaia_does})]}),s(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),D()},children:[o(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:m,onChange:e=>{h(e.target.value),S(null)},disabled:y,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.server.address`)}),o(`input`,{type:`password`,className:`model-input`,autoComplete:`off`,placeholder:l.api_key_stored?e.bare(`settings.server.keySaved`):e.bare(`settings.server.keyOptional`),value:g,onChange:e=>_(e.target.value),disabled:y,"aria-label":e(`settings.server.key`)}),o(`div`,{className:`model-btn-group`,children:o(`button`,{type:`submit`,className:`btn-model-save`,disabled:y||!m.trim(),children:y?s(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.server.checking`)]}):e(`settings.server.use`)})})]})]}),O&&o(`div`,{className:`setting-actions`,children:o(`button`,{type:`button`,className:`btn-secondary`,disabled:y,onClick:()=>void E({mode:`gaia`}),children:e(`settings.server.useOwn`)})}),x&&s(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),s(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:e(w?`settings.server.needsKey`:`settings.server.notSwitched`)}),o(`p`,{children:x})]})]})]})}var N={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},P={gaia:`settings.server.ownerGaia`,user:`settings.server.ownerUser`,remote:`settings.server.ownerRemote`};function F(e){return e?N[e]??e:`unknown`}function I(e){if(!e)return`unknown`;let t=F(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function L(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}var R={asr:`settings.server.kind.speechRecognition`,embedding:`settings.server.kind.embedding`,image:`settings.server.kind.image`,llm:`settings.server.kind.language`,rerank:`settings.server.kind.reranker`,reranking:`settings.server.kind.reranker`,stt:`settings.server.kind.speechRecognition`,transcription:`settings.server.kind.speechRecognition`,tts:`settings.server.kind.speech`,vision:`settings.server.kind.vision`,"3d":`settings.server.kind.threeD`};function z(e,t){if(!e.model_type)return t(`settings.server.loadedModel`);let n=e.model_type.toLowerCase(),r=R[n];return r?t(r):t(`settings.server.kindOther`,{kind:`${n.charAt(0).toUpperCase()}${n.slice(1)}`})}function B(e,t){let n=[e.name?w(e.name):t.bare(`settings.server.unknownModel`),I(e)];return e.backend!==`remote`&&e.ctx_size&&n.push(L(e.ctx_size)),n.join(` · `)}function V({label:e,value:t,title:n}){return s(`div`,{className:`status-row`,children:[o(`span`,{className:`status-label`,children:e}),o(`span`,{className:`status-value model-server-value`,dir:`auto`,title:n??t,children:t})]})}function ee(){let e=r(),t=a(e=>e.openSettings),[n,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(null),[d,p]=(0,j.useState)(null),[h,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(!1);(0,j.useEffect)(()=>{f().then(c).catch(e=>u(e instanceof Error?e.message:String(e)))},[]);let b=(0,j.useCallback)(async t=>{p(t),_(null);try{let n=await m(t);c(n),_({ok:!0,text:e(`settings.server.savedBackend`)})}catch(e){_({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{p(null)}},[e]),S=n?.chat_model??null,C=(0,j.useCallback)(async()=>{if(S?.name){y(!0);try{if(!await g(S.name,S.ctx_size??void 0))return;_({ok:!0,text:e(`settings.server.reloading`,{name:S.name})})}catch(e){_({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},[S,e]),T=o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`settings.server.changeModel`)});if(l)return s(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(x,{message:l})]});if(!n)return s(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(`p`,{className:`loading-text`,children:e(`settings.server.checkingServer`)})]});if(!n.reachable)return s(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(x,{message:n.error??e(`settings.errors.serverDownTitle`)}),T]});let E=n.available_backends??[],D=n.preferred_backend??null,O=E.map(e=>e.name);D&&!O.includes(D)&&O.push(D);let k=D??n.default_backend??null,M=E.filter(e=>e.state===`installable`).map(e=>F(e.name)),N=!!S?.name&&S.recipe===`llamacpp`;return s(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),s(`div`,{className:`status-grid`,children:[o(V,{label:e(`settings.server.server`),value:`${P[n.owner]?e(P[n.owner]):n.owner}${n.version?` v${n.version}`:``}`}),o(V,{label:e(`settings.server.addressShort`),value:n.base_url}),o(V,{label:e(`settings.server.chatModel`),value:S?.name?w(S.name):e(`settings.advanced.noneLoaded`),title:S?.name??void 0}),S&&o(V,{label:e(`settings.server.runsOn`),value:I(S)}),S&&S.backend!==`remote`&&o(V,{label:e(`settings.advanced.context`),value:L(S.ctx_size)}),o(V,{label:e(`settings.advanced.embedding`),value:n.embedding_model?.name?`${n.embedding_model.name} · ${I(n.embedding_model)}`:e(`settings.advanced.noneLoaded`)}),(n.loaded_models??[]).map((t,n)=>o(V,{label:z(t,e),value:B(t,e),title:t.name??void 0},`${t.name??`unknown`}-${n}`))]}),n.embedding_note&&o(`p`,{className:`settings-hint`,children:o(`bdi`,{children:n.embedding_note})}),n.system_info_error&&o(`p`,{className:`settings-hint`,children:o(`bdi`,{children:n.system_info_error})}),s(`div`,{className:`settings-field model-server-backend`,children:[o(`span`,{className:`settings-label`,children:e(`settings.server.backend`)}),E.length===0&&!D?o(`span`,{className:`settings-hint`,children:e(`settings.server.noBackends`)}):s(i.Fragment,{children:[o(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":e(`settings.server.backendShort`),children:O.map(e=>s(`button`,{type:`button`,role:`radio`,"aria-checked":k===e,className:k===e?`is-active`:``,disabled:d!==null,onClick:()=>{e!==k&&b(e)},children:[d===e?o(A,{size:12,className:`spin`}):null,F(e)]},e))}),s(`span`,{className:`settings-hint`,children:[e(`settings.server.backendHint`),M.length>0&&` ${e(`settings.server.installable`,{names:M.join(`, `)})}`]})]}),h?.ok&&o(`p`,{className:`settings-ok`,role:`status`,children:h.text}),h&&!h.ok&&o(x,{message:h.text})]}),s(`div`,{className:`settings-row`,children:[T,N&&s(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void C(),disabled:v,children:[v?o(A,{size:13,className:`spin`}):null,e(`settings.server.reload`)]})]})]})}function H(){let e=r(),[n,a]=(0,j.useState)(null),[c,u]=(0,j.useState)(!0),[f,m]=(0,j.useState)([]),[g,C]=(0,j.useState)(``),[w,N]=(0,j.useState)(``),[P,F]=(0,j.useState)(!1),[I,L]=(0,j.useState)(!1),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(!1),H=(0,j.useRef)(null),[W,G]=(0,j.useState)(!1),[K,ne]=(0,j.useState)(!1),[q,re]=(0,j.useState)(!1),[ie,ae]=(0,j.useState)(null);(0,j.useEffect)(()=>{t.system.info(`Checking system status...`);let e=t.system.time();p().then(n=>{a(n),t.system.timed(`System status received`,e,{lemonade:n.lemonade_running?`running`:`stopped`,model:n.model_loaded||`none`,embedding:n.embedding_model_loaded?`yes`:`no`,disk:`${n.disk_space_gb}GB free`,memory:n.memory_available_gb==null?`unknown`:`${n.memory_available_gb}GB available`}),n.lemonade_running||t.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{t.system.error(`Failed to get system status`,e),a(null)}).finally(()=>u(!1)),d().then(e=>m(e.servers)).catch(()=>{}),h().then(e=>{let t=e.custom_model??``;C(t),N(t),G(e.dynamic_tools),ne(e.dynamic_tools_locked)}).catch(e=>{t.system.error(`Failed to load settings`,e)}).finally(()=>F(!0))},[]),(0,j.useEffect)(()=>()=>{H.current&&clearTimeout(H.current)},[]);let oe=(0,j.useCallback)(async()=>{let e=g.trim(),n=e.length>0?e:``;L(!0),z(null),V(!1);try{t.system.info(`Saving custom_model override`,{custom_model:n});let e=(await l({custom_model:n})).custom_model??``;C(e),N(e),V(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>V(!1),2200)}catch(e){let n=e instanceof Error?e.message:String(e);t.system.error(`Failed to save custom_model`,e),z(n)}finally{L(!1)}},[g]),se=(0,j.useCallback)(async()=>{if(K||q)return;let e=W,n=!e;G(n),re(!0),ae(null);try{t.system.info(`Saving dynamic_tools setting`,{dynamic_tools:n});let e=await l({dynamic_tools:n});G(e.dynamic_tools),ne(e.dynamic_tools_locked)}catch(n){let r=n instanceof Error?n.message:String(n);t.system.error(`Failed to save dynamic_tools`,n),G(e),ae(r)}finally{re(!1)}},[W,K,q]),ce=g.trim()!==w.trim(),J=n?n.default_model_name:b,{isLoadingModel:le,isDownloadingModel:Y,downloadError:X,loadModel:ue,downloadModel:de}=O(J??void 0),Z=!!n?.default_model_is_cloud,Q=!Z&&!!(n?.lemonade_running&&n.model_loaded&&n.expected_model_loaded===!1),fe=!Z&&!!(n?.lemonade_running&&n.model_loaded&&n.context_size_sufficient===!1),$=!Z&&!(!n?.lemonade_running||n.model_loaded||n.model_downloaded!==!1),pe=(Q||fe)&&J!==null,me=f.some(e=>!e.connected);return s(`div`,{className:`settings-pane`,children:[o(`h2`,{className:`settings-pane-title`,children:e(`settings.section.advanced`)}),o(`section`,{className:`settings-card`,"aria-label":e(`settings.advanced.status`),children:c?o(`p`,{className:`loading-text`,children:e(`settings.advanced.checking`)}):n?s(i.Fragment,{children:[s(`div`,{className:`status-grid`,children:[o(U,{label:e(`settings.advanced.modelServer`),value:n.lemonade_running?n.lemonade_version?e(`settings.advanced.runningAt`,{version:n.lemonade_version}):e(`settings.advanced.running`):S(n)?e(`settings.advanced.notInstalled`):n.lemonade_error?e(`settings.advanced.unavailable`):e(`settings.advanced.notRunning`),ok:n.lemonade_running,hint:n.lemonade_running?void 0:S(n)?e(`settings.advanced.notInstalledHint`):n.lemonade_error?e(`settings.advanced.queryFailed`,{reason:n.lemonade_error}):n.start_instruction&&!k(n.start_instruction)?n.start_instruction:e(`settings.advanced.notRunningHint`)}),S(n)&&o(D,{className:`btn-primary`}),o(U,{label:e(`settings.section.model`),value:n.model_loaded||e(`settings.advanced.noneLoaded`),ok:!!n.model_loaded&&(Z||n.expected_model_loaded!==!1),hint:n.model_loaded?!Z&&n.expected_model_loaded===!1?e(`settings.advanced.expected`,{name:J??``}):void 0:e(`settings.advanced.loadsFirst`)}),o(U,{label:e(`settings.advanced.disk`),value:s(`bdi`,{dir:`ltr`,children:[n.disk_space_gb,` GB`]}),ok:n.disk_space_gb>5,hint:!n.model_loaded&&n.disk_space_gb<30?e(`settings.advanced.diskLow`,{need:`6 GB`,size:`${n.disk_space_gb} GB`}):void 0})]}),$&&s(`div`,{className:`model-action-row model-action-row--download`,children:[s(`div`,{className:`model-action-info`,children:[o(`span`,{className:`model-action-label`,children:e(`settings.advanced.notDownloaded`)}),o(`span`,{className:`model-action-desc`,children:e(`settings.advanced.notDownloadedHint`,{name:J??``,need:`6 GB`})})]}),o(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>de(!1,void 0,!n.model_loaded),disabled:Y,children:Y?s(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.model.download`)})]}),$&&X&&o(x,{message:X}),pe&&s(`div`,{className:`model-action-row model-action-row--load`,children:[s(`div`,{className:`model-action-info`,children:[o(`span`,{className:`model-action-label`,children:e(Q?`settings.advanced.wrongModel`:`settings.advanced.smallContext`)}),o(`span`,{className:`model-action-desc`,children:e(`settings.advanced.loadHint`,{name:J??``,size:`${32 .toFixed(0)}K`})})]}),o(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>ue(),disabled:le,children:le?s(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.loading`)]}):e(`settings.advanced.load`)})]}),s(`details`,{className:`settings-more`,children:[s(`summary`,{children:[o(y,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.advanced.details`)]}),s(`div`,{className:`status-grid`,children:[n.model_size_gb!=null&&o(U,{label:e(`settings.advanced.modelSize`),value:s(`bdi`,{dir:`ltr`,children:[n.model_size_gb,` GB`]}),ok:!0}),n.model_device&&!Z&&o(U,{label:e(`settings.advanced.device`),value:n.model_device.toUpperCase(),ok:n.model_device!==`cpu`}),n.model_context_size!=null&&o(U,{label:e(`settings.advanced.context`),value:e(`settings.ctx.tokens`,{size:`${(n.model_context_size/1024).toFixed(0)}K`}),ok:n.context_size_sufficient}),n.model_labels&&n.model_labels.length>0&&o(U,{label:e(`settings.advanced.capabilities`),value:n.model_labels.join(`, `),ok:!0}),o(U,{label:e(`settings.advanced.embedding`),value:n.embedding_model_loaded?e(`settings.advanced.available`):e(`settings.advanced.notLoaded`),ok:n.embedding_model_loaded}),n.gpu_name&&o(U,{label:`GPU`,value:o(`bdi`,{children:`${n.gpu_name}${n.gpu_vram_gb?` (${T(n.gpu_vram_gb)})`:``}`}),ok:!0}),o(U,{label:e(`settings.advanced.memory`),value:n.memory_available_gb==null?e(`settings.advanced.unknown`):s(`bdi`,{dir:`ltr`,children:[n.memory_available_gb,` GB`]}),ok:n.memory_available_gb!=null&&n.memory_available_gb>2}),n.processor_name&&o(U,{label:e(`settings.advanced.processor`),value:o(`bdi`,{children:n.processor_name}),ok:!0})]}),n.lemonade_running&&J!==null&&!Z&&s(`div`,{className:`force-redownload-row`,children:[o(`span`,{className:`force-redownload-label`,children:e(`settings.advanced.corrupted`)}),o(`button`,{className:`btn-force-redownload`,onClick:()=>de(!0,void 0,!n.model_loaded),disabled:Y,children:Y?s(i.Fragment,{children:[o(A,{size:12,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.advanced.redownload`)})]}),!$&&X&&o(x,{message:X})]})]}):o(`div`,{className:`status-error`,children:o(`p`,{children:e(`settings.advanced.unreachable`)})})}),s(E,{title:e(`settings.advanced.serverTitle`),hint:e(`settings.advanced.serverHint`),children:[o(ee,{}),o(M,{})]}),s(E,{title:e(`settings.advanced.customTitle`),hint:w||e(`settings.advanced.customHint`),children:[o(`p`,{className:`model-override-desc`,children:e(`settings.advanced.customDesc`)}),s(`div`,{className:`model-input-row`,children:[o(`input`,{type:`text`,className:`model-input${w?` has-override`:``}`,placeholder:e.bare(`settings.advanced.customPlaceholder`),value:g,onChange:e=>{C(e.target.value),z(null),V(!1)},onKeyDown:e=>{e.key===`Enter`&&!I&&ce&&P&&(e.preventDefault(),oe())},disabled:!P||I,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.advanced.customAria`)}),o(`div`,{className:`model-btn-group`,children:o(`button`,{className:`btn-model-save${B?` saved`:``}`,onClick:()=>{oe()},disabled:!P||I||!ce&&!B,"aria-label":e(`settings.advanced.customSave`),children:I?s(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.models.applying`)]}):B?s(i.Fragment,{children:[o(_,{size:13}),` `,e(`settings.advanced.saved`)]}):e(`settings.advanced.save`)})})]}),o(`p`,{className:`model-status-hint`,children:e(`settings.advanced.customIds`)}),R&&o(te,{message:R})]}),s(E,{title:e(`settings.advanced.dynamicTitle`),children:[o(`p`,{className:`model-override-desc`,children:e(`settings.advanced.dynamicDesc`)}),s(`label`,{className:`setting-row`,children:[o(`span`,{children:e(`settings.advanced.dynamicEnable`)}),s(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:W,onChange:()=>void se(),disabled:!P||q||K,"aria-label":e(W?`settings.advanced.dynamicOff`:`settings.advanced.dynamicOn`)}),o(`span`,{className:`toggle-track`})]})]}),K&&o(`p`,{className:`model-status-hint`,children:e(`settings.advanced.dynamicLocked`)}),ie&&o(te,{message:ie})]}),f.length>0&&o(E,{title:e(`settings.advanced.mcp`),count:f.length,defaultOpen:me,children:o(`div`,{className:`status-grid`,children:f.map(t=>s(`div`,{className:`status-row`,children:[o(`bdi`,{className:`status-label`,children:t.name}),o(`div`,{className:`status-value-wrap`,children:t.connected?s(`span`,{className:`status-value ok mcp-status-connected`,children:[o(_,{size:12}),e.plural(`settings.advanced.tools`,t.tool_count)]}):s(`span`,{className:`status-value warn mcp-status-failed`,title:t.error??void 0,children:[o(v,{size:12}),e(`settings.custom.failed`)]})})]},t.name))})}),s(`div`,{className:`about-info`,children:[s(`p`,{children:[s(`bdi`,{dir:`ltr`,children:[`GAIA v`,`0.25.4`]}),` `,o(`span`,{className:`beta-badge`,children:`BETA`})]}),o(`p`,{className:`about-sub`,children:e(`settings.advanced.about`)})]})]})}function te({message:e}){let t=r();return s(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),s(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:t(`settings.advanced.saveFailed`)}),o(`p`,{children:e})]})]})}function U({label:e,value:t,ok:n,hint:r}){return s(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[o(`span`,{className:`status-label`,children:e}),s(`div`,{className:`status-value-wrap`,children:[o(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&o(`span`,{className:`status-hint`,children:r})]})]})}export{H as AdvancedSettings};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{I as t,J as n,N as r,a as i,c as a,f as o,l as s,q as c,r as l,t as u,u as d}from"./useT-CtECS-vp.js";import{n as ee,t as te}from"./zap-FkXztfRB.js";import{A as ne,At as re,B as ie,Bt as f,C as ae,D as oe,E as se,Et as ce,F as le,G as p,H as ue,I as de,It as m,L as fe,M as pe,Mt as me,N as he,Nt as h,O as ge,P as _e,Pt as g,R as ve,S as ye,T as be,U as xe,Ut as Se,V as Ce,Vt as we,W as Te,X as Ee,_ as De,b as Oe,ct as ke,dt as Ae,g as je,h as Me,ht as Ne,it as Pe,j as Fe,jt as Ie,k as Le,lt as Re,m as ze,mt as Be,nt as Ve,ot as He,p as Ue,pt as We,rt as Ge,st as Ke,t as qe,v as Je,w as Ye,x as Xe,y as Ze,yt as Qe,z as $e,zt as et}from"./index-CsgZhHsw.js";var _={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};_.node;var tt=c(_),nt={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};nt.node;var rt=c(nt),v={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};v.node;var it=c(v),at={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};at.node;var ot=c(at),y={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};y.node;var st=c(y),ct={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};ct.node;var lt=c(ct),ut={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};ut.node;var dt=c(ut),b=e(n(),1),ft=[{title:`mem.about.group.preferences`,categories:[`preference`]},{title:`mem.about.group.about`,categories:[`fact`,`profile`,`skill`]},{title:`mem.about.group.reminders`,categories:[`reminder`]},{title:`mem.about.group.notes`,categories:[`note`]}],pt={user:`mem.source.user`,tool:`mem.source.tool`,llm_extract:`mem.source.llm_extract`,consolidation:`mem.source.consolidation`,inferred:`mem.source.inferred`,discovery:`mem.source.discovery`};function mt(e){return pt[e]??`mem.source.other`}function ht(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return null;let i=Math.floor((Date.now()-n.getTime())/864e5);return i<=0?r(`mem.day.today`):i===1?r(`mem.day.yesterday`):i<30?r(`mem.day.daysAgo`,{n:i}):n.toLocaleDateString(u(t),{month:`short`,day:`numeric`,year:`numeric`})}function gt(e,t=new Date,n=l){let r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),i=r?new Date(+r[1],r[2]-1,+r[3]):new Date(e);if(Number.isNaN(i.getTime()))return null;let a=i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),s=a?i.getTime()<o:i.getTime()<t.getTime(),c=i.toLocaleString(u(n),{weekday:`short`,month:`short`,day:`numeric`,...i.getFullYear()===t.getFullYear()?{}:{year:`numeric`},...a?{}:{hour:`numeric`,minute:`2-digit`}});return{text:n(s?`mem.due.past`:`mem.due.upcoming`,{when:c}),past:s}}function _t({memoryEnabled:e,reloadKey:n,onChanged:o,onOpenAdvanced:c,showToast:l}){let u=i(),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)(null),[ie,f]=(0,b.useState)(null),[oe,se]=(0,b.useState)(``),[le,p]=(0,b.useState)([]),[ue,de]=(0,b.useState)(new Set),[m,fe]=(0,b.useState)(``),[pe,me]=(0,b.useState)(`fact`),[he,h]=(0,b.useState)(null),_e=(0,b.useRef)(0),g=(0,b.useCallback)(async()=>{let e=++_e.current;try{let t=await ge({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,limit:200});if(e!==_e.current)return;te(t.items),re(null)}catch(n){if(e!==_e.current)return;t.system.warn(`Failed to load what GAIA knows about the user`,n),re(n instanceof Error?n.message:String(n))}},[]);(0,b.useEffect)(()=>{g()},[g,n]);let ve=(0,b.useCallback)(async e=>{let n=oe.trim();if(!n||n===e.content)f(null);else{h(e.id);try{await ae(e.id,{content:n}),f(null),l(u(`mem.about.updated`),`success`),await g(),o()}catch(e){t.system.error(`Failed to edit memory`,e),l(u(`mem.about.editFailed`,{error:x(e)}),`error`)}finally{h(null)}}},[oe,g,o,l,u]),be=(0,b.useCallback)(async e=>{h(e.id);try{await ye(e.id),_e.current++,te(t=>(t??[]).filter(t=>t.id!==e.id)),p(t=>[e,...t]),o()}catch(e){t.system.error(`Failed to forget memory`,e),l(u(`mem.about.forgetFailed`,{error:x(e)}),`error`)}finally{h(null)}},[o,l,u]),xe=(0,b.useCallback)(async e=>{h(e.id);try{await Oe({content:e.content,category:e.category,domain:e.domain??void 0,context:e.context,entity:e.entity??void 0,sensitive:e.sensitive,due_at:e.due_at??void 0}),p(t=>t.filter(t=>t.id!==e.id)),await g(),o()}catch(e){t.system.error(`Failed to restore memory`,e),l(u(`mem.about.restoreFailed`,{error:x(e)}),`error`)}finally{h(null)}},[g,o,l,u]),Se=(0,b.useCallback)(async()=>{let e=m.trim();if(e){h(`new`);try{await Oe({content:e,category:pe}),fe(``),l(u(`mem.about.saved`),`success`),await g(),o()}catch(e){t.system.error(`Failed to add memory`,e),l(u(`mem.about.addFailed`,{error:x(e)}),`error`)}finally{h(null)}}},[m,pe,g,o,l,u]);if(!e)return d(`div`,{className:`mem-about`,children:[s(`h2`,{className:`mem-about-title`,children:u(`mem.about.title`)}),d(`div`,{className:`mem-about-empty`,children:[s(`p`,{children:u(`mem.about.off`)}),s(`button`,{className:`btn-secondary`,onClick:c,children:u(`mem.about.turnOn`)})]})]});let Ce=ft.map(e=>({...e,rows:(ee??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return d(`div`,{className:`mem-about`,children:[s(`h2`,{className:`mem-about-title`,children:u(`mem.about.title`)}),s(`p`,{className:`mem-about-intro`,children:u(`mem.about.intro`)}),d(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),Se()},children:[s(`input`,{className:`mem-input`,placeholder:u(`mem.about.addPlaceholder`),"aria-label":u(`mem.about.addLabel`),value:m,onChange:e=>fe(e.target.value)}),d(`select`,{className:`mem-select`,"aria-label":u(`mem.about.kind`),value:pe,onChange:e=>me(e.target.value),children:[s(`option`,{value:`fact`,children:u(`mem.about.group.about`)}),s(`option`,{value:`preference`,children:u(`mem.about.kind.preference`)}),s(`option`,{value:`reminder`,children:u(`mem.about.kind.reminder`)}),s(`option`,{value:`note`,children:u(`mem.about.kind.note`)})]}),d(`button`,{className:`btn-primary`,type:`submit`,disabled:!m.trim()||he===`new`,children:[s(Be,{size:14}),` `,u(`mem.about.add`)]})]}),le.map(e=>d(`div`,{className:`mem-about-forgotten`,role:`status`,children:[s(`span`,{children:e.sensitive?u(`mem.about.forgottenSensitive`):u(`mem.about.forgotten`,{content:e.content})}),d(`button`,{className:`mem-about-link`,disabled:he===e.id,onClick:()=>xe(e),children:[s(He,{size:12}),` `,u(`mem.about.undo`)]})]},e.id)),ne?d(`div`,{className:`mem-about-empty`,children:[s(`p`,{children:u(`mem.about.loadFailed`,{error:ne})}),s(`button`,{className:`btn-secondary`,onClick:g,children:u(`mem.about.retry`)})]}):ee===null?d(`div`,{className:`mem-loading`,children:[s(`div`,{className:`mem-spinner`}),` `,u(`mem.loading`)]}):Ce.length===0?d(`div`,{className:`mem-about-empty`,children:[s(`p`,{children:u(`mem.about.empty`)}),s(`p`,{className:`mem-about-hint`,children:u(`mem.about.emptyHint`)})]}):Ce.map(e=>d(`section`,{className:`mem-about-group`,"aria-label":u(e.title),children:[s(`h3`,{className:`mem-about-group-title`,children:u(e.title)}),s(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let t=e.sensitive&&!ue.has(e.id),n=e.due_at?gt(e.due_at,new Date,u):null,i=ht(e.updated_at,u),o=t?r(`mem.about.sensitiveMemory`):e.content;return s(`li`,{className:`mem-about-item`,children:ie===e.id?d(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),ve(e)},children:[s(`textarea`,{className:`mem-input`,"aria-label":u(`mem.about.editLabel`),rows:2,autoFocus:!0,value:oe,onChange:e=>se(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),f(null)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ve(e))}}),d(`div`,{className:`mem-about-edit-actions`,children:[s(`button`,{className:`btn-primary`,type:`submit`,disabled:he===e.id,children:u(`mem.about.save`)}),s(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>f(null),children:u(`mem.about.cancel`)})]})]}):d(a.Fragment,{children:[d(`div`,{className:`mem-about-text`,children:[t?d(`button`,{className:`mem-about-link`,onClick:()=>de(t=>new Set(t).add(e.id)),children:[s(ce,{size:12}),` `,u(`mem.about.showSensitive`)]}):s(`bdi`,{children:e.content}),n&&s(`span`,{className:`mem-about-due${n.past?` is-overdue`:``}`,children:n.text}),s(`span`,{className:`mem-about-meta`,children:i===null?u(mt(e.source)):u(`mem.about.meta`,{source:r(mt(e.source)),when:i})})]}),d(`div`,{className:`mem-about-actions`,children:[s(`button`,{className:`mem-about-btn`,"aria-label":u(`mem.about.editAria`,{name:o}),title:u(`mem.about.edit`),onClick:()=>{f(e.id),se(e.content)},children:s(Ne,{size:14})}),d(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":u(`mem.about.forgetAria`,{name:o}),title:u(`mem.about.forget`),disabled:he===e.id,onClick:()=>be(e),children:[s(ke,{size:14}),` `,u(`mem.about.forget`)]})]})]})},e.id)})})]},e.title))]})}function x(e){return e instanceof Error?e.message:String(e)}function vt(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r={month:`short`,day:`numeric`};return n.getFullYear()!==new Date().getFullYear()&&(r.year=`numeric`),n.toLocaleDateString(t,r)}catch{return`—`}}function S(e,t){if(!e)return``;try{let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleString(t,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function C(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r=Date.now(),i=n.getTime()-r,a=Math.abs(i),o=Math.floor(a/1e3),s=Math.floor(a/6e4),c=Math.floor(a/36e5),l=Math.floor(a/864e5);return i<0?o<5?t(`time.justNow`):o<60?t(`mem.rel.secondsAgo`,{n:o}):c===0?t(`time.minutesAgo`,{n:s}):l===0?t(`time.hoursAgo`,{n:c}):l===1?t(`time.yesterday`):l<30?t(`time.daysAgo`,{n:l}):S(e,u(t)):o<5?t(`mem.rel.now`):o<60?t(`mem.rel.inSeconds`,{n:o}):c===0?t(`mem.rel.inMinutes`,{n:s}):l===0?t(`mem.rel.inHours`,{n:c}):l===1?t(`mem.rel.tomorrow`):l<30?t(`mem.rel.inDays`,{n:l}):S(e,u(t))}catch{return`—`}}function yt(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function bt(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function xt(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function St(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function Ct(e,t,n){let r=vt(e,n),i=vt(t,n);return r===`—`&&i===`—`?``:r===i?r:`${r} \u2013 ${i}`}function wt(e){if(e.length===0)return 0;let t=new Date().toISOString().slice(0,10),n=e.find(e=>e.date===t);return n?n.knowledge_added:0}var Tt=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],w={fact:`mem.cat.fact`,preference:`mem.cat.preference`,error:`mem.cat.error`,skill:`mem.cat.skill`,note:`mem.cat.note`,reminder:`mem.cat.reminder`},Et={pending_approval:`mem.status.pending_approval`,queued:`mem.status.queued`,in_progress:`mem.status.in_progress`,completed:`mem.status.completed`,failed:`mem.status.failed`,rejected:`mem.status.rejected`,cancelled:`mem.status.cancelled`,blocked:`mem.status.blocked`},Dt={low:`mem.priority.low`,medium:`mem.priority.medium`,high:`mem.priority.high`},Ot={agent_inferred:`mem.goals.source.agent_inferred`,agent_scheduled:`mem.goals.source.agent_scheduled`},kt={user:`mem.role.user`,assistant:`mem.role.assistant`},At={work:`mem.domain.work`,technical:`mem.domain.technical`,personal:`mem.domain.personal`,general:`mem.domain.general`};function T({value:e,keys:t}){let n=i(),r=t[e];return r?s(a.Fragment,{children:n(r)}):s(`bdi`,{children:e})}function E(e){return e instanceof Error?e.message:String(e)}var jt={work:`blue`,technical:`purple`,personal:`green`,general:`gray`};function Mt(){let e=i(),{setShowMemoryDashboard:n,sessions:c,setCurrentSession:l}=o(),ce=(0,b.useMemo)(()=>new Map(c.map(e=>[e.id,e.title])),[c]),He=e=>ce.get(e)||`${e.slice(0,8)}...`,[_,nt]=(0,b.useState)(null),[v,at]=(0,b.useState)([]),[y,ct]=(0,b.useState)(null),[ut,ft]=(0,b.useState)([]),[pt,mt]=(0,b.useState)([]),[ht,gt]=(0,b.useState)([]),[x,vt]=(0,b.useState)(null),[Mt,Nt]=(0,b.useState)([]),[Pt,Ft]=(0,b.useState)(!0),[It,Lt]=(0,b.useState)(!1),[Rt,zt]=(0,b.useState)(null),[Bt,D]=(0,b.useState)(!1),[Vt,Ht]=(0,b.useState)(null),[Ut,Wt]=(0,b.useState)([]),Gt=(0,b.useRef)(0),[O,Kt]=(0,b.useState)([]),[qt,Jt]=(0,b.useState)(``),[Yt,Xt]=(0,b.useState)(``),[Zt,Qt]=(0,b.useState)(``),[k,$t]=(0,b.useState)(`updated_at`),[en,tn]=(0,b.useState)(`desc`),[A,j]=(0,b.useState)(0),[nn,rn]=(0,b.useState)(!1),[an,on]=(0,b.useState)(``),[sn,cn]=(0,b.useState)(null),ln=(0,b.useRef)(null),[M,un]=(0,b.useState)(null),[dn,fn]=(0,b.useState)(!1),[N,pn]=(0,b.useState)(null),[P,F]=(0,b.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[mn,hn]=(0,b.useState)(new Set),[I,gn]=(0,b.useState)(!1),[_n,vn]=(0,b.useState)(!1),[yn,bn]=(0,b.useState)(!1),[L,R]=(0,b.useState)(!1),[xn,Sn]=(0,b.useState)(!1),[z,Cn]=(0,b.useState)(null),[wn,Tn]=(0,b.useState)(!1),[En,B]=(0,b.useState)(null),[V,Dn]=(0,b.useState)(`about`),[On,kn]=(0,b.useState)(0),[An,jn]=(0,b.useState)([]),[Mn,Nn]=(0,b.useState)(null),[Pn,Fn]=(0,b.useState)(!1),[In,Ln]=(0,b.useState)(null),[Rn,zn]=(0,b.useState)(null),[Bn,Vn]=(0,b.useState)(!1),[Hn,Un]=(0,b.useState)({title:``,description:``,priority:`medium`}),[H,U]=(0,b.useState)(`idle`),[Wn,W]=(0,b.useState)([]),[G,K]=(0,b.useState)([]),[Gn,Kn]=(0,b.useState)(null),qn=(0,b.useRef)(null),Jn=(0,b.useRef)(null),[q,Yn]=(0,b.useState)(`idle`),[Xn,J]=(0,b.useState)([]),[Y,Zn]=(0,b.useState)([]),[Qn,$n]=(0,b.useState)(null),[er,tr]=(0,b.useState)(!1),nr=(0,b.useRef)(null),rr=(0,b.useRef)(null),[ir,ar]=(0,b.useState)(30),[or,sr]=(0,b.useState)(!1),[cr,lr]=(0,b.useState)(!1),[ur,dr]=(0,b.useState)(!1),[fr,pr]=(0,b.useState)(!1),[mr,hr]=(0,b.useState)(!1),[gr,_r]=(0,b.useState)(!1),vr=(0,b.useRef)(null),yr=(0,b.useRef)(null),br=(0,b.useRef)(null),X=(0,b.useCallback)((e,t=`info`)=>{let n=++Gt.current;Wt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Wt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,b.useEffect)(()=>{if(!Bt)return;let e=e=>{yr.current&&!yr.current.contains(e.target)&&D(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Bt]),Ve(!0,()=>{En?B(null):xn?Sn(!1):wn?Tn(!1):M?un(null):Bt?D(!1):dn||N?(fn(!1),pn(null)):Vt?Ht(null):n(!1)}),Ee(br,!!En),(0,b.useEffect)(()=>{if(!En)return;let e=br.current;if(!e)return;let t=document.activeElement;return e.focus(),()=>{t?.focus()}},[En]);let xr=(0,b.useCallback)(async()=>{try{let e=await pe();nt(e)}catch(e){t.system.warn(`Failed to load memory stats`,e)}},[]),Sr=(0,b.useCallback)(async()=>{try{let e=await Le(ir);at(e)}catch(e){t.system.warn(`Failed to load memory activity`,e)}},[ir]),Z=(0,b.useCallback)(async()=>{try{let e=await ge({category:O.length>0?O:void 0,context:qt||void 0,entity:Yt||void 0,search:Zt||void 0,sort_by:k,order:en,offset:A,limit:15,include_sensitive:!0,include_superseded:nn});ct(e)}catch(e){t.system.warn(`Failed to load knowledge`,e)}},[O,qt,Yt,Zt,k,en,A,nn]),Cr=(0,b.useCallback)(async()=>{try{let e=await he();ft(e)}catch(e){t.system.warn(`Failed to load tool summary`,e)}},[]),wr=(0,b.useCallback)(async()=>{try{let e=await ne(20);mt(e)}catch(e){t.system.warn(`Failed to load conversations`,e)}},[]),Tr=(0,b.useCallback)(async()=>{try{let e=await _e(7);gt(e)}catch(e){t.system.warn(`Failed to load upcoming items`,e)}},[]),Er=(0,b.useCallback)(async()=>{try{let e=await be();vt(e)}catch(e){t.system.warn(`Failed to load embedding coverage`,e)}},[]),Dr=(0,b.useCallback)(async()=>{try{let e=await se();Nt(e||[])}catch(e){t.system.warn(`Failed to load entities`,e)}},[]),Or=(0,b.useCallback)(async()=>{try{let e=await Fe();vn(e.mcp_memory_enabled),gn(e.memory_enabled),bn(e.system_discovery_consent)}catch(e){t.system.warn(`Failed to load memory settings`,e)}},[]),kr=(0,b.useCallback)(async()=>{Fn(!0);try{let[e,t]=await Promise.all([le(),oe()]);jn(e.goals),Nn(t)}catch(e){t.system.warn(`Failed to load goals`,e)}finally{Fn(!1)}},[]),Ar=(0,b.useCallback)(async(n,i)=>{try{await n()}catch(n){t.system.error(`Goal action failed (${i})`,n),X(e(`mem.goals.failed`,{what:r(i),error:E(n)}),`error`);return}kr()},[kr,X,e]);(0,b.useEffect)(()=>{if(!Rn)return;let e=setTimeout(()=>zn(null),3e3);return()=>clearTimeout(e)},[Rn]);let Q=(0,b.useCallback)(async()=>{Ft(!0),Lt(!1);try{await Promise.all([xr(),Sr(),Z(),Cr(),wr(),Tr(),Er(),Dr(),Or(),kr()]),kn(e=>e+1)}catch(e){Lt(!0),t.system.error(`Memory dashboard load failed`,e)}finally{Ft(!1)}},[xr,Sr,Z,Cr,wr,Tr,Er,Dr,Or,kr]);(0,b.useEffect)(()=>{Q()},[Q]),(0,b.useEffect)(()=>{Z()},[Z]);let jr=(0,b.useRef)(!0);(0,b.useEffect)(()=>{jr.current?jr.current=!1:Sr()},[Sr]);let Mr=(0,b.useCallback)(e=>{Qt(e),_r(!0),vr.current&&clearTimeout(vr.current),vr.current=setTimeout(()=>{j(0),_r(!1)},300)},[]),Nr=(0,b.useCallback)(()=>{Z(),xr(),Er(),Tr(),Dr()},[Z,xr,Er,Tr,Dr]),$=(0,b.useCallback)(()=>{Nr(),kn(e=>e+1)},[Nr]),Pr=(0,b.useCallback)(async()=>{if(P.content.trim())try{let n=await Oe({content:P.content,category:P.category,domain:P.domain||void 0,context:P.context,entity:P.entity||void 0,sensitive:P.sensitive,due_at:P.due_at||void 0});fn(!1),F({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),t.ui.info(`Created new knowledge entry`),n?.embedded===!1?X(n.embed_error?e(`mem.toast.server`,{message:n.embed_error}):e(`mem.toast.notEmbedded`),`error`):X(e(`mem.toast.created`),`success`)}catch(n){t.system.error(`Failed to create knowledge`,n),X(e(`mem.toast.createFailed`,{error:E(n)}),`error`)}},[P,$,X,e]),Fr=(0,b.useCallback)(async()=>{if(N&&P.content.trim())try{let n=await ae(N,{content:P.content,category:P.category,domain:P.domain||void 0,context:P.context,entity:P.entity||void 0,sensitive:P.sensitive,due_at:P.due_at||void 0});pn(null),F({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),t.ui.info(`Updated knowledge ${N}`),n?.embedded===!1?X(n.embed_error?e(`mem.toast.server`,{message:n.embed_error}):e(`mem.toast.notEmbedded`),`error`):X(e(`mem.toast.updated`),`success`)}catch(n){t.system.error(`Failed to update knowledge`,n),X(e(`mem.toast.updateFailed`,{error:E(n)}),`error`)}},[N,P,$,X,e]),Ir=(0,b.useCallback)(async n=>{if(z!==n)Cn(n);else{Cn(null);try{await ye(n),$(),t.ui.info(`Deleted knowledge ${n}`),X(e(`mem.toast.deleted`),`info`)}catch(n){t.system.error(`Failed to delete knowledge`,n),X(e(`mem.toast.deleteFailed`,{error:E(n)}),`error`)}}},[z,$,X,e]);(0,b.useEffect)(()=>{if(!z)return;let e=setTimeout(()=>Cn(null),3e3);return()=>clearTimeout(e)},[z]);let Lr=(0,b.useCallback)(async n=>{try{await ae(n.id,{sensitive:!n.sensitive}),Z(),t.ui.info(`Toggled sensitive for ${n.id}: ${!n.sensitive}`),X(e(n.sensitive?`mem.toast.unmarkedSensitive`:`mem.toast.markedSensitive`),`info`)}catch(n){t.system.error(`Failed to toggle sensitive`,n),X(e(`mem.toast.sensitiveFailed`,{error:E(n)}),`error`)}},[Z,X,e]),Rr=(0,b.useCallback)(e=>{pn(e.id),fn(!1),F({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),zr=(0,b.useCallback)(n=>{navigator.clipboard.writeText(n).then(()=>X(e(`mem.toast.idCopied`),`info`),r=>{t.ui.warn(`Couldn't copy knowledge ID ${n}`,r),X(e(`mem.toast.copyFailed`,{error:E(r)}),`error`)})},[X,e]),Br=(0,b.useCallback)(e=>{on(e),ln.current&&clearTimeout(ln.current),e.trim()?ln.current=setTimeout(async()=>{try{let t=await Te(e.trim(),20);cn(t)}catch(e){t.system.warn(`Conversation search failed`,e)}},300):cn(null)},[]),Vr=(0,b.useCallback)(async e=>{try{let t=await Ye(e);un({sessionId:e,turns:t})}catch(e){t.system.error(`Failed to load conversation detail`,e)}},[]),Hr=(0,b.useCallback)(e=>{Kt(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),j(0)},[]),Ur=(0,b.useCallback)(e=>{k===e?tn(e=>e===`desc`?`asc`:`desc`):($t(e),tn(`desc`)),j(0)},[k]),Wr=(0,b.useCallback)(async()=>{sr(!0),D(!1);try{let t=await Je();await Q(),X(e(`mem.toast.consolidated`,{sessions:t.consolidated??0,items:t.extracted_items??0}),`success`)}catch(n){t.system.error(`Failed to consolidate sessions`,n),X(e(`mem.toast.consolidateFailed`,{error:E(n)}),`error`)}finally{sr(!1)}},[Q,X,e]),Gr=(0,b.useCallback)(async()=>{lr(!0),D(!1);try{let t=await ve();await Er(),X(t.total_without?e(`mem.toast.backfilledMissing`,{n:t.backfilled??0,missing:t.total_without}):e(`mem.toast.backfilled`,{n:t.backfilled??0}),`success`)}catch(n){t.system.error(`Failed to rebuild embeddings`,n),X(e(`mem.toast.rebuildFailed`,{error:E(n)}),`error`)}finally{lr(!1)}},[Er,X,e]),Kr=(0,b.useCallback)(async()=>{dr(!0),D(!1);try{let t=await ie();await Q(),X(e(`mem.toast.reconciled`,{pairs:t.pairs_checked??0,reinforced:t.reinforced??0,contradicted:t.contradicted??0}),`success`)}catch(n){t.system.error(`Failed to reconcile memory`,n),X(e(`mem.toast.reconcileFailed`,{error:E(n)}),`error`)}finally{dr(!1)}},[Q,X,e]),qr=(0,b.useCallback)(async()=>{pr(!0),D(!1);try{await $e(),await Q(),X(e(`mem.toast.ftsRebuilt`),`success`)}catch(n){t.system.error(`Failed to rebuild FTS index`,n),X(e(`mem.toast.ftsFailed`,{error:E(n)}),`error`)}finally{pr(!1)}},[Q,X,e]),Jr=(0,b.useCallback)(async()=>{hr(!0),D(!1);try{let t=await Ce();await Q(),t.skipped?X(e(`mem.toast.systemDisabled`),`error`):X(e(`mem.toast.systemRefreshed`,{n:t.stored}),`success`)}catch(n){t.system.error(`Failed to refresh system context`,n),X(e(`mem.toast.systemFailed`,{error:E(n)}),`error`)}finally{hr(!1)}},[Q,X,e]),Yr=or||cr||ur||fr||mr,Xr=(0,b.useCallback)(()=>{U(`running`),W([]),K([]),Kn(null);let n=de();Jn.current=n,n.onmessage=r=>{try{let t=JSON.parse(r.data);if(t.type===`log`)W(e=>[...e,{text:t.message,kind:`log`,server:!0}]);else if(t.type===`finding`){let n=t.item;W(t=>[...t,{text:e.bare(`mem.log.found`,{content:n.content}),kind:`finding`}]),K(e=>[...e,{...n,_checked:!0}])}else t.type===`error`?W(n=>[...n,{text:e.bare(`mem.log.error`,{message:t.message}),kind:`error`}]):t.type===`done`&&(n.close(),Jn.current=null,W(n=>[...n,{text:e(`mem.log.discoveryDone`,{n:t.total??0}),kind:`log`}]),U(`review`))}catch(n){t.system.warn(`Unreadable discovery event`,n),W(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},n.onerror=()=>{n.close(),Jn.current=null,W(t=>[...t,{text:e(`mem.log.discoveryConnection`),kind:`error`}]),K(e=>(U(e.length>0?`review`:`idle`),e))}},[e]),Zr=(0,b.useCallback)(async()=>{let n=G.filter(e=>e._checked);if(n.length!==0){U(`saving`);try{let t=n.map(({_checked:e,...t})=>t),r=await je(t);Kn(r.stored),U(`done`),$(),X(e(`mem.disc.saved`,{n:r.stored}),`success`)}catch(n){t.system.error(`Failed to commit discovery items`,n),X(e(`mem.disc.saveFailed`,{error:E(n)}),`error`),U(`review`)}}},[G,$,X,e]),Qr=(0,b.useCallback)(()=>{Yn(`running`),J([]),Zn([]),$n(null);let n=fe(er);rr.current=n,n.onmessage=r=>{try{let t=JSON.parse(r.data);if(t.type===`log`)J(e=>[...e,{text:t.message,kind:`log`,server:!0}]);else if(t.type===`insight`){let n=t.item;J(t=>[...t,{text:e.bare(`mem.log.insight`,{content:n.content}),kind:`finding`}]),Zn(e=>[...e,{...n,_checked:!0}])}else t.type===`error`?J(n=>[...n,{text:e.bare(`mem.log.error`,{message:t.message}),kind:`error`}]):t.type===`done`&&(n.close(),rr.current=null,J(n=>[...n,{text:e(`mem.log.inferenceDone`,{n:t.total??0}),kind:`log`}]),Yn(`review`))}catch(n){t.system.warn(`Unreadable inference event`,n),J(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},n.onerror=()=>{n.close(),rr.current=null,J(t=>[...t,{text:e(`mem.log.inferenceConnection`),kind:`error`}]),Zn(e=>(Yn(e.length>0?`review`:`idle`),e))}},[er,e]),$r=(0,b.useCallback)(async()=>{let n=Y.filter(e=>e._checked);if(n.length!==0){Yn(`saving`);try{let t=n.map(({_checked:e,...t})=>t),r=await De(t);$n(r.stored),Yn(`done`),$(),X(e(`mem.inf.saved`,{n:r.stored}),`success`)}catch(n){t.system.error(`Failed to commit inference insights`,n),X(e(`mem.inf.saveFailed`,{error:E(n)}),`error`),Yn(`review`)}}},[Y,$,X,e]);(0,b.useEffect)(()=>{qn.current&&(qn.current.scrollTop=qn.current.scrollHeight)},[Wn]),(0,b.useEffect)(()=>{nr.current&&(nr.current.scrollTop=nr.current.scrollHeight)},[Xn]),(0,b.useEffect)(()=>()=>{Jn.current&&=(Jn.current.close(),null),rr.current&&=(rr.current.close(),null)},[]);let ei=e=>k===e?s(`span`,{className:`mem-sort-arrow`,children:en===`desc`?`↓`:`↑`}):null,ti=Math.max(1,...v.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),ni=_?.knowledge?.by_context?Object.keys(_.knowledge.by_context):[];return d(`div`,{className:`memory-dashboard-page`,children:[d(`div`,{className:`memory-dashboard-header`,children:[d(`div`,{className:`memory-dashboard-header-left`,children:[s(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>n(!1),"aria-label":e(`mem.back`),children:s(tt,{size:18})}),d(`h1`,{children:[e(`mem.title`),` `,s(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`2px 8px`,borderRadius:4,marginInlineStart:8,verticalAlign:`middle`,whiteSpace:`nowrap`},children:e(`mem.beta`)})]})]}),d(`div`,{className:`memory-dashboard-header-actions`,children:[V===`advanced`&&d(a.Fragment,{children:[x&&x.total_items>0&&d(`div`,{className:`mem-embedding-coverage`,title:e(`mem.coverage.title`,{n:x.with_embedding,total:x.total_items}),children:[s(`div`,{className:`mem-embedding-bar`,children:s(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(x.coverage_pct)}%`}})}),s(`span`,{className:`mem-embedding-label`,children:e(`mem.coverage.label`,{pct:`${Math.round(x.coverage_pct)}%`})})]}),d(`div`,{className:`mem-maintenance-wrap`,ref:yr,children:[d(`button`,{className:`btn-icon ${Yr?`mem-spinning`:``}`,onClick:()=>D(e=>!e),title:e(`mem.maint.label`),"aria-label":e(`mem.maint.label`),"aria-expanded":Bt,children:[Yr?s(`div`,{className:`mem-spinner-sm`}):s(re,{size:16}),s(we,{size:10,style:{marginInlineStart:2}})]}),Bt&&d(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[d(`button`,{className:`mem-maintenance-item`,onClick:Wr,disabled:or,role:`menuitem`,children:[s(rt,{size:14}),e(or?`mem.maint.consolidating`:`mem.maint.consolidate`)]}),d(`button`,{className:`mem-maintenance-item`,onClick:Gr,disabled:cr,role:`menuitem`,children:[s(te,{size:14}),e(cr?`mem.maint.rebuilding`:`mem.maint.rebuildEmbeddings`)]}),d(`button`,{className:`mem-maintenance-item`,onClick:Kr,disabled:ur,role:`menuitem`,children:[s(m,{size:14}),e(ur?`mem.maint.reconciling`:`mem.maint.reconcile`)]}),s(`div`,{className:`mem-maintenance-divider`}),d(`button`,{className:`mem-maintenance-item`,onClick:Jr,disabled:mr,role:`menuitem`,children:[s(We,{size:14}),e(mr?`mem.maint.refreshing`:`mem.maint.refreshSystem`)]}),s(`div`,{className:`mem-maintenance-divider`}),d(`button`,{className:`mem-maintenance-item`,onClick:qr,disabled:fr,role:`menuitem`,children:[s(Ae,{size:14}),e(fr?`mem.maint.rebuilding`:`mem.maint.rebuildFts`)]})]})]})]}),s(`button`,{className:`btn-icon`,onClick:Q,title:e(`mem.refresh`),"aria-label":e(`mem.refreshAria`),children:s(We,{size:16})})]})]}),d(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[d(`button`,{className:`mem-tab-btn${V===`about`?` mem-tab-active`:``}`,onClick:()=>Dn(`about`),role:`tab`,"aria-selected":V===`about`,children:[s(dt,{size:14}),` `,e(`mem.tab.about`)]}),d(`button`,{className:`mem-tab-btn${V===`goals`?` mem-tab-active`:``}`,onClick:()=>{Dn(`goals`),kr()},role:`tab`,"aria-selected":V===`goals`,children:[s(st,{size:14}),` `,e(`mem.tab.goals`),Mn&&(Mn.goals.pending_approval??0)>0&&s(`span`,{className:`mem-tab-badge`,children:Mn.goals.pending_approval})]}),d(`button`,{className:`mem-tab-btn${V===`profile`?` mem-tab-active`:``}`,onClick:()=>Dn(`profile`),role:`tab`,"aria-selected":V===`profile`,children:[s(Re,{size:14}),` `,e(`mem.tab.profile`)]}),d(`button`,{className:`mem-tab-btn${V===`advanced`?` mem-tab-active`:``}`,onClick:()=>Dn(`advanced`),role:`tab`,"aria-selected":V===`advanced`,children:[s(Se,{size:14}),` `,e(`mem.tab.advanced`)]})]}),d(`div`,{className:`memory-dashboard-body`,children:[V===`about`&&s(_t,{memoryEnabled:I,reloadKey:On,onChanged:Nr,onOpenAdvanced:()=>Dn(`advanced`),showToast:X}),V===`advanced`&&s(a.Fragment,{children:Pt&&!_?d(`div`,{className:`mem-loading`,children:[s(`div`,{className:`mem-spinner`}),e(`mem.loadingData`)]}):It?d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(Ke,{size:32})}),s(`p`,{children:e(`mem.loadFailed`)}),d(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[s(We,{size:14}),` `,e(`mem.retry`)]})]}):d(a.Fragment,{children:[!I&&d(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[s(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:s(ot,{size:32})}),s(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:e(`mem.offAdvanced`)})]}),I&&d(a.Fragment,{children:[_?.embedding_error&&d(`div`,{className:`mem-advanced-error`,role:`alert`,children:[s(Ke,{size:14}),` `,s(`bdi`,{children:_.embedding_error})]}),d(`div`,{className:`mem-stat-cards`,children:[d(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[s(`div`,{className:`mem-stat-value`,children:_?.knowledge?.total??0}),s(`div`,{className:`mem-stat-label`,children:e(`mem.stat.stored`)}),s(`div`,{className:`mem-stat-sub`,children:(()=>{let t=wt(v);return t>0?e(`mem.stat.addedToday`,{n:t}):_?.knowledge?.by_category?e.compose(e=>Object.entries(_.knowledge.by_category).slice(0,3).map(([t,n])=>e(`mem.stat.categoryCount`,{category:w[t]?r(w[t]):t,n})).join(e(`mem.listSeparator`))):e(`mem.stat.noEntries`)})()})]}),d(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[s(`div`,{className:`mem-stat-value`,children:_?.knowledge?.total_retrievals??0}),s(`div`,{className:`mem-stat-label`,children:e(`mem.stat.retrieved`)}),s(`div`,{className:`mem-stat-sub`,children:_?.knowledge?.total&&_?.knowledge?.total_retrievals?e(`mem.stat.avgRecall`,{n:(_.knowledge.total_retrievals/_.knowledge.total).toFixed(1)}):e(`mem.stat.noRecalls`)})]}),d(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[s(`div`,{className:`mem-stat-value`,children:_?.conversations?.total_sessions??0}),s(`div`,{className:`mem-stat-label`,children:e(`mem.stat.sessions`)}),s(`div`,{className:`mem-stat-sub`,children:Ct(_?.conversations?.first_session??null,_?.conversations?.last_session??null,u(e))||e(`mem.stat.totalTurns`,{n:_?.conversations?.total_turns??0})})]}),d(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[s(`div`,{className:`mem-stat-value`,children:_?.tools?.total_calls??0}),s(`div`,{className:`mem-stat-label`,children:e(`mem.stat.toolCalls`)}),s(`div`,{className:`mem-stat-sub`,title:e(`mem.stat.toolsNotLogged`),children:e(`mem.stat.toolsExclMemory`,{n:_?.tools?.unique_tools??0})})]}),d(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[s(`div`,{className:`mem-stat-value`,children:_?.tools?.overall_success_rate!=null&&(_.tools.total_calls??0)>0?`${Math.round(_.tools.overall_success_rate*100)}%`:`—`}),s(`div`,{className:`mem-stat-label`,children:e(`mem.stat.successRate`)}),s(`div`,{className:`mem-stat-sub`,children:(_?.tools?.total_calls??0)>0?e(`mem.stat.errors`,{n:_?.tools?.total_errors??0}):e(`mem.stat.noToolCalls`)})]})]}),d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title mem-section-title-row`,children:[d(`span`,{className:`mem-section-title-left`,children:[s(lt,{size:14}),` `,e(`mem.activity.title`)]}),s(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":e(`mem.activity.range`),children:[1,7,30].map(t=>s(`button`,{className:`mem-range-tab${ir===t?` active`:``}`,onClick:()=>ar(t),children:e(t===1?`mem.activity.day1`:t===7?`mem.activity.days7`:`mem.activity.days30`)},t))})]}),v.length>0?d(a.Fragment,{children:[s(`div`,{className:`mem-activity-chart`,children:v.map((t,n)=>{let r=t.conversations+t.tool_calls+t.knowledge_added+t.errors,i=n===0||n===v.length-1||n%7==0,o=new Date(t.date+`T00:00:00`).toLocaleDateString(u(e),{month:`short`,day:`numeric`});return d(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>zt(n),onMouseLeave:()=>zt(null),children:[t.errors>0&&s(`div`,{className:`mem-activity-bar errors`,style:{height:`${t.errors/ti*100}%`}}),t.knowledge_added>0&&s(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${t.knowledge_added/ti*100}%`}}),t.tool_calls>0&&s(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${t.tool_calls/ti*100}%`}}),t.conversations>0&&s(`div`,{className:`mem-activity-bar conversations`,style:{height:`${t.conversations/ti*100}%`}}),i&&s(`span`,{className:`mem-activity-date-label`,children:o}),Rt===n&&r>0&&d(`div`,{className:`mem-activity-tooltip`,children:[s(`strong`,{children:o}),s(`br`,{}),t.conversations>0&&d(a.Fragment,{children:[e(`mem.activity.conversations`,{n:t.conversations}),s(`br`,{})]}),t.tool_calls>0&&d(a.Fragment,{children:[e(`mem.activity.toolCalls`,{n:t.tool_calls}),s(`br`,{})]}),t.knowledge_added>0&&d(a.Fragment,{children:[e(`mem.activity.learned`,{n:t.knowledge_added}),s(`br`,{})]}),t.errors>0&&s(a.Fragment,{children:e(`mem.stat.errors`,{n:t.errors})})]})]},t.date)})}),d(`div`,{className:`mem-activity-legend`,children:[d(`span`,{className:`mem-activity-legend-item`,children:[s(`span`,{className:`mem-activity-legend-dot conversations`}),` `,e(`mem.legend.conversations`)]}),d(`span`,{className:`mem-activity-legend-item`,children:[s(`span`,{className:`mem-activity-legend-dot tool_calls`}),` `,e(`mem.stat.toolCalls`)]}),d(`span`,{className:`mem-activity-legend-item`,children:[s(`span`,{className:`mem-activity-legend-dot knowledge`}),` `,e(`mem.legend.knowledge`)]}),d(`span`,{className:`mem-activity-legend-item`,children:[s(`span`,{className:`mem-activity-legend-dot errors`}),` `,e(`mem.legend.errors`)]})]})]}):d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(lt,{size:28})}),s(`p`,{children:e(`mem.activity.empty`)})]})]}),d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title mem-section-title-row`,children:[d(`span`,{className:`mem-section-title-left`,children:[s(Se,{size:14}),` `,e(`mem.knowledge.title`),y&&y.total>0&&s(`span`,{className:`mem-section-count`,children:y.total})]}),!dn&&!N&&d(`button`,{className:`mem-section-add-btn`,onClick:()=>fn(!0),title:e(`mem.knowledge.addTitle`),children:[s(Be,{size:13}),` `,e(`mem.knowledge.add`)]})]}),d(`div`,{className:`mem-filters`,children:[d(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":e(`mem.knowledge.filterCategory`),children:[Tt.map(t=>s(`button`,{className:`mem-category-pill ${t}${O.includes(t)?` active`:``}`,onClick:()=>Hr(t),"aria-pressed":O.includes(t),children:e(w[t])},t)),O.length>0&&d(`button`,{className:`mem-category-pill clear`,onClick:()=>{Kt([]),j(0)},"aria-label":e(`mem.knowledge.clearAria`),children:[`✕ `,e(`mem.knowledge.clear`)]})]}),d(`select`,{className:`mem-filter-select`,value:qt,onChange:e=>{Jt(e.target.value),j(0)},"aria-label":e(`mem.knowledge.filterContext`),children:[s(`option`,{value:``,children:e(`mem.knowledge.allContexts`)}),ni.map(e=>s(`option`,{value:e,children:e},e))]}),d(`select`,{className:`mem-filter-select`,value:Yt,onChange:e=>{Xt(e.target.value),j(0)},"aria-label":e(`mem.knowledge.filterEntity`),children:[s(`option`,{value:``,children:e(`mem.knowledge.allEntities`)}),Mt.map(e=>d(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),d(`div`,{className:`mem-filter-search-wrap`,children:[gr?s(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):s(Ae,{size:13,className:`search-icon`}),s(`input`,{className:`mem-filter-search`,type:`text`,placeholder:e(`mem.knowledge.searchPlaceholder`),value:Zt,onChange:e=>Mr(e.target.value),"aria-label":e(`mem.knowledge.search`)})]}),d(`label`,{className:`mem-filter-toggle`,title:e(`mem.knowledge.supersededTitle`),children:[s(`input`,{type:`checkbox`,checked:nn,onChange:e=>rn(e.target.checked)}),s(`span`,{children:e(`mem.knowledge.superseded`)})]})]}),(dn||N)&&d(`div`,{className:`mem-inline-form`,children:[d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.col.content`)}),s(`textarea`,{value:P.content,onChange:e=>F(t=>({...t,content:e.target.value})),placeholder:e(`mem.form.contentPlaceholder`)})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.col.category`)}),s(`select`,{value:P.category,onChange:e=>F(t=>({...t,category:e.target.value})),children:Tt.map(t=>s(`option`,{value:t,children:e(w[t])},t))})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.col.context`)}),s(`input`,{type:`text`,value:P.context,onChange:e=>F(t=>({...t,context:e.target.value})),placeholder:`global`})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.detail.domain`)}),s(`input`,{type:`text`,value:P.domain,onChange:e=>F(t=>({...t,domain:e.target.value})),placeholder:e(`mem.form.domainPlaceholder`)})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.col.entity`)}),s(`input`,{type:`text`,value:P.entity,onChange:e=>F(t=>({...t,entity:e.target.value})),placeholder:e(`mem.form.entityPlaceholder`)})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.form.dueAt`)}),s(`input`,{type:`text`,value:P.due_at,onChange:e=>F(t=>({...t,due_at:e.target.value})),placeholder:e(`mem.form.dueAtPlaceholder`)})]}),d(`div`,{className:`mem-inline-form-row`,children:[s(`label`,{children:e(`mem.form.sensitive`)}),d(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[s(`input`,{type:`checkbox`,checked:P.sensitive,onChange:e=>F(t=>({...t,sensitive:e.target.checked}))}),e(`mem.form.sensitiveHint`)]})]}),d(`div`,{className:`mem-inline-form-actions`,children:[s(`button`,{className:`btn-secondary`,onClick:()=>{fn(!1),pn(null)},children:e(`mem.cancel`)}),s(`button`,{className:`btn-primary`,onClick:N?Fr:Pr,style:{padding:`8px 20px`,fontSize:13},children:e(N?`mem.form.update`:`mem.form.save`)})]})]}),y&&y.items.length>0?d(a.Fragment,{children:[s(`div`,{style:{overflowX:`auto`},children:d(`table`,{className:`mem-knowledge-table`,children:[s(`thead`,{children:d(`tr`,{children:[d(`th`,{onClick:()=>Ur(`category`),className:k===`category`?`sorted`:``,children:[e(`mem.col.category`),ei(`category`)]}),s(`th`,{children:e(`mem.col.content`)}),d(`th`,{onClick:()=>Ur(`context`),className:k===`context`?`sorted`:``,children:[e(`mem.col.context`),ei(`context`)]}),s(`th`,{children:e(`mem.col.entity`)}),d(`th`,{onClick:()=>Ur(`confidence`),className:k===`confidence`?`sorted`:``,children:[e(`mem.col.confidence`),ei(`confidence`)]}),s(`th`,{children:e(`mem.col.source`)}),d(`th`,{onClick:()=>Ur(`updated_at`),className:k===`updated_at`?`sorted`:``,children:[e(`mem.col.updated`),ei(`updated_at`)]}),d(`th`,{onClick:()=>Ur(`created_at`),className:k===`created_at`?`sorted`:``,children:[e(`mem.col.created`),ei(`created_at`)]}),s(`th`,{children:e(`mem.col.due`)}),s(`th`,{className:`mem-actions-cell`})]})}),s(`tbody`,{children:y.items.map(t=>{let n=Vt===t.id,r=t.has_embedding;return d(b.Fragment,{children:[d(`tr`,{className:`${t.superseded_by?`mem-superseded-row`:``} ${n?`mem-expanded-row`:``}`,onClick:()=>Ht(n?null:t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ht(n?null:t.id))},tabIndex:0,role:`row`,"aria-expanded":n,style:{cursor:`pointer`},children:[s(`td`,{children:s(`span`,{className:`mem-cat-badge ${t.category}`,children:t.category===`error`&&t.source===`error_auto`?e(`mem.cat.errorLearned`):s(T,{value:t.category,keys:w})})}),s(`td`,{children:d(`div`,{className:`mem-content-cell`,title:t.content,children:[r!==void 0&&s(`span`,{className:`mem-embed-dot ${r?`embedded`:`missing`}`,title:e(r?`mem.knowledge.embedded`:`mem.knowledge.embedMissing`),children:s(g,{size:6,fill:`currentColor`})}),t.sensitive&&s(`span`,{className:`mem-sensitive-badge`,title:e(`mem.form.sensitive`),children:s(ot,{size:11})}),s(`span`,{className:t.sensitive&&!mn.has(t.id)?`mem-sensitive-blur`:t.superseded_by?`mem-superseded-text`:``,onClick:e=>{t.sensitive&&(e.stopPropagation(),hn(e=>{let n=new Set(e);return n.has(t.id)?n.delete(t.id):n.add(t.id),n}))},children:s(`bdi`,{children:t.content})})]})}),s(`td`,{children:s(`bdi`,{className:`mem-date-cell`,children:t.context})}),s(`td`,{children:t.entity?s(`span`,{className:`mem-entity-link`,onClick:e=>{e.stopPropagation(),Xt(t.entity),j(0)},title:e(`mem.knowledge.filterBy`,{entity:t.entity}),children:s(`bdi`,{children:t.entity})}):s(`span`,{className:`mem-date-cell`,children:`—`})}),s(`td`,{children:d(`div`,{className:`mem-confidence`,children:[s(`div`,{className:`mem-confidence-bar`,children:s(`div`,{className:`mem-confidence-fill ${xt(t.confidence)}`,style:{width:`${t.confidence*100}%`}})}),t.confidence.toFixed(2)]})}),s(`td`,{children:s(`bdi`,{className:`mem-date-cell`,children:t.source||`—`})}),s(`td`,{children:s(`span`,{className:`mem-date-cell`,title:S(t.updated_at,u(e)),children:C(t.updated_at,e)})}),s(`td`,{children:s(`span`,{className:`mem-date-cell`,title:S(t.created_at,u(e)),children:C(t.created_at,e)})}),s(`td`,{children:t.due_at?s(`span`,{className:`mem-due-badge ${bt(t.due_at)?`overdue`:`upcoming`}`,title:S(t.due_at,u(e)),children:C(t.due_at,e)}):s(`span`,{className:`mem-due-badge none`,children:`—`})}),s(`td`,{className:`mem-actions-cell`,children:d(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[s(`button`,{className:`mem-row-action-btn`,onClick:()=>Rr(t),title:e(`mem.row.edit`),children:s(Ne,{size:13})}),s(`button`,{className:`mem-row-action-btn`,onClick:()=>Lr(t),title:e(t.sensitive?`mem.row.unmarkSensitive`:`mem.row.markSensitive`),children:t.sensitive?s(it,{size:13}):s(ot,{size:13})}),s(`button`,{className:`mem-row-action-btn`,onClick:()=>zr(t.id),title:e(`mem.row.copyId`),children:s(me,{size:13})}),s(`button`,{className:`mem-row-action-btn delete${z===t.id?` is-confirm`:``}`,onClick:()=>Ir(t.id),title:e(z===t.id?`mem.row.clickAgain`:`mem.row.delete`),"aria-label":e(z===t.id?`mem.row.confirmDeleteAria`:`mem.row.deleteAria`),children:z===t.id?s(`span`,{className:`mem-row-delete-label`,children:e(`mem.row.deleteConfirm`)}):s(ke,{size:13})})]})})]}),n&&s(`tr`,{className:`mem-detail-row`,children:s(`td`,{colSpan:10,children:d(`div`,{className:`mem-detail-panel`,children:[d(`div`,{className:`mem-detail-grid`,children:[d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.id`)}),s(`span`,{className:`mem-detail-value`,children:t.id})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.domain`)}),s(`bdi`,{className:`mem-detail-value`,children:t.domain||`—`})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.col.source`)}),s(`bdi`,{className:`mem-detail-value`,children:t.source||`—`})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.useCount`)}),s(`span`,{className:`mem-detail-value`,children:t.use_count??0})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.col.created`)}),s(`span`,{className:`mem-detail-value`,children:S(t.created_at,u(e))})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.col.updated`)}),s(`span`,{className:`mem-detail-value`,children:S(t.updated_at,u(e))})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.lastUsed`)}),s(`span`,{className:`mem-detail-value`,children:S(t.last_used,u(e))})]}),d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.remindedAt`)}),s(`span`,{className:`mem-detail-value`,children:S(t.reminded_at,u(e))})]}),t.superseded_by&&d(`div`,{className:`mem-detail-field`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.supersededBy`)}),s(`span`,{className:`mem-detail-value mem-detail-chain`,children:t.superseded_by})]}),t.metadata&&d(`div`,{className:`mem-detail-field mem-detail-full`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.metadata`)}),s(`span`,{className:`mem-detail-value`,children:s(`bdi`,{dir:`ltr`,children:typeof t.metadata==`object`?JSON.stringify(t.metadata,null,2):t.metadata})})]})]}),d(`div`,{className:`mem-detail-content-full`,children:[s(`span`,{className:`mem-detail-label`,children:e(`mem.detail.fullContent`)}),s(`div`,{className:`mem-detail-content-text`,children:s(`bdi`,{children:t.content})})]})]})})})]},t.id)})})]})}),d(`div`,{className:`mem-pagination`,children:[s(`span`,{children:e(`mem.page.range`,{from:A+1,to:Math.min(A+15,y.total),total:y.total})}),d(`div`,{className:`mem-pagination-btns`,children:[s(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.previous`),disabled:A===0,onClick:()=>j(Math.max(0,A-15)),children:s(f,{size:14})}),s(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.next`),disabled:A+15>=y.total,onClick:()=>j(A+15),children:s(et,{size:14})})]})]})]}):d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(Se,{size:28})}),s(`p`,{children:e(Zt||O.length>0||qt||Yt?`mem.knowledge.noMatch`:`mem.knowledge.empty`)})]})]}),d(`div`,{className:`mem-two-col`,children:[d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title`,children:[s(Pe,{size:14}),` `,e(`mem.tools.title`),s(`span`,{className:`mem-section-note`,title:e(`mem.tools.noteTitle`),children:e(`mem.tools.note`)})]}),ut.length>0?s(`div`,{style:{overflowX:`auto`},children:d(`table`,{className:`mem-tool-table`,children:[s(`thead`,{children:d(`tr`,{children:[s(`th`,{children:e(`mem.tools.tool`)}),s(`th`,{children:e(`mem.tools.calls`)}),s(`th`,{children:e(`mem.tools.success`)}),s(`th`,{children:e(`mem.tools.denied`)}),s(`th`,{children:e(`mem.tools.avgTime`)}),s(`th`,{children:e(`mem.detail.lastUsed`)}),s(`th`,{children:e(`mem.tools.lastError`)})]})}),s(`tbody`,{children:ut.map(t=>d(`tr`,{children:[s(`td`,{children:s(`bdi`,{className:`mem-tool-name`,children:t.tool_name})}),s(`td`,{children:t.total_calls}),s(`td`,{children:d(`div`,{className:`mem-confidence`,children:[s(`div`,{className:`mem-confidence-bar`,style:{width:40},children:s(`div`,{className:`mem-confidence-fill ${St(t.success_rate)}`,style:{width:`${t.success_rate*100}%`}})}),d(`span`,{className:`mem-success-rate ${St(t.success_rate)}`,children:[Math.round(t.success_rate*100),`%`]})]})}),s(`td`,{children:t.denied_count??0}),s(`td`,{children:s(`bdi`,{dir:`ltr`,children:yt(t.avg_duration_ms)})}),s(`td`,{children:s(`span`,{className:`mem-date-cell`,title:S(t.last_used,u(e)),children:C(t.last_used,e)})}),s(`td`,{children:s(`bdi`,{className:`mem-tool-error`,title:t.last_error||``,children:t.last_error||`—`})})]},t.tool_name))})]})}):d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(Pe,{size:28})}),s(`p`,{children:e(`mem.tools.empty`)})]})]}),d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title`,children:[s(h,{size:14}),` `,e(`mem.upcoming.title`)]}),ht.length>0?s(`div`,{className:`mem-temporal-list`,children:ht.map(t=>{let n=bt(t.due_at);return d(`div`,{className:`mem-temporal-item ${n?`overdue`:`upcoming`}`,children:[s(`span`,{className:`mem-temporal-icon`,children:s(n?Ke:h,{size:16})}),d(`div`,{className:`mem-temporal-content`,children:[s(`div`,{className:`mem-temporal-text`,children:s(`bdi`,{children:t.content})}),d(`div`,{className:`mem-temporal-date`,children:[e(n?`mem.upcoming.overdue`:`mem.upcoming.due`,{when:C(t.due_at,e)}),t.context!==`global`&&d(a.Fragment,{children:[` `,`·`,` `,s(`bdi`,{children:t.context})]})]})]})]},t.id)})}):d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(m,{size:28})}),s(`p`,{children:e(`mem.upcoming.empty`)})]})]})]}),d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title`,children:[s(ee,{size:14}),` `,e(`mem.conv.title`)]}),d(`div`,{className:`mem-conv-search`,children:[s(Ae,{size:13,className:`search-icon`}),s(`input`,{type:`text`,placeholder:e(`mem.conv.searchPlaceholder`),value:an,onChange:e=>Br(e.target.value),"aria-label":e(`mem.conv.search`)}),an&&s(`button`,{className:`mem-search-clear`,onClick:()=>{on(``),cn(null)},"aria-label":e(`mem.conv.clearSearch`),children:s(Ge,{size:12})})]}),sn===null?pt.length>0?s(`div`,{className:`mem-conv-list`,children:pt.map(t=>d(`div`,{className:`mem-conv-item`,onClick:()=>Vr(t.session_id),children:[d(`div`,{className:`mem-conv-info`,children:[d(`div`,{className:`mem-conv-session-id`,children:[s(`bdi`,{children:He(t.session_id)}),t.consolidated&&s(`span`,{className:`mem-consolidated-badge`,title:e(`mem.conv.consolidated`),children:s(rt,{size:11})})]}),t.first_message&&s(`div`,{className:`mem-conv-preview`,children:s(`bdi`,{children:t.first_message})})]}),d(`div`,{className:`mem-conv-meta`,children:[s(`span`,{children:e.plural(`mem.conv.turns`,t.turn_count)}),s(`span`,{children:C(t.last_activity,e)})]})]},t.session_id))}):d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(ee,{size:28})}),s(`p`,{children:e(`mem.conv.empty`)})]}):sn.length>0?s(`div`,{className:`mem-conv-list`,children:sn.map(t=>d(`div`,{className:`mem-conv-item`,onClick:()=>Vr(t.session_id),children:[d(`div`,{className:`mem-conv-info`,children:[d(`div`,{className:`mem-conv-session-id`,children:[s(`span`,{className:`mem-conv-turn-role ${t.role}`,children:s(T,{value:t.role,keys:kt})}),` `,s(`bdi`,{children:He(t.session_id)})]}),s(`div`,{className:`mem-conv-preview`,children:s(`bdi`,{children:t.content})})]}),s(`div`,{className:`mem-conv-meta`,children:s(`span`,{children:C(t.timestamp,e)})})]},t.id))}):s(`div`,{className:`mem-empty`,children:s(`p`,{children:e(`mem.conv.noMatch`,{query:an})})})]}),M&&d(`div`,{className:`mem-conv-detail-overlay`,children:[d(`div`,{className:`mem-conv-detail-header`,children:[s(`h2`,{children:s(`bdi`,{children:He(M.sessionId)})}),d(`div`,{className:`mem-conv-detail-actions`,children:[ce.has(M.sessionId)&&s(`button`,{className:`btn-secondary`,onClick:()=>l(M.sessionId),children:e(`mem.conv.openChat`)}),s(`button`,{className:`btn-icon`,onClick:()=>un(null),"aria-label":e(`mem.conv.close`),children:s(Ge,{size:16})})]})]}),d(`div`,{className:`mem-conv-detail-body`,children:[M.turns.map(t=>d(`div`,{className:`mem-conv-turn`,children:[d(`div`,{className:`mem-conv-turn-header`,children:[s(`div`,{className:`mem-conv-turn-role ${t.role}`,children:s(T,{value:t.role,keys:kt})}),s(`span`,{className:`mem-conv-turn-time`,title:S(t.timestamp,u(e)),children:C(t.timestamp,e)})]}),s(`div`,{className:`mem-conv-turn-content`,children:s(`bdi`,{children:t.content})})]},t.id)),M.turns.length===0&&s(`div`,{className:`mem-empty`,children:e(`mem.conv.noTurns`)})]})]})]}),d(`div`,{className:`mem-section`,children:[d(`div`,{className:`mem-section-title`,children:[s(ot,{size:14}),` `,e(`mem.settings.title`),` `,s(`span`,{className:`mem-beta`,style:{fontSize:10,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`1px 6px`,borderRadius:4,marginInlineStart:6,verticalAlign:`middle`},children:e(`mem.beta`)})]}),d(`div`,{className:`mem-setting-row`,children:[d(`div`,{className:`mem-setting-info`,children:[s(`span`,{className:`mem-setting-label`,children:e(`mem.settings.memory`)}),s(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.memoryDesc`)})]}),s(`button`,{className:`mem-toggle${I?` mem-toggle-on`:``}`,disabled:L,onClick:async()=>{if(!I)B(`memory`);else{R(!0);try{let e=await p({memory_enabled:!1});gn(e.memory_enabled)}catch(n){t.system.warn(`Failed to disable memory`,n),X(e(`mem.toast.settingFailed`,{error:E(n)}),`error`)}finally{R(!1)}}},"aria-pressed":I,"aria-label":e(I?`mem.settings.memoryOn`:`mem.settings.memoryOff`),children:e.bare(I?`mem.on`:`mem.off`)})]}),En&&(()=>{let n={memory:{title:`mem.beta.memory.title`,description:`mem.beta.memory.desc`,bullets:[`mem.beta.memory.local`,`mem.beta.memory.lost`,`mem.beta.memory.disable`],buttonLabel:`mem.beta.memory.confirm`,onConfirm:async()=>{let t=await p({memory_enabled:!0});gn(t.memory_enabled),X(e(`mem.toast.memoryEnabled`),`info`)}},mcp:{title:`mem.beta.mcp.title`,description:`mem.beta.mcp.desc`,bullets:[`mem.beta.mcp.read`,`mem.beta.mcp.restart`,`mem.beta.mcp.debug`],buttonLabel:`mem.beta.mcp.confirm`,onConfirm:async()=>{let t=await p({mcp_memory_enabled:!0});vn(t.mcp_memory_enabled),X(e(`mem.toast.mcpEnabled`),`info`)}},discovery:{title:`mem.beta.discovery.title`,description:`mem.beta.discovery.desc`,bullets:[`mem.beta.discovery.collects`,`mem.beta.discovery.scans`,`mem.beta.discovery.local`],buttonLabel:`mem.beta.discovery.confirm`,onConfirm:async()=>{let t=await p({system_discovery_consent:!0});if(bn(t.system_discovery_consent),t.system_context_error)X(e(`mem.toast.discoveryScanFailed`,{error:t.system_context_error}),`error`);else{let n=t.system_context_refresh?.stored??0;X(e(`mem.toast.discoveryEnabled`,{n}),`info`)}Q()}}}[En];return d(a.Fragment,{children:[s(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>B(null)}),d(`div`,{ref:br,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mem-beta-confirm-title`,"aria-describedby":`mem-beta-confirm-desc`,tabIndex:-1,style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:9999,background:`var(--bg-card)`,border:`1px solid var(--border)`,borderRadius:12,padding:`28px 32px`,maxWidth:420,width:`90vw`,boxShadow:`var(--shadow-lg)`},children:[d(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[s(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:700,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`3px 10px`,borderRadius:4},children:e(`mem.beta`)}),s(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e(n.title)})]}),s(`p`,{id:`mem-beta-confirm-desc`,style:{fontSize:13,lineHeight:1.6,color:`var(--text-secondary)`,margin:`0 0 8px`},children:e(n.description)}),s(`ul`,{style:{fontSize:13,lineHeight:1.7,color:`var(--text-secondary)`,margin:`0 0 24px`,paddingInlineStart:20},children:n.bullets.map(t=>s(`li`,{children:e(t)},t))}),d(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[s(`button`,{className:`btn-secondary`,onClick:()=>B(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:e(`mem.cancel`)}),s(`button`,{disabled:L,onClick:async()=>{R(!0);try{await n.onConfirm()}catch(n){t.system.warn(`Failed to update setting`,n),X(e(`mem.toast.settingFailed`,{error:E(n)}),`error`)}finally{R(!1),B(null)}},style:{padding:`8px 24px`,fontSize:13,fontWeight:600,borderRadius:6,border:`none`,cursor:`pointer`,background:`var(--accent-fill)`,color:`var(--accent-fill-text)`},children:e(n.buttonLabel)})]})]})]})})(),d(`div`,{className:`mem-setting-row`,children:[d(`div`,{className:`mem-setting-info`,children:[s(`span`,{className:`mem-setting-label`,children:e(`mem.settings.mcp`)}),s(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.mcpDesc`)})]}),s(`button`,{className:`mem-toggle${_n?` mem-toggle-on`:``}`,disabled:L,onClick:async()=>{if(!_n)B(`mcp`);else{R(!0);try{let e=await p({mcp_memory_enabled:!1});vn(e.mcp_memory_enabled)}catch(n){t.system.warn(`Failed to update memory settings`,n),X(e(`mem.toast.settingFailed`,{error:E(n)}),`error`)}finally{R(!1)}}},"aria-label":e(`mem.settings.mcpToggle`),"aria-pressed":_n,children:e.bare(_n?`mem.on`:`mem.off`)})]}),d(`div`,{className:`mem-setting-row`,children:[d(`div`,{className:`mem-setting-info`,children:[s(`span`,{className:`mem-setting-label`,children:e(`mem.settings.discovery`)}),s(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.discoveryDesc`)})]}),s(`button`,{className:`mem-toggle${yn?` mem-toggle-on`:``}`,disabled:L,onClick:async()=>{if(!yn)B(`discovery`);else{R(!0);try{let e=await p({system_discovery_consent:!1});bn(e.system_discovery_consent)}catch(n){t.system.warn(`Failed to update system discovery setting`,n),X(e(`mem.toast.settingFailed`,{error:E(n)}),`error`)}finally{R(!1)}}},"aria-label":e(`mem.settings.discoveryToggle`),"aria-pressed":yn,children:e.bare(yn?`mem.on`:`mem.off`)})]}),d(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[d(`div`,{className:`mem-setting-info`,children:[s(`span`,{className:`mem-setting-label`,children:e(`mem.settings.reinit`)}),s(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.reinitDesc`)})]}),wn?d(`div`,{className:`mem-delete-confirm`,children:[s(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),s(`button`,{className:`mem-btn-danger`,disabled:L,onClick:async()=>{R(!0);try{let t=await ue();t.system_context.error?X(e(`mem.toast.server`,{message:t.system_context.error}),`error`):X(e(`mem.toast.reinitialized`,{cleared:t.cleared.knowledge,stored:t.system_context.stored}),`info`),Q()}catch(n){t.system.warn(`Failed to reinitialize memory`,n),X(e(`mem.toast.reinitFailed`,{error:E(n)}),`error`)}finally{R(!1),Tn(!1)}},children:e(`mem.settings.reinitConfirm`)}),s(`button`,{className:`btn-secondary`,onClick:()=>Tn(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):s(`button`,{className:`mem-btn-danger`,disabled:L,onClick:()=>Tn(!0),children:e(`mem.settings.reinitButton`)})]}),d(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[d(`div`,{className:`mem-setting-info`,children:[s(`span`,{className:`mem-setting-label`,children:e(`mem.settings.deleteAll`)}),s(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.deleteAllDesc`)})]}),xn?d(`div`,{className:`mem-delete-confirm`,children:[s(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),s(`button`,{className:`mem-btn-danger`,disabled:L,onClick:async()=>{R(!0);try{let t=await Me();X(e(`mem.toast.cleared`,{knowledge:t.knowledge,conversations:t.conversations}),`info`),Q()}catch(n){t.system.warn(`Failed to clear memory`,n),X(e(`mem.toast.clearFailed`,{error:E(n)}),`error`)}finally{R(!1),Sn(!1)}},children:e(`mem.settings.deleteConfirm`)}),s(`button`,{className:`btn-secondary`,onClick:()=>Sn(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):s(`button`,{className:`mem-btn-danger`,disabled:L,onClick:()=>Sn(!0),children:e(`mem.settings.deleteButton`)})]})]}),_&&d(`div`,{className:`mem-db-footer`,children:[d(`span`,{children:[e(`mem.footer.database`),`: `,s(`bdi`,{dir:`ltr`,children:qe(_.db_size_bytes)}),_.knowledge?.avg_confidence!=null&&d(a.Fragment,{children:[` · `,e(`mem.footer.avgConfidence`,{n:_.knowledge.avg_confidence.toFixed(2)})]})]}),d(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[_.knowledge?.entity_count!=null&&_.knowledge.entity_count>0&&s(`span`,{children:e(`mem.footer.entities`,{n:_.knowledge.entity_count})}),_.knowledge?.sensitive_count!=null&&_.knowledge.sensitive_count>0&&d(`span`,{children:[s(ot,{size:10}),` `,e(`mem.footer.sensitive`,{n:_.knowledge.sensitive_count})]})]})]})]})}),V===`profile`&&d(`div`,{className:`mem-profile-grid`,children:[d(`div`,{className:`mem-profile-card`,children:[d(`div`,{className:`mem-profile-card-title`,children:[s(Ie,{size:16}),` `,e(`mem.disc.title`)]}),s(`p`,{className:`mem-profile-desc`,children:e(`mem.disc.desc`)}),s(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:H===`running`||H===`saving`,onClick:Xr,children:H===`running`?d(a.Fragment,{children:[s(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.disc.run`)}),Wn.length>0&&s(`div`,{className:`mem-log`,ref:qn,children:Wn.map((e,t)=>s(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?s(`bdi`,{children:e.text}):e.text},t))}),(H===`review`||H===`saving`||H===`done`)&&G.length>0&&d(`div`,{className:`mem-review-section`,children:[s(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),s(`div`,{className:`mem-review-list`,children:G.map((e,t)=>d(`label`,{className:`mem-review-item`,children:[s(`input`,{type:`checkbox`,checked:e._checked,disabled:H===`saving`||H===`done`,onChange:()=>{K(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),s(`bdi`,{className:`mem-review-content`,children:e.content}),s(`span`,{className:`mem-source-badge`,children:e._source_name?s(`bdi`,{children:e._source_name}):s(T,{value:e.category,keys:w})}),d(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),d(`div`,{className:`mem-review-actions`,children:[s(`button`,{className:`btn-primary`,disabled:H===`saving`||H===`done`||G.filter(e=>e._checked).length===0,onClick:Zr,children:H===`saving`?d(a.Fragment,{children:[s(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:G.filter(e=>e._checked).length})}),d(`span`,{className:`mem-review-select-links`,children:[s(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>K(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,s(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>K(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),H===`done`&&Gn!==null&&d(`div`,{className:`mem-profile-success`,children:[s(m,{size:14}),` `,e(`mem.disc.saved`,{n:Gn})]}),H===`review`&&G.length===0&&s(`div`,{className:`mem-profile-empty`,children:e(`mem.disc.empty`)})]}),d(`div`,{className:`mem-profile-card`,children:[d(`div`,{className:`mem-profile-card-title`,children:[s(Re,{size:16}),` `,e(`mem.inf.title`)]}),s(`p`,{className:`mem-profile-desc`,children:e(`mem.inf.desc`)}),s(`p`,{className:`mem-profile-note`,children:e(`mem.inf.note`)}),d(`label`,{className:`mem-profile-checkbox`,children:[s(`input`,{type:`checkbox`,checked:er,onChange:e=>tr(e.target.checked),disabled:q===`running`||q===`saving`}),e(`mem.inf.browser`)]}),s(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:q===`running`||q===`saving`,onClick:Qr,children:q===`running`?d(a.Fragment,{children:[s(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.inf.run`)}),Xn.length>0&&s(`div`,{className:`mem-log`,ref:nr,children:Xn.map((e,t)=>s(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?s(`bdi`,{children:e.text}):e.text},t))}),(q===`review`||q===`saving`||q===`done`)&&Y.length>0&&d(`div`,{className:`mem-review-section`,children:[s(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),s(`div`,{className:`mem-review-list`,children:Y.map((e,t)=>d(`label`,{className:`mem-review-item`,children:[s(`input`,{type:`checkbox`,checked:e._checked,disabled:q===`saving`||q===`done`,onChange:()=>{Zn(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),s(`bdi`,{className:`mem-review-content`,children:e.content}),s(`span`,{className:`mem-domain-badge ${jt[e.domain]||`gray`}`,children:s(T,{value:e.domain,keys:At})}),d(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),d(`div`,{className:`mem-review-actions`,children:[s(`button`,{className:`btn-primary`,disabled:q===`saving`||q===`done`||Y.filter(e=>e._checked).length===0,onClick:$r,children:q===`saving`?d(a.Fragment,{children:[s(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:Y.filter(e=>e._checked).length})}),d(`span`,{className:`mem-review-select-links`,children:[s(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Zn(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,s(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Zn(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),q===`done`&&Qn!==null&&d(`div`,{className:`mem-profile-success`,children:[s(m,{size:14}),` `,e(`mem.inf.saved`,{n:Qn})]}),q===`review`&&Y.length===0&&s(`div`,{className:`mem-profile-empty`,children:e(`mem.inf.empty`)})]})]}),V===`goals`&&d(`div`,{className:`mem-goals-tab`,children:[s(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(t=>d(`div`,{className:`mem-goals-stat-pill mem-goal-status-${t.replace(`_`,`-`)}`,children:[s(`span`,{className:`mem-goals-stat-n`,children:Mn?.goals[t]??0}),s(`span`,{className:`mem-goals-stat-label`,children:e(Et[t])})]},t))}),An.filter(e=>e.status===`pending_approval`).length>0&&d(`div`,{className:`mem-goals-approval-banner`,children:[d(`div`,{className:`mem-goals-approval-title`,children:[s(te,{size:14}),` `,e(`mem.goals.suggested`,{n:An.filter(e=>e.status===`pending_approval`).length})]}),An.filter(e=>e.status===`pending_approval`).map(t=>d(`div`,{className:`mem-goals-approval-item`,children:[d(`div`,{className:`mem-goals-approval-text`,children:[s(`strong`,{children:s(`bdi`,{children:t.title})}),s(`bdi`,{children:t.description})]}),d(`div`,{className:`mem-goals-approval-actions`,children:[s(`button`,{className:`btn-danger-sm`,onClick:()=>Ar(()=>xe(t.id),`mem.goals.rejectFailed`),children:e(`mem.goals.reject`)}),s(`button`,{className:`btn-secondary`,onClick:()=>Ar(()=>Ue(t.id),`mem.goals.acceptFailed`),children:e(`mem.goals.accept`)})]})]},t.id))]}),s(`div`,{className:`mem-goals-toolbar`,children:d(`button`,{className:`btn-primary`,onClick:()=>Vn(e=>!e),children:[s(Be,{size:14}),` `,e(`mem.goals.new`)]})}),Bn&&d(`div`,{className:`mem-goals-add-form`,children:[s(`input`,{className:`mem-input`,placeholder:e(`mem.goals.titlePlaceholder`),value:Hn.title,onChange:e=>Un(t=>({...t,title:e.target.value}))}),s(`textarea`,{className:`mem-input`,placeholder:e(`mem.goals.descPlaceholder`),rows:2,value:Hn.description,onChange:e=>Un(t=>({...t,description:e.target.value}))}),d(`div`,{className:`mem-goals-form-row`,children:[d(`select`,{className:`mem-select`,value:Hn.priority,onChange:e=>Un(t=>({...t,priority:e.target.value})),children:[s(`option`,{value:`low`,children:e(`mem.goals.priorityLow`)}),s(`option`,{value:`medium`,children:e(`mem.goals.priorityMedium`)}),s(`option`,{value:`high`,children:e(`mem.goals.priorityHigh`)})]}),s(`button`,{className:`btn-primary`,onClick:()=>{Hn.title.trim()&&Ar(async()=>{await Ze(Hn),Un({title:``,description:``,priority:`medium`}),Vn(!1)},`mem.goals.createFailed`)},children:e(`mem.goals.create`)}),s(`button`,{className:`btn-secondary`,onClick:()=>Vn(!1),children:e(`mem.cancel`)})]})]}),Pn?d(`div`,{className:`mem-loading`,children:[s(`div`,{className:`mem-spinner`}),` `,e(`mem.goals.loading`)]}):An.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?d(`div`,{className:`mem-empty`,children:[s(`div`,{className:`mem-empty-icon`,children:s(st,{size:32})}),s(`p`,{children:e(`mem.goals.empty`)})]}):s(`div`,{className:`mem-goals-list`,children:An.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(t=>d(`div`,{className:`mem-goal-card mem-goal-status-${t.status.replace(`_`,`-`)}`,children:[d(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":In===t.id,onClick:()=>Ln(e=>e===t.id?null:t.id),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ln(e=>e===t.id?null:t.id))},children:[d(`div`,{className:`mem-goal-header-left`,children:[s(`span`,{className:`mem-goal-status-dot status-${t.status.replace(`_`,`-`)}`}),s(`bdi`,{className:`mem-goal-title`,children:t.title}),s(`span`,{className:`mem-goal-priority mem-priority-${t.priority}`,children:s(T,{value:t.priority,keys:Dt})}),t.source!==`user`&&d(`span`,{className:`mem-goal-source-badge`,children:[s(te,{size:10}),` `,s(T,{value:t.source,keys:Ot})]})]}),d(`div`,{className:`mem-goal-header-right`,children:[d(`span`,{className:`mem-goal-task-count`,children:[s(Qe,{size:12}),d(`bdi`,{dir:`ltr`,children:[t.tasks.filter(e=>e.status===`completed`).length,`/`,t.tasks.length]})]}),t.status===`queued`&&s(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:e=>{e.stopPropagation(),Ar(()=>ze(t.id),`mem.goals.cancelFailed`)},children:e(`mem.cancel`)}),Rn===t.id?s(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:e=>{e.stopPropagation(),zn(null),Ar(()=>Xe(t.id),`mem.goals.deleteFailed`)},children:e(`mem.row.deleteConfirm`)}):s(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":e(`mem.goals.deleteAria`,{title:t.title}),onClick:e=>{e.stopPropagation(),zn(t.id)},children:s(ke,{size:12})}),s(we,{size:14,className:In===t.id?`mem-chevron-open`:``})]})]}),In===t.id&&d(`div`,{className:`mem-goal-body`,children:[t.description&&s(`p`,{className:`mem-goal-desc`,children:s(`bdi`,{children:t.description})}),t.progress_notes&&s(`p`,{className:`mem-goal-progress`,children:s(`bdi`,{children:t.progress_notes})}),t.tasks.length>0?s(`div`,{className:`mem-task-list`,children:t.tasks.map(e=>d(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[s(`span`,{className:`mem-task-dot status-${e.status}`}),s(`bdi`,{className:`mem-task-desc`,children:e.description}),s(`span`,{className:`mem-task-status-label`,children:s(T,{value:e.status,keys:Et})}),e.result&&s(`bdi`,{className:`mem-task-result`,children:e.result})]},e.id))}):s(`p`,{className:`mem-goal-no-tasks`,children:e(`mem.goals.noTasks`)})]})]},t.id))})]})]}),Ut.length>0&&s(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:Ut.map(e=>d(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&s(m,{size:14}),e.type===`error`&&s(Ke,{size:14}),e.type===`info`&&s(Se,{size:14}),s(`span`,{children:e.text})]},e.id))})]})}export{Mt as MemoryDashboard};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-KnDALPx_.js","./rolldown-runtime-XKyaHtl9.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{I as t,J as n,a as r,c as i,l as a,u as o}from"./useT-CtECS-vp.js";import{X as s}from"./api-D5mTAXjB.js";import{Dt as c,Ht as l,Mt as u,X as d,ft as f,i as p,nt as m,rt as h,u as g,ut as _}from"./index-CsgZhHsw.js";var v=e(n(),1),y=null,b=`https://ngrok.com/download`;function x({isOpen:n,onClose:x,onStop:S,error:C,setupCommands:w,onRetry:T}){let[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),M=r(),N=Array.isArray(w),P=!!C||N,[F,I]=(0,v.useState)(null),L=(0,v.useRef)(null);m(n,x);let R=(0,v.useRef)(null);d(R,n),g(R,n);let z=(0,v.useCallback)(async()=>{try{let e=await s();return D(e),e}catch(e){return t.system.error(`Failed to fetch tunnel status`,e),null}},[]);(0,v.useEffect)(()=>{if(!n||P)return;z();let e=setInterval(async()=>{let t=await z();t?.active&&t?.url&&clearInterval(e)},2e3);return()=>clearInterval(e)},[n,P,z]),(0,v.useEffect)(()=>{if(!E?.active||!E.url||!E.token||!L.current)return;let n=`${E.url}/?token=${E.token}`;t.system.info(`Generating QR code for: ${n}`),(async()=>{if(I(null),!y)try{let t=await p(()=>import(`./browser-KnDALPx_.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1]),import.meta.url);y=t.default||t}catch{t.system.error(`QR code library not available - install with: npm install qrcode`),I(`QR code unavailable on this build. Use the link below instead.`);return}let r=getComputedStyle(document.documentElement),i=r.getPropertyValue(`--text-primary`).trim(),a=r.getPropertyValue(`--bg-primary`).trim();if(!i||!a)t.system.error(`QR code skipped: --text-primary/--bg-primary did not resolve. styles/index.css must be loaded before this modal renders.`),I(`QR code unavailable — the theme did not load. Use the link below instead.`);else try{await y.toCanvas(L.current,n,{width:200,margin:2,color:{dark:i,light:a}})}catch(e){t.system.error(`QR code generation failed`,e),I(`QR code could not be drawn. Use the link below instead.`)}})()},[E?.active,E?.url,E?.token]);let B=(0,v.useRef)(null),V=(0,v.useCallback)(()=>{if(!E?.url||!E?.token)return;let e=`${E.url}/?token=${E.token}`;navigator.clipboard.writeText(e).then(()=>{k(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>k(!1),2e3)})},[E]),H=(0,v.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{j(e),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>j(null),2e3)}).catch(e=>t.system.error(`Could not copy the ngrok install command`,e))},[]);if((0,v.useEffect)(()=>()=>{B.current&&clearTimeout(B.current)},[]),!n)return null;let U=E?.active&&E?.url&&E?.token?`${E.url}/?token=${E.token}`:``;return a(`div`,{ref:R,className:`modal-overlay`,onClick:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Mobile access`,children:o(`div`,{className:`modal-panel mobile-modal`,onClick:e=>e.stopPropagation(),children:[o(`div`,{className:`modal-header`,children:[o(`h3`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[a(_,{size:18}),`Mobile access`]}),a(`button`,{className:`btn-icon`,onClick:x,"aria-label":`Close`,children:a(h,{size:18})})]}),o(`div`,{className:`modal-body mobile-modal-body`,children:[o(`div`,{className:`tunnel-status`,children:[a(`span`,{className:`status-dot ${E?.active?`active`:N?`setup`:C?`error`:`starting`}`}),a(`span`,{children:E?.active?`Tunnel active`:N?M(`mobile.ngrokRequired`):C?`Couldn't start mobile access`:`Starting tunnel...`}),!E?.active&&!P&&a(`span`,{className:`tunnel-spinner`})]}),N&&o(`div`,{className:`tunnel-setup`,children:[a(`div`,{className:`tunnel-setup-title`,children:M(`mobile.setupTitle`)}),o(`p`,{children:[M(`mobile.setupIntro`),` `,w.length>0?M(`mobile.setupInstall`):M(`mobile.setupDownload`)]}),w.map(e=>o(`div`,{className:`tunnel-url-row tunnel-setup-command`,children:[a(`input`,{type:`text`,readOnly:!0,dir:`ltr`,value:e,"aria-label":M(`mobile.installCommand`)}),o(`button`,{className:`copy-url-btn ${A===e?`copied`:``}`,onClick:()=>H(e),title:M(`mobile.copyCommand`),children:[a(A===e?l:u,{size:13}),M(A===e?`mobile.copied`:`mobile.copy`)]})]},e)),o(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:`tunnel-setup-link`,children:[M(`mobile.downloadPage`),` `,a(c,{size:11})]})]}),C&&!N&&a(`div`,{className:`tunnel-error`,children:C}),!P&&a(`div`,{className:`qr-code-area`,children:E?.active?o(i.Fragment,{children:[a(`canvas`,{ref:L,hidden:!!F}),F&&a(`div`,{className:`qr-placeholder error`,children:F})]}):o(`div`,{className:`qr-placeholder`,children:[a(`div`,{className:`placeholder-spinner`}),a(`span`,{children:`Connecting...`})]})}),E?.active&&U&&o(`div`,{className:`tunnel-url-area`,children:[a(`label`,{children:`Mobile URL`}),o(`div`,{className:`tunnel-url-row`,children:[a(`input`,{type:`text`,readOnly:!0,value:U}),o(`button`,{className:`copy-url-btn ${O?`copied`:``}`,onClick:V,title:`Copy URL`,children:[a(O?l:u,{size:13}),O?`Copied`:`Copy`]})]})]}),E?.active&&E?.publicIp&&E?.url&&!E.url.includes(`ngrok-free.app`)&&o(`div`,{className:`tunnel-password-hint`,children:[a(`label`,{children:`Tunnel password`}),a(`div`,{className:`tunnel-password-value`,children:E.publicIp}),a(`span`,{className:`tunnel-password-note`,children:`Enter this when the tunnel page asks for a password`})]}),!P&&a(`div`,{className:`mobile-instructions`,children:o(`ol`,{children:[a(`li`,{children:F?`Open the mobile URL above on your phone`:`Scan the QR code with your phone's camera`}),E?.url&&!E.url.includes(`ngrok-free.app`)&&a(`li`,{children:`Enter the tunnel password shown above when prompted`}),a(`li`,{children:`Chat with GAIA from your mobile device`}),a(`li`,{children:`Your data stays secure via encrypted tunnel`})]})}),E?.active&&!C&&o(`div`,{className:`mobile-install-hint`,children:[a(`div`,{className:`mobile-install-hint-title`,children:M(`mobileAccess.installTitle`)}),a(`p`,{children:M(`mobileAccess.installSteps`)}),a(`p`,{children:M(`mobileAccess.linkLifetime`)})]}),o(`div`,{className:`mobile-access-actions`,children:[E?.active&&S&&a(`button`,{className:`btn-danger`,onClick:S,title:`Close the tunnel and revoke the mobile URL`,children:`Stop tunnel`}),N&&T&&o(`button`,{className:`btn-primary`,onClick:T,children:[a(f,{size:13}),` `,M(`mobile.retry`)]}),a(`button`,{className:`btn-secondary`,onClick:x,children:`Close`})]})]})]})})}export{x as MobileAccessModal};
@@ -1,4 +0,0 @@
1
- import{I as e,o as t}from"./useT-CtECS-vp.js";var n=`gaia:draft:`,r=e=>`chat:${e}`,i=`new-chat`;function a(t){try{return localStorage.getItem(n+t)??``}catch(n){return e.ui.warn(`Couldn't read the saved draft for ${t}`,n),``}}function o(t,r){try{r?localStorage.setItem(n+t,r):localStorage.removeItem(n+t)}catch(n){e.ui.warn(`Couldn't save the draft for ${t}`,n)}}function s(e){o(e,``)}function c(e){if(!(e instanceof L)||e.httpStatus!==409||!e.body)return null;let{code:t,acknowledge:n}=e.body;return(t===`no_fit`||t===`low_disk`)&&typeof n==`string`?e.body:null}async function l(){return V(`GET`,`/onboarding/preflight`)}async function u(e=!1){return V(`GET`,`/setup/check?skip_chat_model=${e}`)}async function d(e,t=!1,n={}){return V(`POST`,`/setup/run`,{skip_chat_model:e,gaia_lemonade:t,acknowledge_low_disk:!!n.acknowledgeLowDisk,keep_trying:!!n.keepTrying,extra_models:n.extraModels??[],server_only:!!n.serverOnly,upgrade_embedded:!!n.upgradeEmbedded})}async function f(e){return V(`POST`,`/setup/cancel`,e?{model_id:e}:void 0)}async function p(e,t){return V(`POST`,`/setup/models/skip`,{model_id:e,skipped:t})}async function m(e,t={}){return V(`POST`,`/setup/models/download`,{model_id:e,acknowledge_low_disk:!!t.acknowledgeLowDisk,keep_trying:!!t.keepTrying})}async function h(e){return V(`POST`,`/setup/models/remove`,{model_id:e})}async function g(){return V(`GET`,`/setup/status`)}async function ee(){return V(`GET`,`/setup/plan`)}async function te(e,t=!1){return V(`POST`,`/setup/chat-model`,{model_id:e,acknowledge_no_fit:t})}async function ne(){return V(`POST`,`/setup/npu/recheck`)}async function re(){return V(`POST`,`/setup/npu/memlock-fix`)}async function ie(e){return V(`POST`,`/setup/vision-model`,{model_id:e})}async function ae(e){return V(`GET`,`/setup/needs/${e}`)}async function oe(e){return V(`GET`,e==null?`/gpu-memory`:`/gpu-memory?setting_gb=${e}`)}async function se(e){return V(`POST`,`/gpu-memory/apply`,{setting_gb:e,confirm:!0})}async function ce(){return V(`POST`,`/gpu-memory/revert`,{confirm:!0})}async function le(e){return V(`POST`,`/gpu-memory/pending`,{setting_gb:e})}async function ue(){return V(`DELETE`,`/gpu-memory/pending`)}async function de(){return V(`GET`,`/onboarding/start`)}async function fe(){return V(`POST`,`/setup/report`)}async function pe(e){let n=await fetch(`${t()}/setup/report/${encodeURIComponent(e)}`,{headers:B});if(!n.ok)throw new L(`Couldn't read the report (HTTP ${n.status}).`,n.status,await n.text().catch(()=>``),null);return n.blob()}async function me(){return V(`GET`,`/connectors`)}async function he(e){return V(`GET`,`/connectors/${e}`)}async function ge(e,t,n=[]){return V(`POST`,`/connectors/${e}/authorize`,{scopes:t,grant_agents:n},B)}async function _e(e,t,n=[]){return V(`POST`,`/connectors/${e}/authorize-device`,{scopes:t,grant_agents:n},B)}async function ve(e,t){return V(`POST`,`/connectors/${e}/configure`,{config:t},B)}async function ye(e){await V(`DELETE`,`/connectors/${e}`,void 0,B)}async function _(e){return V(`POST`,`/connectors/${e}/enable`,{},B)}async function v(e){return V(`POST`,`/connectors/${e}/disable`,{},B)}async function y(){return V(`GET`,`/connectors/agent-mcps`)}async function b(e){return V(`GET`,`/connectors/${e}/grants`)}async function x(e,t,n){await V(`PUT`,`/connectors/${e}/grants/${encodeURIComponent(t)}`,{scopes:n},B)}async function S(e,t){await V(`DELETE`,`/connectors/${e}/grants/${encodeURIComponent(t)}`,void 0,B)}async function C(e){return V(`GET`,`/connectors/${e}/activations`)}async function w(e,t,n){return V(`PUT`,`/connectors/${e}/activations/${encodeURIComponent(t)}`,n?{scopes:n}:{},B)}async function T(e,t){await V(`DELETE`,`/connectors/${e}/activations/${encodeURIComponent(t)}`,void 0,B)}async function E(e){return V(`POST`,`/chat/cancel`,{session_id:e})}async function D(e,t){return V(`POST`,`/chat/followup`,{session_id:e,text:t})}async function O(e){return V(`GET`,`/chat/followup/${encodeURIComponent(e)}`)}async function k(e){return V(`GET`,`/chat/context/${encodeURIComponent(e)}`)}async function A(e){return V(`GET`,`/chat/performance/${encodeURIComponent(e)}`)}async function j(e,t,n){return V(`POST`,`/chat/retry-with`,{session_id:e,message_id:t,model:n})}async function M(e,t,n){return V(`POST`,`/chat/retry-with/choose`,{session_id:e,message_id:t,keep:n})}async function N(){return V(`GET`,`/chat/active`)}async function P(e,t,n={}){return V(`POST`,`/chat/confirm-tool`,{session_id:e,approved:t,always:n.always??!1,...n.confirmId?{confirm_id:n.confirmId}:{}})}async function be(e,t,n){return V(`POST`,`/chat/user-input`,{session_id:e,request_id:t,value:n})}async function xe(e){return V(`GET`,`/chat/permissions/${encodeURIComponent(e)}`)}async function Se(){return V(`GET`,`/chat/permissions`)}async function Ce(e){return V(`PUT`,`/chat/permissions`,{mode:e})}async function we(e,t){return V(`PUT`,`/chat/permissions/${encodeURIComponent(e)}`,{mode:t})}async function Te(e,t){let n=t?`?key=${encodeURIComponent(t)}`:``;return V(`DELETE`,`/chat/permissions/${encodeURIComponent(e)}/grants${n}`)}function F(e){try{let t=JSON.parse(e).detail;return Array.isArray(t)?t.map(e=>e?.msg??JSON.stringify(e)).join(`; `)||e:t&&typeof t==`object`&&typeof t.message==`string`?t.message:t&&typeof t!=`string`?JSON.stringify(t):t||e}catch{return e}}function I(e){try{let t=JSON.parse(e).detail?.status;return typeof t==`string`?t:null}catch{return null}}function Ee(e){try{let t=JSON.parse(e).detail;return Array.isArray(t)?t.map(e=>Array.isArray(e?.loc)?e.loc[e.loc.length-1]:void 0).filter(e=>typeof e==`string`):[]}catch{return[]}}function De(e){try{let t=JSON.parse(e).detail;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}var L=class extends Error{httpStatus;detail;reason;fields;body;constructor(e,t,n,r,i=[],a=null){super(e),this.name=`ApiError`,this.httpStatus=t,this.detail=n,this.reason=r,this.fields=i,this.body=a}};function R(e){return e.trim().toLowerCase()===`internal server error`}function Oe(e){let t=e.trim();return t!==``&&!R(t)&&!/^[<{[]/.test(t)}function z(e,t){switch(e){case 403:return t||`Access denied.`;case 404:return t||`The requested item was not found.`;case 413:return t||`File too large to process.`;case 500:return Oe(t)?t:`Server error. Please try again.`;case 502:return`Service unavailable. Is the backend running?`;case 503:return t||`Service unavailable.`;default:return t||`Request failed (HTTP ${e})`}}var B={"x-gaia-ui":`1`,"x-gaia-client":`agent-ui`},ke=/key|token|secret|password/i;function Ae(e){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ke.test(e)&&typeof t==`string`&&t?`***`:t]))}async function V(n,r,i,a,o){let s=`${t()}${r}`,c=e.api.time();e.api.info(`${n} ${s}`,i===void 0?``:{body:Ae(i)});let l=i===void 0?{}:{"Content-Type":`application/json`},u={method:n,headers:{...B,...a,...l},body:i===void 0?void 0:JSON.stringify(i),signal:o},d;try{d=await fetch(s,u)}catch(t){throw e.api.error(`${n} ${s} - network error`,t),t}if(!d.ok){let t=await d.text().catch(()=>``);e.api.error(`${n} ${s} - HTTP ${d.status}`,{errorText:t});let r=F(t);throw new L(z(d.status,r),d.status,r,I(t),Ee(t),De(t))}let f=d.headers.get(`content-type`)||``;if(!f.includes(`application/json`)){let t=await d.text().catch(()=>``);if(d.status===204||t.trim()===``){e.api.timed(`${n} ${s} -> ${d.status} (no body)`,c);return}throw e.api.error(`${n} ${s} -> ${d.status} (non-JSON body)`,{contentType:f,preview:t.slice(0,200)}),Error(`${n} ${r}: expected JSON, got ${f||`no Content-Type`} (HTTP ${d.status}: ${t.slice(0,120)})`)}let p=await d.json();return e.api.timed(`${n} ${s} -> ${d.status}`,c,p),p}async function je(e){return V(`GET`,`/system/status`,void 0,void 0,e)}async function Me(e=!1){return V(`POST`,e?`/system/warm-up?fresh=true`:`/system/warm-up`)}async function Ne(){return V(`GET`,`/system/warm-up`)}async function Pe(){return V(`GET`,`/system/model-server`)}async function Fe(e){return V(`PUT`,`/system/model-server/backend`,{backend:e})}async function Ie(){return V(`GET`,`/settings`)}async function Le(e){return V(`PUT`,`/settings`,e)}async function H(e,t,n=!1){return V(`POST`,`/system/load-model`,{model_name:e,ctx_size:t,force:n})}async function Re(e,t,n=e=>window.confirm(e)){try{return await H(e,t),!0}catch(r){if(!(r instanceof L)||r.httpStatus!==409)throw r;return n(`${r.detail}
2
-
3
- Load ${e} anyway?`)?(await H(e,t,!0),!0):!1}}async function ze(e,t=!1,n=!1){return V(`POST`,`/system/download-model`,{model_name:e,force:t,load_after:n})}async function Be(){return V(`GET`,`/agents`)}async function Ve(e){return V(`POST`,`/agents/install`,{id:e})}async function He(e){return V(`GET`,`/agents/${encodeURIComponent(e)}/install-status`)}async function Ue(){return V(`GET`,`/lemonade/target`)}async function We(){return V(`GET`,`/lemonade/detect`)}async function Ge(e){try{return await V(`POST`,`/lemonade/target`,e)}catch(e){throw e instanceof L&&e.httpStatus===502&&e.detail?new L(e.detail,e.httpStatus,e.detail,e.reason,e.fields):e}}async function Ke(){return V(`GET`,`/providers`)}async function qe(){return V(`GET`,`/providers/active`)}async function Je(e,t){return V(`POST`,`/providers/${encodeURIComponent(e)}/connect`,t)}var Ye=2e3;async function Xe(e,t,n,r=()=>!1){for(;;)try{return await Je(e,t)}catch(e){if(!(e instanceof L)||e.httpStatus!==409||r())throw e;n(e.detail),await new Promise(e=>setTimeout(e,Ye))}}async function Ze(e){return V(`DELETE`,`/providers/${encodeURIComponent(e)}/key`)}async function Qe(e){return V(`GET`,`/providers/${encodeURIComponent(e)}/models`)}async function $e(e){return V(`GET`,`/providers/local/context?model=${encodeURIComponent(e)}`)}async function et(e,t){return V(`PUT`,`/providers/local/context`,{model:e,ctx_size:t})}async function tt(){return V(`GET`,`/providers/local/status`)}async function nt(e=!1){return V(`POST`,`/providers/local/restart`,{confirm:e})}async function rt(e){return V(`POST`,`/providers/select`,{model:e})}async function it(e,t){return V(`POST`,`/providers/local/custom/check`,{url:e,quant:t||null})}async function at(e,t){return V(`POST`,`/providers/local/custom`,{url:e,quant:t||null})}async function ot(e){return V(`DELETE`,`/providers/local/custom/${encodeURIComponent(e)}`)}async function st(e){return V(`GET`,`/spending/prices/${encodeURIComponent(e)}`)}async function ct(){return V(`GET`,`/spending`)}async function lt(e){return V(`PUT`,`/spending/limit`,{limit_usd:e})}async function ut(){return V(`POST`,`/spending/allow-month`)}async function dt(){return V(`GET`,`/skills`)}async function ft(){let e=new Map,t=0;for(let n=0;;n+=200){let r=await V(`GET`,`/sessions?limit=200&offset=${n}`);t=r.total;for(let t of r.sessions)e.has(t.id)||e.set(t.id,t);if(r.sessions.length<200||n+200>=t)break}return{sessions:[...e.values()],total:t}}async function pt(e={}){return V(`POST`,`/sessions`,e)}async function mt(e,t){return V(`PUT`,`/sessions/${e}`,t)}async function ht(e){await V(`DELETE`,`/sessions/${e}`),s(r(e))}async function gt(e){return V(`GET`,`/sessions/${e}`)}async function _t(e,t){return V(`PUT`,`/sessions/${e}/pin`,{pinned:t})}async function vt(e,t,n){return V(`GET`,`/sessions/search?${new URLSearchParams({q:e,include_automated:String(t)})}`,void 0,void 0,n)}async function yt(e){return V(`POST`,`/sessions/${e}/read`)}async function bt(e){return V(`PATCH`,`/sessions/${e}/private`)}async function xt(e){let{total:t}=await V(`GET`,`/sessions/${e}/messages?limit=1&offset=0`);return t}async function St(e){let t=`/sessions/${e}/messages`,n=await V(`GET`,`${t}?limit=100&offset=0`),r=[...n.messages],i=n.total;for(;r.length<i;){let e=await V(`GET`,`${t}?limit=${Math.min(100,i-r.length)}&offset=${r.length}`);if(e.messages.length===0)throw Error(`Incomplete transcript received. Please reload the conversation.`);r.push(...e.messages)}return{messages:r,total:i}}async function Ct(e){return V(`GET`,`/sessions/${e}/export?format=markdown`)}async function wt(e,t){return V(`DELETE`,`/sessions/${e}/messages/${t}`)}async function Tt(e,t){return V(`DELETE`,`/sessions/${e}/messages/${t}/and-below`)}var Et=new Set([`status`,`step`,`thinking`,`commentary`,`plan`,`tool_start`,`tool_end`,`tool_result`,`tool_args`,`tool_confirm`,`agent_error`,`permission_request`,`needs_confirmation`,`needs_input`,`policy_alert`,`followup_taken`,`followup_returned`,`followup_unavailable`,`context_usage`]);function Dt(n,r,i,a,o,s,c){let l;l=typeof i==`function`?{onChunk:i,onAgentEvent:()=>{},onDone:a||(()=>{}),onError:o||(t=>{e.stream.error(`Unhandled stream error`,t)})}:i;let u=new AbortController,d=e.stream.time();e.stream.info(`Starting SSE stream for session=${n}`,{messageLength:r.length});let f=Y(u,l,U,At);return fetch(`${t()}/chat/send`,{method:`POST`,headers:{...B,"Content-Type":`application/json`},body:JSON.stringify({session_id:n,message:r,stream:!0,...s?{agent_type:s}:{},...c?{device:c}:{}}),signal:u.signal}).then(e=>(f.received(),f.connected(),X(e,l,d,{silentCloseIsError:!0}))).catch(t=>{f.received(),f.timedOut()?(e.stream.error(`No answer to /chat/send within ${U/1e3}s`),l.onError(new J(`send`,U))):t.name===`AbortError`?e.stream.warn(`Stream aborted by user`):(e.stream.error(`Stream fetch error`,t),l.onError(t))}),u}var Ot=3e4,kt=6e5,U=9e4,At=3e3,W=`Waiting for GAIA to start this answer…`,G=3e4,K=class extends Error{idleMs;constructor(e){super(`The connection to GAIA went silent for ${Math.round(e/1e3)} s.`),this.idleMs=e,this.name=`StreamStalledError`}},q=class extends Error{cause;unreachable;constructor(e,t=!1){super(`The connection to GAIA was cut: ${e instanceof Error?e.message:String(e)}`),this.cause=e,this.unreachable=t,this.name=`StreamDroppedError`}},J=class extends Error{endpoint;timeoutMs;constructor(e,t){super(`GAIA did not start answering within ${Math.round(t/1e3)} s.`),this.endpoint=e,this.timeoutMs=t,this.name=`StreamTimeoutError`}};function Y(e,t,n,r){let i=!1,a=r===void 0?void 0:setTimeout(()=>{t.onAgentEvent({type:`status`,status:`working`,phase:`waiting`,message:W})},r),o=setTimeout(()=>{i=!0,e.abort()},n),s=!1;return{received:()=>{clearTimeout(a),clearTimeout(o)},connected:()=>{s||(s=!0,t.onConnected?.())},timedOut:()=>i}}async function jt(e,t){let n,r=new Promise((e,r)=>{n=setTimeout(()=>r(new K(t)),t)});try{return await Promise.race([e.read(),r])}finally{clearTimeout(n)}}async function X(t,n,r,{silentCloseIsError:i=!1}={}){if(e.stream.info(`SSE connection opened -> HTTP ${t.status}`),!t.ok){let r=await t.text().catch(()=>``);e.stream.error(`SSE connection failed: HTTP ${t.status}`,r);let i=F(r),a=i&&!R(i)?i:z(t.status,i);n.onError(new L(a,t.status,i,I(r)));return}let a=t.body?.getReader();if(!a){e.stream.error(`No response body reader available`),n.onError(Error(`No response body`));return}let o=new TextDecoder,s=``,c=!1,l=0,u=0,d=0,f=!1,p=!1,m=!1;try{for(;;){let t;try{t=await jt(a,f?kt:Ot)}catch(t){if(t?.name===`AbortError`)throw t;if(!(t instanceof K)){if(e.stream.error(`SSE connection cut mid-stream`,t),c||p)return;if(m)break;throw new q(t)}if(e.stream.error(`SSE stream silent for ${t.idleMs/1e3}s; dropping the connection`),await a.cancel().catch(t=>e.stream.warn(`Could not cancel the stalled stream`,t)),c||p)return;if(m)break;throw t}let{done:i,value:h}=t;if(i){e.stream.debug(`SSE reader done (stream ended)`);break}s+=o.decode(h,{stream:!0});let g=s.split(`
4
- `);s=g.pop()||``;for(let t of g)if(t.startsWith(`data: `)){let i=t.slice(6).trim();if(!i)continue;try{let t=JSON.parse(i);if(f=t.type===`status`&&t.phase===`queued`,t.type===`chunk`)l++,u+=(t.content||``).length,(l<=3||l%50==0)&&e.stream.debug(`Chunk #${l} (+${(t.content||``).length} chars)`),n.onChunk(t);else if(t.type===`answer`)n.onChunk(t);else if(t.type===`done`)c=!0,e.stream.timed(`Stream complete: ${l} chunks, ${u} chars, ${d} agent events`,r),n.onDone(t);else if(t.type===`error`)e.stream.error(`Stream error event:`,t.content),p=!0,n.onError(Error(t.content||`Unknown error`));else if(t.type===`agent_created`)e.stream.info(`Agent created: ${t.agent_id}`),n.onAgentCreated?.(t);else if(t.type===`mcp_status`){let n=t.servers??[];e.stream.debug(`MCP status: ${n.length} server(s)`,n);for(let t of n)t.connected||e.stream.warn(`MCP server "${t.name}" is not connected: ${t.error??`no error reported`}`)}else Et.has(t.type)?(d++,t.type===`agent_error`&&!t.recoverable&&(m=!0),e.stream.debug(`Agent event: ${t.type}`,t),n.onAgentEvent(t)):e.stream.warn(`Unknown SSE event type: ${t.type}`,t)}catch{e.stream.warn(`Malformed SSE data, skipping`,{raw:i.slice(0,100)})}}}}finally{a.releaseLock()}if(!c){if(e.stream.timed(`SSE connection closed without done event: ${l} chunks, ${d} agent events`,r),i&&l===0&&d===0&&!p){n.onError(Error(`GAIA closed the connection before any answer arrived. Send the message again; if it keeps happening, check the GAIA server log.`));return}n.onDone({type:`done`})}}function Mt(n,r){let i=new AbortController,a=e.stream.time();e.stream.info(`Attaching to background run for session=${n}`);let o=Y(i,r,G);return fetch(`${t()}/chat/attach?session_id=${encodeURIComponent(n)}`,{method:`GET`,signal:i.signal}).then(t=>{if(o.received(),o.connected(),t.status===404)e.stream.info(`Run for session=${n} finished before the attach`),r.onDone({type:`done`,content:``});else return X(t,r,a)}).catch(t=>{o.received(),o.timedOut()?(e.stream.error(`No answer to /chat/attach within ${G/1e3}s`),r.onError(new J(`attach`,G))):t.name===`AbortError`?e.stream.warn(`Run attach detached by client`):t instanceof TypeError?(e.stream.error(`Run attach could not connect`,t),r.onError(new q(t,!0))):(e.stream.error(`Run attach fetch error`,t),r.onError(t))}),i}async function Nt(){return V(`GET`,`/documents`)}async function Pt(e){return V(`POST`,`/documents/upload-path`,{filepath:e})}async function Ft(n){let r=`${t()}/documents/upload`,i=e.api.time();e.api.info(`POST ${r}`,{fileName:n.name,size:n.size});let a=new FormData;a.append(`file`,n);let o;try{o=await fetch(r,{method:`POST`,headers:B,body:a})}catch(t){throw e.api.error(`POST ${r} - network error`,t),t}if(!o.ok){let t=await o.text().catch(()=>``);e.api.error(`POST ${r} - HTTP ${o.status}`,{errorText:t});let n=F(t);throw new L(z(o.status,n),o.status,n,I(t))}let s=await o.json();return e.api.timed(`POST ${r} -> ${o.status}`,i,s),s}async function It(e){return V(`DELETE`,`/documents/${e}`)}async function Lt(e){return V(`GET`,`/documents/${e}/status`)}function Rt(e,n){let r=new URL(`${t()}/documents/${encodeURIComponent(e)}/file`,window.location.href);return n&&(r.hash=`page=${n}`),r.href}async function zt(e){return V(`POST`,`/documents/${e}/cancel`)}async function Bt(e){return V(`POST`,`/documents/${e}/reindex`)}async function Vt(e,t){return V(`POST`,`/sessions/${e}/documents`,{document_id:t})}async function Ht(e,t){return V(`DELETE`,`/sessions/${e}/documents/${t}`)}async function Ut(e){return V(`GET`,`/files/browse${e?`?path=${encodeURIComponent(e)}`:``}`)}async function Wt(e,t=!0){return V(`POST`,`/documents/index-folder`,{folder_path:e,recursive:t})}async function Gt(e,t=!0){return V(`POST`,`/files/open`,{path:e,reveal:t})}async function Kt(e){return V(`POST`,`/files/open`,{path:e,launch:!0})}async function qt(e){return V(`POST`,`/files/status`,{paths:e})}async function Jt(n){let r=`${t()}/files/upload`,i=e.api.time();e.api.info(`POST ${r}`,{fileName:n.name,size:n.size});let a=new FormData;a.append(`file`,n);let o=await fetch(r,{method:`POST`,headers:B,body:a});if(!o.ok){let t=await o.text().catch(()=>``);e.api.error(`POST ${r} - HTTP ${o.status}`,{errorText:t});let n=F(t);throw new L(z(o.status,n),o.status,n,I(t))}let s=await o.json();return e.api.timed(`POST ${r} -> ${o.status}`,i,s),s}async function Yt(e,t,n){let r=new URLSearchParams({query:e});return t&&r.set(`file_types`,t),n&&r.set(`max_results`,String(n)),V(`GET`,`/files/search?${r}`)}async function Xt(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`lines`,String(t)),V(`GET`,`/files/preview?${n}`)}async function Zt(){return V(`POST`,`/tunnel/start`)}async function Qt(){return V(`POST`,`/tunnel/stop`)}async function $t(){return V(`GET`,`/tunnel/status`)}async function en(){return V(`GET`,`/mcp/status`)}async function tn(){return V(`GET`,`/schedules`)}function Z(){return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}async function nn(e,t,n){return V(`POST`,`/schedules`,{name:e,interval:t,prompt:n,timezone:Z()})}async function rn(e,t){return V(`PUT`,`/schedules/${encodeURIComponent(e)}`,{status:t})}async function an(e){return V(`POST`,`/schedules/${encodeURIComponent(e)}/run`)}async function on(e){return V(`DELETE`,`/schedules/${encodeURIComponent(e)}`)}async function sn(e,t=20){return V(`GET`,`/schedules/${encodeURIComponent(e)}/results?limit=${t}`)}async function cn(e){return V(`POST`,`/schedules/parse`,{input:e,timezone:Z()})}async function ln(e){return V(`GET`,`/sessions/${encodeURIComponent(e)}/changes`)}async function un(e,t){return V(`GET`,`/sessions/${encodeURIComponent(e)}/changes/${encodeURIComponent(t)}/diff`)}async function dn(e,t,n=!1){return V(`POST`,`/sessions/${encodeURIComponent(e)}/changes/${encodeURIComponent(t)}/undo`,{force:n})}async function fn(){return V(`GET`,`/settings/undo`)}async function pn(e,t){return V(`PUT`,`/settings/undo`,{retention_days:e,max_mb:t})}var Q=e=>`/sessions/${encodeURIComponent(e)}`;async function mn(e){return V(`GET`,`${Q(e)}/environment`)}async function $(e,t){return V(`POST`,`${Q(e)}/environment/folders`,{path:t})}async function hn(e,t){return V(`POST`,`${Q(e)}/environment/folders/remove`,{path:t})}async function gn(e,t){return V(`PUT`,`${Q(e)}/environment/internet`,{on:t})}async function _n(e){return V(`GET`,`${Q(e)}/outputs`)}async function vn(e){return V(`GET`,`${Q(e)}/capabilities`)}async function yn(e){return V(`GET`,`${Q(e)}/changes/total`)}async function bn(e,t=!1){return V(`POST`,`${Q(e)}/changes/undo`,{force:t})}async function xn(e){return V(`GET`,`${Q(e)}/changes/git`)}async function Sn(e,t,n){return V(`POST`,`${Q(e)}/changes/git/commit`,{root:t,message:n,confirmed:!0})}async function Cn(e,t,n,r){return V(`POST`,`${Q(e)}/changes/git/pr`,{root:t,title:n,body:r,confirmed:!0})}export{Ne as $,Se as $t,vn as A,re as An,Ge as At,St as B,ce as Bn,Le as Bt,We as C,u as Cn,an as Ct,Ze as D,ue as Dn,Dt,Ct as E,fe as En,rt as Et,qt as F,g as Fn,bt as Ft,yn as G,r as Gn,E as Gt,_n as H,p as Hn,Ft as Ht,Ue as I,de as In,bn as It,ct as J,o as Jn,N as Jt,xn as K,s as Kn,M as Kt,tt as L,ne as Ln,dn as Lt,$e as M,ae as Mn,lt as Mt,Lt as N,l as Nn,Zt as Nt,qe as O,m as On,et as Ot,mn as P,ee as Pn,Qt as Pt,fn as Q,xe as Qt,en as R,le as Rn,rn as Rt,Ht as S,f as Sn,nt as St,ze as T,ie as Tn,vt as Tt,sn as U,d as Un,Pt as Ut,Pe as V,c as Vn,pn as Vt,gt as W,i as Wn,Jt as Wt,$t as X,k as Xt,je as Y,A as Yt,un as Z,O as Zt,It as _,C as _n,Xt as _t,$ as a,we as an,Ke as at,on as b,S as bn,hn as bt,Mt as c,_e as cn,dt as ct,it as d,v as dn,yt as dt,be as en,Wt as et,Sn as f,ye as fn,Kt as ft,pt as g,y as gn,_t as gt,nn as h,x as hn,cn as ht,at as i,Ce as in,Qe as it,st as j,oe as jn,Fe as jt,He as k,pe as kn,gn as kt,Ut as l,ve as ln,ln as lt,Cn as m,he as mn,F as mt,W as n,Te as nn,Be as nt,ut as o,w as on,tn as ot,Xe as p,_ as pn,Gt as pt,Ie as q,a as qn,P as qt,J as r,D as rn,Nt as rt,Vt as s,ge as sn,ft as st,L as t,j as tn,Ve as tt,zt as u,T as un,Re as ut,wt as v,b as vn,Bt as vt,Rt as w,te as wn,Yt as wt,ht as x,se as xn,Me as xt,Tt as y,me as yn,ot as yt,xt as z,h as zn,mt as zt};