@amd-gaia/agent-ui 0.25.2-rc.4 → 0.25.2-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdvancedSettings-DxzL09lt.js → AdvancedSettings-BlYNI6AZ.js} +1 -1
- package/dist/assets/{ConnectorsPane-BOaVt5wd.js → ConnectorsPane-DtYVWxBo.js} +1 -1
- package/dist/assets/DocumentLibrary-DBHK1rnR.js +4 -0
- package/dist/assets/{FileBrowser-mE75Zm-P.js → FileBrowser-CSXzEgI5.js} +4 -4
- package/dist/assets/MemoryDashboard-qcp2siub.js +1 -0
- package/dist/assets/{MobileAccessModal-SPNutZLD.js → MobileAccessModal-BU3rxH7C.js} +1 -1
- package/dist/assets/{ScheduleManager-DUwRXGd2.js → ScheduleManager-CHq7l6Ex.js} +1 -1
- package/dist/assets/index-BK59gm9q.css +1 -0
- package/dist/assets/index-DIGoe3Yc.js +78 -0
- package/dist/index.html +2 -2
- package/main.cjs +3 -0
- package/package.json +1 -1
- package/preload.cjs +6 -0
- package/services/folder-dialog.cjs +44 -0
- package/dist/assets/DocumentLibrary-DjgHNHF0.js +0 -4
- package/dist/assets/MemoryDashboard-AN4yi3u6.js +0 -1
- package/dist/assets/index-B73021Op.js +0 -79
- package/dist/assets/index-DJViDewM.css +0 -1
package/dist/index.html
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
<meta name="theme-color" content="#1A1917" />
|
|
9
9
|
<link rel="icon" type="image/png" href="./favicon.png" />
|
|
10
10
|
<title>GAIA Agent UI</title>
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-DIGoe3Yc.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="./assets/apiBase-CS6zLsJY.js">
|
|
14
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
14
|
+
<link rel="stylesheet" crossorigin href="./assets/index-BK59gm9q.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
package/main.cjs
CHANGED
|
@@ -91,6 +91,7 @@ const installerProgressDialog = require("./services/backend-installer-progress-d
|
|
|
91
91
|
const autoUpdater = require("./services/auto-updater.cjs");
|
|
92
92
|
const agentSeeder = require("./services/agent-seeder.cjs");
|
|
93
93
|
const systemMetrics = require("./services/system-metrics.cjs");
|
|
94
|
+
const folderDialog = require("./services/folder-dialog.cjs");
|
|
94
95
|
const {
|
|
95
96
|
parseDeepLink,
|
|
96
97
|
extractDeepLinkFromArgv,
|
|
@@ -763,6 +764,8 @@ function initializeServices() {
|
|
|
763
764
|
// #2007: System metrics for the observability dashboard
|
|
764
765
|
systemMetrics.registerIpcHandlers();
|
|
765
766
|
|
|
767
|
+
folderDialog.registerIpcHandlers();
|
|
768
|
+
|
|
766
769
|
console.log("[main] Services initialized");
|
|
767
770
|
}
|
|
768
771
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amd-gaia/agent-ui",
|
|
3
|
-
"version": "0.25.2-rc.
|
|
3
|
+
"version": "0.25.2-rc.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"productName": "GAIA Agent UI",
|
|
6
6
|
"description": "Chat with the GAIA agent - local and private by default on AMD Ryzen AI, cloud models when you choose them",
|
package/preload.cjs
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* gaia:update:* — Auto-update status & manual check (Phase F)
|
|
16
16
|
* system:* — System metrics for the observability dashboard (#2007)
|
|
17
17
|
* power:* — Keep the PC awake while a chat turn runs (#5226)
|
|
18
|
+
* dialog:* — The OS folder picker
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
const { contextBridge, ipcRenderer } = require("electron");
|
|
@@ -84,6 +85,11 @@ contextBridge.exposeInMainWorld("gaiaAPI", {
|
|
|
84
85
|
system: {
|
|
85
86
|
getMetrics: () => ipcRenderer.invoke("system:get-metrics"),
|
|
86
87
|
},
|
|
88
|
+
|
|
89
|
+
// ── OS folder picker; resolves the chosen path, or null on cancel ─────
|
|
90
|
+
dialog: {
|
|
91
|
+
pickFolder: (defaultPath) => ipcRenderer.invoke("dialog:pick-folder", defaultPath),
|
|
92
|
+
},
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
// ── Window frame ─────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GAIA Agent UI — the OS folder picker for "give this chat a folder".
|
|
6
|
+
*
|
|
7
|
+
* The renderer invokes `dialog:pick-folder` and gets the chosen absolute path,
|
|
8
|
+
* or null when the user cancels. The web build has no preload, so it keeps
|
|
9
|
+
* GAIA's own picker.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
const { BrowserWindow, dialog, ipcMain } = require("electron");
|
|
15
|
+
|
|
16
|
+
const PICK_FOLDER_CHANNEL = "dialog:pick-folder";
|
|
17
|
+
|
|
18
|
+
async function pickFolder(event, defaultPath) {
|
|
19
|
+
if (defaultPath !== undefined && typeof defaultPath !== "string") {
|
|
20
|
+
throw new TypeError(`The folder picker's start folder must be a path, got ${typeof defaultPath}.`);
|
|
21
|
+
}
|
|
22
|
+
const owner = BrowserWindow.fromWebContents(event.sender);
|
|
23
|
+
if (!owner) {
|
|
24
|
+
throw new Error("The folder picker was asked for by a page that has no window.");
|
|
25
|
+
}
|
|
26
|
+
const { canceled, filePaths } = await dialog.showOpenDialog(owner, {
|
|
27
|
+
title: "Add a folder to this chat",
|
|
28
|
+
message: "GAIA will be able to read and write everything in the folder you pick, in this chat only.",
|
|
29
|
+
buttonLabel: "Add Folder",
|
|
30
|
+
properties: ["openDirectory", "createDirectory"],
|
|
31
|
+
...(defaultPath ? { defaultPath } : {}),
|
|
32
|
+
});
|
|
33
|
+
if (canceled) return null;
|
|
34
|
+
if (!filePaths[0]) {
|
|
35
|
+
throw new Error("The folder picker closed without a folder or a cancel.");
|
|
36
|
+
}
|
|
37
|
+
return filePaths[0];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function registerIpcHandlers() {
|
|
41
|
+
ipcMain.handle(PICK_FOLDER_CHANNEL, pickFolder);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { PICK_FOLDER_CHANNEL, registerIpcHandlers };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{$ as a,B as o,Ft as s,H as ee,Ht as te,Lt as c,Pt as ne,Q as re,Qt as l,U as ie,V as ae,W as u,Wt as d,Y as f,Z as oe,_t as se,cn as ce,dn as le,en as ue,fn as p,ft as de,lt as fe,ot as pe,q as me,st as m,t as h,vt as he,zt as ge}from"./index-B73021Op.js";var g={name:`circle-stop`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]],aliases:[`stop-circle`]};g.node;var _=t(g),v={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};v.node;var _e=t(v),y={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};y.node;var ve=t(y),b={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};b.node;var ye=t(b),x=e(r(),1),S=n();function be(e){let[t,...n]=e.replace(/^RAG indexing failed for [^:]+:\s*/,``).trim().split(`
|
|
2
|
-
`);return{summary:t.trim(),more:n.join(`
|
|
3
|
-
`).trim()}}function xe(e,t){let n=t.skipped??0,r=[];if(t.indexed>0?r.push(`Indexed ${t.indexed} file${t.indexed===1?``:`s`} from "${e}".`):t.failed===0&&r.push(`"${e}" has no documents GAIA can index.`),n>0&&r.push(`Skipped ${n} file${n===1?``:`s`} of a type GAIA doesn't index.`),t.failed>0){let e=t.errors[0]?` ${t.errors[0].split(`
|
|
4
|
-
`)[0]}`:``;r.push(`${t.failed} file${t.failed===1?``:`s`} couldn't be indexed.${e}`)}return r.push(`Subfolders aren't included.`),r.join(` `)}function Se(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ce(e){try{let t=new Date(e);if(isNaN(t.getTime()))return``;let n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:o===1?`yesterday`:o<7?`${o}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return``}}function we(e){try{let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function C(){let{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:r,currentSessionId:g,sessions:v,updateSessionInList:y,draftDocumentIds:b,addDraftDocuments:C,removeDraftDocument:w}=s(),T=v.find(e=>e.id===g)??null,[E,Te]=(0,x.useState)(g?`chat`:`next`),D=E===`chat`?g:null,O=`“${T?.title||`Untitled chat`}”`,[k,A]=(0,x.useState)(``),Ee=(0,x.useCallback)(()=>n(!1),[n]);ne(!0,Ee);let j=(0,x.useRef)(null);u(j,!0);let[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(!1),[De,I]=(0,x.useState)(``),[L,R]=(0,x.useState)(``),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(new Set),G=(0,x.useRef)(new Map),[,Oe]=(0,x.useState)(0);(0,x.useEffect)(()=>{i.doc.info(`Loading document library...`);let e=i.doc.time();m().then(n=>{let r=n.documents||[];t(r),i.doc.timed(`Loaded ${r.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{i.doc.error(`Failed to load documents`,e),t([])})},[t]);let K=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,x.useEffect)(()=>{if(!K)return;let e=s.getState().documents;for(let t of e)(t.indexing_status===`indexing`||t.indexing_status===`pending`)&&!G.current.has(t.id)&&G.current.set(t.id,Date.now());let n=!1,r=setInterval(async()=>{if(Oe(e=>e+1),!n){n=!0;try{let e=s.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await a(n.id);if(e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){G.current.delete(n.id);let e=await m();t(e.documents||[]);break}}catch{}}finally{n=!1}}},2e3);return()=>clearInterval(r)},[K,t]),(0,x.useEffect)(()=>{let t=new Set(e.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let e of G.current.keys())t.has(e)||G.current.delete(e)},[e]),(0,x.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await m()).documents||[],n=s.getState().documents;(e.length!==n.length||e.some((e,t)=>{let r=n.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(t(e),i.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let ke=e.reduce((e,t)=>e+t.file_size,0),q=e.reduce((e,t)=>e+t.chunk_count,0),J=(0,x.useCallback)(async(e,t)=>{if(!D){C([e]),A(`${t} will be attached to your next new chat.`),i.doc.info(`"${t}" will be attached to the next new chat`);return}await f(D,e);let n=s.getState().sessions.find(e=>e.id===D)?.document_ids??[];n.includes(e)||y(D,{document_ids:[...n,e]}),A(`Attached ${t} to ${O}.`),i.doc.info(`Attached "${t}" to session ${D}`)},[D,O,y,C]),Y=(0,x.useCallback)(async(e,t)=>{if(e.length===0)return;if(!D){C(e),i.doc.info(`"${t}" will be attached to the next new chat`);return}let n=[];for(let t of e)try{await f(D,t),n.push(t)}catch(e){i.doc.warn(`Could not attach document to session: ${e}`)}let r=s.getState().sessions.find(e=>e.id===D)?.document_ids??[],a=n.filter(e=>!r.includes(e));a.length>0&&y(D,{document_ids:[...r,...a]}),i.doc.info(`Attached "${t}" to session ${D}`)},[D,y,C]),X=(0,x.useCallback)(async(e,n,r)=>{let a=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,o=a&&!ie(a)?ee(a)?.message??`The file type "${a}" is not supported for indexing.`:null;if(o&&!r){i.doc.warn(`Unsupported file type: ${e} (${a})`),B({filename:e,error:o});return}i.doc.info(`Indexing document: ${e}`);let s=i.doc.time();F(!0),I(`Indexing ${e}...`),B(null),H(null),A(``);try{let r=await n();if(i.doc.timed(`Indexed "${e}": ${r?.chunk_count||`?`} chunks`,s),r?.id)try{await J(r.id,r.filename||e)}catch(t){i.doc.error(`Could not attach "${e}" to ${O}`,t),B({filename:e,error:`Indexed, but not attached to ${O}: ${t instanceof Error?t.message:t}`})}let a=await m();t(a.documents||[]),I(``)}catch(t){let{httpStatus:n,reason:a}=t??{};if(a===`is_folder`&&r){await r();return}i.doc.error(`Failed to index "${e}"`,t);let s=n===400&&o?o:t instanceof Error?t.message:`Upload failed`;B({filename:e,error:s,status:n,kind:a}),I(``)}finally{F(!1)}},[J,O,t]),Z=(0,x.useCallback)(async(e,n)=>{i.doc.info(`"${e}" is a folder; indexing its documents`),I(`Indexing the documents in ${n}...`);try{let r=await pe(e,!1);await Y(r.documents.map(e=>e.id).filter(Boolean),n),H(xe(n,r));let i=await m();t(i.documents||[])}catch(t){i.doc.error(`Failed to index folder "${e}"`,t);let r=t instanceof Error?t.message:`Folder indexing failed`,{httpStatus:a}=t??{};B({filename:n,error:r,status:a})}finally{I(``)}},[Y,t]),Q=(0,x.useCallback)(async(e,t)=>{await X(t,()=>he(e),()=>Z(e,t))},[X,Z]),$=(0,x.useCallback)(async e=>{await X(e.name,()=>se(e))},[X]),Ae=(0,x.useCallback)(async e=>{e.preventDefault(),N(!1);let t=Array.from(e.dataTransfer.files);i.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await $(e)},[$]),je=(0,x.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Deleting document: ${r?.filename||n}`);try{await re(n),G.current.delete(n),w(n),t(e.filter(e=>e.id!==n)),i.doc.info(`Deleted document: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to delete document: ${r?.filename||n}`,e)}},[e,t,w]),Me=(0,x.useCallback)(async(e,t)=>{i.doc.info(`Opening folder for: ${e}`);try{await fe(e,!0)}catch(e){i.doc.error(`Failed to open folder for: ${t}`,e)}},[]),Ne=(0,x.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Cancelling indexing for: ${r?.filename||n}`);try{await oe(n),G.current.delete(n);let e=await m();t(e.documents||[]),i.doc.info(`Cancelled indexing for: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to cancel indexing: ${r?.filename||n}`,e)}},[e,t]),Pe=(0,x.useCallback)(async n=>{if(U.has(n))return;let r=e.find(e=>e.id===n);i.doc.info(`Reindexing document: ${r?.filename||n}`),W(e=>new Set(e).add(n));try{await de(n),i.doc.info(`Reindex complete for: ${r?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.doc.error(`Reindex failed for: ${r?.filename||n}`,e),B({filename:r?.filename||n,error:t})}finally{try{let e=await m();t(e.documents||[])}catch(e){i.doc.error(`Failed to refresh documents after reindex`,e)}W(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,U]),Fe=(0,x.useCallback)(async t=>{let n=e.find(e=>e.id===t)?.filename||t;A(``);try{await J(t,n)}catch(e){i.doc.error(`Failed to attach ${n} to ${O}`,e),B({filename:n,error:`Not attached to ${O}: ${e instanceof Error?e.message:e}`})}},[e,J,O]),Ie=(0,x.useCallback)(async e=>{if(e.preventDefault(),!L.trim())return;let t=L.trim();i.doc.info(`Indexing from path input: ${t}`),await Q(t,t.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||`file`),R(``)},[L,Q]),Le=e=>{let t=e.indexing_status||`complete`,n=G.current.get(e.id),r=e.indexed_at?Ce(e.indexed_at):``,i=e.indexed_at?we(e.indexed_at):``;switch(t){case`indexing`:case`pending`:return(0,S.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,S.jsxs)(`div`,{className:`doc-indexing-bar`,children:[(0,S.jsx)(`div`,{className:`doc-indexing-bar-track`,children:(0,S.jsx)(`div`,{className:`doc-indexing-bar-fill`})}),(0,S.jsxs)(`span`,{className:`doc-indexing-label`,children:[(0,S.jsx)(ve,{size:12,className:`doc-spin`}),`Indexing`,n?` (${Se(n)})`:`...`]})]}),(0,S.jsxs)(`button`,{className:`btn-cancel`,onClick:t=>{t.stopPropagation(),Ne(e.id)},title:`Cancel indexing`,"aria-label":`Cancel indexing ${e.filename}`,children:[(0,S.jsx)(_,{size:14}),`Cancel`]})]});case`failed`:{let t=e.error_kind?o[e.error_kind]:void 0,n=e.last_error?be(e.last_error):null;return(0,S.jsxs)(`div`,{className:`doc-failure`,children:[(0,S.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-failed`,title:e.last_error||void 0,"aria-label":e.last_error?`Failed: ${e.last_error}`:`Indexing failed`,children:[(0,S.jsx)(p,{size:12}),` `,t?`Can't be read`:`Failed`]}),(0,S.jsxs)(`button`,{className:t?`btn-retry btn-retry-quiet`:`btn-retry`,onClick:t=>{t.stopPropagation(),Pe(e.id)},title:t?`Retry indexing (fix the file first, or this fails again)`:`Retry indexing`,"aria-label":`Retry indexing ${e.filename}`,disabled:U.has(e.id),children:[(0,S.jsx)(ye,{size:t?12:14}),U.has(e.id)?`Retrying…`:`Retry`]})]}),t&&(0,S.jsx)(`p`,{className:`doc-failure-hint`,children:t}),n&&(n.more?(0,S.jsxs)(`details`,{className:`doc-failure-reason`,children:[(0,S.jsx)(`summary`,{children:n.summary}),(0,S.jsx)(`p`,{children:n.more})]}):(0,S.jsx)(`p`,{className:`doc-failure-reason`,children:n.summary})),!n&&!t&&(0,S.jsx)(`p`,{className:`doc-failure-reason`,children:`GAIA didn't record why. Retry to see the error.`})]})}case`cancelled`:return(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[(0,S.jsx)(_,{size:12}),` Cancelled`]});case`missing`:return(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-missing`,children:[(0,S.jsx)(p,{size:12}),` File missing`]});default:return(0,S.jsxs)(`span`,{className:`doc-meta`,children:[h(e.file_size),` · `,e.chunk_count,` chunk`,e.chunk_count===1?``:`s`,r&&(0,S.jsxs)(`span`,{className:`doc-timestamp`,title:`Indexed: ${i}`,children:[(0,S.jsx)(ce,{size:10}),r]})]})}};return(0,S.jsx)(`div`,{ref:j,className:`modal-overlay`,onClick:()=>n(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`Document library`,children:(0,S.jsxs)(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`modal-header`,children:[(0,S.jsx)(`h3`,{children:`Document library`}),(0,S.jsx)(`button`,{className:`btn-icon`,onClick:()=>n(!1),"aria-label":`Close document library`,children:(0,S.jsx)(c,{size:18})})]}),(0,S.jsxs)(`div`,{className:`modal-body`,children:[(0,S.jsxs)(`div`,{className:`doc-target`,children:[g?(0,S.jsxs)(`label`,{className:`doc-target-choice`,children:[`Add documents to`,(0,S.jsxs)(`select`,{value:E,onChange:e=>{Te(e.target.value),A(``)},children:[(0,S.jsxs)(`option`,{value:`chat`,children:[`This chat: `,O]}),(0,S.jsx)(`option`,{value:`next`,children:`Your next new chat`})]})]}):(0,S.jsx)(`span`,{children:`Documents you add here are attached to your next new chat.`}),(0,S.jsx)(`span`,{className:`doc-target-hint`,children:`A chat searches only the documents attached to it.`})]}),(0,S.jsx)(`div`,{className:`drop-zone ${M?`drag-over`:``} ${P?`uploading`:``}`,onDragOver:e=>{e.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:Ae,children:P?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`upload-spinner`}),(0,S.jsx)(`p`,{children:De})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(ge,{size:32,strokeWidth:1.5}),(0,S.jsx)(`p`,{children:`Drop files here to index`}),(0,S.jsx)(`span`,{className:`drop-hint`,children:`PDF, TXT, MD, code files, and 50+ formats`})]})}),(0,S.jsxs)(`form`,{className:`path-input-form`,onSubmit:Ie,children:[(0,S.jsx)(l,{size:16,className:`path-icon`}),(0,S.jsx)(`input`,{type:`text`,className:`path-input`,value:L,onChange:e=>R(e.target.value),placeholder:`Or enter a file or folder path: ${me()}`,"aria-label":`File path to index`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn-secondary`,disabled:!L.trim()||P,children:`Index`}),(0,S.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(!1),r(!0)},title:`Browse files on this computer`,children:[(0,S.jsx)(d,{size:14}),`Browse files`]})]}),k&&(0,S.jsx)(`p`,{className:`doc-target-notice`,role:`status`,children:k}),z&&(0,S.jsx)(ae,{filename:z.filename,error:z.error,status:z.status,kind:z.kind,onDismiss:()=>B(null)}),V&&(0,S.jsxs)(`div`,{className:`doc-folder-notice`,role:`status`,children:[(0,S.jsx)(le,{size:14}),(0,S.jsx)(`span`,{children:V}),(0,S.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>H(null),"aria-label":`Dismiss folder indexing result`,children:(0,S.jsx)(c,{size:12})})]}),e.length>0&&(0,S.jsxs)(`div`,{className:`doc-stats`,children:[(0,S.jsxs)(`span`,{children:[e.length,` document`,e.length===1?``:`s`]}),(0,S.jsx)(`span`,{children:`·`}),(0,S.jsxs)(`span`,{children:[q,` chunk`,q===1?``:`s`]}),(0,S.jsx)(`span`,{children:`·`}),(0,S.jsx)(`span`,{children:h(ke)})]}),(0,S.jsxs)(`div`,{className:`doc-list`,children:[e.length===0&&!P&&(0,S.jsxs)(`div`,{className:`empty-docs`,children:[(0,S.jsx)(ue,{size:32,strokeWidth:1}),(0,S.jsx)(`p`,{children:`No documents indexed yet`}),(0,S.jsx)(`span`,{children:`Drop files above or enter a file path`})]}),e.map(e=>(0,S.jsxs)(`div`,{className:`doc-row ${e.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[(0,S.jsxs)(`div`,{className:`doc-info`,children:[(0,S.jsx)(`span`,{className:`doc-name`,children:e.filename}),Le(e)]}),(0,S.jsxs)(`div`,{className:`doc-row-actions`,children:[e.filepath&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>Me(e.filepath,e.filename),title:`Open folder: ${e.filepath}`,"aria-label":`Open containing folder for ${e.filename}`,children:(0,S.jsx)(l,{size:14})}),e.indexing_status===`complete`&&!(D?T?.document_ids?.includes(e.id):b.includes(e.id))&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>Fe(e.id),title:D?`Use in ${O}`:`Use in your next chat`,"aria-label":D?`Attach ${e.filename} to ${O}`:`Attach ${e.filename} to your next chat`,children:(0,S.jsx)(_e,{size:14})}),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>je(e.id),title:`Remove`,"aria-label":`Remove ${e.filename}`,children:(0,S.jsx)(te,{size:14})})]})]},e.id))]})]})]})})}export{C as DocumentLibrary};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{t as a}from"./message-square-CLnmengs.js";import{A as o,Bt as s,C as c,D as ee,E as te,F as ne,Ft as l,Gt as u,Ht as re,I as ie,It as ae,Kt as oe,L as d,Lt as se,M as ce,N as le,O as ue,P as de,Pt as fe,Rt as f,S as p,T as pe,Vt as m,W as me,Wt as he,Xt as ge,_ as _e,_n as h,a as ve,an as ye,b as be,c as xe,cn as Se,d as Ce,dn as we,f as Te,g as Ee,h as De,hn as Oe,j as ke,k as Ae,l as je,ln as Me,m as Ne,mn as Pe,o as Fe,on as Ie,p as Le,qt as Re,s as ze,sn as Be,t as Ve,tn as g,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./index-B73021Op.js";var qe={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};qe.node;var Je=t(qe),_={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};_.node;var Ye=t(_),Xe={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`}]]};Xe.node;var Ze=t(Xe),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 Qe=t(v),$e={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`}]]};$e.node;var et=t($e),tt={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};tt.node;var nt=t(tt),rt={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`}]]};rt.node;var it=t(rt),at={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`}]]};at.node;var ot=t(at),st={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`}]]};st.node;var ct=t(st),y=e(r(),1),b=n(),lt=[{title:`Preferences`,categories:[`preference`]},{title:`About you`,categories:[`fact`,`profile`,`skill`]},{title:`Reminders`,categories:[`reminder`]},{title:`Notes`,categories:[`note`]}];function ut(e){switch(e){case`user`:return`You added this`;case`tool`:return`You asked GAIA to remember this`;case`llm_extract`:return`Picked up in a chat`;case`consolidation`:return`From an older chat`;case`inferred`:return`From your profile setup`;case`discovery`:return`Found on this PC during profile setup`;default:return`Saved`}}function x(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Math.floor((Date.now()-t.getTime())/864e5);return n<=0?`today`:n===1?`yesterday`:n<30?`${n} days ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function dt(e,t=new Date){let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),r=n?new Date(+n[1],n[2]-1,+n[3]):new Date(e);if(Number.isNaN(r.getTime()))return null;let i=r.getHours()===0&&r.getMinutes()===0&&r.getSeconds()===0,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),o=i?r.getTime()<a:r.getTime()<t.getTime(),s=r.toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,...r.getFullYear()===t.getFullYear()?{}:{year:`numeric`},...i?{}:{hour:`numeric`,minute:`2-digit`}});return{text:`${o?`Was due`:`Due`} ${s}`,past:o}}function ft({memoryEnabled:e,reloadKey:t,onChanged:n,onOpenAdvanced:r,showToast:a}){let[o,c]=(0,y.useState)(null),[ee,te]=(0,y.useState)(null),[ne,l]=(0,y.useState)(null),[u,ie]=(0,y.useState)(``),[ae,d]=(0,y.useState)([]),[se,ce]=(0,y.useState)(new Set),[le,ue]=(0,y.useState)(``),[de,fe]=(0,y.useState)(`fact`),[f,p]=(0,y.useState)(null),pe=(0,y.useRef)(0),m=(0,y.useCallback)(async()=>{let e=++pe.current;try{let t=await be({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,limit:200});if(e!==pe.current)return;c(t.items),te(null)}catch(t){if(e!==pe.current)return;i.system.warn(`Failed to load what GAIA knows about the user`,t),te(t instanceof Error?t.message:String(t))}},[]);(0,y.useEffect)(()=>{m()},[m,t]);let me=(0,y.useCallback)(async e=>{let t=u.trim();if(!t||t===e.content)l(null);else{p(e.id);try{await De(e.id,{content:t}),l(null),a(`Updated`,`success`),await m(),n()}catch(e){i.system.error(`Failed to edit memory`,e),a(`Couldn't save the change: ${e instanceof Error?e.message:e}`,`error`)}finally{p(null)}}},[u,m,n,a]),he=(0,y.useCallback)(async e=>{p(e.id);try{await Ne(e.id),pe.current++,c(t=>(t??[]).filter(t=>t.id!==e.id)),d(t=>[e,...t]),n()}catch(e){i.system.error(`Failed to forget memory`,e),a(`Couldn't forget that: ${e instanceof Error?e.message:e}`,`error`)}finally{p(null)}},[n,a]),ge=(0,y.useCallback)(async e=>{p(e.id);try{await Te({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}),d(t=>t.filter(t=>t.id!==e.id)),await m(),n()}catch(e){i.system.error(`Failed to restore memory`,e),a(`Couldn't restore it: ${e instanceof Error?e.message:e}`,`error`)}finally{p(null)}},[m,n,a]),_e=(0,y.useCallback)(async()=>{let e=le.trim();if(e){p(`new`);try{await Te({content:e,category:de}),ue(``),a(`Saved`,`success`),await m(),n()}catch(e){i.system.error(`Failed to add memory`,e),a(`Couldn't save it: ${e instanceof Error?e.message:e}`,`error`)}finally{p(null)}}},[le,de,m,n,a]);if(!e)return(0,b.jsxs)(`div`,{className:`mem-about`,children:[(0,b.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,b.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,b.jsx)(`p`,{children:`Memory is off, so GAIA isn't saving anything about you.`}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:r,children:`Turn it on in Advanced`})]})]});let h=lt.map(e=>({...e,rows:(o??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return(0,b.jsxs)(`div`,{className:`mem-about`,children:[(0,b.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,b.jsx)(`p`,{className:`mem-about-intro`,children:`GAIA uses these in every chat. Edit anything that's wrong, or forget it so GAIA stops using it.`}),(0,b.jsxs)(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),_e()},children:[(0,b.jsx)(`input`,{className:`mem-input`,placeholder:`Tell GAIA something about you, e.g. “I prefer short answers”`,"aria-label":`Something GAIA should know about you`,value:le,onChange:e=>ue(e.target.value)}),(0,b.jsxs)(`select`,{className:`mem-select`,"aria-label":`Kind`,value:de,onChange:e=>fe(e.target.value),children:[(0,b.jsx)(`option`,{value:`fact`,children:`About you`}),(0,b.jsx)(`option`,{value:`preference`,children:`Preference`}),(0,b.jsx)(`option`,{value:`reminder`,children:`Reminder`}),(0,b.jsx)(`option`,{value:`note`,children:`Note`})]}),(0,b.jsxs)(`button`,{className:`btn-primary`,type:`submit`,disabled:!le.trim()||f===`new`,children:[(0,b.jsx)(oe,{size:14}),` Add`]})]}),ae.map(e=>(0,b.jsxs)(`div`,{className:`mem-about-forgotten`,role:`status`,children:[(0,b.jsxs)(`span`,{children:[`Forgotten: `,e.sensitive?`a sensitive memory`:`“${e.content}”`,` — GAIA won't learn it again from old chats.`]}),(0,b.jsxs)(`button`,{className:`mem-about-link`,disabled:f===e.id,onClick:()=>ge(e),children:[(0,b.jsx)(s,{size:12}),` Undo`]})]},e.id)),ee?(0,b.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,b.jsxs)(`p`,{children:[`Couldn't load your memories: `,ee]}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:m,children:`Try again`})]}):o===null?(0,b.jsxs)(`div`,{className:`mem-loading`,children:[(0,b.jsx)(`div`,{className:`mem-spinner`}),` Loading…`]}):h.length===0?(0,b.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,b.jsx)(`p`,{children:`GAIA hasn't saved anything about you yet.`}),(0,b.jsx)(`p`,{className:`mem-about-hint`,children:`Tell it in a chat (“remember that I live in Calgary”) or add something above.`})]}):h.map(e=>(0,b.jsxs)(`section`,{className:`mem-about-group`,"aria-label":e.title,children:[(0,b.jsx)(`h3`,{className:`mem-about-group-title`,children:e.title}),(0,b.jsx)(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let t=e.sensitive&&!se.has(e.id),n=e.due_at?dt(e.due_at):null;return(0,b.jsx)(`li`,{className:`mem-about-item`,children:ne===e.id?(0,b.jsxs)(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),me(e)},children:[(0,b.jsx)(`textarea`,{className:`mem-input`,"aria-label":`Edit memory`,rows:2,autoFocus:!0,value:u,onChange:e=>ie(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),l(null)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),me(e))}}),(0,b.jsxs)(`div`,{className:`mem-about-edit-actions`,children:[(0,b.jsx)(`button`,{className:`btn-primary`,type:`submit`,disabled:f===e.id,children:`Save`}),(0,b.jsx)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>l(null),children:`Cancel`})]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mem-about-text`,children:[t?(0,b.jsxs)(`button`,{className:`mem-about-link`,onClick:()=>ce(t=>new Set(t).add(e.id)),children:[(0,b.jsx)(g,{size:12}),` Sensitive — show`]}):e.content,n&&(0,b.jsx)(`span`,{className:`mem-about-due${n.past?` is-overdue`:``}`,children:n.text}),(0,b.jsxs)(`span`,{className:`mem-about-meta`,children:[ut(e.source),` · `,x(e.updated_at)]})]}),(0,b.jsxs)(`div`,{className:`mem-about-actions`,children:[(0,b.jsx)(`button`,{className:`mem-about-btn`,"aria-label":`Edit: ${t?`sensitive memory`:e.content}`,title:`Edit`,onClick:()=>{l(e.id),ie(e.content)},children:(0,b.jsx)(Re,{size:14})}),(0,b.jsxs)(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":`Forget: ${t?`sensitive memory`:e.content}`,title:`Forget`,disabled:f===e.id,onClick:()=>he(e),children:[(0,b.jsx)(re,{size:14}),` Forget`]})]})]})},e.id)})})]},e.title))]})}function pt(e){if(!e)return`—`;try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n={month:`short`,day:`numeric`};return t.getFullYear()!==new Date().getFullYear()&&(n.year=`numeric`),t.toLocaleDateString(void 0,n)}catch{return`—`}}function S(e){if(!e)return``;try{let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function C(e){if(!e)return`—`;try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=Date.now(),r=t.getTime()-n,i=Math.abs(r),a=Math.floor(i/1e3),o=Math.floor(i/6e4),s=Math.floor(i/36e5),c=Math.floor(i/864e5);return r<0?a<5?`just now`:a<60?`${a}s ago`:s===0?`${o}m ago`:c===0?`${s}h ago`:c===1?`yesterday`:c<30?`${c}d ago`:S(e):a<5?`now`:a<60?`in ${a}s`:s===0?`in ${o}m`:c===0?`in ${s}h`:c===1?`tomorrow`:c<30?`in ${c}d`:S(e)}catch{return`—`}}function mt(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function ht(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function gt(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function _t(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function vt(e,t){let n=pt(e),r=pt(t);return n===`—`&&r===`—`?``:n===r?n:`${n} \u2013 ${r}`}function yt(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 bt=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],xt={work:`blue`,technical:`purple`,personal:`green`,general:`gray`};function St(){let{setShowMemoryDashboard:e,sessions:t,setCurrentSession:n}=l(),r=(0,y.useMemo)(()=>new Map(t.map(e=>[e.id,e.title])),[t]),s=e=>r.get(e)||`${e.slice(0,8)}...`,[g,qe]=(0,y.useState)(null),[_,Xe]=(0,y.useState)([]),[v,$e]=(0,y.useState)(null),[tt,rt]=(0,y.useState)([]),[at,st]=(0,y.useState)([]),[lt,ut]=(0,y.useState)([]),[x,dt]=(0,y.useState)(null),[pt,St]=(0,y.useState)([]),[Ct,wt]=(0,y.useState)(!0),[Tt,Et]=(0,y.useState)(null),[Dt,Ot]=(0,y.useState)(null),[kt,w]=(0,y.useState)(!1),[At,jt]=(0,y.useState)(null),[Mt,Nt]=(0,y.useState)([]),Pt=(0,y.useRef)(0),[T,Ft]=(0,y.useState)([]),[It,Lt]=(0,y.useState)(``),[Rt,zt]=(0,y.useState)(``),[Bt,Vt]=(0,y.useState)(``),[E,Ht]=(0,y.useState)(`updated_at`),[Ut,Wt]=(0,y.useState)(`desc`),[D,O]=(0,y.useState)(0),[Gt,Kt]=(0,y.useState)(!1),[qt,Jt]=(0,y.useState)(``),[Yt,Xt]=(0,y.useState)(null),Zt=(0,y.useRef)(null),[k,Qt]=(0,y.useState)(null),[$t,en]=(0,y.useState)(!1),[A,tn]=(0,y.useState)(null),[j,M]=(0,y.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[nn,rn]=(0,y.useState)(new Set),[N,an]=(0,y.useState)(!1),[on,sn]=(0,y.useState)(!1),[cn,ln]=(0,y.useState)(!1),[P,F]=(0,y.useState)(!1),[un,dn]=(0,y.useState)(!1),[I,fn]=(0,y.useState)(null),[pn,mn]=(0,y.useState)(!1),[L,R]=(0,y.useState)(null),[z,hn]=(0,y.useState)(`about`),[gn,_n]=(0,y.useState)(0),[vn,yn]=(0,y.useState)([]),[bn,xn]=(0,y.useState)(null),[Sn,Cn]=(0,y.useState)(!1),[wn,Tn]=(0,y.useState)(null),[En,Dn]=(0,y.useState)(null),[On,kn]=(0,y.useState)(!1),[An,jn]=(0,y.useState)({title:``,description:``,priority:`medium`}),[B,V]=(0,y.useState)(`idle`),[Mn,H]=(0,y.useState)([]),[U,W]=(0,y.useState)([]),[Nn,Pn]=(0,y.useState)(null),Fn=(0,y.useRef)(null),In=(0,y.useRef)(null),[G,K]=(0,y.useState)(`idle`),[Ln,q]=(0,y.useState)([]),[J,Y]=(0,y.useState)([]),[Rn,zn]=(0,y.useState)(null),[Bn,Vn]=(0,y.useState)(!1),Hn=(0,y.useRef)(null),Un=(0,y.useRef)(null),[Wn,Gn]=(0,y.useState)(30),[Kn,qn]=(0,y.useState)(!1),[Jn,Yn]=(0,y.useState)(!1),[Xn,Zn]=(0,y.useState)(!1),[Qn,$n]=(0,y.useState)(!1),[er,tr]=(0,y.useState)(!1),[nr,rr]=(0,y.useState)(!1),ir=(0,y.useRef)(null),ar=(0,y.useRef)(null),or=(0,y.useRef)(null),X=(0,y.useCallback)((e,t=`info`)=>{let n=++Pt.current;Nt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Nt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,y.useEffect)(()=>{if(!kt)return;let e=e=>{ar.current&&!ar.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[kt]),fe(!0,()=>{L?R(null):un?dn(!1):pn?mn(!1):k?Qt(null):kt?w(!1):$t||A?(en(!1),tn(null)):At?jt(null):e(!1)}),me(or,!!L),(0,y.useEffect)(()=>{if(!L)return;let e=or.current;if(!e)return;let t=document.activeElement;return e.focus(),()=>{t?.focus()}},[L]);let sr=(0,y.useCallback)(async()=>{try{let e=await We();qe(e)}catch(e){i.system.warn(`Failed to load memory stats`,e)}},[]),cr=(0,y.useCallback)(async()=>{try{let e=await Ge(Wn);Xe(e)}catch(e){i.system.warn(`Failed to load memory activity`,e)}},[Wn]),Z=(0,y.useCallback)(async()=>{try{let e=await be({category:T.length>0?T:void 0,context:It||void 0,entity:Rt||void 0,search:Bt||void 0,sort_by:E,order:Ut,offset:D,limit:15,include_sensitive:!0,include_superseded:Gt});$e(e)}catch(e){i.system.warn(`Failed to load knowledge`,e)}},[T,It,Rt,Bt,E,Ut,D,Gt]),lr=(0,y.useCallback)(async()=>{try{let e=await pe();rt(e)}catch(e){i.system.warn(`Failed to load tool summary`,e)}},[]),ur=(0,y.useCallback)(async()=>{try{let e=await p(20);st(e)}catch(e){i.system.warn(`Failed to load conversations`,e)}},[]),dr=(0,y.useCallback)(async()=>{try{let e=await te(7);ut(e)}catch(e){i.system.warn(`Failed to load upcoming items`,e)}},[]),fr=(0,y.useCallback)(async()=>{try{let e=await _e();dt(e)}catch(e){i.system.warn(`Failed to load embedding coverage`,e)}},[]),pr=(0,y.useCallback)(async()=>{try{let e=await Ue();St(e||[])}catch(e){i.system.warn(`Failed to load entities`,e)}},[]),mr=(0,y.useCallback)(async()=>{try{let e=await c();sn(e.mcp_memory_enabled),an(e.memory_enabled),ln(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to load memory settings`,e)}},[]),hr=(0,y.useCallback)(async()=>{Cn(!0);try{let[e,t]=await Promise.all([ee(),Ke()]);yn(e.goals),xn(t)}catch(e){i.system.warn(`Failed to load goals`,e)}finally{Cn(!1)}},[]),gr=(0,y.useCallback)(async(e,t)=>{try{await e()}catch(e){i.system.error(t,e),X(`${t}: ${e instanceof Error?e.message:e}`,`error`);return}hr()},[hr,X]);(0,y.useEffect)(()=>{if(!En)return;let e=setTimeout(()=>Dn(null),3e3);return()=>clearTimeout(e)},[En]);let Q=(0,y.useCallback)(async()=>{wt(!0),Et(null);try{await Promise.all([sr(),cr(),Z(),lr(),ur(),dr(),fr(),pr(),mr(),hr()]),_n(e=>e+1)}catch(e){Et(`Failed to load memory data. Is the backend running?`),i.system.error(`Memory dashboard load failed`,e)}finally{wt(!1)}},[sr,cr,Z,lr,ur,dr,fr,pr,mr,hr]);(0,y.useEffect)(()=>{Q()},[Q]),(0,y.useEffect)(()=>{Z()},[Z]);let _r=(0,y.useRef)(!0);(0,y.useEffect)(()=>{_r.current?_r.current=!1:cr()},[cr]);let vr=(0,y.useCallback)(e=>{Vt(e),rr(!0),ir.current&&clearTimeout(ir.current),ir.current=setTimeout(()=>{O(0),rr(!1)},300)},[]),yr=(0,y.useCallback)(()=>{Z(),sr(),fr(),dr(),pr()},[Z,sr,fr,dr,pr]),$=(0,y.useCallback)(()=>{yr(),_n(e=>e+1)},[yr]),br=(0,y.useCallback)(async()=>{if(j.content.trim())try{let e=await Te({content:j.content,category:j.category,domain:j.domain||void 0,context:j.context,entity:j.entity||void 0,sensitive:j.sensitive,due_at:j.due_at||void 0});en(!1),M({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Created new knowledge entry`),e?.embedded===!1?X(e.embed_error??`Saved, but not embedded`,`error`):X(`Memory created successfully`,`success`)}catch(e){i.system.error(`Failed to create knowledge`,e),X(`Failed to create memory`,`error`)}},[j,$,X]),xr=(0,y.useCallback)(async()=>{if(A&&j.content.trim())try{let e=await De(A,{content:j.content,category:j.category,domain:j.domain||void 0,context:j.context,entity:j.entity||void 0,sensitive:j.sensitive,due_at:j.due_at||void 0});tn(null),M({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Updated knowledge ${A}`),e?.embedded===!1?X(e.embed_error??`Saved, but not embedded`,`error`):X(`Memory updated`,`success`)}catch(e){i.system.error(`Failed to update knowledge`,e),X(`Failed to update memory`,`error`)}},[A,j,$,X]),Sr=(0,y.useCallback)(async e=>{if(I!==e)fn(e);else{fn(null);try{await Ne(e),$(),i.ui.info(`Deleted knowledge ${e}`),X(`Memory deleted`,`info`)}catch(e){i.system.error(`Failed to delete knowledge`,e),X(`Failed to delete memory`,`error`)}}},[I,$,X]);(0,y.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>fn(null),3e3);return()=>clearTimeout(e)},[I]);let Cr=(0,y.useCallback)(async e=>{try{await De(e.id,{sensitive:!e.sensitive}),Z(),i.ui.info(`Toggled sensitive for ${e.id}: ${!e.sensitive}`),X(e.sensitive?`Unmarked as sensitive`:`Marked as sensitive`,`info`)}catch(e){i.system.error(`Failed to toggle sensitive`,e),X(`Failed to toggle sensitive flag`,`error`)}},[Z,X]),wr=(0,y.useCallback)(e=>{tn(e.id),en(!1),M({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),Tr=(0,y.useCallback)(e=>{navigator.clipboard.writeText(e).catch(()=>{}),i.ui.info(`Copied knowledge ID: ${e}`),X(`ID copied to clipboard`,`info`)},[X]),Er=(0,y.useCallback)(e=>{Jt(e),Zt.current&&clearTimeout(Zt.current),e.trim()?Zt.current=setTimeout(async()=>{try{let t=await ie(e.trim(),20);Xt(t)}catch(e){i.system.warn(`Conversation search failed`,e)}},300):Xt(null)},[]),Dr=(0,y.useCallback)(async e=>{try{let t=await Ee(e);Qt({sessionId:e,turns:t})}catch(e){i.system.error(`Failed to load conversation detail`,e)}},[]),Or=(0,y.useCallback)(e=>{Ft(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),O(0)},[]),kr=(0,y.useCallback)(e=>{E===e?Wt(e=>e===`desc`?`asc`:`desc`):(Ht(e),Wt(`desc`)),O(0)},[E]),Ar=(0,y.useCallback)(async()=>{qn(!0),w(!1);try{let e=await He();await Q(),X(`Consolidated ${e.consolidated??0} sessions, extracted ${e.extracted_items??0} items`,`success`)}catch(e){i.system.error(`Failed to consolidate sessions`,e),X(`Failed to consolidate sessions`,`error`)}finally{qn(!1)}},[Q,X]),jr=(0,y.useCallback)(async()=>{Yn(!0),w(!1);try{let e=await o();await fr(),X(`Backfilled ${e.backfilled??0} embeddings${e.total_without?` (${e.total_without} were missing)`:``}`,`success`)}catch(e){i.system.error(`Failed to rebuild embeddings`,e),X(`Failed to rebuild embeddings`,`error`)}finally{Yn(!1)}},[fr,X]),Mr=(0,y.useCallback)(async()=>{Zn(!0),w(!1);try{let e=await ce();await Q(),X(`Checked ${e.pairs_checked??0} pairs: ${e.reinforced??0} reinforced, ${e.contradicted??0} contradicted`,`success`)}catch(e){i.system.error(`Failed to reconcile memory`,e),X(`Failed to reconcile memory`,`error`)}finally{Zn(!1)}},[Q,X]),Nr=(0,y.useCallback)(async()=>{$n(!0),w(!1);try{await ke(),await Q(),X(`FTS indexes rebuilt successfully`,`success`)}catch(e){i.system.error(`Failed to rebuild FTS index`,e),X(`Failed to rebuild FTS indexes`,`error`)}finally{$n(!1)}},[Q,X]),Pr=(0,y.useCallback)(async()=>{tr(!0),w(!1);try{let e=await le();await Q(),e.skipped?X(`System context collection is disabled — enable it in settings`,`error`):X(`System context refreshed: ${e.stored} facts updated`,`success`)}catch(e){i.system.error(`Failed to refresh system context`,e),X(`Failed to refresh system context`,`error`)}finally{tr(!1)}},[Q,X]),Fr=Kn||Jn||Xn||Qn||er,Ir=(0,y.useCallback)(()=>{V(`running`),H([]),W([]),Pn(null);let e=ue();In.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)H(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`finding`){let e=n.item;H(t=>[...t,{text:` Found: ${e.content}`,kind:`finding`}]),W(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?H(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),In.current=null,H(e=>[...e,{text:`Done. ${n.total??0} items discovered.`,kind:`log`}]),V(`review`))}catch{H(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),In.current=null,H(e=>[...e,{text:`Connection error. Is the GAIA server running?`,kind:`error`}]),W(e=>(V(e.length>0?`review`:`idle`),e))}},[]),Lr=(0,y.useCallback)(async()=>{let e=U.filter(e=>e._checked);if(e.length!==0){V(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await xe(t);Pn(n.stored),V(`done`),$(),X(`Saved ${n.stored} items to memory`,`success`)}catch(e){i.system.error(`Failed to commit discovery items`,e),X(`Failed to save discovery items`,`error`),V(`review`)}}},[U,$,X]),Rr=(0,y.useCallback)(()=>{K(`running`),q([]),Y([]),zn(null);let e=Ae(Bn);Un.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)q(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`insight`){let e=n.item;q(t=>[...t,{text:` Insight: ${e.content}`,kind:`finding`}]),Y(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?q(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),Un.current=null,q(e=>[...e,{text:`Done. ${n.total??0} insights generated.`,kind:`log`}]),K(`review`))}catch{q(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),Un.current=null,q(e=>[...e,{text:`Connection error. Is Lemonade Server running?`,kind:`error`}]),Y(e=>(K(e.length>0?`review`:`idle`),e))}},[Bn]),zr=(0,y.useCallback)(async()=>{let e=J.filter(e=>e._checked);if(e.length!==0){K(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await je(t);zn(n.stored),K(`done`),$(),X(`Saved ${n.stored} insights to memory`,`success`)}catch(e){i.system.error(`Failed to commit inference insights`,e),X(`Failed to save inference insights`,`error`),K(`review`)}}},[J,$,X]);(0,y.useEffect)(()=>{Fn.current&&(Fn.current.scrollTop=Fn.current.scrollHeight)},[Mn]),(0,y.useEffect)(()=>{Hn.current&&(Hn.current.scrollTop=Hn.current.scrollHeight)},[Ln]),(0,y.useEffect)(()=>()=>{In.current&&=(In.current.close(),null),Un.current&&=(Un.current.close(),null)},[]);let Br=e=>E===e?(0,b.jsx)(`span`,{className:`mem-sort-arrow`,children:Ut===`desc`?`↓`:`↑`}):null,Vr=Math.max(1,..._.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),Hr=g?.knowledge?.by_context?Object.keys(g.knowledge.by_context):[];return(0,b.jsxs)(`div`,{className:`memory-dashboard-page`,children:[(0,b.jsxs)(`div`,{className:`memory-dashboard-header`,children:[(0,b.jsxs)(`div`,{className:`memory-dashboard-header-left`,children:[(0,b.jsx)(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>e(!1),"aria-label":`Back`,children:(0,b.jsx)(Je,{size:18})}),(0,b.jsxs)(`h1`,{children:[`Memory `,(0,b.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`2px 8px`,borderRadius:4,marginLeft:8,verticalAlign:`middle`,letterSpacing:`0.5px`},children:`BETA`})]})]}),(0,b.jsxs)(`div`,{className:`memory-dashboard-header-actions`,children:[z===`advanced`&&(0,b.jsxs)(b.Fragment,{children:[x&&x.total_items>0&&(0,b.jsxs)(`div`,{className:`mem-embedding-coverage`,title:`${x.with_embedding} of ${x.total_items} entries embedded`,children:[(0,b.jsx)(`div`,{className:`mem-embedding-bar`,children:(0,b.jsx)(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(x.coverage_pct)}%`}})}),(0,b.jsxs)(`span`,{className:`mem-embedding-label`,children:[Math.round(x.coverage_pct),`% embedded`]})]}),(0,b.jsxs)(`div`,{className:`mem-maintenance-wrap`,ref:ar,children:[(0,b.jsxs)(`button`,{className:`btn-icon ${Fr?`mem-spinning`:``}`,onClick:()=>w(e=>!e),title:`Maintenance actions`,"aria-label":`Maintenance actions`,"aria-expanded":kt,children:[Fr?(0,b.jsx)(`div`,{className:`mem-spinner-sm`}):(0,b.jsx)(ye,{size:16}),(0,b.jsx)(Oe,{size:10,style:{marginLeft:2}})]}),kt&&(0,b.jsxs)(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[(0,b.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Ar,disabled:Kn,role:`menuitem`,children:[(0,b.jsx)(Ze,{size:14}),Kn?`Consolidating...`:`Consolidate Sessions`]}),(0,b.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:jr,disabled:Jn,role:`menuitem`,children:[(0,b.jsx)(ae,{size:14}),Jn?`Rebuilding...`:`Rebuild Embeddings`]}),(0,b.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Mr,disabled:Xn,role:`menuitem`,children:[(0,b.jsx)(we,{size:14}),Xn?`Reconciling...`:`Reconcile Memory`]}),(0,b.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,b.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Pr,disabled:er,role:`menuitem`,children:[(0,b.jsx)(u,{size:14}),er?`Refreshing...`:`Refresh System Context`]}),(0,b.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,b.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Nr,disabled:Qn,role:`menuitem`,children:[(0,b.jsx)(he,{size:14}),Qn?`Rebuilding...`:`Rebuild FTS Indexes`]})]})]})]}),(0,b.jsx)(`button`,{className:`btn-icon`,onClick:Q,title:`Refresh`,"aria-label":`Refresh dashboard`,children:(0,b.jsx)(u,{size:16})})]})]}),(0,b.jsxs)(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[(0,b.jsxs)(`button`,{className:`mem-tab-btn${z===`about`?` mem-tab-active`:``}`,onClick:()=>hn(`about`),role:`tab`,"aria-selected":z===`about`,children:[(0,b.jsx)(ct,{size:14}),` About you`]}),(0,b.jsxs)(`button`,{className:`mem-tab-btn${z===`goals`?` mem-tab-active`:``}`,onClick:()=>{hn(`goals`),hr()},role:`tab`,"aria-selected":z===`goals`,children:[(0,b.jsx)(it,{size:14}),` Goals`,bn&&(bn.goals.pending_approval??0)>0&&(0,b.jsx)(`span`,{className:`mem-tab-badge`,children:bn.goals.pending_approval})]}),(0,b.jsxs)(`button`,{className:`mem-tab-btn${z===`profile`?` mem-tab-active`:``}`,onClick:()=>hn(`profile`),role:`tab`,"aria-selected":z===`profile`,children:[(0,b.jsx)(nt,{size:14}),` Profile setup`]}),(0,b.jsxs)(`button`,{className:`mem-tab-btn${z===`advanced`?` mem-tab-active`:``}`,onClick:()=>hn(`advanced`),role:`tab`,"aria-selected":z===`advanced`,children:[(0,b.jsx)(h,{size:14}),` Advanced`]})]}),(0,b.jsxs)(`div`,{className:`memory-dashboard-body`,children:[z===`about`&&(0,b.jsx)(ft,{memoryEnabled:N,reloadKey:gn,onChanged:yr,onOpenAdvanced:()=>hn(`advanced`),showToast:X}),z===`advanced`&&(0,b.jsx)(b.Fragment,{children:Ct&&!g?(0,b.jsxs)(`div`,{className:`mem-loading`,children:[(0,b.jsx)(`div`,{className:`mem-spinner`}),`Loading memory data...`]}):Tt?(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(m,{size:32})}),(0,b.jsx)(`p`,{children:Tt}),(0,b.jsxs)(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[(0,b.jsx)(u,{size:14}),` Retry`]})]}):(0,b.jsxs)(b.Fragment,{children:[!N&&(0,b.jsxs)(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:(0,b.jsx)(et,{size:32})}),(0,b.jsx)(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:`Memory is off. Turn it on in Settings below to let GAIA remember what you tell it.`})]}),N&&(0,b.jsxs)(b.Fragment,{children:[g?.embedding_error&&(0,b.jsxs)(`div`,{className:`mem-advanced-error`,role:`alert`,children:[(0,b.jsx)(m,{size:14}),` `,g.embedding_error]}),(0,b.jsxs)(`div`,{className:`mem-stat-cards`,children:[(0,b.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[(0,b.jsx)(`div`,{className:`mem-stat-value`,children:g?.knowledge?.total??0}),(0,b.jsx)(`div`,{className:`mem-stat-label`,children:`Stored`}),(0,b.jsx)(`div`,{className:`mem-stat-sub`,children:(()=>{let e=yt(_);return e>0?`+${e} today`:g?.knowledge?.by_category?Object.entries(g.knowledge.by_category).slice(0,3).map(([e,t])=>`${t} ${e}${t===1?``:`s`}`).join(`, `):`No entries`})()})]}),(0,b.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[(0,b.jsx)(`div`,{className:`mem-stat-value`,children:g?.knowledge?.total_retrievals??0}),(0,b.jsx)(`div`,{className:`mem-stat-label`,children:`Retrieved`}),(0,b.jsx)(`div`,{className:`mem-stat-sub`,children:g?.knowledge?.total&&g?.knowledge?.total_retrievals?`avg ${(g.knowledge.total_retrievals/g.knowledge.total).toFixed(1)}x per memory`:`No recalls yet`})]}),(0,b.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[(0,b.jsx)(`div`,{className:`mem-stat-value`,children:g?.conversations?.total_sessions??0}),(0,b.jsx)(`div`,{className:`mem-stat-label`,children:`Sessions`}),(0,b.jsx)(`div`,{className:`mem-stat-sub`,children:vt(g?.conversations?.first_session??null,g?.conversations?.last_session??null)||`${g?.conversations?.total_turns??0} total turns`})]}),(0,b.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[(0,b.jsx)(`div`,{className:`mem-stat-value`,children:g?.tools?.total_calls??0}),(0,b.jsx)(`div`,{className:`mem-stat-label`,children:`Tool Calls`}),(0,b.jsxs)(`div`,{className:`mem-stat-sub`,title:`Memory tools (remember, recall, ...) are not logged`,children:[g?.tools?.unique_tools??0,` tools, excl. memory`]})]}),(0,b.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[(0,b.jsx)(`div`,{className:`mem-stat-value`,children:g?.tools?.overall_success_rate!=null&&(g.tools.total_calls??0)>0?`${Math.round(g.tools.overall_success_rate*100)}%`:`—`}),(0,b.jsx)(`div`,{className:`mem-stat-label`,children:`Success Rate`}),(0,b.jsx)(`div`,{className:`mem-stat-sub`,children:(g?.tools?.total_calls??0)>0?`${g?.tools?.total_errors??0} errors`:`No tool calls yet`})]})]}),(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,b.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,b.jsx)(ot,{size:14}),` Activity`]}),(0,b.jsx)(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":`Activity range`,children:[1,7,30].map(e=>(0,b.jsx)(`button`,{className:`mem-range-tab${Wn===e?` active`:``}`,onClick:()=>Gn(e),children:e===1?`1D`:e===7?`7D`:`30D`},e))})]}),_.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mem-activity-chart`,children:_.map((e,t)=>{let n=e.conversations+e.tool_calls+e.knowledge_added+e.errors,r=t===0||t===_.length-1||t%7==0,i=new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,b.jsxs)(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>Ot(t),onMouseLeave:()=>Ot(null),children:[e.errors>0&&(0,b.jsx)(`div`,{className:`mem-activity-bar errors`,style:{height:`${e.errors/Vr*100}%`}}),e.knowledge_added>0&&(0,b.jsx)(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${e.knowledge_added/Vr*100}%`}}),e.tool_calls>0&&(0,b.jsx)(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${e.tool_calls/Vr*100}%`}}),e.conversations>0&&(0,b.jsx)(`div`,{className:`mem-activity-bar conversations`,style:{height:`${e.conversations/Vr*100}%`}}),r&&(0,b.jsx)(`span`,{className:`mem-activity-date-label`,children:i}),Dt===t&&n>0&&(0,b.jsxs)(`div`,{className:`mem-activity-tooltip`,children:[(0,b.jsx)(`strong`,{children:i}),(0,b.jsx)(`br`,{}),e.conversations>0&&(0,b.jsxs)(b.Fragment,{children:[e.conversations,` conversations`,(0,b.jsx)(`br`,{})]}),e.tool_calls>0&&(0,b.jsxs)(b.Fragment,{children:[e.tool_calls,` tool calls`,(0,b.jsx)(`br`,{})]}),e.knowledge_added>0&&(0,b.jsxs)(b.Fragment,{children:[e.knowledge_added,` learned`,(0,b.jsx)(`br`,{})]}),e.errors>0&&(0,b.jsxs)(b.Fragment,{children:[e.errors,` errors`]})]})]},e.date)})}),(0,b.jsxs)(`div`,{className:`mem-activity-legend`,children:[(0,b.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,b.jsx)(`span`,{className:`mem-activity-legend-dot conversations`}),` Conversations`]}),(0,b.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,b.jsx)(`span`,{className:`mem-activity-legend-dot tool_calls`}),` Tool Calls`]}),(0,b.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,b.jsx)(`span`,{className:`mem-activity-legend-dot knowledge`}),` Knowledge`]}),(0,b.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,b.jsx)(`span`,{className:`mem-activity-legend-dot errors`}),` Errors`]})]})]}):(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(ot,{size:28})}),(0,b.jsx)(`p`,{children:`No activity data yet`})]})]}),(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,b.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,b.jsx)(h,{size:14}),` Knowledge Browser`,v&&v.total>0&&(0,b.jsx)(`span`,{className:`mem-section-count`,children:v.total})]}),!$t&&!A&&(0,b.jsxs)(`button`,{className:`mem-section-add-btn`,onClick:()=>en(!0),title:`Add a memory entry`,children:[(0,b.jsx)(oe,{size:13}),` Add`]})]}),(0,b.jsxs)(`div`,{className:`mem-filters`,children:[(0,b.jsxs)(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":`Filter by category`,children:[bt.map(e=>(0,b.jsx)(`button`,{className:`mem-category-pill ${e}${T.includes(e)?` active`:``}`,onClick:()=>Or(e),"aria-pressed":T.includes(e),children:e},e)),T.length>0&&(0,b.jsx)(`button`,{className:`mem-category-pill clear`,onClick:()=>{Ft([]),O(0)},"aria-label":`Clear category filters`,children:`✕ Clear`})]}),(0,b.jsxs)(`select`,{className:`mem-filter-select`,value:It,onChange:e=>{Lt(e.target.value),O(0)},"aria-label":`Filter by context`,children:[(0,b.jsx)(`option`,{value:``,children:`All Contexts`}),Hr.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),(0,b.jsxs)(`select`,{className:`mem-filter-select`,value:Rt,onChange:e=>{zt(e.target.value),O(0)},"aria-label":`Filter by entity`,children:[(0,b.jsx)(`option`,{value:``,children:`All Entities`}),pt.map(e=>(0,b.jsxs)(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),(0,b.jsxs)(`div`,{className:`mem-filter-search-wrap`,children:[nr?(0,b.jsx)(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):(0,b.jsx)(he,{size:13,className:`search-icon`}),(0,b.jsx)(`input`,{className:`mem-filter-search`,type:`text`,placeholder:`Search memories...`,value:Bt,onChange:e=>vr(e.target.value),"aria-label":`Search memories`})]}),(0,b.jsxs)(`label`,{className:`mem-filter-toggle`,title:`Show entries that have been superseded by newer versions`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:Gt,onChange:e=>Kt(e.target.checked)}),(0,b.jsx)(`span`,{children:`Superseded`})]})]}),($t||A)&&(0,b.jsxs)(`div`,{className:`mem-inline-form`,children:[(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Content`}),(0,b.jsx)(`textarea`,{value:j.content,onChange:e=>M(t=>({...t,content:e.target.value})),placeholder:`What should the agent remember?`})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Category`}),(0,b.jsx)(`select`,{value:j.category,onChange:e=>M(t=>({...t,category:e.target.value})),children:bt.map(e=>(0,b.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Context`}),(0,b.jsx)(`input`,{type:`text`,value:j.context,onChange:e=>M(t=>({...t,context:e.target.value})),placeholder:`global`})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Domain`}),(0,b.jsx)(`input`,{type:`text`,value:j.domain,onChange:e=>M(t=>({...t,domain:e.target.value})),placeholder:`e.g., python, frontend`})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Entity`}),(0,b.jsx)(`input`,{type:`text`,value:j.entity,onChange:e=>M(t=>({...t,entity:e.target.value})),placeholder:`e.g., person:sarah_chen`})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Due At`}),(0,b.jsx)(`input`,{type:`text`,value:j.due_at,onChange:e=>M(t=>({...t,due_at:e.target.value})),placeholder:`ISO 8601 (e.g., 2026-03-25T09:00:00-07:00)`})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,b.jsx)(`label`,{children:`Sensitive`}),(0,b.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:j.sensitive,onChange:e=>M(t=>({...t,sensitive:e.target.checked}))}),`Mark as sensitive (excluded from system prompt)`]})]}),(0,b.jsxs)(`div`,{className:`mem-inline-form-actions`,children:[(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{en(!1),tn(null)},children:`Cancel`}),(0,b.jsx)(`button`,{className:`btn-primary`,onClick:A?xr:br,style:{padding:`8px 20px`,fontSize:13},children:A?`Update`:`Save`})]})]}),v&&v.items.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{style:{overflowX:`auto`},children:(0,b.jsxs)(`table`,{className:`mem-knowledge-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`th`,{onClick:()=>kr(`category`),className:E===`category`?`sorted`:``,children:[`Category`,Br(`category`)]}),(0,b.jsx)(`th`,{children:`Content`}),(0,b.jsxs)(`th`,{onClick:()=>kr(`context`),className:E===`context`?`sorted`:``,children:[`Context`,Br(`context`)]}),(0,b.jsx)(`th`,{children:`Entity`}),(0,b.jsxs)(`th`,{onClick:()=>kr(`confidence`),className:E===`confidence`?`sorted`:``,children:[`Confidence`,Br(`confidence`)]}),(0,b.jsx)(`th`,{children:`Source`}),(0,b.jsxs)(`th`,{onClick:()=>kr(`updated_at`),className:E===`updated_at`?`sorted`:``,children:[`Updated`,Br(`updated_at`)]}),(0,b.jsxs)(`th`,{onClick:()=>kr(`created_at`),className:E===`created_at`?`sorted`:``,children:[`Created`,Br(`created_at`)]}),(0,b.jsx)(`th`,{children:`Due`}),(0,b.jsx)(`th`,{className:`mem-actions-cell`})]})}),(0,b.jsx)(`tbody`,{children:v.items.map(e=>{let t=At===e.id,n=e.has_embedding;return(0,b.jsxs)(y.Fragment,{children:[(0,b.jsxs)(`tr`,{className:`${e.superseded_by?`mem-superseded-row`:``} ${t?`mem-expanded-row`:``}`,onClick:()=>jt(t?null:e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),jt(t?null:e.id))},tabIndex:0,role:`row`,"aria-expanded":t,style:{cursor:`pointer`},children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-cat-badge ${e.category}`,children:e.category})}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`div`,{className:`mem-content-cell`,title:e.content,children:[n!==void 0&&(0,b.jsx)(`span`,{className:`mem-embed-dot ${n?`embedded`:`missing`}`,title:n?`Embedded`:`Embedding missing`,children:(0,b.jsx)(Me,{size:6,fill:`currentColor`})}),e.sensitive&&(0,b.jsx)(`span`,{className:`mem-sensitive-badge`,title:`Sensitive`,children:(0,b.jsx)(et,{size:11})}),(0,b.jsx)(`span`,{className:e.sensitive&&!nn.has(e.id)?`mem-sensitive-blur`:e.superseded_by?`mem-superseded-text`:``,onClick:t=>{e.sensitive&&(t.stopPropagation(),rn(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}))},children:e.content})]})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-date-cell`,children:e.context})}),(0,b.jsx)(`td`,{children:e.entity?(0,b.jsx)(`span`,{className:`mem-entity-link`,onClick:t=>{t.stopPropagation(),zt(e.entity),O(0)},title:`Filter by ${e.entity}`,children:e.entity}):(0,b.jsx)(`span`,{className:`mem-date-cell`,children:`—`})}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`div`,{className:`mem-confidence`,children:[(0,b.jsx)(`div`,{className:`mem-confidence-bar`,children:(0,b.jsx)(`div`,{className:`mem-confidence-fill ${gt(e.confidence)}`,style:{width:`${e.confidence*100}%`}})}),e.confidence.toFixed(2)]})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-date-cell`,children:e.source||`—`})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-date-cell`,title:S(e.updated_at),children:C(e.updated_at)})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-date-cell`,title:S(e.created_at),children:C(e.created_at)})}),(0,b.jsx)(`td`,{children:e.due_at?(0,b.jsx)(`span`,{className:`mem-due-badge ${ht(e.due_at)?`overdue`:`upcoming`}`,title:S(e.due_at),children:C(e.due_at)}):(0,b.jsx)(`span`,{className:`mem-due-badge none`,children:`—`})}),(0,b.jsx)(`td`,{className:`mem-actions-cell`,children:(0,b.jsxs)(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[(0,b.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>wr(e),title:`Edit`,children:(0,b.jsx)(Re,{size:13})}),(0,b.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Cr(e),title:e.sensitive?`Unmark sensitive`:`Mark sensitive`,children:e.sensitive?(0,b.jsx)(Qe,{size:13}):(0,b.jsx)(et,{size:13})}),(0,b.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Tr(e.id),title:`Copy ID`,children:(0,b.jsx)(Be,{size:13})}),(0,b.jsx)(`button`,{className:`mem-row-action-btn delete${I===e.id?` is-confirm`:``}`,onClick:()=>Sr(e.id),title:I===e.id?`Click again to delete`:`Delete`,"aria-label":I===e.id?`Confirm delete memory`:`Delete memory`,children:I===e.id?(0,b.jsx)(`span`,{className:`mem-row-delete-label`,children:`Delete?`}):(0,b.jsx)(re,{size:13})})]})})]}),t&&(0,b.jsx)(`tr`,{className:`mem-detail-row`,children:(0,b.jsx)(`td`,{colSpan:10,children:(0,b.jsxs)(`div`,{className:`mem-detail-panel`,children:[(0,b.jsxs)(`div`,{className:`mem-detail-grid`,children:[(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`ID`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:e.id})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Domain`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:e.domain||`—`})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Source`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:e.source||`—`})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Use Count`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:e.use_count??0})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Created`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:S(e.created_at)})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Updated`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:S(e.updated_at)})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Last Used`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:S(e.last_used)})]}),(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Reminded At`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:S(e.reminded_at)})]}),e.superseded_by&&(0,b.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Superseded By`}),(0,b.jsx)(`span`,{className:`mem-detail-value mem-detail-chain`,children:e.superseded_by})]}),e.metadata&&(0,b.jsxs)(`div`,{className:`mem-detail-field mem-detail-full`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Metadata`}),(0,b.jsx)(`span`,{className:`mem-detail-value`,children:typeof e.metadata==`object`?JSON.stringify(e.metadata,null,2):e.metadata})]})]}),(0,b.jsxs)(`div`,{className:`mem-detail-content-full`,children:[(0,b.jsx)(`span`,{className:`mem-detail-label`,children:`Full Content`}),(0,b.jsx)(`div`,{className:`mem-detail-content-text`,children:e.content})]})]})})})]},e.id)})})]})}),(0,b.jsxs)(`div`,{className:`mem-pagination`,children:[(0,b.jsxs)(`span`,{children:[D+1,`–`,Math.min(D+15,v.total),` of `,v.total]}),(0,b.jsxs)(`div`,{className:`mem-pagination-btns`,children:[(0,b.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Previous page`,disabled:D===0,onClick:()=>O(Math.max(0,D-15)),children:(0,b.jsx)(Ye,{size:14})}),(0,b.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Next page`,disabled:D+15>=v.total,onClick:()=>O(D+15),children:(0,b.jsx)(Pe,{size:14})})]})]})]}):(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(h,{size:28})}),(0,b.jsx)(`p`,{children:Bt||T.length>0||It||Rt?`No matching memories`:`No memories stored yet`})]})]}),(0,b.jsxs)(`div`,{className:`mem-two-col`,children:[(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title`,children:[(0,b.jsx)(f,{size:14}),` Tool Performance`,(0,b.jsx)(`span`,{className:`mem-section-note`,title:`remember, recall, update_memory, forget and search_past_conversations are not logged`,children:`excludes memory tools`})]}),tt.length>0?(0,b.jsx)(`div`,{style:{overflowX:`auto`},children:(0,b.jsxs)(`table`,{className:`mem-tool-table`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Tool`}),(0,b.jsx)(`th`,{children:`Calls`}),(0,b.jsx)(`th`,{children:`Success`}),(0,b.jsx)(`th`,{children:`Avg Time`}),(0,b.jsx)(`th`,{children:`Last Used`}),(0,b.jsx)(`th`,{children:`Last Error`})]})}),(0,b.jsx)(`tbody`,{children:tt.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-tool-name`,children:e.tool_name})}),(0,b.jsx)(`td`,{children:e.total_calls}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`div`,{className:`mem-confidence`,children:[(0,b.jsx)(`div`,{className:`mem-confidence-bar`,style:{width:40},children:(0,b.jsx)(`div`,{className:`mem-confidence-fill ${_t(e.success_rate)}`,style:{width:`${e.success_rate*100}%`}})}),(0,b.jsxs)(`span`,{className:`mem-success-rate ${_t(e.success_rate)}`,children:[Math.round(e.success_rate*100),`%`]})]})}),(0,b.jsx)(`td`,{children:mt(e.avg_duration_ms)}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-date-cell`,title:S(e.last_used),children:C(e.last_used)})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`mem-tool-error`,title:e.last_error||``,children:e.last_error||`—`})})]},e.tool_name))})]})}):(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(f,{size:28})}),(0,b.jsx)(`p`,{children:`No tool calls recorded yet`})]})]}),(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title`,children:[(0,b.jsx)(Se,{size:14}),` Upcoming & Overdue`]}),lt.length>0?(0,b.jsx)(`div`,{className:`mem-temporal-list`,children:lt.map(e=>{let t=ht(e.due_at);return(0,b.jsxs)(`div`,{className:`mem-temporal-item ${t?`overdue`:`upcoming`}`,children:[(0,b.jsx)(`span`,{className:`mem-temporal-icon`,children:t?(0,b.jsx)(m,{size:16}):(0,b.jsx)(Se,{size:16})}),(0,b.jsxs)(`div`,{className:`mem-temporal-content`,children:[(0,b.jsx)(`div`,{className:`mem-temporal-text`,children:e.content}),(0,b.jsxs)(`div`,{className:`mem-temporal-date`,children:[t?`OVERDUE`:`Due`,`: `,C(e.due_at),e.context!==`global`&&` \u00B7 ${e.context}`]})]})]},e.id)})}):(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(we,{size:28})}),(0,b.jsx)(`p`,{children:`Nothing upcoming or overdue`})]})]})]}),(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title`,children:[(0,b.jsx)(a,{size:14}),` Conversation History`]}),(0,b.jsxs)(`div`,{className:`mem-conv-search`,children:[(0,b.jsx)(he,{size:13,className:`search-icon`}),(0,b.jsx)(`input`,{type:`text`,placeholder:`Search conversations...`,value:qt,onChange:e=>Er(e.target.value),"aria-label":`Search conversations`}),qt&&(0,b.jsx)(`button`,{className:`mem-search-clear`,onClick:()=>{Jt(``),Xt(null)},"aria-label":`Clear search`,children:(0,b.jsx)(se,{size:12})})]}),Yt===null?at.length>0?(0,b.jsx)(`div`,{className:`mem-conv-list`,children:at.map(e=>(0,b.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Dr(e.session_id),children:[(0,b.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,b.jsxs)(`div`,{className:`mem-conv-session-id`,children:[s(e.session_id),e.consolidated&&(0,b.jsx)(`span`,{className:`mem-consolidated-badge`,title:`Consolidated`,children:(0,b.jsx)(Ze,{size:11})})]}),e.first_message&&(0,b.jsx)(`div`,{className:`mem-conv-preview`,children:e.first_message})]}),(0,b.jsxs)(`div`,{className:`mem-conv-meta`,children:[(0,b.jsxs)(`span`,{children:[e.turn_count,` turns`]}),(0,b.jsx)(`span`,{children:C(e.last_activity)})]})]},e.session_id))}):(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(a,{size:28})}),(0,b.jsx)(`p`,{children:`No conversation history in memory`})]}):Yt.length>0?(0,b.jsx)(`div`,{className:`mem-conv-list`,children:Yt.map(e=>(0,b.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Dr(e.session_id),children:[(0,b.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,b.jsxs)(`div`,{className:`mem-conv-session-id`,children:[(0,b.jsx)(`span`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),` `,s(e.session_id)]}),(0,b.jsx)(`div`,{className:`mem-conv-preview`,children:e.content})]}),(0,b.jsx)(`div`,{className:`mem-conv-meta`,children:(0,b.jsx)(`span`,{children:C(e.timestamp)})})]},e.id))}):(0,b.jsx)(`div`,{className:`mem-empty`,children:(0,b.jsxs)(`p`,{children:[`No conversations match “`,qt,`”`]})})]}),k&&(0,b.jsxs)(`div`,{className:`mem-conv-detail-overlay`,children:[(0,b.jsxs)(`div`,{className:`mem-conv-detail-header`,children:[(0,b.jsx)(`h2`,{children:s(k.sessionId)}),(0,b.jsxs)(`div`,{className:`mem-conv-detail-actions`,children:[r.has(k.sessionId)&&(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>n(k.sessionId),children:`Open chat`}),(0,b.jsx)(`button`,{className:`btn-icon`,onClick:()=>Qt(null),"aria-label":`Close conversation`,children:(0,b.jsx)(se,{size:16})})]})]}),(0,b.jsxs)(`div`,{className:`mem-conv-detail-body`,children:[k.turns.map(e=>(0,b.jsxs)(`div`,{className:`mem-conv-turn`,children:[(0,b.jsxs)(`div`,{className:`mem-conv-turn-header`,children:[(0,b.jsx)(`div`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),(0,b.jsx)(`span`,{className:`mem-conv-turn-time`,title:S(e.timestamp),children:C(e.timestamp)})]}),(0,b.jsx)(`div`,{className:`mem-conv-turn-content`,children:e.content})]},e.id)),k.turns.length===0&&(0,b.jsx)(`div`,{className:`mem-empty`,children:`No turns found`})]})]})]}),(0,b.jsxs)(`div`,{className:`mem-section`,children:[(0,b.jsxs)(`div`,{className:`mem-section-title`,children:[(0,b.jsx)(et,{size:14}),` Settings `,(0,b.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`1px 6px`,borderRadius:4,marginLeft:6,verticalAlign:`middle`,letterSpacing:`0.5px`},children:`BETA`})]}),(0,b.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,b.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,b.jsx)(`span`,{className:`mem-setting-label`,children:`Memory enabled`}),(0,b.jsx)(`span`,{className:`mem-setting-desc`,children:`When disabled, no knowledge or conversation data is stored during any session (global incognito).`})]}),(0,b.jsx)(`button`,{className:`mem-toggle${N?` mem-toggle-on`:``}`,disabled:P,onClick:async()=>{if(!N)R(`memory`);else{F(!0);try{let e=await d({memory_enabled:!1});an(e.memory_enabled)}catch(e){i.system.warn(`Failed to disable memory`,e)}finally{F(!1)}}},"aria-pressed":N,"aria-label":`Memory is ${N?`enabled`:`disabled`}`,children:N?`On`:`Off`})]}),L&&(()=>{let e={memory:{title:`Enable Agent Memory?`,description:`Agent memory is a work-in-progress. By enabling it:`,bullets:[[`Conversations and facts are stored `,`locally on this machine`],[`Stored data `,`may be lost`,` during updates`],[`You can disable it at any time from this settings panel`]],buttonLabel:`Enable Memory`,onConfirm:async()=>{let e=await d({memory_enabled:!0});an(e.memory_enabled),X(`Memory enabled`,`info`)}},mcp:{title:`Enable MCP Memory Access?`,description:`This exposes memory data to external MCP clients:`,bullets:[[`MCP clients can `,`read your stored memories`,` (read-only)`],[`Requires an `,`MCP server restart`,` to take effect`],[`Intended for debugging and troubleshooting only`]],buttonLabel:`Enable MCP Access`,onConfirm:async()=>{let e=await d({mcp_memory_enabled:!0});sn(e.mcp_memory_enabled),X(`MCP memory access enabled`,`info`)}},discovery:{title:`Enable System Discovery?`,description:`This scans your system to personalize responses:`,bullets:[[`Collects `,`hardware, software, and environment`,` information`],[`Scans files, git repos, browser history, and SSH config`],[`All data stays `,`local on this machine`]],buttonLabel:`Enable Discovery`,onConfirm:async()=>{let e=await d({system_discovery_consent:!0});if(ln(e.system_discovery_consent),e.system_context_error)X(`System discovery enabled but scan failed: ${e.system_context_error}`,`error`);else{let t=e.system_context_refresh?.stored??0;X(`System discovery enabled — ${t} system facts collected`,`info`)}Q()}}}[L];return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>R(null)}),(0,b.jsxs)(`div`,{ref:or,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:[(0,b.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[(0,b.jsx)(`span`,{style:{fontSize:11,fontWeight:700,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`3px 10px`,borderRadius:4,letterSpacing:`0.5px`},children:`BETA`}),(0,b.jsx)(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e.title})]}),(0,b.jsx)(`p`,{id:`mem-beta-confirm-desc`,style:{fontSize:13,lineHeight:1.6,color:`var(--text-secondary)`,margin:`0 0 8px`},children:e.description}),(0,b.jsx)(`ul`,{style:{fontSize:13,lineHeight:1.7,color:`var(--text-secondary)`,margin:`0 0 24px`,paddingLeft:20},children:e.bullets.map((e,t)=>(0,b.jsx)(`li`,{children:e.map((e,t)=>t%2==1?(0,b.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:e},t):(0,b.jsx)(`span`,{children:e},t))},t))}),(0,b.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>R(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:`Cancel`}),(0,b.jsx)(`button`,{disabled:P,onClick:async()=>{F(!0);try{await e.onConfirm()}catch(e){i.system.warn(`Failed to update setting`,e),X(`Failed to update setting. Please try again.`,`error`)}finally{F(!1),R(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.buttonLabel})]})]})]})})(),(0,b.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,b.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,b.jsx)(`span`,{className:`mem-setting-label`,children:`MCP memory access`}),(0,b.jsx)(`span`,{className:`mem-setting-desc`,children:`Expose read-only memory tools to MCP clients (for debug/troubleshooting). Requires MCP server restart.`})]}),(0,b.jsx)(`button`,{className:`mem-toggle${on?` mem-toggle-on`:``}`,disabled:P,onClick:async()=>{if(!on)R(`mcp`);else{F(!0);try{let e=await d({mcp_memory_enabled:!1});sn(e.mcp_memory_enabled)}catch(e){i.system.warn(`Failed to update memory settings`,e)}finally{F(!1)}}},"aria-label":`Toggle MCP memory access`,"aria-pressed":on,children:on?`On`:`Off`})]}),(0,b.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,b.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,b.jsx)(`span`,{className:`mem-setting-label`,children:`System discovery`}),(0,b.jsx)(`span`,{className:`mem-setting-desc`,children:`Allow GAIA to scan your system for hardware, software, and environment information to personalize responses.`})]}),(0,b.jsx)(`button`,{className:`mem-toggle${cn?` mem-toggle-on`:``}`,disabled:P,onClick:async()=>{if(!cn)R(`discovery`);else{F(!0);try{let e=await d({system_discovery_consent:!1});ln(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to update system discovery setting`,e)}finally{F(!1)}}},"aria-label":`Toggle system discovery`,"aria-pressed":cn,children:cn?`On`:`Off`})]}),(0,b.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,b.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,b.jsx)(`span`,{className:`mem-setting-label`,children:`Re-initialize memory`}),(0,b.jsx)(`span`,{className:`mem-setting-desc`,children:`Wipe all memories, conversations, and tool logs, then re-collect system information. This cannot be undone.`})]}),pn?(0,b.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,b.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,b.jsx)(`button`,{className:`mem-btn-danger`,disabled:P,onClick:async()=>{F(!0);try{let e=await de();e.system_context.error?X(e.system_context.error,`error`):X(`Re-initialized: cleared ${e.cleared.knowledge} entries, restored ${e.system_context.stored} system facts`,`info`),Q()}catch(e){i.system.warn(`Failed to reinitialize memory`,e),X(`Failed to re-initialize memory`,`error`)}finally{F(!1),mn(!1)}},children:`Yes, re-initialize`}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>mn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,b.jsx)(`button`,{className:`mem-btn-danger`,disabled:P,onClick:()=>mn(!0),children:`Re-initialize`})]}),(0,b.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,b.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,b.jsx)(`span`,{className:`mem-setting-label`,children:`Delete all memories`}),(0,b.jsx)(`span`,{className:`mem-setting-desc`,children:`Permanently wipe all knowledge entries, conversation history, and tool logs. This cannot be undone.`})]}),un?(0,b.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,b.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,b.jsx)(`button`,{className:`mem-btn-danger`,disabled:P,onClick:async()=>{F(!0);try{let e=await ze();X(`Deleted ${e.knowledge} knowledge entries, ${e.conversations} conversations`,`info`),Q()}catch(e){i.system.warn(`Failed to clear memory`,e),X(`Failed to clear memory`,`error`)}finally{F(!1),dn(!1)}},children:`Yes, delete all`}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>dn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,b.jsx)(`button`,{className:`mem-btn-danger`,disabled:P,onClick:()=>dn(!0),children:`Delete All`})]})]}),g&&(0,b.jsxs)(`div`,{className:`mem-db-footer`,children:[(0,b.jsxs)(`span`,{children:[`Database: `,Ve(g.db_size_bytes),g.knowledge?.avg_confidence!=null&&` \u00B7 Avg confidence: ${g.knowledge.avg_confidence.toFixed(2)}`]}),(0,b.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[g.knowledge?.entity_count!=null&&g.knowledge.entity_count>0&&(0,b.jsxs)(`span`,{children:[g.knowledge.entity_count,` entities`]}),g.knowledge?.sensitive_count!=null&&g.knowledge.sensitive_count>0&&(0,b.jsxs)(`span`,{children:[(0,b.jsx)(et,{size:10}),` `,g.knowledge.sensitive_count,` sensitive`]})]})]})]})}),z===`profile`&&(0,b.jsxs)(`div`,{className:`mem-profile-grid`,children:[(0,b.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,b.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,b.jsx)(Ie,{size:16}),` System Discovery`]}),(0,b.jsx)(`p`,{className:`mem-profile-desc`,children:`Scan your system to discover apps, projects, and usage patterns.`}),(0,b.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:B===`running`||B===`saving`,onClick:Ir,children:B===`running`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Discovery`}),Mn.length>0&&(0,b.jsx)(`div`,{className:`mem-log`,ref:Fn,children:Mn.map((e,t)=>(0,b.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(B===`review`||B===`saving`||B===`done`)&&U.length>0&&(0,b.jsxs)(`div`,{className:`mem-review-section`,children:[(0,b.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,b.jsx)(`div`,{className:`mem-review-list`,children:U.map((e,t)=>(0,b.jsxs)(`label`,{className:`mem-review-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:B===`saving`||B===`done`,onChange:()=>{W(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,b.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,b.jsx)(`span`,{className:`mem-source-badge`,children:e._source_name||e.category}),(0,b.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,b.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,b.jsx)(`button`,{className:`btn-primary`,disabled:B===`saving`||B===`done`||U.filter(e=>e._checked).length===0,onClick:Lr,children:B===`saving`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${U.filter(e=>e._checked).length})`}),(0,b.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,b.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>W(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,b.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>W(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),B===`done`&&Nn!==null&&(0,b.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,b.jsx)(we,{size:14}),` Saved `,Nn,` items to memory`]}),B===`review`&&U.length===0&&(0,b.jsx)(`div`,{className:`mem-profile-empty`,children:`No items discovered.`})]}),(0,b.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,b.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,b.jsx)(nt,{size:16}),` AI Profile Inference`]}),(0,b.jsx)(`p`,{className:`mem-profile-desc`,children:`Use the local LLM to generate profile insights from your data.`}),(0,b.jsx)(`p`,{className:`mem-profile-note`,children:`Requires Lemonade Server running.`}),(0,b.jsxs)(`label`,{className:`mem-profile-checkbox`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:Bn,onChange:e=>Vn(e.target.checked),disabled:G===`running`||G===`saving`}),`Include browser history`]}),(0,b.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:G===`running`||G===`saving`,onClick:Rr,children:G===`running`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Inference`}),Ln.length>0&&(0,b.jsx)(`div`,{className:`mem-log`,ref:Hn,children:Ln.map((e,t)=>(0,b.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(G===`review`||G===`saving`||G===`done`)&&J.length>0&&(0,b.jsxs)(`div`,{className:`mem-review-section`,children:[(0,b.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,b.jsx)(`div`,{className:`mem-review-list`,children:J.map((e,t)=>(0,b.jsxs)(`label`,{className:`mem-review-item`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:G===`saving`||G===`done`,onChange:()=>{Y(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,b.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,b.jsx)(`span`,{className:`mem-domain-badge ${xt[e.domain]||`gray`}`,children:e.domain}),(0,b.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,b.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,b.jsx)(`button`,{className:`btn-primary`,disabled:G===`saving`||G===`done`||J.filter(e=>e._checked).length===0,onClick:zr,children:G===`saving`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${J.filter(e=>e._checked).length})`}),(0,b.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,b.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Y(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,b.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Y(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),G===`done`&&Rn!==null&&(0,b.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,b.jsx)(we,{size:14}),` Saved `,Rn,` insights to memory`]}),G===`review`&&J.length===0&&(0,b.jsx)(`div`,{className:`mem-profile-empty`,children:`No insights generated.`})]})]}),z===`goals`&&(0,b.jsxs)(`div`,{className:`mem-goals-tab`,children:[(0,b.jsx)(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(e=>(0,b.jsxs)(`div`,{className:`mem-goals-stat-pill mem-goal-status-${e.replace(`_`,`-`)}`,children:[(0,b.jsx)(`span`,{className:`mem-goals-stat-n`,children:bn?.goals[e]??0}),(0,b.jsx)(`span`,{className:`mem-goals-stat-label`,children:e.replace(`_`,` `)})]},e))}),vn.filter(e=>e.status===`pending_approval`).length>0&&(0,b.jsxs)(`div`,{className:`mem-goals-approval-banner`,children:[(0,b.jsxs)(`div`,{className:`mem-goals-approval-title`,children:[(0,b.jsx)(ae,{size:14}),` Agent suggested `,vn.filter(e=>e.status===`pending_approval`).length,` goal(s) — review before execution`]}),vn.filter(e=>e.status===`pending_approval`).map(e=>(0,b.jsxs)(`div`,{className:`mem-goals-approval-item`,children:[(0,b.jsxs)(`div`,{className:`mem-goals-approval-text`,children:[(0,b.jsx)(`strong`,{children:e.title}),(0,b.jsx)(`span`,{children:e.description})]}),(0,b.jsxs)(`div`,{className:`mem-goals-approval-actions`,children:[(0,b.jsx)(`button`,{className:`btn-danger-sm`,onClick:()=>gr(()=>ne(e.id),`Couldn't reject the goal`),children:`Reject`}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>gr(()=>ve(e.id),`Couldn't accept the goal`),children:`Accept`})]})]},e.id))]}),(0,b.jsx)(`div`,{className:`mem-goals-toolbar`,children:(0,b.jsxs)(`button`,{className:`btn-primary`,onClick:()=>kn(e=>!e),children:[(0,b.jsx)(oe,{size:14}),` New Goal`]})}),On&&(0,b.jsxs)(`div`,{className:`mem-goals-add-form`,children:[(0,b.jsx)(`input`,{className:`mem-input`,placeholder:`Goal title`,value:An.title,onChange:e=>jn(t=>({...t,title:e.target.value}))}),(0,b.jsx)(`textarea`,{className:`mem-input`,placeholder:`Description — what should the agent work toward?`,rows:2,value:An.description,onChange:e=>jn(t=>({...t,description:e.target.value}))}),(0,b.jsxs)(`div`,{className:`mem-goals-form-row`,children:[(0,b.jsxs)(`select`,{className:`mem-select`,value:An.priority,onChange:e=>jn(t=>({...t,priority:e.target.value})),children:[(0,b.jsx)(`option`,{value:`low`,children:`Low priority`}),(0,b.jsx)(`option`,{value:`medium`,children:`Medium priority`}),(0,b.jsx)(`option`,{value:`high`,children:`High priority`})]}),(0,b.jsx)(`button`,{className:`btn-primary`,onClick:()=>{An.title.trim()&&gr(async()=>{await Ce(An),jn({title:``,description:``,priority:`medium`}),kn(!1)},`Couldn't create the goal`)},children:`Create`}),(0,b.jsx)(`button`,{className:`btn-secondary`,onClick:()=>kn(!1),children:`Cancel`})]})]}),Sn?(0,b.jsxs)(`div`,{className:`mem-loading`,children:[(0,b.jsx)(`div`,{className:`mem-spinner`}),` Loading goals...`]}):vn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?(0,b.jsxs)(`div`,{className:`mem-empty`,children:[(0,b.jsx)(`div`,{className:`mem-empty-icon`,children:(0,b.jsx)(it,{size:32})}),(0,b.jsx)(`p`,{children:`No goals yet. Create one or let the agent suggest goals in autonomous mode.`})]}):(0,b.jsx)(`div`,{className:`mem-goals-list`,children:vn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(e=>(0,b.jsxs)(`div`,{className:`mem-goal-card mem-goal-status-${e.status.replace(`_`,`-`)}`,children:[(0,b.jsxs)(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":wn===e.id,onClick:()=>Tn(t=>t===e.id?null:e.id),onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Tn(t=>t===e.id?null:e.id))},children:[(0,b.jsxs)(`div`,{className:`mem-goal-header-left`,children:[(0,b.jsx)(`span`,{className:`mem-goal-status-dot status-${e.status.replace(`_`,`-`)}`}),(0,b.jsx)(`span`,{className:`mem-goal-title`,children:e.title}),(0,b.jsx)(`span`,{className:`mem-goal-priority mem-priority-${e.priority}`,children:e.priority}),e.source!==`user`&&(0,b.jsxs)(`span`,{className:`mem-goal-source-badge`,children:[(0,b.jsx)(ae,{size:10}),` `,e.source.replace(`_`,` `)]})]}),(0,b.jsxs)(`div`,{className:`mem-goal-header-right`,children:[(0,b.jsxs)(`span`,{className:`mem-goal-task-count`,children:[(0,b.jsx)(ge,{size:12}),e.tasks.filter(e=>e.status===`completed`).length,`/`,e.tasks.length]}),e.status===`queued`&&(0,b.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:t=>{t.stopPropagation(),gr(()=>Fe(e.id),`Couldn't cancel the goal`)},children:`Cancel`}),En===e.id?(0,b.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:t=>{t.stopPropagation(),Dn(null),gr(()=>Le(e.id),`Couldn't delete the goal`)},children:`Delete?`}):(0,b.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":`Delete goal ${e.title}`,onClick:t=>{t.stopPropagation(),Dn(e.id)},children:(0,b.jsx)(re,{size:12})}),(0,b.jsx)(Oe,{size:14,className:wn===e.id?`mem-chevron-open`:``})]})]}),wn===e.id&&(0,b.jsxs)(`div`,{className:`mem-goal-body`,children:[e.description&&(0,b.jsx)(`p`,{className:`mem-goal-desc`,children:e.description}),e.progress_notes&&(0,b.jsx)(`p`,{className:`mem-goal-progress`,children:e.progress_notes}),e.tasks.length>0?(0,b.jsx)(`div`,{className:`mem-task-list`,children:e.tasks.map(e=>(0,b.jsxs)(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[(0,b.jsx)(`span`,{className:`mem-task-dot status-${e.status}`}),(0,b.jsx)(`span`,{className:`mem-task-desc`,children:e.description}),(0,b.jsx)(`span`,{className:`mem-task-status-label`,children:e.status}),e.result&&(0,b.jsx)(`span`,{className:`mem-task-result`,children:e.result})]},e.id))}):(0,b.jsx)(`p`,{className:`mem-goal-no-tasks`,children:`No tasks yet — the agent will break this down when it starts.`})]})]},e.id))})]})]}),Mt.length>0&&(0,b.jsx)(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:Mt.map(e=>(0,b.jsxs)(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&(0,b.jsx)(we,{size:14}),e.type===`error`&&(0,b.jsx)(m,{size:14}),e.type===`info`&&(0,b.jsx)(h,{size:14}),(0,b.jsx)(`span`,{children:e.text})]},e.id))})]})}export{St as MemoryDashboard};
|