@amd-gaia/agent-ui 0.25.0-rc.2 → 0.25.0-rc.8
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/bin/gaia-ui.cjs +13 -7
- package/dist/assets/AdvancedSettings-DNQod9tb.js +1 -0
- package/dist/assets/{ConnectorsPane-KLjT1y3F.js → ConnectorsPane-DXvmZT6E.js} +1 -1
- package/dist/assets/DocumentLibrary-H6_dL1FQ.js +1 -0
- package/dist/assets/FileBrowser-JEScQZqn.js +4 -0
- package/dist/assets/{MemoryDashboard-DG9P8Bqf.js → MemoryDashboard-CK5IZKJ8.js} +1 -1
- package/dist/assets/{MobileAccessModal-Jub4U6L2.js → MobileAccessModal-CV7e2cgI.js} +1 -1
- package/dist/assets/{ScheduleManager-BStuwsjn.js → ScheduleManager-A5eLWyGP.js} +1 -1
- package/dist/assets/index-D00FJoXi.js +58 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/services/backend-installer.cjs +32 -6
- package/dist/assets/AdvancedSettings-DabrR6sf.js +0 -1
- package/dist/assets/DocumentLibrary-CElkmNvc.js +0 -1
- package/dist/assets/FileBrowser-ROrpBhVm.js +0 -4
- package/dist/assets/index-CXbVMk3u.js +0 -58
package/bin/gaia-ui.cjs
CHANGED
|
@@ -141,11 +141,13 @@ function openBrowser(url) {
|
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
let shuttingDown = false;
|
|
145
|
+
|
|
144
146
|
/**
|
|
145
147
|
* Start the Python backend.
|
|
146
148
|
* Uses "chat --ui" for compatibility with all gaia versions.
|
|
147
149
|
*/
|
|
148
|
-
function startBackend(gaiaBin, port) {
|
|
150
|
+
function startBackend(gaiaBin, port, exit = process.exit) {
|
|
149
151
|
console.log(`Starting GAIA backend on port ${port}...`);
|
|
150
152
|
|
|
151
153
|
const child = spawn(
|
|
@@ -176,13 +178,16 @@ function startBackend(gaiaBin, port) {
|
|
|
176
178
|
|
|
177
179
|
child.on("error", (err) => {
|
|
178
180
|
console.error(`Failed to start backend: ${err.message}`);
|
|
179
|
-
|
|
181
|
+
exit(1);
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
// The backend serves the UI, so once it is gone there is nothing to open.
|
|
185
|
+
child.on("exit", (code, signal) => {
|
|
186
|
+
if (shuttingDown) return;
|
|
187
|
+
console.error(
|
|
188
|
+
`Backend exited with ${code !== null ? `code ${code}` : signal} — see the [backend] lines above.`
|
|
189
|
+
);
|
|
190
|
+
exit(code ?? 1);
|
|
186
191
|
});
|
|
187
192
|
|
|
188
193
|
return child;
|
|
@@ -358,6 +363,7 @@ async function main() {
|
|
|
358
363
|
|
|
359
364
|
// Graceful shutdown
|
|
360
365
|
function cleanup() {
|
|
366
|
+
shuttingDown = true;
|
|
361
367
|
if (backendProcess) {
|
|
362
368
|
console.log("\nShutting down GAIA...");
|
|
363
369
|
backendProcess.kill("SIGTERM");
|
|
@@ -385,4 +391,4 @@ if (require.main === module) {
|
|
|
385
391
|
});
|
|
386
392
|
}
|
|
387
393
|
|
|
388
|
-
module.exports = { npmDistTag, helpText };
|
|
394
|
+
module.exports = { npmDistTag, helpText, startBackend };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,r as n,t as r}from"./jsx-runtime-DVeaULmT.js";import{$t as i,Bt as a,R as o,Tt as s,Zt as c,at as l,ct as u,n as ee,r as d,st as te}from"./index-D00FJoXi.js";var f=e(t(),1),p=r();function m(){return window.gaiaUpdater}function ne({onClose:e}){let[t,n]=(0,f.useState)({kind:`loading`}),r=(0,f.useRef)(null);(0,f.useEffect)(()=>{let e=m();if(!e){n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`});return}e.listReleases().then(e=>{n(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})})},[]),(0,f.useEffect)(()=>{function t(t){t.key===`Escape`&&e()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),(0,f.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,f.useEffect)(()=>{let e=r.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function i(e,t){e.isCurrent||n({kind:`confirm`,release:e,releases:t})}async function a(t){n({kind:`installing`});let r=m();if(!r){n({kind:`error`,message:`Bridge unavailable — please restart the app.`});return}try{await r.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);n({kind:`error`,message:`Failed to start rollback: ${t}`})}}function o(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,p.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,p.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Roll back to a previous version`,ref:r,children:[(0,p.jsxs)(`div`,{className:`version-picker-header`,children:[(0,p.jsx)(`h3`,{children:`Roll back to a previous version`}),(0,p.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,p.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,p.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,p.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,p.jsxs)(`div`,{className:`version-picker-error`,children:[(0,p.jsx)(`p`,{children:t.message}),(0,p.jsx)(`p`,{children:(0,p.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,p.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":`${e.version}${e.isCurrent?` — installed`:``}${e.isPinned?` — pinned`:``}`,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>i(e,t.releases),disabled:e.isCurrent,children:[(0,p.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,p.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,p.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,p.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,p.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,p.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,p.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,p.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,p.jsxs)(`p`,{children:[`This will `,(0,p.jsxs)(`strong`,{children:[`downgrade to v`,t.release.version]}),` and restart the app.`]}),(0,p.jsxs)(`p`,{className:`vp-confirm-note`,children:[`Auto-update will be paused after rollback so the app stays on v`,t.release.version,`. You can resume updates from Settings → About.`]}),(0,p.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,p.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,p.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Confirm downgrade & restart`})]})]}),t.kind===`installing`&&(0,p.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,p.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}function h(){let[e,t]=(0,f.useState)(null),[r,m]=(0,f.useState)(!0),[h,re]=(0,f.useState)([]),[ie,_]=(0,f.useState)(!1),v=ee(),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(``),[C,ae]=(0,f.useState)(!1),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1),A=(0,f.useRef)(null),[j,M]=(0,f.useState)(!1),[N,P]=(0,f.useState)(!1),[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(null);(0,f.useEffect)(()=>{n.system.info(`Checking system status...`);let e=n.system.time();u().then(r=>{t(r),n.system.timed(`System status received`,e,{lemonade:r.lemonade_running?`running`:`stopped`,model:r.model_loaded||`none`,embedding:r.embedding_model_loaded?`yes`:`no`,disk:`${r.disk_space_gb}GB free`,memory:r.memory_available_gb==null?`unknown`:`${r.memory_available_gb}GB available`}),r.lemonade_running||n.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{n.system.error(`Failed to get system status`,e),t(null)}).finally(()=>m(!1)),l().then(e=>re(e.servers)).catch(()=>{}),te().then(e=>{let t=e.custom_model??``;b(t),S(t),M(e.dynamic_tools),P(e.dynamic_tools_locked)}).catch(e=>{n.system.error(`Failed to load settings`,e)}).finally(()=>ae(!0))},[]),(0,f.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[]);let z=(0,f.useCallback)(async()=>{let e=y.trim(),t=e.length>0?e:``;T(!0),D(null),k(!1);try{n.system.info(`Saving custom_model override`,{custom_model:t});let e=(await s({custom_model:t})).custom_model??``;b(e),S(e),k(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>k(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);n.system.error(`Failed to save custom_model`,e),D(t)}finally{T(!1)}},[y]),oe=(0,f.useCallback)(async()=>{if(N||F)return;let e=j,t=!e;M(t),I(!0),R(null);try{n.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await s({dynamic_tools:t});M(e.dynamic_tools),P(e.dynamic_tools_locked)}catch(t){let r=t instanceof Error?t.message:String(t);n.system.error(`Failed to save dynamic_tools`,t),M(e),R(r)}finally{I(!1)}},[j,N,F]),B=y.trim()!==x.trim(),V=e?e.default_model_name:o,{isLoadingModel:H,isDownloadingModel:U,loadModel:W,downloadModel:G}=d(V??void 0),K=[{label:`4K`,value:4096},{label:`8K`,value:8192},{label:`16K`,value:16384},{label:`32K`,value:32768}],q=e?.model_context_size??null,[J,Y]=(0,f.useState)(``);(0,f.useEffect)(()=>{q!=null&&Y(String(q))},[q]);let X=(()=>{let e=parseInt(J,10);return Number.isFinite(e)&&e>0?e:null})(),se=X!=null&&X!==q,Z=e?.model_loaded??V,ce=(0,f.useCallback)(async()=>{X&&Z&&(n.system.info(`Reloading ${Z} with ctx_size=${X}`),await W(Z,X))},[X,Z,W]),Q=!!e?.default_model_is_cloud,$=!Q&&!!(e?.lemonade_running&&e.model_loaded&&e.expected_model_loaded===!1),le=!Q&&!!(e?.lemonade_running&&e.model_loaded&&e.context_size_sufficient===!1),ue=!Q&&!(!e?.lemonade_running||e.model_loaded||e.model_downloaded!==!1),de=($||le)&&V!==null;return(0,p.jsxs)(`div`,{className:`settings-pane`,children:[(0,p.jsx)(`h2`,{className:`settings-pane-title`,children:`Advanced`}),(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsx)(`h4`,{children:`Local model server`}),r?(0,p.jsx)(`p`,{className:`loading-text`,children:`Checking system...`}):e?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`status-grid`,children:[(0,p.jsx)(g,{label:`Model server`,value:e.lemonade_running?`Running${e.lemonade_version?` v${e.lemonade_version}`:``}`:e.lemonade_error?`Status unavailable`:`Not Running`,ok:e.lemonade_running,hint:e.lemonade_running?void 0:e.lemonade_error?`Could not query it: ${e.lemonade_error}`:e.start_command?`Run: ${e.start_command}`:e.start_instruction??`Not running.`}),(0,p.jsx)(g,{label:`Model`,value:e.model_loaded||`None loaded`,ok:!!e.model_loaded&&(Q||e.expected_model_loaded!==!1),hint:e.model_loaded?!Q&&e.expected_model_loaded===!1?`Expected: ${V}`:void 0:`None loaded yet — it loads with the first message.`}),e.model_size_gb!=null&&(0,p.jsx)(g,{label:`Model Size`,value:`${e.model_size_gb} GB`,ok:!0}),e.model_device&&!Q&&(0,p.jsx)(g,{label:`Device`,value:e.model_device.toUpperCase(),ok:e.model_device!==`cpu`}),e.model_context_size!=null&&(0,p.jsx)(g,{label:`Context Window`,value:`${(e.model_context_size/1024).toFixed(0)}K tokens`,ok:e.context_size_sufficient}),e.model_labels&&e.model_labels.length>0&&(0,p.jsx)(g,{label:`Capabilities`,value:e.model_labels.join(`, `),ok:!0}),(0,p.jsx)(g,{label:`Embedding Model`,value:e.embedding_model_loaded?`Available`:`Not loaded`,ok:e.embedding_model_loaded}),e.gpu_name&&(0,p.jsx)(g,{label:`GPU`,value:`${e.gpu_name}${e.gpu_vram_gb?` (${e.gpu_vram_gb} GB)`:``}`,ok:!0}),(0,p.jsx)(g,{label:`Disk Space`,value:`${e.disk_space_gb} GB free`,ok:e.disk_space_gb>5,hint:!e.model_loaded&&e.disk_space_gb<30?`Local models need about 6 GB — only ${e.disk_space_gb} GB free`:void 0}),(0,p.jsx)(g,{label:`Memory`,value:e.memory_available_gb==null?`unknown`:`${e.memory_available_gb} GB available`,ok:e.memory_available_gb!=null&&e.memory_available_gb>2}),e.processor_name&&(0,p.jsx)(g,{label:`Processor`,value:e.processor_name,ok:!0})]}),ue&&(0,p.jsxs)(`div`,{className:`model-action-row model-action-row--download`,children:[(0,p.jsxs)(`div`,{className:`model-action-info`,children:[(0,p.jsx)(`span`,{className:`model-action-label`,children:`Model not downloaded.`}),(0,p.jsxs)(`span`,{className:`model-action-desc`,children:[(0,p.jsx)(`strong`,{children:V}),` is GAIA’s default local model (about 6 GB).`]})]}),(0,p.jsx)(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>G(!1),disabled:U,children:U?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a,{size:13,className:`btn-spinner`}),` Downloading…`]}):`Download`})]}),de&&(0,p.jsxs)(`div`,{className:`model-action-row model-action-row--load`,children:[(0,p.jsxs)(`div`,{className:`model-action-info`,children:[(0,p.jsx)(`span`,{className:`model-action-label`,children:$?`Wrong model loaded.`:`Context window too small.`}),(0,p.jsxs)(`span`,{className:`model-action-desc`,children:[`Load `,(0,p.jsx)(`strong`,{children:V}),` with `,32 .toFixed(0),`K token context.`]})]}),(0,p.jsx)(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>W(),disabled:H,children:H?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a,{size:13,className:`btn-spinner`}),` Loading…`]}):`Load Model`})]}),e.lemonade_running&&V!==null&&!Q&&(0,p.jsxs)(`div`,{className:`force-redownload-row`,children:[(0,p.jsx)(`span`,{className:`force-redownload-label`,children:`If the model file is corrupted:`}),(0,p.jsx)(`button`,{className:`btn-force-redownload`,onClick:()=>G(!0),disabled:U,children:U?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a,{size:12,className:`btn-spinner`}),` Downloading…`]}):`Force Re-download`})]})]}):(0,p.jsx)(`div`,{className:`status-error`,children:(0,p.jsx)(`p`,{children:`Could not reach GAIA. Check that it is still running.`})})]}),(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsx)(`h4`,{children:`Custom model ID`}),(0,p.jsx)(`p`,{className:`model-override-desc`,children:`Run any model the local server knows by its ID. Leave empty to use the model chosen under Model.`}),(0,p.jsxs)(`div`,{className:`model-input-row`,children:[(0,p.jsx)(`input`,{type:`text`,className:`model-input${x?` has-override`:``}`,placeholder:`Use the model chosen under Model`,value:y,onChange:e=>{b(e.target.value),D(null),k(!1)},onKeyDown:e=>{e.key===`Enter`&&!w&&B&&C&&(e.preventDefault(),z())},disabled:!C||w,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Custom model override`}),(0,p.jsx)(`div`,{className:`model-btn-group`,children:(0,p.jsx)(`button`,{className:`btn-model-save${O?` saved`:``}`,onClick:()=>{z()},disabled:!C||w||!B&&!O,"aria-label":`Save custom model`,children:w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a,{size:13,className:`btn-spinner`}),` Saving…`]}):O?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(c,{size:13}),` Saved`]}):`Save`})})]}),(0,p.jsxs)(`p`,{className:`model-status-hint`,children:[`Accepts a Lemonade model ID (e.g. `,(0,p.jsx)(`code`,{children:`Qwen3-4B-Instruct-2507-GGUF`}),`)`,` `,`or a HuggingFace ID (e.g. `,(0,p.jsx)(`code`,{children:`unsloth/Qwen3-4B-GGUF`}),`).`]}),E&&(0,p.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,p.jsx)(i,{size:14}),(0,p.jsxs)(`div`,{className:`model-warning-content`,children:[(0,p.jsx)(`strong`,{children:`Could not save`}),(0,p.jsx)(`p`,{children:E})]})]})]}),!Q&&(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsx)(`h4`,{children:`Context Size`}),(0,p.jsx)(`p`,{className:`model-override-desc`,children:`Reload the active model with a different context window. Larger contexts use more memory and slow inference; going past the model’s training length may degrade quality.`}),(0,p.jsx)(`div`,{className:`ctx-preset-row`,children:K.map(e=>{let t=X===e.value;return(0,p.jsx)(`button`,{className:`btn-ctx-preset${t?` active`:``}`,onClick:()=>Y(String(e.value)),disabled:H,type:`button`,children:e.label},e.value)})}),(0,p.jsxs)(`div`,{className:`model-input-row`,children:[(0,p.jsx)(`input`,{type:`number`,className:`model-input`,placeholder:q==null?`4096`:String(q),value:J,min:512,step:1024,onChange:e=>Y(e.target.value),disabled:H,"aria-label":`Context size in tokens`}),(0,p.jsx)(`div`,{className:`model-btn-group`,children:(0,p.jsx)(`button`,{className:`btn-model-save`,onClick:()=>{ce()},disabled:H||!se||!e?.lemonade_running,"aria-label":`Reload model with new context size`,children:H?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(a,{size:13,className:`btn-spinner`}),` Reloading…`]}):`Apply`})})]}),(0,p.jsxs)(`p`,{className:`model-status-hint`,children:[`Current: `,(0,p.jsx)(`code`,{children:q==null?`unknown`:`${q.toLocaleString()} tokens`}),e?.model_loaded&&(0,p.jsxs)(p.Fragment,{children:[` on `,(0,p.jsx)(`code`,{children:e.model_loaded})]}),`.`]})]}),(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsxs)(`h4`,{children:[`Dynamic Tools `,(0,p.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`model-override-desc`,children:`Trim each turn’s tool list to a semantically-matched subset to speed up the first response. It does not apply to the GAIA agent yet.`}),(0,p.jsxs)(`label`,{className:`setting-row`,children:[(0,p.jsx)(`span`,{children:`Enable dynamic tool loading`}),(0,p.jsxs)(`span`,{className:`toggle-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:j,onChange:()=>void oe(),disabled:!C||F||N,"aria-label":j?`Disable dynamic tools`:`Enable dynamic tools`}),(0,p.jsx)(`span`,{className:`toggle-track`})]})]}),N&&(0,p.jsxs)(`p`,{className:`model-status-hint`,children:[`Controlled by `,(0,p.jsx)(`code`,{children:`GAIA_DYNAMIC_TOOLS`}),` — unset that environment variable to change this here.`]}),L&&(0,p.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,p.jsx)(i,{size:14}),(0,p.jsxs)(`div`,{className:`model-warning-content`,children:[(0,p.jsx)(`strong`,{children:`Could not save`}),(0,p.jsx)(`p`,{children:L})]})]})]}),h.length>0&&(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsx)(`h4`,{children:`MCP Servers`}),(0,p.jsx)(`div`,{className:`status-grid`,children:h.map(e=>(0,p.jsxs)(`div`,{className:`status-row`,children:[(0,p.jsx)(`span`,{className:`status-label`,children:e.name}),(0,p.jsx)(`div`,{className:`status-value-wrap`,children:e.connected?(0,p.jsxs)(`span`,{className:`status-value ok mcp-status-connected`,children:[(0,p.jsx)(c,{size:12}),e.tool_count,` tool`,e.tool_count===1?``:`s`]}):(0,p.jsxs)(`span`,{className:`status-value warn mcp-status-failed`,title:e.error??void 0,children:[(0,p.jsx)(i,{size:12}),`Failed`]})})]},e.name))})]}),(0,p.jsxs)(`section`,{className:`settings-section`,children:[(0,p.jsx)(`h4`,{children:`About`}),(0,p.jsxs)(`div`,{className:`about-info`,children:[(0,p.jsxs)(`p`,{children:[`GAIA v`,`0.25.0rc8`,` `,(0,p.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`about-sub`,children:`Privacy-first AI chat for AMD Ryzen AI PCs.`}),v.pinnedVersion&&(0,p.jsxs)(`p`,{className:`about-pinned-notice`,children:[`Auto-update paused (pinned to `,v.pinnedVersion,`).`,` `,(0,p.jsx)(`button`,{type:`button`,className:`about-resume-btn`,onClick:()=>{window.gaiaUpdater?.resumeUpdates().catch(e=>{n.system.error(`Resume updates failed`,e)})},children:`Resume updates`})]})]}),(0,p.jsx)(`div`,{className:`setting-actions`,children:(0,p.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(!0),children:`Roll back to a previous version`})})]}),ie&&(0,p.jsx)(ne,{onClose:()=>_(!1)})]})}function g({label:e,value:t,ok:n,hint:r}){return(0,p.jsxs)(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[(0,p.jsx)(`span`,{className:`status-label`,children:e}),(0,p.jsxs)(`div`,{className:`status-value-wrap`,children:[(0,p.jsx)(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&(0,p.jsx)(`span`,{className:`status-hint`,children:(0,p.jsx)(`code`,{children:r})})]})]})}export{h as AdvancedSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,n,o as r,r as i,t as a}from"./jsx-runtime-DVeaULmT.js";import{$t as o,Bt as s,G as c,Gt as l,K as u,Ot as d,St as f,U as p,Y as m,Z as h,Zt as g,et as _,ft as v,ht as y,mt as b,nt as x,pt as S,rt as C,tn as w,tt as T,ut as E}from"./index-CXbVMk3u.js";var D={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};D.node;var O=t(D),k={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};k.node;var A=t(k),j=a(),M=e(r(),1),N=i.api;function P(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;default:return null}}function F(e){let t=(0,M.useRef)(e);(0,M.useEffect)(()=>{t.current=e},[e]),(0,M.useEffect)(()=>{let e=`${n()}/connectors/events`,r=null,i=1e3,a=null,o=!1,s=()=>{o||(r=new EventSource(e),r.onopen=()=>{i=1e3},r.onmessage=e=>{try{let n=JSON.parse(e.data),r=P(n.type);if(r===null){N.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){N.warn(`connectors-sse: malformed event`,e)}},r.onerror=()=>{r?.close(),r=null,!o&&(a=setTimeout(s,i),i=Math.min(i*2,3e4))})};return s(),()=>{o=!0,a&&clearTimeout(a),r?.close()}},[])}function I(e){return e.type===`mcp_server`&&e.configured}function L({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);if((0,M.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;u.current&&!u.current.contains(t)&&d.current&&!d.current.contains(t)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=()=>{if(!u.current)return;let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),!I(e))return null;let f=e=>{e.stopPropagation(),e.preventDefault()},p=e=>{if(f(e),!n&&u.current){let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})}r(e=>!e)},m=async e=>{a(!0),s(null);try{await e(),r(!1),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`connector-tile-menu`,onClick:f,onKeyDown:f,children:[(0,j.jsx)(`button`,{ref:u,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:p,disabled:i,children:(0,j.jsx)(A,{size:14})}),n&&c&&(0,j.jsxs)(`div`,{ref:d,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:c.top,right:c.right},children:[e.enabled?(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>_(e.id)),disabled:i,children:`Disable`}):(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>x(e.id)),disabled:i,children:`Enable`}),(0,j.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void m(()=>T(e.id)),disabled:i,children:`Disconnect`}),o&&(0,j.jsx)(`div`,{className:`connector-tile-menu-error`,children:o})]})]})}var R={"https://www.googleapis.com/auth/gmail.readonly":`Read emails`,"https://www.googleapis.com/auth/gmail.modify":`Organize emails (archive, label, trash)`,"https://www.googleapis.com/auth/gmail.send":`Send emails on your behalf`,"https://www.googleapis.com/auth/gmail.compose":`Compose emails`,"https://www.googleapis.com/auth/calendar.readonly":`View calendar events`,"https://www.googleapis.com/auth/calendar.events":`Create & respond to calendar events`,"https://www.googleapis.com/auth/drive.readonly":`Read Google Drive files`,"https://www.googleapis.com/auth/drive.file":`Manage Drive files created by this app`,"https://www.googleapis.com/auth/spreadsheets.readonly":`Read Google Sheets`,"https://www.googleapis.com/auth/spreadsheets":`Edit Google Sheets`,openid:`Identify you`,email:`See your email address`,profile:`See your basic profile info`,"https://graph.microsoft.com/Mail.ReadWrite":`Read & organize Outlook mail (archive, label, trash)`,"https://graph.microsoft.com/Mail.Send":`Send Outlook mail on your behalf`,"https://graph.microsoft.com/Calendars.ReadWrite":`Create & respond to Outlook calendar events`,"https://graph.microsoft.com/Calendars.Read":`View Outlook calendar events`,"https://graph.microsoft.com/User.Read":`Read your basic Microsoft profile`};function z(e){return R[e]??e.split(/[/.:]/).pop()??e}var B=[`use`];function V(e){return!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_supported&&!e.revoked_remotely?`Disconnected locally, but the provider did not confirm the revoke (${String(e.revoke_error??`unknown error`)}). It may still show as connected in your account's app permissions.`:e.revoke_error?`Disconnected locally. ${String(e.revoke_error)}`:`Disconnected locally. This provider has no API to revoke access remotely — remove GAIA from your account's connected-apps page if you want to fully revoke it.`}function H(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(!0),[c,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(null),m=(0,M.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([y(),v()]);t(e),r(n),l(null)}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,M.useEffect)(()=>{m()},[m]);let h=e=>p(t=>t===e?null:e),g=(0,M.useCallback)(async e=>{try{let n=await C(e);t(t=>t.map(t=>t.id===e?n:t))}catch{m()}},[m]);return F((0,M.useCallback)(e=>{e.reason===`disconnected`&&d(V(e.payload)),e.connectorId?g(e.connectorId):m()},[g,m])),(0,j.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,j.jsx)(`p`,{className:`settings-help`,children:`Connect accounts and MCP servers so GAIA can use them on your behalf. Choose what GAIA may do with each one.`}),c&&(0,j.jsxs)(`div`,{className:`error-banner`,children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:c})]}),u&&(0,j.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>d(null),children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:u})]}),i?(0,j.jsx)(`div`,{className:`connectors-loading`,children:(0,j.jsx)(s,{size:16,className:`spin`})}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,j.jsx)(U,{connector:e,expanded:f===e.id,onToggle:()=>h(e.id),onChanged:()=>void g(e.id)},e.id))}),n.length>0&&(0,j.jsx)(J,{servers:n,expanded:f,onToggle:h})]})]})}function U({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,j.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,j.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,j.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`connector-status ok`,children:[(0,j.jsx)(g,{size:12}),e.account_id??`Configured`]}):(0,j.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,j.jsx)(L,{connector:e,onChanged:r}),(0,j.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,j.jsx)(W,{connector:e,onChanged:r}):(0,j.jsx)(K,{connector:e,onChanged:r}),e.configured&&(0,j.jsx)(X,{connectorId:e.id,connectorType:e.type})]})]})}function W({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),[f,p]=(0,M.useState)({}),[h,g]=(0,M.useState)(null),{agents:_}=d(),v=_.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),y=v.map(e=>e.namespaced_agent_id).join(`,`),[b,x]=(0,M.useState)(()=>new Set);(0,M.useEffect)(()=>{x(new Set(v.map(e=>e.namespaced_agent_id)))},[y]);let S=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),C=()=>[...b];(0,M.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let w=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},E=async()=>{r(!0),a(null);try{let t=await c(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());w(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},D=async()=>{r(!0),a(null),g(null);try{let t=await u(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());g(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,M.useEffect)(()=>{e.configured&&g(null)},[e.configured]),F((0,M.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),g(null)):t.reason===`oauth_completed`&&g(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await T(e.id),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},k=async()=>{let n=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!f[e.key]?.trim()).map(e=>e.label);if(n.length){a(`Required: ${n.join(`, `)}`);return}r(!0),a(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await m(e.id,{...f,scopes:n,grant_agents:C()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&w(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},A=e.oauth_setup_fields??[],N=e.configurable===!1&&!e.configured&&A.length>0;return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),N&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsx)(`p`,{className:`connector-desc`,children:`First-time setup — provide your OAuth client credentials below. They’re stored encrypted in your OS keyring and reused for future connections.`}),A.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:f[e.key]??``,onChange:t=>p(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&v.length>0&&(0,j.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),v.map(e=>(0,j.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b.has(e.namespaced_agent_id),onChange:()=>S(e.namespaced_agent_id)}),(0,j.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!N&&(0,j.jsx)(G,{connector:e,onChanged:t}),i&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,i]}),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):`Disconnect`}):N?(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void k(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,j.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n||h!==null,onClick:()=>void E(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Connect`]})}),e.supports_device_code&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n||h!==null,onClick:()=>void D(),title:`Enter a short code at a URL — no browser redirect or app registration needed`,children:`Sign in with a code`})]}),(e.docs_url||e.product_url)&&(0,j.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,j.jsx)(l,{size:11})]})]}),h&&!e.configured&&(0,j.jsxs)(`div`,{className:`device-code-block`,children:[(0,j.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,j.jsx)(`a`,{href:h.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),w(h.verification_uri)},children:h.verification_uri}),` `,`and enter this code:`]}),(0,j.jsxs)(`div`,{className:`device-code-value`,children:[(0,j.jsx)(`code`,{children:h.user_code}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(h.user_code),title:`Copy code`,children:`Copy`})]}),(0,j.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,j.jsx)(s,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>g(null),children:`Cancel`})]})]})}function G({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)({}),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),h=e.oauth_setup_fields??[];if(h.length===0)return null;let _=e.oauth_client,v=_?.source===`keyring`?`Saved client: ${_.client_id}`:_?.source===`env`?`From environment: ${_.client_id}`:`No OAuth client configured`,y=async()=>{if(!i.client_id?.trim()){p(`Client ID is required.`);return}l(!0),p(null),d(!1);try{await m(e.id,{...Object.fromEntries(Object.entries(i).map(([e,t])=>[e,t.trim()])),save_only:!0}),d(!0),a({}),t(),setTimeout(()=>d(!1),2200)}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,j.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,j.jsx)(O,{size:12}):(0,j.jsx)(w,{size:12}),(0,j.jsx)(`span`,{children:`OAuth client`}),(0,j.jsx)(`span`,{className:`oauth-client-editor__status`,children:v})]}),n&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,j.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),h.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&_?.source===`keyring`&&_.has_secret?`••••••••`:e.placeholder,value:i[e.key]??``,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),f&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,f]}),(0,j.jsx)(`div`,{className:`configure-actions`,children:(0,j.jsx)(`button`,{className:`btn-model-save${u?` saved`:``}`,disabled:c||!i.client_id?.trim(),onClick:()=>void y(),children:c?(0,j.jsx)(s,{size:12,className:`spin`}):u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save client`})})]})]})}function K({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,M.useState)(!1),[c,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(null);(0,M.useEffect)(()=>{r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let p=async()=>{let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.trim()!==``));if(Object.keys(r).length!==0){a(!0),f(null),u(!1);try{await m(e.id,r),u(!0),t(),setTimeout(()=>u(!1),2200)}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}}},h=async()=>{a(!0),f(null);try{await T(e.id),r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}},v=async()=>{a(!0),f(null);try{e.enabled?await _(e.id):await x(e.id),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),d&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,d]}),e.configured&&(0,j.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,j.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void v(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,j.jsx)(`p`,{className:`connector-toggle-help`,children:`Credentials and per-agent grants are preserved. Re-enable to make this server's tools available again.`}),e.mcp_env_keys.map(t=>(0,j.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,j.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,j.jsx)(`input`,{type:`password`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:`Enter value`,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`})]},t)),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[(0,j.jsx)(`button`,{className:`btn-model-save${c?` saved`:``}`,disabled:i||Object.values(n).every(e=>e.trim()===``),onClick:()=>void p(),children:i?(0,j.jsx)(s,{size:12,className:`spin`}):c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save`}),e.configured&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void h(),children:`Disconnect`}),e.product_url&&(0,j.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,j.jsx)(l,{size:11})]})]})]})}function q({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=e.required_connections?.find(e=>e.connector_id===t),a=e.namespaced_agent_id;if(!i||!a)return null;let[s,c]=(0,M.useState)(()=>new Set(n)),[l,u]=(0,M.useState)(null),[d,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{c(new Set(n))},[n.join(`,`)]);let m=async e=>{if(l!==null)return;let i=new Set(s);i.has(e)?i.delete(e):i.add(e),c(i),u(e),p(null);try{i.size===0?await f(t,a):await E(t,a,[...i]),r()}catch(e){c(new Set(n)),p(e instanceof Error?e.message:String(e))}finally{u(null)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:z(e)}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e),onChange:()=>void m(e),disabled:l!==null}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]},e))}),d&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,d]})]})}function J({servers:e,expanded:t,onToggle:n}){return(0,j.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,j.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,j.jsx)(Y,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function Y({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,j.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,j.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,j.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,j.jsx)(g,{size:11}),` Active`]}),(0,j.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,j.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,j.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,j.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,j.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,j.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function X({connectorId:e,connectorType:t}){let{agents:n}=d(),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({}),[s,c]=(0,M.useState)(!0),l=(0,M.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([b(e),S(e)]);i(t),o(n)}catch{i({}),o({})}finally{c(!1)}},[e]);if((0,M.useEffect)(()=>{l()},[l]),F((0,M.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&l()},[e,l])),s)return null;let u=n.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),f=t===`mcp_server`?n.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return(0,j.jsxs)(`div`,{className:`connection-grants`,children:[(0,j.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),u.length===0?(0,j.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):u.map(t=>(0,j.jsx)(q,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},t.namespaced_agent_id)),f.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,j.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),f.map(t=>(0,j.jsx)(Z,{agent:t,connectorId:e,active:!!a[t.namespaced_agent_id],grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},`activation-${t.namespaced_agent_id}`))]})]})}function Z({agent:e,connectorId:t,active:n,grantedScopes:r,onChanged:i}){let a=e.required_connections?.find(e=>e.connector_id===t),s=e.namespaced_agent_id;if(!s)return null;let[c,l]=(0,M.useState)(n),[u,d]=(0,M.useState)(!1),[f,m]=(0,M.useState)(null);(0,M.useEffect)(()=>{l(n)},[n]);let g=async()=>{if(u)return;let e=!c;l(e),d(!0),m(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...B]:void 0;await p(t,s,e)}else await h(t,s);i()}catch(e){l(n),m(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:c?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>void g(),disabled:u}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]})}),f&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,f]})]})}function Q(){return(0,j.jsxs)(`div`,{className:`settings-pane`,children:[(0,j.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,j.jsx)(H,{})]})}export{Q as ConnectorsPane};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,n,o as r,r as i,t as a}from"./jsx-runtime-DVeaULmT.js";import{$t as o,Bt as s,G as c,Gt as l,K as u,Ot as d,St as f,U as p,Y as m,Z as h,Zt as g,et as _,ft as v,ht as y,mt as b,nt as x,pt as S,rt as C,tn as w,tt as T,ut as E}from"./index-D00FJoXi.js";var D={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};D.node;var O=t(D),k={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};k.node;var A=t(k),j=a(),M=e(r(),1),N=i.api;function P(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;default:return null}}function F(e){let t=(0,M.useRef)(e);(0,M.useEffect)(()=>{t.current=e},[e]),(0,M.useEffect)(()=>{let e=`${n()}/connectors/events`,r=null,i=1e3,a=null,o=!1,s=()=>{o||(r=new EventSource(e),r.onopen=()=>{i=1e3},r.onmessage=e=>{try{let n=JSON.parse(e.data),r=P(n.type);if(r===null){N.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){N.warn(`connectors-sse: malformed event`,e)}},r.onerror=()=>{r?.close(),r=null,!o&&(a=setTimeout(s,i),i=Math.min(i*2,3e4))})};return s(),()=>{o=!0,a&&clearTimeout(a),r?.close()}},[])}function I(e){return e.type===`mcp_server`&&e.configured}function L({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);if((0,M.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;u.current&&!u.current.contains(t)&&d.current&&!d.current.contains(t)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=()=>{if(!u.current)return;let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),!I(e))return null;let f=e=>{e.stopPropagation(),e.preventDefault()},p=e=>{if(f(e),!n&&u.current){let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})}r(e=>!e)},m=async e=>{a(!0),s(null);try{await e(),r(!1),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`connector-tile-menu`,onClick:f,onKeyDown:f,children:[(0,j.jsx)(`button`,{ref:u,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:p,disabled:i,children:(0,j.jsx)(A,{size:14})}),n&&c&&(0,j.jsxs)(`div`,{ref:d,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:c.top,right:c.right},children:[e.enabled?(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>_(e.id)),disabled:i,children:`Disable`}):(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>x(e.id)),disabled:i,children:`Enable`}),(0,j.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void m(()=>T(e.id)),disabled:i,children:`Disconnect`}),o&&(0,j.jsx)(`div`,{className:`connector-tile-menu-error`,children:o})]})]})}var R={"https://www.googleapis.com/auth/gmail.readonly":`Read emails`,"https://www.googleapis.com/auth/gmail.modify":`Organize emails (archive, label, trash)`,"https://www.googleapis.com/auth/gmail.send":`Send emails on your behalf`,"https://www.googleapis.com/auth/gmail.compose":`Compose emails`,"https://www.googleapis.com/auth/calendar.readonly":`View calendar events`,"https://www.googleapis.com/auth/calendar.events":`Create & respond to calendar events`,"https://www.googleapis.com/auth/drive.readonly":`Read Google Drive files`,"https://www.googleapis.com/auth/drive.file":`Manage Drive files created by this app`,"https://www.googleapis.com/auth/spreadsheets.readonly":`Read Google Sheets`,"https://www.googleapis.com/auth/spreadsheets":`Edit Google Sheets`,openid:`Identify you`,email:`See your email address`,profile:`See your basic profile info`,"https://graph.microsoft.com/Mail.ReadWrite":`Read & organize Outlook mail (archive, label, trash)`,"https://graph.microsoft.com/Mail.Send":`Send Outlook mail on your behalf`,"https://graph.microsoft.com/Calendars.ReadWrite":`Create & respond to Outlook calendar events`,"https://graph.microsoft.com/Calendars.Read":`View Outlook calendar events`,"https://graph.microsoft.com/User.Read":`Read your basic Microsoft profile`};function z(e){return R[e]??e.split(/[/.:]/).pop()??e}var B=[`use`];function V(e){return!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_supported&&!e.revoked_remotely?`Disconnected locally, but the provider did not confirm the revoke (${String(e.revoke_error??`unknown error`)}). It may still show as connected in your account's app permissions.`:e.revoke_error?`Disconnected locally. ${String(e.revoke_error)}`:`Disconnected locally. This provider has no API to revoke access remotely — remove GAIA from your account's connected-apps page if you want to fully revoke it.`}function H(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(!0),[c,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(null),m=(0,M.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([y(),v()]);t(e),r(n),l(null)}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,M.useEffect)(()=>{m()},[m]);let h=e=>p(t=>t===e?null:e),g=(0,M.useCallback)(async e=>{try{let n=await C(e);t(t=>t.map(t=>t.id===e?n:t))}catch{m()}},[m]);return F((0,M.useCallback)(e=>{e.reason===`disconnected`&&d(V(e.payload)),e.connectorId?g(e.connectorId):m()},[g,m])),(0,j.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,j.jsx)(`p`,{className:`settings-help`,children:`Connect accounts and MCP servers so GAIA can use them on your behalf. Choose what GAIA may do with each one.`}),c&&(0,j.jsxs)(`div`,{className:`error-banner`,children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:c})]}),u&&(0,j.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>d(null),children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:u})]}),i?(0,j.jsx)(`div`,{className:`connectors-loading`,children:(0,j.jsx)(s,{size:16,className:`spin`})}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,j.jsx)(U,{connector:e,expanded:f===e.id,onToggle:()=>h(e.id),onChanged:()=>void g(e.id)},e.id))}),n.length>0&&(0,j.jsx)(J,{servers:n,expanded:f,onToggle:h})]})]})}function U({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,j.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,j.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,j.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`connector-status ok`,children:[(0,j.jsx)(g,{size:12}),e.account_id??`Configured`]}):(0,j.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,j.jsx)(L,{connector:e,onChanged:r}),(0,j.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,j.jsx)(W,{connector:e,onChanged:r}):(0,j.jsx)(K,{connector:e,onChanged:r}),e.configured&&(0,j.jsx)(X,{connectorId:e.id,connectorType:e.type})]})]})}function W({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),[f,p]=(0,M.useState)({}),[h,g]=(0,M.useState)(null),{agents:_}=d(),v=_.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),y=v.map(e=>e.namespaced_agent_id).join(`,`),[b,x]=(0,M.useState)(()=>new Set);(0,M.useEffect)(()=>{x(new Set(v.map(e=>e.namespaced_agent_id)))},[y]);let S=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),C=()=>[...b];(0,M.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let w=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},E=async()=>{r(!0),a(null);try{let t=await c(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());w(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},D=async()=>{r(!0),a(null),g(null);try{let t=await u(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());g(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,M.useEffect)(()=>{e.configured&&g(null)},[e.configured]),F((0,M.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),g(null)):t.reason===`oauth_completed`&&g(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await T(e.id),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},k=async()=>{let n=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!f[e.key]?.trim()).map(e=>e.label);if(n.length){a(`Required: ${n.join(`, `)}`);return}r(!0),a(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await m(e.id,{...f,scopes:n,grant_agents:C()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&w(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},A=e.oauth_setup_fields??[],N=e.configurable===!1&&!e.configured&&A.length>0;return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),N&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsx)(`p`,{className:`connector-desc`,children:`First-time setup — provide your OAuth client credentials below. They’re stored encrypted in your OS keyring and reused for future connections.`}),A.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:f[e.key]??``,onChange:t=>p(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&v.length>0&&(0,j.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),v.map(e=>(0,j.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b.has(e.namespaced_agent_id),onChange:()=>S(e.namespaced_agent_id)}),(0,j.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!N&&(0,j.jsx)(G,{connector:e,onChanged:t}),i&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,i]}),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):`Disconnect`}):N?(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void k(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,j.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n||h!==null,onClick:()=>void E(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Connect`]})}),e.supports_device_code&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n||h!==null,onClick:()=>void D(),title:`Enter a short code at a URL — no browser redirect or app registration needed`,children:`Sign in with a code`})]}),(e.docs_url||e.product_url)&&(0,j.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,j.jsx)(l,{size:11})]})]}),h&&!e.configured&&(0,j.jsxs)(`div`,{className:`device-code-block`,children:[(0,j.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,j.jsx)(`a`,{href:h.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),w(h.verification_uri)},children:h.verification_uri}),` `,`and enter this code:`]}),(0,j.jsxs)(`div`,{className:`device-code-value`,children:[(0,j.jsx)(`code`,{children:h.user_code}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(h.user_code),title:`Copy code`,children:`Copy`})]}),(0,j.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,j.jsx)(s,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>g(null),children:`Cancel`})]})]})}function G({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)({}),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),h=e.oauth_setup_fields??[];if(h.length===0)return null;let _=e.oauth_client,v=_?.source===`keyring`?`Saved client: ${_.client_id}`:_?.source===`env`?`From environment: ${_.client_id}`:`No OAuth client configured`,y=async()=>{if(!i.client_id?.trim()){p(`Client ID is required.`);return}l(!0),p(null),d(!1);try{await m(e.id,{...Object.fromEntries(Object.entries(i).map(([e,t])=>[e,t.trim()])),save_only:!0}),d(!0),a({}),t(),setTimeout(()=>d(!1),2200)}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,j.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,j.jsx)(O,{size:12}):(0,j.jsx)(w,{size:12}),(0,j.jsx)(`span`,{children:`OAuth client`}),(0,j.jsx)(`span`,{className:`oauth-client-editor__status`,children:v})]}),n&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,j.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),h.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&_?.source===`keyring`&&_.has_secret?`••••••••`:e.placeholder,value:i[e.key]??``,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),f&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,f]}),(0,j.jsx)(`div`,{className:`configure-actions`,children:(0,j.jsx)(`button`,{className:`btn-model-save${u?` saved`:``}`,disabled:c||!i.client_id?.trim(),onClick:()=>void y(),children:c?(0,j.jsx)(s,{size:12,className:`spin`}):u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save client`})})]})]})}function K({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,M.useState)(!1),[c,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(null);(0,M.useEffect)(()=>{r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let p=async()=>{let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.trim()!==``));if(Object.keys(r).length!==0){a(!0),f(null),u(!1);try{await m(e.id,r),u(!0),t(),setTimeout(()=>u(!1),2200)}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}}},h=async()=>{a(!0),f(null);try{await T(e.id),r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}},v=async()=>{a(!0),f(null);try{e.enabled?await _(e.id):await x(e.id),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),d&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,d]}),e.configured&&(0,j.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,j.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void v(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,j.jsx)(`p`,{className:`connector-toggle-help`,children:`Credentials and per-agent grants are preserved. Re-enable to make this server's tools available again.`}),e.mcp_env_keys.map(t=>(0,j.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,j.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,j.jsx)(`input`,{type:`password`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:`Enter value`,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`})]},t)),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[(0,j.jsx)(`button`,{className:`btn-model-save${c?` saved`:``}`,disabled:i||Object.values(n).every(e=>e.trim()===``),onClick:()=>void p(),children:i?(0,j.jsx)(s,{size:12,className:`spin`}):c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save`}),e.configured&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void h(),children:`Disconnect`}),e.product_url&&(0,j.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,j.jsx)(l,{size:11})]})]})]})}function q({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=e.required_connections?.find(e=>e.connector_id===t),a=e.namespaced_agent_id;if(!i||!a)return null;let[s,c]=(0,M.useState)(()=>new Set(n)),[l,u]=(0,M.useState)(null),[d,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{c(new Set(n))},[n.join(`,`)]);let m=async e=>{if(l!==null)return;let i=new Set(s);i.has(e)?i.delete(e):i.add(e),c(i),u(e),p(null);try{i.size===0?await f(t,a):await E(t,a,[...i]),r()}catch(e){c(new Set(n)),p(e instanceof Error?e.message:String(e))}finally{u(null)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:z(e)}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e),onChange:()=>void m(e),disabled:l!==null}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]},e))}),d&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,d]})]})}function J({servers:e,expanded:t,onToggle:n}){return(0,j.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,j.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,j.jsx)(Y,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function Y({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,j.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,j.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,j.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,j.jsx)(g,{size:11}),` Active`]}),(0,j.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,j.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,j.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,j.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,j.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,j.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function X({connectorId:e,connectorType:t}){let{agents:n}=d(),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({}),[s,c]=(0,M.useState)(!0),l=(0,M.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([b(e),S(e)]);i(t),o(n)}catch{i({}),o({})}finally{c(!1)}},[e]);if((0,M.useEffect)(()=>{l()},[l]),F((0,M.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&l()},[e,l])),s)return null;let u=n.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),f=t===`mcp_server`?n.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return(0,j.jsxs)(`div`,{className:`connection-grants`,children:[(0,j.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),u.length===0?(0,j.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):u.map(t=>(0,j.jsx)(q,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},t.namespaced_agent_id)),f.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,j.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),f.map(t=>(0,j.jsx)(Z,{agent:t,connectorId:e,active:!!a[t.namespaced_agent_id],grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},`activation-${t.namespaced_agent_id}`))]})]})}function Z({agent:e,connectorId:t,active:n,grantedScopes:r,onChanged:i}){let a=e.required_connections?.find(e=>e.connector_id===t),s=e.namespaced_agent_id;if(!s)return null;let[c,l]=(0,M.useState)(n),[u,d]=(0,M.useState)(!1),[f,m]=(0,M.useState)(null);(0,M.useEffect)(()=>{l(n)},[n]);let g=async()=>{if(u)return;let e=!c;l(e),d(!0),m(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...B]:void 0;await p(t,s,e)}else await h(t,s);i()}catch(e){l(n),m(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:c?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>void g(),disabled:u}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]})}),f&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,f]})]})}function Q(){return(0,j.jsxs)(`div`,{className:`settings-pane`,children:[(0,j.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,j.jsx)(H,{})]})}export{Q as ConnectorsPane};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{$t as a,B as o,Dt as s,Et as ee,Ft as te,H as c,Ht as l,J as u,Lt as d,Nt as f,Ot as p,Q as ne,V as re,W as m,Wt as h,Xt as g,gt as _,it as v,jt as y,t as b,vt as x,xt as S}from"./index-D00FJoXi.js";var C={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`]};C.node;var w=t(C),T={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`}]]};T.node;var ie=t(T),E={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`}]]};E.node;var ae=t(E),D={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`}]]};D.node;var oe=t(D),O=e(n(),1),k=i();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 A(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 j(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 M(){let{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:i,currentSessionId:C,sessions:T,updateSessionInList:E,draftDocumentIds:D,addDraftDocuments:M,removeDraftDocument:N}=p(),P=T.find(e=>e.id===C)??null,[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,W]=(0,O.useState)(null),[G,K]=(0,O.useState)(new Set),q=(0,O.useRef)(new Map),[,ce]=(0,O.useState)(0);(0,O.useEffect)(()=>{r.doc.info(`Loading document library...`);let e=r.doc.time();_().then(n=>{let i=n.documents||[];t(i),r.doc.timed(`Loaded ${i.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{r.doc.error(`Failed to load documents`,e),t([])})},[t]);let J=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,O.useEffect)(()=>{if(!J)return;let e=p.getState().documents;for(let t of e)(t.indexing_status===`indexing`||t.indexing_status===`pending`)&&!q.current.has(t.id)&&q.current.set(t.id,Date.now());let n=!1,r=setInterval(async()=>{if(ce(e=>e+1),!n){n=!0;try{let e=p.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await v(n.id);if(e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){q.current.delete(n.id);let e=await _();t(e.documents||[]);break}}catch{}}finally{n=!1}}},2e3);return()=>clearInterval(r)},[J,t]),(0,O.useEffect)(()=>{let t=new Set(e.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let e of q.current.keys())t.has(e)||q.current.delete(e)},[e]),(0,O.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await _()).documents||[],n=p.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),r.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let le=e.reduce((e,t)=>e+t.file_size,0),Y=e.reduce((e,t)=>e+t.chunk_count,0),X=(0,O.useCallback)(async(e,n)=>{let i=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;if(i&&!c(i)){let t=re(i),n=t?t.message:`The file type "${i}" is not supported for indexing.`;r.doc.warn(`Unsupported file type: ${e} (${i})`),W({filename:e,error:n});return}r.doc.info(`Indexing document: ${e}`);let a=r.doc.time();R(!0),B(`Indexing ${e}...`),W(null);try{let i=await n();if(r.doc.timed(`Indexed "${e}": ${i?.chunk_count||`?`} chunks`,a),C&&i?.id)try{await m(C,i.id);let t=p.getState().sessions.find(e=>e.id===C)?.document_ids??[];t.includes(i.id)||E(C,{document_ids:[...t,i.id]}),r.doc.info(`Auto-attached "${e}" to session ${C}`)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}else i?.id&&(M([i.id]),r.doc.info(`"${e}" will be attached to the next new chat`));let o=await _();t(o.documents||[]),B(``)}catch(t){r.doc.error(`Failed to index "${e}"`,t);let n=t instanceof Error?t.message:`Upload failed`;W({filename:e,error:n}),B(``)}finally{R(!1)}},[C,E,t,M]),Z=(0,O.useCallback)(async(e,t)=>{await X(t,()=>s(e))},[X]),Q=(0,O.useCallback)(async e=>{await X(e.name,()=>ee(e))},[X]),$=(0,O.useCallback)(async e=>{e.preventDefault(),I(!1);let t=Array.from(e.dataTransfer.files);r.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),ue=(0,O.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Deleting document: ${i?.filename||n}`);try{await ne(n),q.current.delete(n),N(n),t(e.filter(e=>e.id!==n)),r.doc.info(`Deleted document: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to delete document: ${i?.filename||n}`,e)}},[e,t,N]),de=(0,O.useCallback)(async(e,t)=>{r.doc.info(`Opening folder for: ${e}`);try{await x(e,!0)}catch(e){r.doc.error(`Failed to open folder for: ${t}`,e)}},[]),fe=(0,O.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Cancelling indexing for: ${i?.filename||n}`);try{await u(n),q.current.delete(n);let e=await _();t(e.documents||[]),r.doc.info(`Cancelled indexing for: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to cancel indexing: ${i?.filename||n}`,e)}},[e,t]),pe=(0,O.useCallback)(async n=>{if(G.has(n))return;let i=e.find(e=>e.id===n);r.doc.info(`Reindexing document: ${i?.filename||n}`),K(e=>new Set(e).add(n));try{await S(n),r.doc.info(`Reindex complete for: ${i?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);r.doc.error(`Reindex failed for: ${i?.filename||n}`,e),W({filename:i?.filename||n,error:t})}finally{try{let e=await _();t(e.documents||[])}catch(e){r.doc.error(`Failed to refresh documents after reindex`,e)}K(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,G]),me=(0,O.useCallback)(async t=>{let n=e.find(e=>e.id===t);if(!C){M([t]),r.doc.info(`"${n?.filename||t}" will be attached to the next new chat`);return}r.doc.info(`Attaching document to session: ${n?.filename||t}`);try{await m(C,t);let e=p.getState().sessions.find(e=>e.id===C)?.document_ids??[];e.includes(t)||E(C,{document_ids:[...e,t]}),r.doc.info(`Attached "${n?.filename||t}" to session ${C}`)}catch(e){r.doc.error(`Failed to attach document to session: ${n?.filename||t}`,e)}},[C,e,E,M]),he=(0,O.useCallback)(async e=>{e.preventDefault(),V.trim()&&(r.doc.info(`Indexing from path input: ${V.trim()}`),await Z(V.trim(),V.trim().split(/[\\/]/).pop()||`file`),H(``))},[V,Z]),ge=e=>{let t=e.indexing_status||`complete`,n=q.current.get(e.id),r=e.indexed_at?A(e.indexed_at):``,i=e.indexed_at?j(e.indexed_at):``;switch(t){case`indexing`:case`pending`:return(0,k.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,k.jsxs)(`div`,{className:`doc-indexing-bar`,children:[(0,k.jsx)(`div`,{className:`doc-indexing-bar-track`,children:(0,k.jsx)(`div`,{className:`doc-indexing-bar-fill`})}),(0,k.jsxs)(`span`,{className:`doc-indexing-label`,children:[(0,k.jsx)(ae,{size:12,className:`doc-spin`}),`Indexing`,n?` (${se(n)})`:`...`]})]}),(0,k.jsxs)(`button`,{className:`btn-cancel`,onClick:t=>{t.stopPropagation(),fe(e.id)},title:`Cancel indexing`,"aria-label":`Cancel indexing ${e.filename}`,children:[(0,k.jsx)(w,{size:14}),`Cancel`]})]});case`failed`:return(0,k.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,k.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,k.jsx)(a,{size:12}),` Failed`]}),(0,k.jsxs)(`button`,{className:`btn-retry`,onClick:t=>{t.stopPropagation(),pe(e.id)},title:`Retry indexing`,"aria-label":`Retry indexing ${e.filename}`,disabled:G.has(e.id),children:[(0,k.jsx)(oe,{size:14}),G.has(e.id)?`Retrying…`:`Retry`]})]});case`cancelled`:return(0,k.jsxs)(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[(0,k.jsx)(w,{size:12}),` Cancelled`]});case`missing`:return(0,k.jsxs)(`span`,{className:`doc-status-badge doc-status-missing`,children:[(0,k.jsx)(a,{size:12}),` File missing`]});default:return(0,k.jsxs)(`span`,{className:`doc-meta`,children:[b(e.file_size),` · `,e.chunk_count,` chunk`,e.chunk_count===1?``:`s`,r&&(0,k.jsxs)(`span`,{className:`doc-timestamp`,title:`Indexed: ${i}`,children:[(0,k.jsx)(g,{size:10}),r]})]})}};return(0,k.jsx)(`div`,{className:`modal-overlay`,onClick:()=>n(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`Document Library`,children:(0,k.jsxs)(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:`Document Library`}),(0,k.jsx)(`button`,{className:`btn-icon`,onClick:()=>n(!1),"aria-label":`Close document library`,children:(0,k.jsx)(y,{size:18})})]}),(0,k.jsxs)(`div`,{className:`modal-body`,children:[(0,k.jsx)(`div`,{className:`drop-zone ${F?`drag-over`:``} ${L?`uploading`:``}`,onDragOver:e=>{e.preventDefault(),I(!0)},onDragLeave:()=>I(!1),onDrop:$,children:L?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`upload-spinner`}),(0,k.jsx)(`p`,{children:z})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f,{size:32,strokeWidth:1.5}),(0,k.jsx)(`p`,{children:`Drop files here to index`}),(0,k.jsx)(`span`,{className:`drop-hint`,children:`PDF, TXT, MD, code files, and 50+ formats`})]})}),(0,k.jsxs)(`form`,{className:`path-input-form`,onSubmit:he,children:[(0,k.jsx)(l,{size:16,className:`path-icon`}),(0,k.jsx)(`input`,{type:`text`,className:`path-input`,value:V,onChange:e=>H(e.target.value),placeholder:`Or enter file path: C:\\docs\\manual.pdf`,"aria-label":`File path to index`}),(0,k.jsx)(`button`,{type:`submit`,className:`btn-secondary`,disabled:!V.trim()||L,children:`Index`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(!1),i(!0)},title:`Browse files on this computer`,children:[(0,k.jsx)(d,{size:14}),`Browse Files`]})]}),U&&(0,k.jsx)(o,{filename:U.filename,error:U.error,onDismiss:()=>W(null)}),e.length>0&&(0,k.jsxs)(`div`,{className:`doc-stats`,children:[(0,k.jsxs)(`span`,{children:[e.length,` document`,e.length===1?``:`s`]}),(0,k.jsx)(`span`,{children:`·`}),(0,k.jsxs)(`span`,{children:[Y,` chunk`,Y===1?``:`s`]}),(0,k.jsx)(`span`,{children:`·`}),(0,k.jsx)(`span`,{children:b(le)})]}),(0,k.jsxs)(`div`,{className:`doc-list`,children:[e.length===0&&!L&&(0,k.jsxs)(`div`,{className:`empty-docs`,children:[(0,k.jsx)(h,{size:32,strokeWidth:1}),(0,k.jsx)(`p`,{children:`No documents indexed yet`}),(0,k.jsx)(`span`,{children:`Drop files above or enter a file path`})]}),e.map(e=>(0,k.jsxs)(`div`,{className:`doc-row ${e.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[(0,k.jsxs)(`div`,{className:`doc-info`,children:[(0,k.jsx)(`span`,{className:`doc-name`,children:e.filename}),ge(e)]}),(0,k.jsxs)(`div`,{className:`doc-row-actions`,children:[e.filepath&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>de(e.filepath,e.filename),title:`Open folder: ${e.filepath}`,"aria-label":`Open containing folder for ${e.filename}`,children:(0,k.jsx)(l,{size:14})}),e.indexing_status===`complete`&&!(C?P?.document_ids?.includes(e.id):D.includes(e.id))&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>me(e.id),title:C?`Use in current session`:`Use in your next chat`,"aria-label":C?`Attach ${e.filename} to current session`:`Attach ${e.filename} to your next chat`,children:(0,k.jsx)(ie,{size:14})}),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>ue(e.id),title:`Remove`,"aria-label":`Remove ${e.filename}`,children:(0,k.jsx)(te,{size:14})})]})]},e.id))]})]})]})})}export{M as DocumentLibrary};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{B as a,Ct as o,Dt as s,H as c,Ht as l,Kt as u,Lt as d,Nt as f,Ot as p,Ut as m,V as h,W as ee,Wt as g,bt as te,dt as _,en as ne,gt as v,in as re,jt as y,q as ie,rn as ae,t as oe}from"./index-D00FJoXi.js";var b={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};b.node;var x=t(b),S={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};S.node;var se=t(S),C={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};C.node;var w=t(C),T={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};T.node;var ce=t(T),E={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};E.node;var D=t(E),O={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};O.node;var k=t(O),A={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};A.node;var j=t(A),M=e(n(),1),N=i();function le(e){if(e.type===`folder`)return(0,N.jsx)(w,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?(0,N.jsx)(j,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?(0,N.jsx)(x,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?(0,N.jsx)(g,{size:16}):(0,N.jsx)(m,{size:16})}function ue(e){if(!e)return``;let t=new Date(e),n=new Date,r=n.getTime()-t.getTime(),i=Math.floor(r/36e5);if(i<1)return`Just now`;if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})}function de(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function fe(e){switch(e){case`home`:return(0,N.jsx)(D,{size:14});case`desktop`:return(0,N.jsx)(k,{size:14});case`documents`:return(0,N.jsx)(g,{size:14});case`download`:return(0,N.jsx)(u,{size:14});default:return(0,N.jsx)(w,{size:14})}}var pe=[{label:`All Files`,value:``},{label:`Documents`,value:`pdf,doc,docx,txt,md`},{label:`Spreadsheets`,value:`csv,xlsx,xls,tsv`},{label:`Code`,value:`py,js,ts,java,c,cpp,go,rs,rb,sh`},{label:`Data`,value:`json,xml,yaml,yml,csv,tsv`}];async function P(e,t,n,i){let a=[],o=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!c(e)?o.push(t):a.push(t)}let l=[],u=[],d=0,f=``,m=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(m.has(e)){let t=await _(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),n.length>0&&(n.forEach(e=>l.push(e)),u.push(e))}else{let t=await s(e);t?.id&&(l.push(t.id),u.push(e))}}catch(e){d++,f=e instanceof Error?e.message:`Unknown error`}if(n&&l.length>0){let e=[];for(let t of l)try{await ee(n,t),e.push(t)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}let t=p.getState().sessions.find(e=>e.id===n)?.document_ids??[],a=e.filter(e=>!t.includes(e));a.length>0&&i(n,{document_ids:[...t,...a]})}else l.length>0&&p.getState().addDraftDocuments(l);if(l.length>0)try{let e=await v();p.getState().setDocuments(e.documents||[])}catch(e){r.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:l,supported:a,succeededFiles:u,unsupported:o,failed:d,lastError:f}}function F(){let{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n,setPendingPrompt:i}=p(),[s,u]=(0,M.useState)(``),[m,ee]=(0,M.useState)(null),[g,_]=(0,M.useState)([]),[v,b]=(0,M.useState)([]),[x,S]=(0,M.useState)(!1),[C,w]=(0,M.useState)(null),[T,E]=(0,M.useState)(``),[D,O]=(0,M.useState)(null),[k,A]=(0,M.useState)([]),[j,F]=(0,M.useState)(!1),[I,L]=(0,M.useState)(!1),[R,me]=(0,M.useState)(``),[z,B]=(0,M.useState)(new Set),[V,H]=(0,M.useState)(null),[he,U]=(0,M.useState)(!1),[W,G]=(0,M.useState)(new Set),[K,q]=(0,M.useState)(null),J=(0,M.useRef)(null),[Y,X]=(0,M.useState)(null),Z=(0,M.useCallback)(async e=>{S(!0),w(null),O(null),E(``),A([]);try{let t=await ie(e);u(t.current_path),ee(t.parent_path),_(t.entries),t.quick_links.length>0&&b(t.quick_links),r.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;w(t),r.ui.error(`Browse failed`,e)}finally{S(!1)}},[]);(0,M.useEffect)(()=>{Z()},[Z]),(0,M.useEffect)(()=>()=>{J.current&&clearTimeout(J.current)},[]);let Q=(0,M.useCallback)(async()=>{if(!T.trim()){O(null),A([]);return}L(!0),w(null);try{let e=await o(T.trim(),R||void 0,30);O(e.results),A(e.searched_locations??[]),F(e.truncated===!0),r.ui.info(`Search "${T}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;w(t),r.ui.error(`Search failed`,e)}finally{L(!1)}},[T,R]),ge=e=>{e.key===`Enter`&&Q()},_e=(0,M.useCallback)(e=>{e.type===`folder`&&(Z(e.path),B(new Set),H(null))},[Z]),ve=(0,M.useCallback)(async e=>{U(!0);try{let t=await te(e);H(t)}catch(e){r.ui.error(`Preview failed`,e)}finally{U(!1)}},[]),ye=(0,M.useCallback)(e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),be=(0,M.useCallback)(async()=>{if(z.size===0)return;let e=Array.from(z);if(X(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||c(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=h(r);X({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`});return}G(new Set(e)),q(`Indexing ${e.length} file(s)...`);try{let r=await P(e,g,t,n);if(r.failed>0)q(`Done: ${r.docIds.length} indexed, ${r.failed} failed`),X({filename:`${r.failed} file(s)`,error:r.lastError||`Indexing failed for some files`});else{let e=r.unsupported.length>0?` (${r.unsupported.length} skipped — unsupported type)`:``;q(`Successfully indexed ${r.docIds.length} file(s)${e}`)}J.current&&clearTimeout(J.current),J.current=setTimeout(()=>q(null),5e3),B(new Set)}catch(t){r.doc.error(`Index selected failed`,t),X({filename:e.length===1?e[0].split(/[\\/]/).pop()||e[0]:`${e.length} files`,error:t instanceof Error?t.message:`An unexpected error occurred.`})}finally{G(new Set)}},[z,t,n,g]),xe=(0,M.useCallback)(async()=>{if(z.size===0)return;let a=Array.from(z);X(null),G(new Set(a)),q(`Indexing ${a.length} file(s) for analysis...`);try{let r=await P(a,g,t,n);if(r.supported.length===0){let e=a[0].lastIndexOf(`.`),t=e>0?a[0].slice(e).toLowerCase():``,n=h(t);X({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(r.docIds.length===0){X({filename:r.supported.length===1?r.supported[0].split(/[\\/]/).pop()||r.supported[0]:`${r.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}r.failed>0&&q(`Warning: ${r.failed} file(s) failed to index and will be excluded.`);let o=(r.succeededFiles.length>0?r.succeededFiles:r.supported).map(e=>e.split(/[\\/]/).pop()||e),s=o.length===1?`Please analyze this document for me: ${o[0]}`:`Please analyze these documents for me:\n${o.map(e=>`- ${e}`).join(`
|
|
2
|
+
`)}`;i(s),e(!1),B(new Set)}catch(e){r.doc.error(`Ask Agent failed`,e),X({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{G(new Set),q(null)}},[z,t,n,g,i,e]),Se=s?s.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],Ce=Se.map((e,t)=>({label:e,path:Se.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),we=de(k),$=D?D.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):g;return(0,N.jsx)(`div`,{className:`modal-overlay`,onClick:()=>e(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File Browser`,children:(0,N.jsxs)(`div`,{className:`modal-panel file-browser-modal ${V?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`modal-header`,children:[(0,N.jsxs)(`h3`,{children:[(0,N.jsx)(l,{size:18}),` File Browser`]}),(0,N.jsx)(`button`,{className:`btn-icon`,onClick:()=>e(!1),"aria-label":`Close`,children:(0,N.jsx)(y,{size:18})})]}),(0,N.jsxs)(`div`,{className:`file-browser-body`,children:[(0,N.jsx)(`div`,{className:`fb-quick-links`,children:v.map(e=>(0,N.jsxs)(`button`,{className:`fb-quick-link`,onClick:()=>Z(e.path),title:e.path,children:[fe(e.icon),(0,N.jsx)(`span`,{children:e.name})]},e.path))}),(0,N.jsxs)(`div`,{className:`fb-search-bar`,children:[(0,N.jsxs)(`div`,{className:`fb-search-input-wrap`,children:[(0,N.jsx)(d,{size:14,className:`fb-search-icon`}),(0,N.jsx)(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:T,onChange:e=>E(e.target.value),onKeyDown:ge,"aria-label":`Search files`}),T&&(0,N.jsx)(`button`,{className:`fb-search-clear`,onClick:()=>{E(``),O(null),A([])},"aria-label":`Clear search`,children:(0,N.jsx)(y,{size:12})})]}),(0,N.jsx)(`select`,{className:`fb-type-filter`,value:R,onChange:e=>me(e.target.value),"aria-label":`File type filter`,children:pe.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,N.jsx)(`button`,{className:`fb-search-btn`,onClick:Q,disabled:!T.trim()||I,children:I?`Searching...`:`Search`})]}),!D&&(0,N.jsxs)(`div`,{className:`fb-breadcrumb`,children:[(0,N.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Z(`/`),children:(0,N.jsx)(ce,{size:12})}),Ce.map((e,t)=>(0,N.jsxs)(`span`,{className:`fb-crumb-item`,children:[(0,N.jsx)(ne,{size:12,className:`fb-crumb-sep`}),(0,N.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Z(e.path),children:e.label})]},t)),m&&(0,N.jsx)(`button`,{className:`fb-up-btn`,onClick:()=>Z(m),title:`Go up`,children:(0,N.jsx)(re,{size:14})})]}),D&&(0,N.jsxs)(`div`,{className:`fb-search-header`,children:[(0,N.jsxs)(`div`,{className:`fb-search-summary`,children:[(0,N.jsxs)(`span`,{children:[`Found `,D.length,` result(s) for "`,T,`"`]}),we&&(0,N.jsxs)(`span`,{className:`fb-search-scope`,title:k.join(`
|
|
3
|
+
`),children:[`Searching in: `,(0,N.jsx)(`code`,{children:we})]}),j&&(0,N.jsx)(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),(0,N.jsx)(`button`,{className:`fb-back-btn`,onClick:()=>{O(null),E(``),A([])},children:`Back to browsing`})]}),C&&(0,N.jsx)(`div`,{className:`fb-error`,children:C}),(0,N.jsxs)(`div`,{className:`fb-content`,children:[(0,N.jsxs)(`div`,{className:`fb-file-list`,children:[x&&(0,N.jsx)(`div`,{className:`fb-loading`,children:`Loading...`}),!x&&$.length===0&&(0,N.jsx)(`div`,{className:`fb-empty`,children:D?`No files found`:`This folder is empty`}),!x&&$.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!c(t),r=n?h(t):null;return(0,N.jsxs)(`div`,{className:`fb-entry ${e.type} ${z.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?_e(e):ye(e.path),onDoubleClick:()=>e.type===`folder`?_e(e):void 0,title:n?`${r?.label||`This`} file type cannot be indexed`:e.path,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:z.has(e.path),onChange:()=>ye(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),(0,N.jsx)(`span`,{className:`fb-entry-icon`,children:le(e)}),(0,N.jsx)(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&(0,N.jsx)(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&(0,N.jsx)(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),ve(e.path)},"aria-label":`Preview ${e.name}`,title:`Preview file`,children:(0,N.jsx)(se,{size:14})}),(0,N.jsx)(`span`,{className:`fb-entry-size`,children:e.type===`file`?oe(e.size):``}),(0,N.jsx)(`span`,{className:`fb-entry-date`,children:ue(e.modified)})]},e.path)})]}),V&&(0,N.jsxs)(`div`,{className:`fb-preview`,children:[(0,N.jsxs)(`div`,{className:`fb-preview-header`,children:[(0,N.jsx)(`span`,{className:`fb-preview-name`,children:V.name}),(0,N.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>H(null),"aria-label":`Close preview`,children:(0,N.jsx)(y,{size:14})})]}),(0,N.jsxs)(`div`,{className:`fb-preview-meta`,children:[(0,N.jsx)(`span`,{children:V.size_display}),V.total_lines&&(0,N.jsxs)(`span`,{children:[V.total_lines,` lines`]}),V.columns&&(0,N.jsxs)(`span`,{children:[V.columns.length,` columns`]}),V.row_count!==null&&(0,N.jsxs)(`span`,{children:[V.row_count,` rows`]})]}),V.columns&&(0,N.jsxs)(`div`,{className:`fb-preview-columns`,children:[(0,N.jsx)(`strong`,{children:`Columns:`}),` `,V.columns.join(`, `)]}),he?(0,N.jsx)(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):V.is_text&&V.preview_lines.length>0?(0,N.jsx)(`pre`,{className:`fb-preview-content`,children:V.preview_lines.slice(0,30).join(`
|
|
4
|
+
`)}):(0,N.jsx)(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),Y&&(0,N.jsx)(a,{filename:Y.filename,error:Y.error,onDismiss:()=>X(null)}),(0,N.jsxs)(`div`,{className:`fb-actions`,children:[(0,N.jsx)(`div`,{className:`fb-selection-info`,children:z.size>0?`${z.size} item(s) selected`:`Select files to index or analyze`}),K&&(0,N.jsx)(`span`,{className:`fb-index-status`,children:K}),(0,N.jsxs)(`div`,{className:`fb-action-btns`,children:[(0,N.jsxs)(`button`,{className:`fb-action-btn secondary`,onClick:be,disabled:z.size===0||W.size>0,title:`Index selected files for RAG search`,children:[(0,N.jsx)(f,{size:14}),`Index Selected`]}),(0,N.jsxs)(`button`,{className:`fb-action-btn primary`,onClick:xe,disabled:z.size===0||W.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[(0,N.jsx)(ae,{size:14}),`Ask Agent`]})]})]})]})]})})}export{F as FileBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{t as a}from"./message-square-Ccmbk96j.js";import{A as ee,At as o,C as s,D as te,E as ne,F as re,Ft as ie,I as ae,Jt as oe,L as c,Lt as se,M as ce,Mt as le,N as ue,O as de,Ot as fe,P as pe,Pt as me,Qt as l,Rt as he,S as ge,T as _e,Vt as ve,Xt as ye,Yt as be,_ as xe,a as Se,b as Ce,c as we,d as Te,en as Ee,f as De,g as Oe,h as ke,j as Ae,jt as je,k as Me,l as Ne,m as Pe,o as Fe,p as Ie,qt as Le,rn as Re,s as ze,t as Be,tn as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke,zt as qe}from"./index-CXbVMk3u.js";var Je={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Je.node;var Ye=t(Je),u={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};u.node;var Xe=t(u),Ze={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ze.node;var Qe=t(Ze),$e={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`}]]};$e.node;var et=t($e),tt={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};tt.node;var nt=t(tt),rt={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`}]]};rt.node;var it=t(rt),at={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};at.node;var d=t(at),ot={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`]};ot.node;var st=t(ot),ct={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`}]]};ct.node;var lt=t(ct),f={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`}]]};f.node;var ut=t(f),dt={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`}]]};dt.node;var ft=t(dt),p=e(n(),1),m=i();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 h(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 g(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),ee=Math.floor(i/6e4),o=Math.floor(i/36e5),s=Math.floor(i/864e5);return r<0?a<5?`just now`:a<60?`${a}s ago`:o===0?`${ee}m ago`:s===0?`${o}h ago`:s===1?`yesterday`:s<30?`${s}d ago`:h(e):a<5?`now`:a<60?`in ${a}s`:o===0?`in ${ee}m`:s===0?`in ${o}h`:s===1?`tomorrow`:s<30?`in ${s}d`:h(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}=fe(),[t,n]=(0,p.useState)(null),[i,Je]=(0,p.useState)([]),[u,Ze]=(0,p.useState)(null),[$e,tt]=(0,p.useState)([]),[rt,at]=(0,p.useState)([]),[ot,ct]=(0,p.useState)([]),[f,dt]=(0,p.useState)(null),[pt,St]=(0,p.useState)([]),[Ct,wt]=(0,p.useState)(!0),[Tt,Et]=(0,p.useState)(null),[Dt,Ot]=(0,p.useState)(null),[_,v]=(0,p.useState)(!1),[kt,At]=(0,p.useState)(null),[jt,Mt]=(0,p.useState)([]),Nt=(0,p.useRef)(0),[y,Pt]=(0,p.useState)([]),[Ft,It]=(0,p.useState)(``),[Lt,Rt]=(0,p.useState)(``),[zt,Bt]=(0,p.useState)(``),[b,Vt]=(0,p.useState)(`updated_at`),[Ht,Ut]=(0,p.useState)(`desc`),[x,S]=(0,p.useState)(0),[Wt,Gt]=(0,p.useState)(!1),[Kt,qt]=(0,p.useState)(``),[Jt,Yt]=(0,p.useState)(null),Xt=(0,p.useRef)(null),[C,Zt]=(0,p.useState)(null),[Qt,w]=(0,p.useState)(!1),[T,$t]=(0,p.useState)(null),[E,D]=(0,p.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[en,tn]=(0,p.useState)(new Set),[O,nn]=(0,p.useState)(!1),[rn,an]=(0,p.useState)(!1),[on,sn]=(0,p.useState)(!1),[k,A]=(0,p.useState)(!1),[cn,ln]=(0,p.useState)(!1),[j,un]=(0,p.useState)(null),[dn,fn]=(0,p.useState)(!1),[M,N]=(0,p.useState)(null),[P,pn]=(0,p.useState)(`dashboard`),[F,mn]=(0,p.useState)([]),[hn,gn]=(0,p.useState)(null),[_n,vn]=(0,p.useState)(!1),[yn,bn]=(0,p.useState)(null),[xn,Sn]=(0,p.useState)(!1),[Cn,wn]=(0,p.useState)({title:``,description:``,priority:`medium`}),[I,L]=(0,p.useState)(`idle`),[Tn,R]=(0,p.useState)([]),[z,B]=(0,p.useState)([]),[En,Dn]=(0,p.useState)(null),On=(0,p.useRef)(null),kn=(0,p.useRef)(null),[V,H]=(0,p.useState)(`idle`),[An,U]=(0,p.useState)([]),[W,G]=(0,p.useState)([]),[jn,Mn]=(0,p.useState)(null),[Nn,Pn]=(0,p.useState)(!1),Fn=(0,p.useRef)(null),In=(0,p.useRef)(null),[Ln,Rn]=(0,p.useState)(30),[zn,Bn]=(0,p.useState)(!1),[Vn,Hn]=(0,p.useState)(!1),[Un,Wn]=(0,p.useState)(!1),[Gn,Kn]=(0,p.useState)(!1),[qn,Jn]=(0,p.useState)(!1),[Yn,Xn]=(0,p.useState)(!1),Zn=(0,p.useRef)(null),Qn=(0,p.useRef)(null),$n=(0,p.useRef)(null),K=(0,p.useCallback)((e,t=`info`)=>{let n=++Nt.current;Mt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Mt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,p.useEffect)(()=>{if(!_)return;let e=e=>{Qn.current&&!Qn.current.contains(e.target)&&v(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),(0,p.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(M?N(null):cn?ln(!1):dn?fn(!1):C?Zt(null):_?v(!1):Qt||T?(w(!1),$t(null)):kt?At(null):e(!1))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[C,_,Qt,T,kt,e,M,cn,dn]),(0,p.useEffect)(()=>{if(!M)return;let e=$n.current;if(!e)return;let t=document.activeElement;e.focus();let n=()=>Array.from(e.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)),r=t=>{if(t.key!==`Tab`)return;let r=n();if(r.length===0){t.preventDefault();return}let i=document.activeElement,a=!!i&&e.contains(i)&&i!==e;t.shiftKey&&(!a||i===r[0])?(t.preventDefault(),r[r.length-1].focus()):!t.shiftKey&&(!a||i===r[r.length-1])&&(t.preventDefault(),r[0].focus())};return document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`keydown`,r),t?.focus()}},[M]);let er=(0,p.useCallback)(async()=>{try{let e=await We();n(e)}catch(e){r.system.warn(`Failed to load memory stats`,e)}},[]),tr=(0,p.useCallback)(async()=>{try{let e=await Ge(Ln);Je(e)}catch(e){r.system.warn(`Failed to load memory activity`,e)}},[Ln]),q=(0,p.useCallback)(async()=>{try{let e=await Ce({category:y.length>0?y:void 0,context:Ft||void 0,entity:Lt||void 0,search:zt||void 0,sort_by:b,order:Ht,offset:x,limit:15,include_sensitive:!0,include_superseded:Wt});Ze(e)}catch(e){r.system.warn(`Failed to load knowledge`,e)}},[y,Ft,Lt,zt,b,Ht,x,Wt]),nr=(0,p.useCallback)(async()=>{try{let e=await _e();tt(e)}catch(e){r.system.warn(`Failed to load tool summary`,e)}},[]),rr=(0,p.useCallback)(async()=>{try{let e=await ge(20);at(e)}catch(e){r.system.warn(`Failed to load conversations`,e)}},[]),ir=(0,p.useCallback)(async()=>{try{let e=await ne(7);ct(e)}catch(e){r.system.warn(`Failed to load upcoming items`,e)}},[]),J=(0,p.useCallback)(async()=>{try{let e=await xe();dt(e)}catch(e){r.system.warn(`Failed to load embedding coverage`,e)}},[]),ar=(0,p.useCallback)(async()=>{try{let e=await Ue();St(e||[])}catch(e){r.system.warn(`Failed to load entities`,e)}},[]),or=(0,p.useCallback)(async()=>{try{let e=await s();an(e.mcp_memory_enabled),nn(e.memory_enabled),sn(e.system_discovery_consent)}catch(e){r.system.warn(`Failed to load memory settings`,e)}},[]),Y=(0,p.useCallback)(async()=>{vn(!0);try{let[e,t]=await Promise.all([te(),Ke()]);mn(e.goals),gn(t)}catch(e){r.system.warn(`Failed to load goals`,e)}finally{vn(!1)}},[]),X=(0,p.useCallback)(async()=>{wt(!0),Et(null);try{await Promise.all([er(),tr(),q(),nr(),rr(),ir(),J(),ar(),or(),Y()])}catch(e){Et(`Failed to load memory data. Is the backend running?`),r.system.error(`Memory dashboard load failed`,e)}finally{wt(!1)}},[er,tr,q,nr,rr,ir,J,ar,or,Y]);(0,p.useEffect)(()=>{X()},[X]),(0,p.useEffect)(()=>{q()},[q]);let sr=(0,p.useRef)(!0);(0,p.useEffect)(()=>{if(sr.current){sr.current=!1;return}tr()},[tr]);let cr=(0,p.useCallback)(e=>{Bt(e),Xn(!0),Zn.current&&clearTimeout(Zn.current),Zn.current=setTimeout(()=>{S(0),Xn(!1)},300)},[]),Z=(0,p.useCallback)(()=>{q(),er(),J(),ir(),ar()},[q,er,J,ir,ar]),lr=(0,p.useCallback)(async()=>{if(E.content.trim())try{let e=await De({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});w(!1),D({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),Z(),r.ui.info(`Created new knowledge entry`),e?.embedded===!1?K(e.embed_error??`Saved, but not embedded`,`error`):K(`Memory created successfully`,`success`)}catch(e){r.system.error(`Failed to create knowledge`,e),K(`Failed to create memory`,`error`)}},[E,Z,K]),ur=(0,p.useCallback)(async()=>{if(T&&E.content.trim())try{let e=await ke(T,{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});$t(null),D({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),Z(),r.ui.info(`Updated knowledge ${T}`),e?.embedded===!1?K(e.embed_error??`Saved, but not embedded`,`error`):K(`Memory updated`,`success`)}catch(e){r.system.error(`Failed to update knowledge`,e),K(`Failed to update memory`,`error`)}},[T,E,Z,K]),dr=(0,p.useCallback)(async e=>{if(j!==e){un(e);return}un(null);try{await Pe(e),Z(),r.ui.info(`Deleted knowledge ${e}`),K(`Memory deleted`,`info`)}catch(e){r.system.error(`Failed to delete knowledge`,e),K(`Failed to delete memory`,`error`)}},[j,Z,K]);(0,p.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>un(null),3e3);return()=>clearTimeout(e)},[j]);let fr=(0,p.useCallback)(async e=>{try{await ke(e.id,{sensitive:!e.sensitive}),q(),r.ui.info(`Toggled sensitive for ${e.id}: ${!e.sensitive}`),K(e.sensitive?`Unmarked as sensitive`:`Marked as sensitive`,`info`)}catch(e){r.system.error(`Failed to toggle sensitive`,e),K(`Failed to toggle sensitive flag`,`error`)}},[q,K]),pr=(0,p.useCallback)(e=>{$t(e.id),w(!1),D({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),mr=(0,p.useCallback)(e=>{navigator.clipboard.writeText(e).catch(()=>{}),r.ui.info(`Copied knowledge ID: ${e}`),K(`ID copied to clipboard`,`info`)},[K]),hr=(0,p.useCallback)(e=>{if(qt(e),Xt.current&&clearTimeout(Xt.current),!e.trim()){Yt(null);return}Xt.current=setTimeout(async()=>{try{let t=await ae(e.trim(),20);Yt(t)}catch(e){r.system.warn(`Conversation search failed`,e)}},300)},[]),gr=(0,p.useCallback)(async e=>{try{let t=await Oe(e);Zt({sessionId:e,turns:t})}catch(e){r.system.error(`Failed to load conversation detail`,e)}},[]),_r=(0,p.useCallback)(e=>{Pt(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),S(0)},[]),Q=(0,p.useCallback)(e=>{b===e?Ut(e=>e===`desc`?`asc`:`desc`):(Vt(e),Ut(`desc`)),S(0)},[b]),vr=(0,p.useCallback)(async()=>{Bn(!0),v(!1);try{let e=await He();await X(),K(`Consolidated ${e.consolidated??0} sessions, extracted ${e.extracted_items??0} items`,`success`)}catch(e){r.system.error(`Failed to consolidate sessions`,e),K(`Failed to consolidate sessions`,`error`)}finally{Bn(!1)}},[X,K]),yr=(0,p.useCallback)(async()=>{Hn(!0),v(!1);try{let e=await ee();await J(),K(`Backfilled ${e.backfilled??0} embeddings${e.total_without?` (${e.total_without} were missing)`:``}`,`success`)}catch(e){r.system.error(`Failed to rebuild embeddings`,e),K(`Failed to rebuild embeddings`,`error`)}finally{Hn(!1)}},[J,K]),br=(0,p.useCallback)(async()=>{Wn(!0),v(!1);try{let e=await ce();await X(),K(`Checked ${e.pairs_checked??0} pairs: ${e.reinforced??0} reinforced, ${e.contradicted??0} contradicted`,`success`)}catch(e){r.system.error(`Failed to reconcile memory`,e),K(`Failed to reconcile memory`,`error`)}finally{Wn(!1)}},[X,K]),xr=(0,p.useCallback)(async()=>{Kn(!0),v(!1);try{await Ae(),await X(),K(`FTS indexes rebuilt successfully`,`success`)}catch(e){r.system.error(`Failed to rebuild FTS index`,e),K(`Failed to rebuild FTS indexes`,`error`)}finally{Kn(!1)}},[X,K]),Sr=(0,p.useCallback)(async()=>{Jn(!0),v(!1);try{let e=await ue();await X(),e.skipped?K(`System context collection is disabled — enable it in settings`,`error`):K(`System context refreshed: ${e.stored} facts updated`,`success`)}catch(e){r.system.error(`Failed to refresh system context`,e),K(`Failed to refresh system context`,`error`)}finally{Jn(!1)}},[X,K]),Cr=zn||Vn||Un||Gn||qn,wr=(0,p.useCallback)(()=>{L(`running`),R([]),B([]),Dn(null);let e=de();kn.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)R(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`finding`){let e=n.item;R(t=>[...t,{text:` Found: ${e.content}`,kind:`finding`}]),B(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?R(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),kn.current=null,R(e=>[...e,{text:`Done. ${n.total??0} items discovered.`,kind:`log`}]),L(`review`))}catch{R(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),kn.current=null,R(e=>[...e,{text:`Connection error. Is the GAIA server running?`,kind:`error`}]),B(e=>(L(e.length>0?`review`:`idle`),e))}},[]),Tr=(0,p.useCallback)(async()=>{let e=z.filter(e=>e._checked);if(e.length!==0){L(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await we(t);Dn(n.stored),L(`done`),K(`Saved ${n.stored} items to memory`,`success`)}catch(e){r.system.error(`Failed to commit discovery items`,e),K(`Failed to save discovery items`,`error`),L(`review`)}}},[z,K]),Er=(0,p.useCallback)(()=>{H(`running`),U([]),G([]),Mn(null);let e=Me(Nn);In.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)U(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`insight`){let e=n.item;U(t=>[...t,{text:` Insight: ${e.content}`,kind:`finding`}]),G(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?U(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),In.current=null,U(e=>[...e,{text:`Done. ${n.total??0} insights generated.`,kind:`log`}]),H(`review`))}catch{U(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),In.current=null,U(e=>[...e,{text:`Connection error. Is Lemonade Server running?`,kind:`error`}]),G(e=>(H(e.length>0?`review`:`idle`),e))}},[Nn]),Dr=(0,p.useCallback)(async()=>{let e=W.filter(e=>e._checked);if(e.length!==0){H(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await Ne(t);Mn(n.stored),H(`done`),K(`Saved ${n.stored} insights to memory`,`success`)}catch(e){r.system.error(`Failed to commit inference insights`,e),K(`Failed to save inference insights`,`error`),H(`review`)}}},[W,K]);(0,p.useEffect)(()=>{On.current&&(On.current.scrollTop=On.current.scrollHeight)},[Tn]),(0,p.useEffect)(()=>{Fn.current&&(Fn.current.scrollTop=Fn.current.scrollHeight)},[An]),(0,p.useEffect)(()=>()=>{kn.current&&=(kn.current.close(),null),In.current&&=(In.current.close(),null)},[]);let $=e=>b===e?(0,m.jsx)(`span`,{className:`mem-sort-arrow`,children:Ht===`desc`?`↓`:`↑`}):null,Or=Math.max(1,...i.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),kr=t?.knowledge?.by_context?Object.keys(t.knowledge.by_context):[];return(0,m.jsxs)(`div`,{className:`memory-dashboard-page`,children:[(0,m.jsxs)(`div`,{className:`memory-dashboard-header`,children:[(0,m.jsxs)(`div`,{className:`memory-dashboard-header-left`,children:[(0,m.jsx)(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>e(!1),"aria-label":`Back`,children:(0,m.jsx)(Ye,{size:18})}),(0,m.jsxs)(`h1`,{children:[`Memory Dashboard `,(0,m.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,m.jsxs)(`div`,{className:`memory-dashboard-header-actions`,children:[f&&f.total_items>0&&(0,m.jsxs)(`div`,{className:`mem-embedding-coverage`,title:`${f.with_embedding} of ${f.total_items} entries embedded`,children:[(0,m.jsx)(`div`,{className:`mem-embedding-bar`,children:(0,m.jsx)(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(f.coverage_pct)}%`}})}),(0,m.jsxs)(`span`,{className:`mem-embedding-label`,children:[Math.round(f.coverage_pct),`% embedded`]})]}),(0,m.jsxs)(`div`,{className:`mem-maintenance-wrap`,ref:Qn,children:[(0,m.jsxs)(`button`,{className:`btn-icon ${Cr?`mem-spinning`:``}`,onClick:()=>v(e=>!e),title:`Maintenance actions`,"aria-label":`Maintenance actions`,"aria-expanded":_,children:[Cr?(0,m.jsx)(`div`,{className:`mem-spinner-sm`}):(0,m.jsx)(Le,{size:16}),(0,m.jsx)(Ve,{size:10,style:{marginLeft:2}})]}),_&&(0,m.jsxs)(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:vr,disabled:zn,role:`menuitem`,children:[(0,m.jsx)(et,{size:14}),zn?`Consolidating...`:`Consolidate Sessions`]}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:yr,disabled:Vn,role:`menuitem`,children:[(0,m.jsx)(o,{size:14}),Vn?`Rebuilding...`:`Rebuild Embeddings`]}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:br,disabled:Un,role:`menuitem`,children:[(0,m.jsx)(l,{size:14}),Un?`Reconciling...`:`Reconcile Memory`]}),(0,m.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Sr,disabled:qn,role:`menuitem`,children:[(0,m.jsx)(he,{size:14}),qn?`Refreshing...`:`Refresh System Context`]}),(0,m.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:xr,disabled:Gn,role:`menuitem`,children:[(0,m.jsx)(se,{size:14}),Gn?`Rebuilding...`:`Rebuild FTS Indexes`]})]})]}),(0,m.jsx)(`button`,{className:`btn-icon`,onClick:X,title:`Refresh`,"aria-label":`Refresh dashboard`,children:(0,m.jsx)(he,{size:16})})]})]}),(0,m.jsxs)(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`dashboard`?` mem-tab-active`:``}`,onClick:()=>pn(`dashboard`),role:`tab`,"aria-selected":P===`dashboard`,children:[(0,m.jsx)(Re,{size:14}),` Dashboard`]}),(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`goals`?` mem-tab-active`:``}`,onClick:()=>{pn(`goals`),Y()},role:`tab`,"aria-selected":P===`goals`,children:[(0,m.jsx)(lt,{size:14}),` Goals`,hn&&(hn.goals.pending_approval??0)>0&&(0,m.jsx)(`span`,{className:`mem-tab-badge`,children:hn.goals.pending_approval})]}),(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`profile`?` mem-tab-active`:``}`,onClick:()=>pn(`profile`),role:`tab`,"aria-selected":P===`profile`,children:[(0,m.jsx)(ft,{size:14}),` Profile`]})]}),(0,m.jsxs)(`div`,{className:`memory-dashboard-body`,children:[P===`dashboard`&&(0,m.jsx)(m.Fragment,{children:Ct&&!t?(0,m.jsxs)(`div`,{className:`mem-loading`,children:[(0,m.jsx)(`div`,{className:`mem-spinner`}),`Loading memory data...`]}):Tt?(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(me,{size:32})}),(0,m.jsx)(`p`,{children:Tt}),(0,m.jsxs)(`button`,{className:`btn-secondary`,onClick:X,style:{marginTop:12},children:[(0,m.jsx)(he,{size:14}),` Retry`]})]}):(0,m.jsxs)(m.Fragment,{children:[!O&&(0,m.jsxs)(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:(0,m.jsx)(d,{size:32})}),(0,m.jsx)(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:`Memory is disabled. Enable it in Settings below to start storing knowledge, conversations, and preferences.`})]}),O&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`mem-stat-cards`,children:[(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.knowledge?.total??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Stored`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:(()=>{let e=yt(i);return e>0?`+${e} today`:t?.knowledge?.by_category?Object.entries(t.knowledge.by_category).slice(0,3).map(([e,t])=>`${t} ${e}s`).join(`, `):`No entries`})()})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.knowledge?.total_retrievals??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Retrieved`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:t?.knowledge?.total&&t?.knowledge?.total_retrievals?`avg ${(t.knowledge.total_retrievals/t.knowledge.total).toFixed(1)}x per memory`:`No recalls yet`})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.conversations?.total_sessions??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Sessions`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:vt(t?.conversations?.first_session??null,t?.conversations?.last_session??null)||`${t?.conversations?.total_turns??0} total turns`})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.tools?.total_calls??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Tool Calls`}),(0,m.jsxs)(`div`,{className:`mem-stat-sub`,title:`Memory tools (remember, recall, ...) are not logged`,children:[t?.tools?.unique_tools??0,` tools, excl. memory`]})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.tools?.overall_success_rate!=null&&(t.tools.total_calls??0)>0?`${Math.round(t.tools.overall_success_rate*100)}%`:`—`}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Success Rate`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:(t?.tools?.total_calls??0)>0?`${t?.tools?.total_errors??0} errors`:`No tool calls yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,m.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,m.jsx)(ut,{size:14}),` Activity`]}),(0,m.jsx)(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":`Activity range`,children:[1,7,30].map(e=>(0,m.jsx)(`button`,{className:`mem-range-tab${Ln===e?` active`:``}`,onClick:()=>Rn(e),children:e===1?`1D`:e===7?`7D`:`30D`},e))})]}),i.length>0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-activity-chart`,children:i.map((e,t)=>{let n=e.conversations+e.tool_calls+e.knowledge_added+e.errors,r=t===0||t===i.length-1||t%7==0,a=new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,m.jsxs)(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>Ot(t),onMouseLeave:()=>Ot(null),children:[e.errors>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar errors`,style:{height:`${e.errors/Or*100}%`}}),e.knowledge_added>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${e.knowledge_added/Or*100}%`}}),e.tool_calls>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${e.tool_calls/Or*100}%`}}),e.conversations>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar conversations`,style:{height:`${e.conversations/Or*100}%`}}),r&&(0,m.jsx)(`span`,{className:`mem-activity-date-label`,children:a}),Dt===t&&n>0&&(0,m.jsxs)(`div`,{className:`mem-activity-tooltip`,children:[(0,m.jsx)(`strong`,{children:a}),(0,m.jsx)(`br`,{}),e.conversations>0&&(0,m.jsxs)(m.Fragment,{children:[e.conversations,` conversations`,(0,m.jsx)(`br`,{})]}),e.tool_calls>0&&(0,m.jsxs)(m.Fragment,{children:[e.tool_calls,` tool calls`,(0,m.jsx)(`br`,{})]}),e.knowledge_added>0&&(0,m.jsxs)(m.Fragment,{children:[e.knowledge_added,` learned`,(0,m.jsx)(`br`,{})]}),e.errors>0&&(0,m.jsxs)(m.Fragment,{children:[e.errors,` errors`]})]})]},e.date)})}),(0,m.jsxs)(`div`,{className:`mem-activity-legend`,children:[(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot conversations`}),` Conversations`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot tool_calls`}),` Tool Calls`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot knowledge`}),` Knowledge`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot errors`}),` Errors`]})]})]}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(ut,{size:28})}),(0,m.jsx)(`p`,{children:`No activity data yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,m.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,m.jsx)(Re,{size:14}),` Knowledge Browser`,u&&u.total>0&&(0,m.jsx)(`span`,{className:`mem-section-count`,children:u.total})]}),!Qt&&!T&&(0,m.jsxs)(`button`,{className:`mem-section-add-btn`,onClick:()=>w(!0),title:`Add a memory entry`,children:[(0,m.jsx)(qe,{size:13}),` Add`]})]}),(0,m.jsxs)(`div`,{className:`mem-filters`,children:[(0,m.jsxs)(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":`Filter by category`,children:[bt.map(e=>(0,m.jsx)(`button`,{className:`mem-category-pill ${e}${y.includes(e)?` active`:``}`,onClick:()=>_r(e),"aria-pressed":y.includes(e),children:e},e)),y.length>0&&(0,m.jsx)(`button`,{className:`mem-category-pill clear`,onClick:()=>{Pt([]),S(0)},"aria-label":`Clear category filters`,children:`✕ Clear`})]}),(0,m.jsxs)(`select`,{className:`mem-filter-select`,value:Ft,onChange:e=>{It(e.target.value),S(0)},"aria-label":`Filter by context`,children:[(0,m.jsx)(`option`,{value:``,children:`All Contexts`}),kr.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsxs)(`select`,{className:`mem-filter-select`,value:Lt,onChange:e=>{Rt(e.target.value),S(0)},"aria-label":`Filter by entity`,children:[(0,m.jsx)(`option`,{value:``,children:`All Entities`}),pt.map(e=>(0,m.jsxs)(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),(0,m.jsxs)(`div`,{className:`mem-filter-search-wrap`,children:[Yn?(0,m.jsx)(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):(0,m.jsx)(se,{size:13,className:`search-icon`}),(0,m.jsx)(`input`,{className:`mem-filter-search`,type:`text`,placeholder:`Search memories...`,value:zt,onChange:e=>cr(e.target.value),"aria-label":`Search memories`})]}),(0,m.jsxs)(`label`,{className:`mem-filter-toggle`,title:`Show entries that have been superseded by newer versions`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:Wt,onChange:e=>Gt(e.target.checked)}),(0,m.jsx)(`span`,{children:`Superseded`})]})]}),(Qt||T)&&(0,m.jsxs)(`div`,{className:`mem-inline-form`,children:[(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Content`}),(0,m.jsx)(`textarea`,{value:E.content,onChange:e=>D(t=>({...t,content:e.target.value})),placeholder:`What should the agent remember?`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Category`}),(0,m.jsx)(`select`,{value:E.category,onChange:e=>D(t=>({...t,category:e.target.value})),children:bt.map(e=>(0,m.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Context`}),(0,m.jsx)(`input`,{type:`text`,value:E.context,onChange:e=>D(t=>({...t,context:e.target.value})),placeholder:`global`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Domain`}),(0,m.jsx)(`input`,{type:`text`,value:E.domain,onChange:e=>D(t=>({...t,domain:e.target.value})),placeholder:`e.g., python, frontend`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Entity`}),(0,m.jsx)(`input`,{type:`text`,value:E.entity,onChange:e=>D(t=>({...t,entity:e.target.value})),placeholder:`e.g., person:sarah_chen`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Due At`}),(0,m.jsx)(`input`,{type:`text`,value:E.due_at,onChange:e=>D(t=>({...t,due_at:e.target.value})),placeholder:`ISO 8601 (e.g., 2026-03-25T09:00:00-07:00)`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Sensitive`}),(0,m.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:E.sensitive,onChange:e=>D(t=>({...t,sensitive:e.target.checked}))}),`Mark as sensitive (excluded from system prompt)`]})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-actions`,children:[(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{w(!1),$t(null)},children:`Cancel`}),(0,m.jsx)(`button`,{className:`btn-primary`,onClick:T?ur:lr,style:{padding:`8px 20px`,fontSize:13},children:T?`Update`:`Save`})]})]}),u&&u.items.length>0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{style:{overflowX:`auto`},children:(0,m.jsxs)(`table`,{className:`mem-knowledge-table`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsxs)(`th`,{onClick:()=>Q(`category`),className:b===`category`?`sorted`:``,children:[`Category`,$(`category`)]}),(0,m.jsx)(`th`,{children:`Content`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`context`),className:b===`context`?`sorted`:``,children:[`Context`,$(`context`)]}),(0,m.jsx)(`th`,{children:`Entity`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`confidence`),className:b===`confidence`?`sorted`:``,children:[`Confidence`,$(`confidence`)]}),(0,m.jsx)(`th`,{children:`Source`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`updated_at`),className:b===`updated_at`?`sorted`:``,children:[`Updated`,$(`updated_at`)]}),(0,m.jsxs)(`th`,{onClick:()=>Q(`created_at`),className:b===`created_at`?`sorted`:``,children:[`Created`,$(`created_at`)]}),(0,m.jsx)(`th`,{children:`Due`}),(0,m.jsx)(`th`,{className:`mem-actions-cell`})]})}),(0,m.jsx)(`tbody`,{children:u.items.map(e=>{let t=kt===e.id,n=e.has_embedding;return(0,m.jsxs)(p.Fragment,{children:[(0,m.jsxs)(`tr`,{className:`${e.superseded_by?`mem-superseded-row`:``} ${t?`mem-expanded-row`:``}`,onClick:()=>At(t?null:e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),At(t?null:e.id))},tabIndex:0,role:`row`,"aria-expanded":t,style:{cursor:`pointer`},children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-cat-badge ${e.category}`,children:e.category})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-content-cell`,title:e.content,children:[n!==void 0&&(0,m.jsx)(`span`,{className:`mem-embed-dot ${n?`embedded`:`missing`}`,title:n?`Embedded`:`Embedding missing`,children:(0,m.jsx)(Qe,{size:6,fill:`currentColor`})}),e.sensitive&&(0,m.jsx)(`span`,{className:`mem-sensitive-badge`,title:`Sensitive`,children:(0,m.jsx)(d,{size:11})}),(0,m.jsx)(`span`,{className:e.sensitive&&!en.has(e.id)?`mem-sensitive-blur`:e.superseded_by?`mem-superseded-text`:``,onClick:t=>{e.sensitive&&(t.stopPropagation(),tn(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}))},children:e.content})]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,children:e.context})}),(0,m.jsx)(`td`,{children:e.entity?(0,m.jsx)(`span`,{className:`mem-entity-link`,onClick:t=>{t.stopPropagation(),Rt(e.entity),S(0)},title:`Filter by ${e.entity}`,children:e.entity}):(0,m.jsx)(`span`,{className:`mem-date-cell`,children:`—`})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-confidence`,children:[(0,m.jsx)(`div`,{className:`mem-confidence-bar`,children:(0,m.jsx)(`div`,{className:`mem-confidence-fill ${gt(e.confidence)}`,style:{width:`${e.confidence*100}%`}})}),e.confidence.toFixed(2)]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,children:e.source||`—`})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.updated_at),children:g(e.updated_at)})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.created_at),children:g(e.created_at)})}),(0,m.jsx)(`td`,{children:e.due_at?(0,m.jsx)(`span`,{className:`mem-due-badge ${ht(e.due_at)?`overdue`:`upcoming`}`,title:h(e.due_at),children:g(e.due_at)}):(0,m.jsx)(`span`,{className:`mem-due-badge none`,children:`—`})}),(0,m.jsx)(`td`,{className:`mem-actions-cell`,children:(0,m.jsxs)(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>pr(e),title:`Edit`,children:(0,m.jsx)(nt,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>fr(e),title:e.sensitive?`Unmark sensitive`:`Mark sensitive`,children:e.sensitive?(0,m.jsx)(it,{size:13}):(0,m.jsx)(d,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>mr(e.id),title:`Copy ID`,children:(0,m.jsx)(be,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn delete${j===e.id?` is-confirm`:``}`,onClick:()=>dr(e.id),title:j===e.id?`Click again to delete`:`Delete`,"aria-label":j===e.id?`Confirm delete memory`:`Delete memory`,children:j===e.id?(0,m.jsx)(`span`,{className:`mem-row-delete-label`,children:`Delete?`}):(0,m.jsx)(ie,{size:13})})]})})]}),t&&(0,m.jsx)(`tr`,{className:`mem-detail-row`,children:(0,m.jsx)(`td`,{colSpan:10,children:(0,m.jsxs)(`div`,{className:`mem-detail-panel`,children:[(0,m.jsxs)(`div`,{className:`mem-detail-grid`,children:[(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`ID`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.id})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Domain`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.domain||`—`})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Source`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.source||`—`})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Use Count`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.use_count??0})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Created`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.created_at)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Updated`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.updated_at)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Last Used`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.last_used)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Reminded At`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.reminded_at)})]}),e.superseded_by&&(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Superseded By`}),(0,m.jsx)(`span`,{className:`mem-detail-value mem-detail-chain`,children:e.superseded_by})]}),e.metadata&&(0,m.jsxs)(`div`,{className:`mem-detail-field mem-detail-full`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Metadata`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:typeof e.metadata==`object`?JSON.stringify(e.metadata,null,2):e.metadata})]})]}),(0,m.jsxs)(`div`,{className:`mem-detail-content-full`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Full Content`}),(0,m.jsx)(`div`,{className:`mem-detail-content-text`,children:e.content})]})]})})})]},e.id)})})]})}),(0,m.jsxs)(`div`,{className:`mem-pagination`,children:[(0,m.jsxs)(`span`,{children:[x+1,`–`,Math.min(x+15,u.total),` of `,u.total]}),(0,m.jsxs)(`div`,{className:`mem-pagination-btns`,children:[(0,m.jsx)(`button`,{className:`mem-page-btn`,disabled:x===0,onClick:()=>S(Math.max(0,x-15)),children:(0,m.jsx)(Xe,{size:14})}),(0,m.jsx)(`button`,{className:`mem-page-btn`,disabled:x+15>=u.total,onClick:()=>S(x+15),children:(0,m.jsx)(Ee,{size:14})})]})]})]}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(Re,{size:28})}),(0,m.jsx)(`p`,{children:zt||y.length>0||Ft||Lt?`No matching memories`:`No memories stored yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-two-col`,children:[(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(le,{size:14}),` Tool Performance`,(0,m.jsx)(`span`,{className:`mem-section-note`,title:`remember, recall, update_memory, forget and search_past_conversations are not logged`,children:`excludes memory tools`})]}),$e.length>0?(0,m.jsx)(`div`,{style:{overflowX:`auto`},children:(0,m.jsxs)(`table`,{className:`mem-tool-table`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`Tool`}),(0,m.jsx)(`th`,{children:`Calls`}),(0,m.jsx)(`th`,{children:`Success`}),(0,m.jsx)(`th`,{children:`Avg Time`}),(0,m.jsx)(`th`,{children:`Last Used`}),(0,m.jsx)(`th`,{children:`Last Error`})]})}),(0,m.jsx)(`tbody`,{children:$e.map(e=>(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-tool-name`,children:e.tool_name})}),(0,m.jsx)(`td`,{children:e.total_calls}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-confidence`,children:[(0,m.jsx)(`div`,{className:`mem-confidence-bar`,style:{width:40},children:(0,m.jsx)(`div`,{className:`mem-confidence-fill ${_t(e.success_rate)}`,style:{width:`${e.success_rate*100}%`}})}),(0,m.jsxs)(`span`,{className:`mem-success-rate ${_t(e.success_rate)}`,children:[Math.round(e.success_rate*100),`%`]})]})}),(0,m.jsx)(`td`,{children:mt(e.avg_duration_ms)}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.last_used),children:g(e.last_used)})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-tool-error`,title:e.last_error||``,children:e.last_error||`—`})})]},e.tool_name))})]})}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(le,{size:28})}),(0,m.jsx)(`p`,{children:`No tool calls recorded yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(ye,{size:14}),` Upcoming & Overdue`]}),ot.length>0?(0,m.jsx)(`div`,{className:`mem-temporal-list`,children:ot.map(e=>{let t=ht(e.due_at);return(0,m.jsxs)(`div`,{className:`mem-temporal-item ${t?`overdue`:`upcoming`}`,children:[(0,m.jsx)(`span`,{className:`mem-temporal-icon`,children:t?(0,m.jsx)(me,{size:16}):(0,m.jsx)(ye,{size:16})}),(0,m.jsxs)(`div`,{className:`mem-temporal-content`,children:[(0,m.jsx)(`div`,{className:`mem-temporal-text`,children:e.content}),(0,m.jsxs)(`div`,{className:`mem-temporal-date`,children:[t?`OVERDUE`:`Due`,`: `,g(e.due_at),e.context!==`global`&&` \u00B7 ${e.context}`]})]})]},e.id)})}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(l,{size:28})}),(0,m.jsx)(`p`,{children:`Nothing upcoming or overdue`})]})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(a,{size:14}),` Conversation History`]}),(0,m.jsxs)(`div`,{className:`mem-conv-search`,children:[(0,m.jsx)(se,{size:13,className:`search-icon`}),(0,m.jsx)(`input`,{type:`text`,placeholder:`Search conversations...`,value:Kt,onChange:e=>hr(e.target.value),"aria-label":`Search conversations`}),Kt&&(0,m.jsx)(`button`,{className:`mem-search-clear`,onClick:()=>{qt(``),Yt(null)},"aria-label":`Clear search`,children:(0,m.jsx)(je,{size:12})})]}),Jt===null?rt.length>0?(0,m.jsx)(`div`,{className:`mem-conv-list`,children:rt.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>gr(e.session_id),children:[(0,m.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-session-id`,children:[e.session_id.slice(0,8),`...`,e.consolidated&&(0,m.jsx)(`span`,{className:`mem-consolidated-badge`,title:`Consolidated`,children:(0,m.jsx)(et,{size:11})})]}),e.first_message&&(0,m.jsx)(`div`,{className:`mem-conv-preview`,children:e.first_message})]}),(0,m.jsxs)(`div`,{className:`mem-conv-meta`,children:[(0,m.jsxs)(`span`,{children:[e.turn_count,` turns`]}),(0,m.jsx)(`span`,{children:g(e.last_activity)})]})]},e.session_id))}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(a,{size:28})}),(0,m.jsx)(`p`,{children:`No conversation history in memory`})]}):Jt.length>0?(0,m.jsx)(`div`,{className:`mem-conv-list`,children:Jt.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>gr(e.session_id),children:[(0,m.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-session-id`,children:[(0,m.jsx)(`span`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),` `,e.session_id.slice(0,8),`...`]}),(0,m.jsx)(`div`,{className:`mem-conv-preview`,children:e.content})]}),(0,m.jsx)(`div`,{className:`mem-conv-meta`,children:(0,m.jsx)(`span`,{children:g(e.timestamp)})})]},e.id))}):(0,m.jsx)(`div`,{className:`mem-empty`,children:(0,m.jsxs)(`p`,{children:[`No conversations match “`,Kt,`”`]})})]}),C&&(0,m.jsxs)(`div`,{className:`mem-conv-detail-overlay`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-detail-header`,children:[(0,m.jsxs)(`h2`,{children:[`Session: `,C.sessionId.slice(0,12),`...`]}),(0,m.jsx)(`button`,{className:`btn-icon`,onClick:()=>Zt(null),children:(0,m.jsx)(je,{size:16})})]}),(0,m.jsxs)(`div`,{className:`mem-conv-detail-body`,children:[C.turns.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-turn`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-turn-header`,children:[(0,m.jsx)(`div`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),(0,m.jsx)(`span`,{className:`mem-conv-turn-time`,title:h(e.timestamp),children:g(e.timestamp)})]}),(0,m.jsx)(`div`,{className:`mem-conv-turn-content`,children:e.content})]},e.id)),C.turns.length===0&&(0,m.jsx)(`div`,{className:`mem-empty`,children:`No turns found`})]})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(d,{size:14}),` Settings `,(0,m.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,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Memory enabled`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`When disabled, no knowledge or conversation data is stored during any session (global incognito).`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${O?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!O){N(`memory`);return}A(!0);try{let e=await c({memory_enabled:!1});nn(e.memory_enabled)}catch(e){r.system.warn(`Failed to disable memory`,e)}finally{A(!1)}},"aria-pressed":O,"aria-label":`Memory is ${O?`enabled`:`disabled`}`,children:O?`On`:`Off`})]}),M&&(()=>{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 c({memory_enabled:!0});nn(e.memory_enabled),K(`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 c({mcp_memory_enabled:!0});an(e.mcp_memory_enabled),K(`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 c({system_discovery_consent:!0});if(sn(e.system_discovery_consent),e.system_context_error)K(`System discovery enabled but scan failed: ${e.system_context_error}`,`error`);else{let t=e.system_context_refresh?.stored??0;K(`System discovery enabled — ${t} system facts collected`,`info`)}X()}}}[M];return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>N(null)}),(0,m.jsxs)(`div`,{ref:$n,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,m.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[(0,m.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,m.jsx)(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e.title})]}),(0,m.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,m.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,m.jsx)(`li`,{children:e.map((e,t)=>t%2==1?(0,m.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:e},t):(0,m.jsx)(`span`,{children:e},t))},t))}),(0,m.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>N(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:`Cancel`}),(0,m.jsx)(`button`,{disabled:k,onClick:async()=>{A(!0);try{await e.onConfirm()}catch(e){r.system.warn(`Failed to update setting`,e),K(`Failed to update setting. Please try again.`,`error`)}finally{A(!1),N(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,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`MCP memory access`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Expose read-only memory tools to MCP clients (for debug/troubleshooting). Requires MCP server restart.`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${rn?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!rn){N(`mcp`);return}A(!0);try{let e=await c({mcp_memory_enabled:!1});an(e.mcp_memory_enabled)}catch(e){r.system.warn(`Failed to update memory settings`,e)}finally{A(!1)}},"aria-label":`Toggle MCP memory access`,"aria-pressed":rn,children:rn?`On`:`Off`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`System discovery`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Allow GAIA to scan your system for hardware, software, and environment information to personalize responses.`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${on?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!on){N(`discovery`);return}A(!0);try{let e=await c({system_discovery_consent:!1});sn(e.system_discovery_consent)}catch(e){r.system.warn(`Failed to update system discovery setting`,e)}finally{A(!1)}},"aria-label":`Toggle system discovery`,"aria-pressed":on,children:on?`On`:`Off`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Re-initialize memory`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Wipe all memories, conversations, and tool logs, then re-collect system information. This cannot be undone.`})]}),dn?(0,m.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,m.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:async()=>{A(!0);try{let e=await pe();K(`Re-initialized: cleared ${e.cleared.knowledge} entries, restored ${e.system_context.stored} system facts`,`info`),X()}catch(e){r.system.warn(`Failed to reinitialize memory`,e),K(`Failed to re-initialize memory`,`error`)}finally{A(!1),fn(!1)}},children:`Yes, re-initialize`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>fn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:()=>fn(!0),children:`Re-initialize`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Delete all memories`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Permanently wipe all knowledge entries, conversation history, and tool logs. This cannot be undone.`})]}),cn?(0,m.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,m.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:async()=>{A(!0);try{let e=await ze();K(`Deleted ${e.knowledge} knowledge entries, ${e.conversations} conversations`,`info`),X()}catch(e){r.system.warn(`Failed to clear memory`,e),K(`Failed to clear memory`,`error`)}finally{A(!1),ln(!1)}},children:`Yes, delete all`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>ln(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:()=>ln(!0),children:`Delete All`})]})]}),t&&(0,m.jsxs)(`div`,{className:`mem-db-footer`,children:[(0,m.jsxs)(`span`,{children:[`Database: `,Be(t.db_size_bytes),t.knowledge?.avg_confidence!=null&&` \u00B7 Avg confidence: ${t.knowledge.avg_confidence.toFixed(2)}`]}),(0,m.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[t.knowledge?.entity_count!=null&&t.knowledge.entity_count>0&&(0,m.jsxs)(`span`,{children:[t.knowledge.entity_count,` entities`]}),t.knowledge?.sensitive_count!=null&&t.knowledge.sensitive_count>0&&(0,m.jsxs)(`span`,{children:[(0,m.jsx)(d,{size:10}),` `,t.knowledge.sensitive_count,` sensitive`]})]})]})]})}),P===`profile`&&(0,m.jsxs)(`div`,{className:`mem-profile-grid`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,m.jsx)(oe,{size:16}),` System Discovery`]}),(0,m.jsx)(`p`,{className:`mem-profile-desc`,children:`Scan your system to discover apps, projects, and usage patterns.`}),(0,m.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:I===`running`||I===`saving`,onClick:wr,children:I===`running`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Discovery`}),Tn.length>0&&(0,m.jsx)(`div`,{className:`mem-log`,ref:On,children:Tn.map((e,t)=>(0,m.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(I===`review`||I===`saving`||I===`done`)&&z.length>0&&(0,m.jsxs)(`div`,{className:`mem-review-section`,children:[(0,m.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,m.jsx)(`div`,{className:`mem-review-list`,children:z.map((e,t)=>(0,m.jsxs)(`label`,{className:`mem-review-item`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:I===`saving`||I===`done`,onChange:()=>{B(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,m.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,m.jsx)(`span`,{className:`mem-source-badge`,children:e._source_name||e.category}),(0,m.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,m.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,m.jsx)(`button`,{className:`btn-primary`,disabled:I===`saving`||I===`done`||z.filter(e=>e._checked).length===0,onClick:Tr,children:I===`saving`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${z.filter(e=>e._checked).length})`}),(0,m.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,m.jsx)(`a`,{onClick:()=>B(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,m.jsx)(`a`,{onClick:()=>B(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),I===`done`&&En!==null&&(0,m.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,m.jsx)(l,{size:14}),` Saved `,En,` items to memory`]}),I===`review`&&z.length===0&&(0,m.jsx)(`div`,{className:`mem-profile-empty`,children:`No items discovered.`})]}),(0,m.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,m.jsx)(st,{size:16}),` AI Profile Inference`]}),(0,m.jsx)(`p`,{className:`mem-profile-desc`,children:`Use the local LLM to generate profile insights from your data.`}),(0,m.jsx)(`p`,{className:`mem-profile-note`,children:`Requires Lemonade Server running.`}),(0,m.jsxs)(`label`,{className:`mem-profile-checkbox`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:Nn,onChange:e=>Pn(e.target.checked),disabled:V===`running`||V===`saving`}),`Include browser history`]}),(0,m.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:V===`running`||V===`saving`,onClick:Er,children:V===`running`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Inference`}),An.length>0&&(0,m.jsx)(`div`,{className:`mem-log`,ref:Fn,children:An.map((e,t)=>(0,m.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(V===`review`||V===`saving`||V===`done`)&&W.length>0&&(0,m.jsxs)(`div`,{className:`mem-review-section`,children:[(0,m.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,m.jsx)(`div`,{className:`mem-review-list`,children:W.map((e,t)=>(0,m.jsxs)(`label`,{className:`mem-review-item`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:V===`saving`||V===`done`,onChange:()=>{G(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,m.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,m.jsx)(`span`,{className:`mem-domain-badge ${xt[e.domain]||`gray`}`,children:e.domain}),(0,m.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,m.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,m.jsx)(`button`,{className:`btn-primary`,disabled:V===`saving`||V===`done`||W.filter(e=>e._checked).length===0,onClick:Dr,children:V===`saving`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${W.filter(e=>e._checked).length})`}),(0,m.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,m.jsx)(`a`,{onClick:()=>G(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,m.jsx)(`a`,{onClick:()=>G(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),V===`done`&&jn!==null&&(0,m.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,m.jsx)(l,{size:14}),` Saved `,jn,` insights to memory`]}),V===`review`&&W.length===0&&(0,m.jsx)(`div`,{className:`mem-profile-empty`,children:`No insights generated.`})]})]}),P===`goals`&&(0,m.jsxs)(`div`,{className:`mem-goals-tab`,children:[(0,m.jsx)(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(e=>(0,m.jsxs)(`div`,{className:`mem-goals-stat-pill mem-goal-status-${e.replace(`_`,`-`)}`,children:[(0,m.jsx)(`span`,{className:`mem-goals-stat-n`,children:hn?.goals[e]??0}),(0,m.jsx)(`span`,{className:`mem-goals-stat-label`,children:e.replace(`_`,` `)})]},e))}),F.filter(e=>e.status===`pending_approval`).length>0&&(0,m.jsxs)(`div`,{className:`mem-goals-approval-banner`,children:[(0,m.jsxs)(`div`,{className:`mem-goals-approval-title`,children:[(0,m.jsx)(o,{size:14}),` Agent suggested `,F.filter(e=>e.status===`pending_approval`).length,` goal(s) — review before execution`]}),F.filter(e=>e.status===`pending_approval`).map(e=>(0,m.jsxs)(`div`,{className:`mem-goals-approval-item`,children:[(0,m.jsxs)(`div`,{className:`mem-goals-approval-text`,children:[(0,m.jsx)(`strong`,{children:e.title}),(0,m.jsx)(`span`,{children:e.description})]}),(0,m.jsxs)(`div`,{className:`mem-goals-approval-actions`,children:[(0,m.jsx)(`button`,{className:`btn-danger-sm`,onClick:async()=>{await re(e.id),Y()},children:`Reject`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:async()=>{await Se(e.id),Y()},children:`Accept`})]})]},e.id))]}),(0,m.jsx)(`div`,{className:`mem-goals-toolbar`,children:(0,m.jsxs)(`button`,{className:`btn-primary`,onClick:()=>Sn(e=>!e),children:[(0,m.jsx)(qe,{size:14}),` New Goal`]})}),xn&&(0,m.jsxs)(`div`,{className:`mem-goals-add-form`,children:[(0,m.jsx)(`input`,{className:`mem-input`,placeholder:`Goal title`,value:Cn.title,onChange:e=>wn(t=>({...t,title:e.target.value}))}),(0,m.jsx)(`textarea`,{className:`mem-input`,placeholder:`Description — what should the agent work toward?`,rows:2,value:Cn.description,onChange:e=>wn(t=>({...t,description:e.target.value}))}),(0,m.jsxs)(`div`,{className:`mem-goals-form-row`,children:[(0,m.jsxs)(`select`,{className:`mem-select`,value:Cn.priority,onChange:e=>wn(t=>({...t,priority:e.target.value})),children:[(0,m.jsx)(`option`,{value:`low`,children:`Low priority`}),(0,m.jsx)(`option`,{value:`medium`,children:`Medium priority`}),(0,m.jsx)(`option`,{value:`high`,children:`High priority`})]}),(0,m.jsx)(`button`,{className:`btn-primary`,onClick:async()=>{Cn.title.trim()&&(await Te(Cn),wn({title:``,description:``,priority:`medium`}),Sn(!1),Y())},children:`Create`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>Sn(!1),children:`Cancel`})]})]}),_n?(0,m.jsxs)(`div`,{className:`mem-loading`,children:[(0,m.jsx)(`div`,{className:`mem-spinner`}),` Loading goals...`]}):F.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(lt,{size:32})}),(0,m.jsx)(`p`,{children:`No goals yet. Create one or let the agent suggest goals in autonomous mode.`})]}):(0,m.jsx)(`div`,{className:`mem-goals-list`,children:F.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(e=>(0,m.jsxs)(`div`,{className:`mem-goal-card mem-goal-status-${e.status.replace(`_`,`-`)}`,children:[(0,m.jsxs)(`div`,{className:`mem-goal-header`,onClick:()=>bn(t=>t===e.id?null:e.id),children:[(0,m.jsxs)(`div`,{className:`mem-goal-header-left`,children:[(0,m.jsx)(`span`,{className:`mem-goal-status-dot status-${e.status.replace(`_`,`-`)}`}),(0,m.jsx)(`span`,{className:`mem-goal-title`,children:e.title}),(0,m.jsx)(`span`,{className:`mem-goal-priority mem-priority-${e.priority}`,children:e.priority}),e.source!==`user`&&(0,m.jsxs)(`span`,{className:`mem-goal-source-badge`,children:[(0,m.jsx)(o,{size:10}),` `,e.source.replace(`_`,` `)]})]}),(0,m.jsxs)(`div`,{className:`mem-goal-header-right`,children:[(0,m.jsxs)(`span`,{className:`mem-goal-task-count`,children:[(0,m.jsx)(ve,{size:12}),e.tasks.filter(e=>e.status===`completed`).length,`/`,e.tasks.length]}),e.status===`queued`&&(0,m.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:async t=>{t.stopPropagation(),await Fe(e.id),Y()},children:`Cancel`}),(0,m.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,onClick:async t=>{t.stopPropagation(),confirm(`Delete goal "${e.title}"?`)&&(await Ie(e.id),Y())},children:(0,m.jsx)(ie,{size:12})}),(0,m.jsx)(Ve,{size:14,className:yn===e.id?`mem-chevron-open`:``})]})]}),yn===e.id&&(0,m.jsxs)(`div`,{className:`mem-goal-body`,children:[e.description&&(0,m.jsx)(`p`,{className:`mem-goal-desc`,children:e.description}),e.progress_notes&&(0,m.jsx)(`p`,{className:`mem-goal-progress`,children:e.progress_notes}),e.tasks.length>0?(0,m.jsx)(`div`,{className:`mem-task-list`,children:e.tasks.map(e=>(0,m.jsxs)(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[(0,m.jsx)(`span`,{className:`mem-task-dot status-${e.status}`}),(0,m.jsx)(`span`,{className:`mem-task-desc`,children:e.description}),(0,m.jsx)(`span`,{className:`mem-task-status-label`,children:e.status}),e.result&&(0,m.jsx)(`span`,{className:`mem-task-result`,children:e.result})]},e.id))}):(0,m.jsx)(`p`,{className:`mem-goal-no-tasks`,children:`No tasks yet — the agent will break this down when it starts.`})]})]},e.id))})]})]}),jt.length>0&&(0,m.jsx)(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:jt.map(e=>(0,m.jsxs)(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&(0,m.jsx)(l,{size:14}),e.type===`error`&&(0,m.jsx)(me,{size:14}),e.type===`info`&&(0,m.jsx)(Re,{size:14}),(0,m.jsx)(`span`,{children:e.text})]},e.id))})]})}export{St as MemoryDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{t as a}from"./message-square-Ccmbk96j.js";import{A as ee,At as o,C as s,D as te,E as ne,F as re,Ft as ie,I as ae,Jt as oe,L as c,Lt as se,M as ce,Mt as le,N as ue,O as de,Ot as fe,P as pe,Pt as me,Qt as l,Rt as he,S as ge,T as _e,Vt as ve,Xt as ye,Yt as be,_ as xe,a as Se,b as Ce,c as we,d as Te,en as Ee,f as De,g as Oe,h as ke,j as Ae,jt as je,k as Me,l as Ne,m as Pe,o as Fe,p as Ie,qt as Le,rn as Re,s as ze,t as Be,tn as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke,zt as qe}from"./index-D00FJoXi.js";var Je={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Je.node;var Ye=t(Je),u={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};u.node;var Xe=t(u),Ze={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ze.node;var Qe=t(Ze),$e={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`}]]};$e.node;var et=t($e),tt={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};tt.node;var nt=t(tt),rt={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`}]]};rt.node;var it=t(rt),at={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};at.node;var d=t(at),ot={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`]};ot.node;var st=t(ot),ct={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`}]]};ct.node;var lt=t(ct),f={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`}]]};f.node;var ut=t(f),dt={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`}]]};dt.node;var ft=t(dt),p=e(n(),1),m=i();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 h(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 g(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),ee=Math.floor(i/6e4),o=Math.floor(i/36e5),s=Math.floor(i/864e5);return r<0?a<5?`just now`:a<60?`${a}s ago`:o===0?`${ee}m ago`:s===0?`${o}h ago`:s===1?`yesterday`:s<30?`${s}d ago`:h(e):a<5?`now`:a<60?`in ${a}s`:o===0?`in ${ee}m`:s===0?`in ${o}h`:s===1?`tomorrow`:s<30?`in ${s}d`:h(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}=fe(),[t,n]=(0,p.useState)(null),[i,Je]=(0,p.useState)([]),[u,Ze]=(0,p.useState)(null),[$e,tt]=(0,p.useState)([]),[rt,at]=(0,p.useState)([]),[ot,ct]=(0,p.useState)([]),[f,dt]=(0,p.useState)(null),[pt,St]=(0,p.useState)([]),[Ct,wt]=(0,p.useState)(!0),[Tt,Et]=(0,p.useState)(null),[Dt,Ot]=(0,p.useState)(null),[_,v]=(0,p.useState)(!1),[kt,At]=(0,p.useState)(null),[jt,Mt]=(0,p.useState)([]),Nt=(0,p.useRef)(0),[y,Pt]=(0,p.useState)([]),[Ft,It]=(0,p.useState)(``),[Lt,Rt]=(0,p.useState)(``),[zt,Bt]=(0,p.useState)(``),[b,Vt]=(0,p.useState)(`updated_at`),[Ht,Ut]=(0,p.useState)(`desc`),[x,S]=(0,p.useState)(0),[Wt,Gt]=(0,p.useState)(!1),[Kt,qt]=(0,p.useState)(``),[Jt,Yt]=(0,p.useState)(null),Xt=(0,p.useRef)(null),[C,Zt]=(0,p.useState)(null),[Qt,w]=(0,p.useState)(!1),[T,$t]=(0,p.useState)(null),[E,D]=(0,p.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[en,tn]=(0,p.useState)(new Set),[O,nn]=(0,p.useState)(!1),[rn,an]=(0,p.useState)(!1),[on,sn]=(0,p.useState)(!1),[k,A]=(0,p.useState)(!1),[cn,ln]=(0,p.useState)(!1),[j,un]=(0,p.useState)(null),[dn,fn]=(0,p.useState)(!1),[M,N]=(0,p.useState)(null),[P,pn]=(0,p.useState)(`dashboard`),[F,mn]=(0,p.useState)([]),[hn,gn]=(0,p.useState)(null),[_n,vn]=(0,p.useState)(!1),[yn,bn]=(0,p.useState)(null),[xn,Sn]=(0,p.useState)(!1),[Cn,wn]=(0,p.useState)({title:``,description:``,priority:`medium`}),[I,L]=(0,p.useState)(`idle`),[Tn,R]=(0,p.useState)([]),[z,B]=(0,p.useState)([]),[En,Dn]=(0,p.useState)(null),On=(0,p.useRef)(null),kn=(0,p.useRef)(null),[V,H]=(0,p.useState)(`idle`),[An,U]=(0,p.useState)([]),[W,G]=(0,p.useState)([]),[jn,Mn]=(0,p.useState)(null),[Nn,Pn]=(0,p.useState)(!1),Fn=(0,p.useRef)(null),In=(0,p.useRef)(null),[Ln,Rn]=(0,p.useState)(30),[zn,Bn]=(0,p.useState)(!1),[Vn,Hn]=(0,p.useState)(!1),[Un,Wn]=(0,p.useState)(!1),[Gn,Kn]=(0,p.useState)(!1),[qn,Jn]=(0,p.useState)(!1),[Yn,Xn]=(0,p.useState)(!1),Zn=(0,p.useRef)(null),Qn=(0,p.useRef)(null),$n=(0,p.useRef)(null),K=(0,p.useCallback)((e,t=`info`)=>{let n=++Nt.current;Mt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Mt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,p.useEffect)(()=>{if(!_)return;let e=e=>{Qn.current&&!Qn.current.contains(e.target)&&v(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),(0,p.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(M?N(null):cn?ln(!1):dn?fn(!1):C?Zt(null):_?v(!1):Qt||T?(w(!1),$t(null)):kt?At(null):e(!1))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[C,_,Qt,T,kt,e,M,cn,dn]),(0,p.useEffect)(()=>{if(!M)return;let e=$n.current;if(!e)return;let t=document.activeElement;e.focus();let n=()=>Array.from(e.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)),r=t=>{if(t.key!==`Tab`)return;let r=n();if(r.length===0){t.preventDefault();return}let i=document.activeElement,a=!!i&&e.contains(i)&&i!==e;t.shiftKey&&(!a||i===r[0])?(t.preventDefault(),r[r.length-1].focus()):!t.shiftKey&&(!a||i===r[r.length-1])&&(t.preventDefault(),r[0].focus())};return document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`keydown`,r),t?.focus()}},[M]);let er=(0,p.useCallback)(async()=>{try{let e=await We();n(e)}catch(e){r.system.warn(`Failed to load memory stats`,e)}},[]),tr=(0,p.useCallback)(async()=>{try{let e=await Ge(Ln);Je(e)}catch(e){r.system.warn(`Failed to load memory activity`,e)}},[Ln]),q=(0,p.useCallback)(async()=>{try{let e=await Ce({category:y.length>0?y:void 0,context:Ft||void 0,entity:Lt||void 0,search:zt||void 0,sort_by:b,order:Ht,offset:x,limit:15,include_sensitive:!0,include_superseded:Wt});Ze(e)}catch(e){r.system.warn(`Failed to load knowledge`,e)}},[y,Ft,Lt,zt,b,Ht,x,Wt]),nr=(0,p.useCallback)(async()=>{try{let e=await _e();tt(e)}catch(e){r.system.warn(`Failed to load tool summary`,e)}},[]),rr=(0,p.useCallback)(async()=>{try{let e=await ge(20);at(e)}catch(e){r.system.warn(`Failed to load conversations`,e)}},[]),ir=(0,p.useCallback)(async()=>{try{let e=await ne(7);ct(e)}catch(e){r.system.warn(`Failed to load upcoming items`,e)}},[]),J=(0,p.useCallback)(async()=>{try{let e=await xe();dt(e)}catch(e){r.system.warn(`Failed to load embedding coverage`,e)}},[]),ar=(0,p.useCallback)(async()=>{try{let e=await Ue();St(e||[])}catch(e){r.system.warn(`Failed to load entities`,e)}},[]),or=(0,p.useCallback)(async()=>{try{let e=await s();an(e.mcp_memory_enabled),nn(e.memory_enabled),sn(e.system_discovery_consent)}catch(e){r.system.warn(`Failed to load memory settings`,e)}},[]),Y=(0,p.useCallback)(async()=>{vn(!0);try{let[e,t]=await Promise.all([te(),Ke()]);mn(e.goals),gn(t)}catch(e){r.system.warn(`Failed to load goals`,e)}finally{vn(!1)}},[]),X=(0,p.useCallback)(async()=>{wt(!0),Et(null);try{await Promise.all([er(),tr(),q(),nr(),rr(),ir(),J(),ar(),or(),Y()])}catch(e){Et(`Failed to load memory data. Is the backend running?`),r.system.error(`Memory dashboard load failed`,e)}finally{wt(!1)}},[er,tr,q,nr,rr,ir,J,ar,or,Y]);(0,p.useEffect)(()=>{X()},[X]),(0,p.useEffect)(()=>{q()},[q]);let sr=(0,p.useRef)(!0);(0,p.useEffect)(()=>{if(sr.current){sr.current=!1;return}tr()},[tr]);let cr=(0,p.useCallback)(e=>{Bt(e),Xn(!0),Zn.current&&clearTimeout(Zn.current),Zn.current=setTimeout(()=>{S(0),Xn(!1)},300)},[]),Z=(0,p.useCallback)(()=>{q(),er(),J(),ir(),ar()},[q,er,J,ir,ar]),lr=(0,p.useCallback)(async()=>{if(E.content.trim())try{let e=await De({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});w(!1),D({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),Z(),r.ui.info(`Created new knowledge entry`),e?.embedded===!1?K(e.embed_error??`Saved, but not embedded`,`error`):K(`Memory created successfully`,`success`)}catch(e){r.system.error(`Failed to create knowledge`,e),K(`Failed to create memory`,`error`)}},[E,Z,K]),ur=(0,p.useCallback)(async()=>{if(T&&E.content.trim())try{let e=await ke(T,{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});$t(null),D({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),Z(),r.ui.info(`Updated knowledge ${T}`),e?.embedded===!1?K(e.embed_error??`Saved, but not embedded`,`error`):K(`Memory updated`,`success`)}catch(e){r.system.error(`Failed to update knowledge`,e),K(`Failed to update memory`,`error`)}},[T,E,Z,K]),dr=(0,p.useCallback)(async e=>{if(j!==e){un(e);return}un(null);try{await Pe(e),Z(),r.ui.info(`Deleted knowledge ${e}`),K(`Memory deleted`,`info`)}catch(e){r.system.error(`Failed to delete knowledge`,e),K(`Failed to delete memory`,`error`)}},[j,Z,K]);(0,p.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>un(null),3e3);return()=>clearTimeout(e)},[j]);let fr=(0,p.useCallback)(async e=>{try{await ke(e.id,{sensitive:!e.sensitive}),q(),r.ui.info(`Toggled sensitive for ${e.id}: ${!e.sensitive}`),K(e.sensitive?`Unmarked as sensitive`:`Marked as sensitive`,`info`)}catch(e){r.system.error(`Failed to toggle sensitive`,e),K(`Failed to toggle sensitive flag`,`error`)}},[q,K]),pr=(0,p.useCallback)(e=>{$t(e.id),w(!1),D({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),mr=(0,p.useCallback)(e=>{navigator.clipboard.writeText(e).catch(()=>{}),r.ui.info(`Copied knowledge ID: ${e}`),K(`ID copied to clipboard`,`info`)},[K]),hr=(0,p.useCallback)(e=>{if(qt(e),Xt.current&&clearTimeout(Xt.current),!e.trim()){Yt(null);return}Xt.current=setTimeout(async()=>{try{let t=await ae(e.trim(),20);Yt(t)}catch(e){r.system.warn(`Conversation search failed`,e)}},300)},[]),gr=(0,p.useCallback)(async e=>{try{let t=await Oe(e);Zt({sessionId:e,turns:t})}catch(e){r.system.error(`Failed to load conversation detail`,e)}},[]),_r=(0,p.useCallback)(e=>{Pt(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),S(0)},[]),Q=(0,p.useCallback)(e=>{b===e?Ut(e=>e===`desc`?`asc`:`desc`):(Vt(e),Ut(`desc`)),S(0)},[b]),vr=(0,p.useCallback)(async()=>{Bn(!0),v(!1);try{let e=await He();await X(),K(`Consolidated ${e.consolidated??0} sessions, extracted ${e.extracted_items??0} items`,`success`)}catch(e){r.system.error(`Failed to consolidate sessions`,e),K(`Failed to consolidate sessions`,`error`)}finally{Bn(!1)}},[X,K]),yr=(0,p.useCallback)(async()=>{Hn(!0),v(!1);try{let e=await ee();await J(),K(`Backfilled ${e.backfilled??0} embeddings${e.total_without?` (${e.total_without} were missing)`:``}`,`success`)}catch(e){r.system.error(`Failed to rebuild embeddings`,e),K(`Failed to rebuild embeddings`,`error`)}finally{Hn(!1)}},[J,K]),br=(0,p.useCallback)(async()=>{Wn(!0),v(!1);try{let e=await ce();await X(),K(`Checked ${e.pairs_checked??0} pairs: ${e.reinforced??0} reinforced, ${e.contradicted??0} contradicted`,`success`)}catch(e){r.system.error(`Failed to reconcile memory`,e),K(`Failed to reconcile memory`,`error`)}finally{Wn(!1)}},[X,K]),xr=(0,p.useCallback)(async()=>{Kn(!0),v(!1);try{await Ae(),await X(),K(`FTS indexes rebuilt successfully`,`success`)}catch(e){r.system.error(`Failed to rebuild FTS index`,e),K(`Failed to rebuild FTS indexes`,`error`)}finally{Kn(!1)}},[X,K]),Sr=(0,p.useCallback)(async()=>{Jn(!0),v(!1);try{let e=await ue();await X(),e.skipped?K(`System context collection is disabled — enable it in settings`,`error`):K(`System context refreshed: ${e.stored} facts updated`,`success`)}catch(e){r.system.error(`Failed to refresh system context`,e),K(`Failed to refresh system context`,`error`)}finally{Jn(!1)}},[X,K]),Cr=zn||Vn||Un||Gn||qn,wr=(0,p.useCallback)(()=>{L(`running`),R([]),B([]),Dn(null);let e=de();kn.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)R(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`finding`){let e=n.item;R(t=>[...t,{text:` Found: ${e.content}`,kind:`finding`}]),B(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?R(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),kn.current=null,R(e=>[...e,{text:`Done. ${n.total??0} items discovered.`,kind:`log`}]),L(`review`))}catch{R(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),kn.current=null,R(e=>[...e,{text:`Connection error. Is the GAIA server running?`,kind:`error`}]),B(e=>(L(e.length>0?`review`:`idle`),e))}},[]),Tr=(0,p.useCallback)(async()=>{let e=z.filter(e=>e._checked);if(e.length!==0){L(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await we(t);Dn(n.stored),L(`done`),K(`Saved ${n.stored} items to memory`,`success`)}catch(e){r.system.error(`Failed to commit discovery items`,e),K(`Failed to save discovery items`,`error`),L(`review`)}}},[z,K]),Er=(0,p.useCallback)(()=>{H(`running`),U([]),G([]),Mn(null);let e=Me(Nn);In.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)U(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`insight`){let e=n.item;U(t=>[...t,{text:` Insight: ${e.content}`,kind:`finding`}]),G(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?U(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),In.current=null,U(e=>[...e,{text:`Done. ${n.total??0} insights generated.`,kind:`log`}]),H(`review`))}catch{U(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),In.current=null,U(e=>[...e,{text:`Connection error. Is Lemonade Server running?`,kind:`error`}]),G(e=>(H(e.length>0?`review`:`idle`),e))}},[Nn]),Dr=(0,p.useCallback)(async()=>{let e=W.filter(e=>e._checked);if(e.length!==0){H(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await Ne(t);Mn(n.stored),H(`done`),K(`Saved ${n.stored} insights to memory`,`success`)}catch(e){r.system.error(`Failed to commit inference insights`,e),K(`Failed to save inference insights`,`error`),H(`review`)}}},[W,K]);(0,p.useEffect)(()=>{On.current&&(On.current.scrollTop=On.current.scrollHeight)},[Tn]),(0,p.useEffect)(()=>{Fn.current&&(Fn.current.scrollTop=Fn.current.scrollHeight)},[An]),(0,p.useEffect)(()=>()=>{kn.current&&=(kn.current.close(),null),In.current&&=(In.current.close(),null)},[]);let $=e=>b===e?(0,m.jsx)(`span`,{className:`mem-sort-arrow`,children:Ht===`desc`?`↓`:`↑`}):null,Or=Math.max(1,...i.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),kr=t?.knowledge?.by_context?Object.keys(t.knowledge.by_context):[];return(0,m.jsxs)(`div`,{className:`memory-dashboard-page`,children:[(0,m.jsxs)(`div`,{className:`memory-dashboard-header`,children:[(0,m.jsxs)(`div`,{className:`memory-dashboard-header-left`,children:[(0,m.jsx)(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>e(!1),"aria-label":`Back`,children:(0,m.jsx)(Ye,{size:18})}),(0,m.jsxs)(`h1`,{children:[`Memory Dashboard `,(0,m.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,m.jsxs)(`div`,{className:`memory-dashboard-header-actions`,children:[f&&f.total_items>0&&(0,m.jsxs)(`div`,{className:`mem-embedding-coverage`,title:`${f.with_embedding} of ${f.total_items} entries embedded`,children:[(0,m.jsx)(`div`,{className:`mem-embedding-bar`,children:(0,m.jsx)(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(f.coverage_pct)}%`}})}),(0,m.jsxs)(`span`,{className:`mem-embedding-label`,children:[Math.round(f.coverage_pct),`% embedded`]})]}),(0,m.jsxs)(`div`,{className:`mem-maintenance-wrap`,ref:Qn,children:[(0,m.jsxs)(`button`,{className:`btn-icon ${Cr?`mem-spinning`:``}`,onClick:()=>v(e=>!e),title:`Maintenance actions`,"aria-label":`Maintenance actions`,"aria-expanded":_,children:[Cr?(0,m.jsx)(`div`,{className:`mem-spinner-sm`}):(0,m.jsx)(Le,{size:16}),(0,m.jsx)(Ve,{size:10,style:{marginLeft:2}})]}),_&&(0,m.jsxs)(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:vr,disabled:zn,role:`menuitem`,children:[(0,m.jsx)(et,{size:14}),zn?`Consolidating...`:`Consolidate Sessions`]}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:yr,disabled:Vn,role:`menuitem`,children:[(0,m.jsx)(o,{size:14}),Vn?`Rebuilding...`:`Rebuild Embeddings`]}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:br,disabled:Un,role:`menuitem`,children:[(0,m.jsx)(l,{size:14}),Un?`Reconciling...`:`Reconcile Memory`]}),(0,m.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Sr,disabled:qn,role:`menuitem`,children:[(0,m.jsx)(he,{size:14}),qn?`Refreshing...`:`Refresh System Context`]}),(0,m.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,m.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:xr,disabled:Gn,role:`menuitem`,children:[(0,m.jsx)(se,{size:14}),Gn?`Rebuilding...`:`Rebuild FTS Indexes`]})]})]}),(0,m.jsx)(`button`,{className:`btn-icon`,onClick:X,title:`Refresh`,"aria-label":`Refresh dashboard`,children:(0,m.jsx)(he,{size:16})})]})]}),(0,m.jsxs)(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`dashboard`?` mem-tab-active`:``}`,onClick:()=>pn(`dashboard`),role:`tab`,"aria-selected":P===`dashboard`,children:[(0,m.jsx)(Re,{size:14}),` Dashboard`]}),(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`goals`?` mem-tab-active`:``}`,onClick:()=>{pn(`goals`),Y()},role:`tab`,"aria-selected":P===`goals`,children:[(0,m.jsx)(lt,{size:14}),` Goals`,hn&&(hn.goals.pending_approval??0)>0&&(0,m.jsx)(`span`,{className:`mem-tab-badge`,children:hn.goals.pending_approval})]}),(0,m.jsxs)(`button`,{className:`mem-tab-btn${P===`profile`?` mem-tab-active`:``}`,onClick:()=>pn(`profile`),role:`tab`,"aria-selected":P===`profile`,children:[(0,m.jsx)(ft,{size:14}),` Profile`]})]}),(0,m.jsxs)(`div`,{className:`memory-dashboard-body`,children:[P===`dashboard`&&(0,m.jsx)(m.Fragment,{children:Ct&&!t?(0,m.jsxs)(`div`,{className:`mem-loading`,children:[(0,m.jsx)(`div`,{className:`mem-spinner`}),`Loading memory data...`]}):Tt?(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(me,{size:32})}),(0,m.jsx)(`p`,{children:Tt}),(0,m.jsxs)(`button`,{className:`btn-secondary`,onClick:X,style:{marginTop:12},children:[(0,m.jsx)(he,{size:14}),` Retry`]})]}):(0,m.jsxs)(m.Fragment,{children:[!O&&(0,m.jsxs)(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:(0,m.jsx)(d,{size:32})}),(0,m.jsx)(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:`Memory is disabled. Enable it in Settings below to start storing knowledge, conversations, and preferences.`})]}),O&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`mem-stat-cards`,children:[(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.knowledge?.total??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Stored`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:(()=>{let e=yt(i);return e>0?`+${e} today`:t?.knowledge?.by_category?Object.entries(t.knowledge.by_category).slice(0,3).map(([e,t])=>`${t} ${e}s`).join(`, `):`No entries`})()})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.knowledge?.total_retrievals??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Retrieved`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:t?.knowledge?.total&&t?.knowledge?.total_retrievals?`avg ${(t.knowledge.total_retrievals/t.knowledge.total).toFixed(1)}x per memory`:`No recalls yet`})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.conversations?.total_sessions??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Sessions`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:vt(t?.conversations?.first_session??null,t?.conversations?.last_session??null)||`${t?.conversations?.total_turns??0} total turns`})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.tools?.total_calls??0}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Tool Calls`}),(0,m.jsxs)(`div`,{className:`mem-stat-sub`,title:`Memory tools (remember, recall, ...) are not logged`,children:[t?.tools?.unique_tools??0,` tools, excl. memory`]})]}),(0,m.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[(0,m.jsx)(`div`,{className:`mem-stat-value`,children:t?.tools?.overall_success_rate!=null&&(t.tools.total_calls??0)>0?`${Math.round(t.tools.overall_success_rate*100)}%`:`—`}),(0,m.jsx)(`div`,{className:`mem-stat-label`,children:`Success Rate`}),(0,m.jsx)(`div`,{className:`mem-stat-sub`,children:(t?.tools?.total_calls??0)>0?`${t?.tools?.total_errors??0} errors`:`No tool calls yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,m.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,m.jsx)(ut,{size:14}),` Activity`]}),(0,m.jsx)(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":`Activity range`,children:[1,7,30].map(e=>(0,m.jsx)(`button`,{className:`mem-range-tab${Ln===e?` active`:``}`,onClick:()=>Rn(e),children:e===1?`1D`:e===7?`7D`:`30D`},e))})]}),i.length>0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-activity-chart`,children:i.map((e,t)=>{let n=e.conversations+e.tool_calls+e.knowledge_added+e.errors,r=t===0||t===i.length-1||t%7==0,a=new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,m.jsxs)(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>Ot(t),onMouseLeave:()=>Ot(null),children:[e.errors>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar errors`,style:{height:`${e.errors/Or*100}%`}}),e.knowledge_added>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${e.knowledge_added/Or*100}%`}}),e.tool_calls>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${e.tool_calls/Or*100}%`}}),e.conversations>0&&(0,m.jsx)(`div`,{className:`mem-activity-bar conversations`,style:{height:`${e.conversations/Or*100}%`}}),r&&(0,m.jsx)(`span`,{className:`mem-activity-date-label`,children:a}),Dt===t&&n>0&&(0,m.jsxs)(`div`,{className:`mem-activity-tooltip`,children:[(0,m.jsx)(`strong`,{children:a}),(0,m.jsx)(`br`,{}),e.conversations>0&&(0,m.jsxs)(m.Fragment,{children:[e.conversations,` conversations`,(0,m.jsx)(`br`,{})]}),e.tool_calls>0&&(0,m.jsxs)(m.Fragment,{children:[e.tool_calls,` tool calls`,(0,m.jsx)(`br`,{})]}),e.knowledge_added>0&&(0,m.jsxs)(m.Fragment,{children:[e.knowledge_added,` learned`,(0,m.jsx)(`br`,{})]}),e.errors>0&&(0,m.jsxs)(m.Fragment,{children:[e.errors,` errors`]})]})]},e.date)})}),(0,m.jsxs)(`div`,{className:`mem-activity-legend`,children:[(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot conversations`}),` Conversations`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot tool_calls`}),` Tool Calls`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot knowledge`}),` Knowledge`]}),(0,m.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,m.jsx)(`span`,{className:`mem-activity-legend-dot errors`}),` Errors`]})]})]}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(ut,{size:28})}),(0,m.jsx)(`p`,{children:`No activity data yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,m.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,m.jsx)(Re,{size:14}),` Knowledge Browser`,u&&u.total>0&&(0,m.jsx)(`span`,{className:`mem-section-count`,children:u.total})]}),!Qt&&!T&&(0,m.jsxs)(`button`,{className:`mem-section-add-btn`,onClick:()=>w(!0),title:`Add a memory entry`,children:[(0,m.jsx)(qe,{size:13}),` Add`]})]}),(0,m.jsxs)(`div`,{className:`mem-filters`,children:[(0,m.jsxs)(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":`Filter by category`,children:[bt.map(e=>(0,m.jsx)(`button`,{className:`mem-category-pill ${e}${y.includes(e)?` active`:``}`,onClick:()=>_r(e),"aria-pressed":y.includes(e),children:e},e)),y.length>0&&(0,m.jsx)(`button`,{className:`mem-category-pill clear`,onClick:()=>{Pt([]),S(0)},"aria-label":`Clear category filters`,children:`✕ Clear`})]}),(0,m.jsxs)(`select`,{className:`mem-filter-select`,value:Ft,onChange:e=>{It(e.target.value),S(0)},"aria-label":`Filter by context`,children:[(0,m.jsx)(`option`,{value:``,children:`All Contexts`}),kr.map(e=>(0,m.jsx)(`option`,{value:e,children:e},e))]}),(0,m.jsxs)(`select`,{className:`mem-filter-select`,value:Lt,onChange:e=>{Rt(e.target.value),S(0)},"aria-label":`Filter by entity`,children:[(0,m.jsx)(`option`,{value:``,children:`All Entities`}),pt.map(e=>(0,m.jsxs)(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),(0,m.jsxs)(`div`,{className:`mem-filter-search-wrap`,children:[Yn?(0,m.jsx)(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):(0,m.jsx)(se,{size:13,className:`search-icon`}),(0,m.jsx)(`input`,{className:`mem-filter-search`,type:`text`,placeholder:`Search memories...`,value:zt,onChange:e=>cr(e.target.value),"aria-label":`Search memories`})]}),(0,m.jsxs)(`label`,{className:`mem-filter-toggle`,title:`Show entries that have been superseded by newer versions`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:Wt,onChange:e=>Gt(e.target.checked)}),(0,m.jsx)(`span`,{children:`Superseded`})]})]}),(Qt||T)&&(0,m.jsxs)(`div`,{className:`mem-inline-form`,children:[(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Content`}),(0,m.jsx)(`textarea`,{value:E.content,onChange:e=>D(t=>({...t,content:e.target.value})),placeholder:`What should the agent remember?`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Category`}),(0,m.jsx)(`select`,{value:E.category,onChange:e=>D(t=>({...t,category:e.target.value})),children:bt.map(e=>(0,m.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Context`}),(0,m.jsx)(`input`,{type:`text`,value:E.context,onChange:e=>D(t=>({...t,context:e.target.value})),placeholder:`global`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Domain`}),(0,m.jsx)(`input`,{type:`text`,value:E.domain,onChange:e=>D(t=>({...t,domain:e.target.value})),placeholder:`e.g., python, frontend`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Entity`}),(0,m.jsx)(`input`,{type:`text`,value:E.entity,onChange:e=>D(t=>({...t,entity:e.target.value})),placeholder:`e.g., person:sarah_chen`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Due At`}),(0,m.jsx)(`input`,{type:`text`,value:E.due_at,onChange:e=>D(t=>({...t,due_at:e.target.value})),placeholder:`ISO 8601 (e.g., 2026-03-25T09:00:00-07:00)`})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,m.jsx)(`label`,{children:`Sensitive`}),(0,m.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:E.sensitive,onChange:e=>D(t=>({...t,sensitive:e.target.checked}))}),`Mark as sensitive (excluded from system prompt)`]})]}),(0,m.jsxs)(`div`,{className:`mem-inline-form-actions`,children:[(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{w(!1),$t(null)},children:`Cancel`}),(0,m.jsx)(`button`,{className:`btn-primary`,onClick:T?ur:lr,style:{padding:`8px 20px`,fontSize:13},children:T?`Update`:`Save`})]})]}),u&&u.items.length>0?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{style:{overflowX:`auto`},children:(0,m.jsxs)(`table`,{className:`mem-knowledge-table`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsxs)(`th`,{onClick:()=>Q(`category`),className:b===`category`?`sorted`:``,children:[`Category`,$(`category`)]}),(0,m.jsx)(`th`,{children:`Content`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`context`),className:b===`context`?`sorted`:``,children:[`Context`,$(`context`)]}),(0,m.jsx)(`th`,{children:`Entity`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`confidence`),className:b===`confidence`?`sorted`:``,children:[`Confidence`,$(`confidence`)]}),(0,m.jsx)(`th`,{children:`Source`}),(0,m.jsxs)(`th`,{onClick:()=>Q(`updated_at`),className:b===`updated_at`?`sorted`:``,children:[`Updated`,$(`updated_at`)]}),(0,m.jsxs)(`th`,{onClick:()=>Q(`created_at`),className:b===`created_at`?`sorted`:``,children:[`Created`,$(`created_at`)]}),(0,m.jsx)(`th`,{children:`Due`}),(0,m.jsx)(`th`,{className:`mem-actions-cell`})]})}),(0,m.jsx)(`tbody`,{children:u.items.map(e=>{let t=kt===e.id,n=e.has_embedding;return(0,m.jsxs)(p.Fragment,{children:[(0,m.jsxs)(`tr`,{className:`${e.superseded_by?`mem-superseded-row`:``} ${t?`mem-expanded-row`:``}`,onClick:()=>At(t?null:e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),At(t?null:e.id))},tabIndex:0,role:`row`,"aria-expanded":t,style:{cursor:`pointer`},children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-cat-badge ${e.category}`,children:e.category})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-content-cell`,title:e.content,children:[n!==void 0&&(0,m.jsx)(`span`,{className:`mem-embed-dot ${n?`embedded`:`missing`}`,title:n?`Embedded`:`Embedding missing`,children:(0,m.jsx)(Qe,{size:6,fill:`currentColor`})}),e.sensitive&&(0,m.jsx)(`span`,{className:`mem-sensitive-badge`,title:`Sensitive`,children:(0,m.jsx)(d,{size:11})}),(0,m.jsx)(`span`,{className:e.sensitive&&!en.has(e.id)?`mem-sensitive-blur`:e.superseded_by?`mem-superseded-text`:``,onClick:t=>{e.sensitive&&(t.stopPropagation(),tn(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}))},children:e.content})]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,children:e.context})}),(0,m.jsx)(`td`,{children:e.entity?(0,m.jsx)(`span`,{className:`mem-entity-link`,onClick:t=>{t.stopPropagation(),Rt(e.entity),S(0)},title:`Filter by ${e.entity}`,children:e.entity}):(0,m.jsx)(`span`,{className:`mem-date-cell`,children:`—`})}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-confidence`,children:[(0,m.jsx)(`div`,{className:`mem-confidence-bar`,children:(0,m.jsx)(`div`,{className:`mem-confidence-fill ${gt(e.confidence)}`,style:{width:`${e.confidence*100}%`}})}),e.confidence.toFixed(2)]})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,children:e.source||`—`})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.updated_at),children:g(e.updated_at)})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.created_at),children:g(e.created_at)})}),(0,m.jsx)(`td`,{children:e.due_at?(0,m.jsx)(`span`,{className:`mem-due-badge ${ht(e.due_at)?`overdue`:`upcoming`}`,title:h(e.due_at),children:g(e.due_at)}):(0,m.jsx)(`span`,{className:`mem-due-badge none`,children:`—`})}),(0,m.jsx)(`td`,{className:`mem-actions-cell`,children:(0,m.jsxs)(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>pr(e),title:`Edit`,children:(0,m.jsx)(nt,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>fr(e),title:e.sensitive?`Unmark sensitive`:`Mark sensitive`,children:e.sensitive?(0,m.jsx)(it,{size:13}):(0,m.jsx)(d,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>mr(e.id),title:`Copy ID`,children:(0,m.jsx)(be,{size:13})}),(0,m.jsx)(`button`,{className:`mem-row-action-btn delete${j===e.id?` is-confirm`:``}`,onClick:()=>dr(e.id),title:j===e.id?`Click again to delete`:`Delete`,"aria-label":j===e.id?`Confirm delete memory`:`Delete memory`,children:j===e.id?(0,m.jsx)(`span`,{className:`mem-row-delete-label`,children:`Delete?`}):(0,m.jsx)(ie,{size:13})})]})})]}),t&&(0,m.jsx)(`tr`,{className:`mem-detail-row`,children:(0,m.jsx)(`td`,{colSpan:10,children:(0,m.jsxs)(`div`,{className:`mem-detail-panel`,children:[(0,m.jsxs)(`div`,{className:`mem-detail-grid`,children:[(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`ID`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.id})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Domain`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.domain||`—`})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Source`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.source||`—`})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Use Count`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:e.use_count??0})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Created`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.created_at)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Updated`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.updated_at)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Last Used`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.last_used)})]}),(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Reminded At`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:h(e.reminded_at)})]}),e.superseded_by&&(0,m.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Superseded By`}),(0,m.jsx)(`span`,{className:`mem-detail-value mem-detail-chain`,children:e.superseded_by})]}),e.metadata&&(0,m.jsxs)(`div`,{className:`mem-detail-field mem-detail-full`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Metadata`}),(0,m.jsx)(`span`,{className:`mem-detail-value`,children:typeof e.metadata==`object`?JSON.stringify(e.metadata,null,2):e.metadata})]})]}),(0,m.jsxs)(`div`,{className:`mem-detail-content-full`,children:[(0,m.jsx)(`span`,{className:`mem-detail-label`,children:`Full Content`}),(0,m.jsx)(`div`,{className:`mem-detail-content-text`,children:e.content})]})]})})})]},e.id)})})]})}),(0,m.jsxs)(`div`,{className:`mem-pagination`,children:[(0,m.jsxs)(`span`,{children:[x+1,`–`,Math.min(x+15,u.total),` of `,u.total]}),(0,m.jsxs)(`div`,{className:`mem-pagination-btns`,children:[(0,m.jsx)(`button`,{className:`mem-page-btn`,disabled:x===0,onClick:()=>S(Math.max(0,x-15)),children:(0,m.jsx)(Xe,{size:14})}),(0,m.jsx)(`button`,{className:`mem-page-btn`,disabled:x+15>=u.total,onClick:()=>S(x+15),children:(0,m.jsx)(Ee,{size:14})})]})]})]}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(Re,{size:28})}),(0,m.jsx)(`p`,{children:zt||y.length>0||Ft||Lt?`No matching memories`:`No memories stored yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-two-col`,children:[(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(le,{size:14}),` Tool Performance`,(0,m.jsx)(`span`,{className:`mem-section-note`,title:`remember, recall, update_memory, forget and search_past_conversations are not logged`,children:`excludes memory tools`})]}),$e.length>0?(0,m.jsx)(`div`,{style:{overflowX:`auto`},children:(0,m.jsxs)(`table`,{className:`mem-tool-table`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{children:`Tool`}),(0,m.jsx)(`th`,{children:`Calls`}),(0,m.jsx)(`th`,{children:`Success`}),(0,m.jsx)(`th`,{children:`Avg Time`}),(0,m.jsx)(`th`,{children:`Last Used`}),(0,m.jsx)(`th`,{children:`Last Error`})]})}),(0,m.jsx)(`tbody`,{children:$e.map(e=>(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-tool-name`,children:e.tool_name})}),(0,m.jsx)(`td`,{children:e.total_calls}),(0,m.jsx)(`td`,{children:(0,m.jsxs)(`div`,{className:`mem-confidence`,children:[(0,m.jsx)(`div`,{className:`mem-confidence-bar`,style:{width:40},children:(0,m.jsx)(`div`,{className:`mem-confidence-fill ${_t(e.success_rate)}`,style:{width:`${e.success_rate*100}%`}})}),(0,m.jsxs)(`span`,{className:`mem-success-rate ${_t(e.success_rate)}`,children:[Math.round(e.success_rate*100),`%`]})]})}),(0,m.jsx)(`td`,{children:mt(e.avg_duration_ms)}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-date-cell`,title:h(e.last_used),children:g(e.last_used)})}),(0,m.jsx)(`td`,{children:(0,m.jsx)(`span`,{className:`mem-tool-error`,title:e.last_error||``,children:e.last_error||`—`})})]},e.tool_name))})]})}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(le,{size:28})}),(0,m.jsx)(`p`,{children:`No tool calls recorded yet`})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(ye,{size:14}),` Upcoming & Overdue`]}),ot.length>0?(0,m.jsx)(`div`,{className:`mem-temporal-list`,children:ot.map(e=>{let t=ht(e.due_at);return(0,m.jsxs)(`div`,{className:`mem-temporal-item ${t?`overdue`:`upcoming`}`,children:[(0,m.jsx)(`span`,{className:`mem-temporal-icon`,children:t?(0,m.jsx)(me,{size:16}):(0,m.jsx)(ye,{size:16})}),(0,m.jsxs)(`div`,{className:`mem-temporal-content`,children:[(0,m.jsx)(`div`,{className:`mem-temporal-text`,children:e.content}),(0,m.jsxs)(`div`,{className:`mem-temporal-date`,children:[t?`OVERDUE`:`Due`,`: `,g(e.due_at),e.context!==`global`&&` \u00B7 ${e.context}`]})]})]},e.id)})}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(l,{size:28})}),(0,m.jsx)(`p`,{children:`Nothing upcoming or overdue`})]})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(a,{size:14}),` Conversation History`]}),(0,m.jsxs)(`div`,{className:`mem-conv-search`,children:[(0,m.jsx)(se,{size:13,className:`search-icon`}),(0,m.jsx)(`input`,{type:`text`,placeholder:`Search conversations...`,value:Kt,onChange:e=>hr(e.target.value),"aria-label":`Search conversations`}),Kt&&(0,m.jsx)(`button`,{className:`mem-search-clear`,onClick:()=>{qt(``),Yt(null)},"aria-label":`Clear search`,children:(0,m.jsx)(je,{size:12})})]}),Jt===null?rt.length>0?(0,m.jsx)(`div`,{className:`mem-conv-list`,children:rt.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>gr(e.session_id),children:[(0,m.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-session-id`,children:[e.session_id.slice(0,8),`...`,e.consolidated&&(0,m.jsx)(`span`,{className:`mem-consolidated-badge`,title:`Consolidated`,children:(0,m.jsx)(et,{size:11})})]}),e.first_message&&(0,m.jsx)(`div`,{className:`mem-conv-preview`,children:e.first_message})]}),(0,m.jsxs)(`div`,{className:`mem-conv-meta`,children:[(0,m.jsxs)(`span`,{children:[e.turn_count,` turns`]}),(0,m.jsx)(`span`,{children:g(e.last_activity)})]})]},e.session_id))}):(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(a,{size:28})}),(0,m.jsx)(`p`,{children:`No conversation history in memory`})]}):Jt.length>0?(0,m.jsx)(`div`,{className:`mem-conv-list`,children:Jt.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>gr(e.session_id),children:[(0,m.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-session-id`,children:[(0,m.jsx)(`span`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),` `,e.session_id.slice(0,8),`...`]}),(0,m.jsx)(`div`,{className:`mem-conv-preview`,children:e.content})]}),(0,m.jsx)(`div`,{className:`mem-conv-meta`,children:(0,m.jsx)(`span`,{children:g(e.timestamp)})})]},e.id))}):(0,m.jsx)(`div`,{className:`mem-empty`,children:(0,m.jsxs)(`p`,{children:[`No conversations match “`,Kt,`”`]})})]}),C&&(0,m.jsxs)(`div`,{className:`mem-conv-detail-overlay`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-detail-header`,children:[(0,m.jsxs)(`h2`,{children:[`Session: `,C.sessionId.slice(0,12),`...`]}),(0,m.jsx)(`button`,{className:`btn-icon`,onClick:()=>Zt(null),children:(0,m.jsx)(je,{size:16})})]}),(0,m.jsxs)(`div`,{className:`mem-conv-detail-body`,children:[C.turns.map(e=>(0,m.jsxs)(`div`,{className:`mem-conv-turn`,children:[(0,m.jsxs)(`div`,{className:`mem-conv-turn-header`,children:[(0,m.jsx)(`div`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),(0,m.jsx)(`span`,{className:`mem-conv-turn-time`,title:h(e.timestamp),children:g(e.timestamp)})]}),(0,m.jsx)(`div`,{className:`mem-conv-turn-content`,children:e.content})]},e.id)),C.turns.length===0&&(0,m.jsx)(`div`,{className:`mem-empty`,children:`No turns found`})]})]})]}),(0,m.jsxs)(`div`,{className:`mem-section`,children:[(0,m.jsxs)(`div`,{className:`mem-section-title`,children:[(0,m.jsx)(d,{size:14}),` Settings `,(0,m.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,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Memory enabled`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`When disabled, no knowledge or conversation data is stored during any session (global incognito).`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${O?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!O){N(`memory`);return}A(!0);try{let e=await c({memory_enabled:!1});nn(e.memory_enabled)}catch(e){r.system.warn(`Failed to disable memory`,e)}finally{A(!1)}},"aria-pressed":O,"aria-label":`Memory is ${O?`enabled`:`disabled`}`,children:O?`On`:`Off`})]}),M&&(()=>{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 c({memory_enabled:!0});nn(e.memory_enabled),K(`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 c({mcp_memory_enabled:!0});an(e.mcp_memory_enabled),K(`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 c({system_discovery_consent:!0});if(sn(e.system_discovery_consent),e.system_context_error)K(`System discovery enabled but scan failed: ${e.system_context_error}`,`error`);else{let t=e.system_context_refresh?.stored??0;K(`System discovery enabled — ${t} system facts collected`,`info`)}X()}}}[M];return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>N(null)}),(0,m.jsxs)(`div`,{ref:$n,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,m.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[(0,m.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,m.jsx)(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e.title})]}),(0,m.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,m.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,m.jsx)(`li`,{children:e.map((e,t)=>t%2==1?(0,m.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:e},t):(0,m.jsx)(`span`,{children:e},t))},t))}),(0,m.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>N(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:`Cancel`}),(0,m.jsx)(`button`,{disabled:k,onClick:async()=>{A(!0);try{await e.onConfirm()}catch(e){r.system.warn(`Failed to update setting`,e),K(`Failed to update setting. Please try again.`,`error`)}finally{A(!1),N(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,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`MCP memory access`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Expose read-only memory tools to MCP clients (for debug/troubleshooting). Requires MCP server restart.`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${rn?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!rn){N(`mcp`);return}A(!0);try{let e=await c({mcp_memory_enabled:!1});an(e.mcp_memory_enabled)}catch(e){r.system.warn(`Failed to update memory settings`,e)}finally{A(!1)}},"aria-label":`Toggle MCP memory access`,"aria-pressed":rn,children:rn?`On`:`Off`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`System discovery`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Allow GAIA to scan your system for hardware, software, and environment information to personalize responses.`})]}),(0,m.jsx)(`button`,{className:`mem-toggle${on?` mem-toggle-on`:``}`,disabled:k,onClick:async()=>{if(!on){N(`discovery`);return}A(!0);try{let e=await c({system_discovery_consent:!1});sn(e.system_discovery_consent)}catch(e){r.system.warn(`Failed to update system discovery setting`,e)}finally{A(!1)}},"aria-label":`Toggle system discovery`,"aria-pressed":on,children:on?`On`:`Off`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Re-initialize memory`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Wipe all memories, conversations, and tool logs, then re-collect system information. This cannot be undone.`})]}),dn?(0,m.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,m.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:async()=>{A(!0);try{let e=await pe();K(`Re-initialized: cleared ${e.cleared.knowledge} entries, restored ${e.system_context.stored} system facts`,`info`),X()}catch(e){r.system.warn(`Failed to reinitialize memory`,e),K(`Failed to re-initialize memory`,`error`)}finally{A(!1),fn(!1)}},children:`Yes, re-initialize`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>fn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:()=>fn(!0),children:`Re-initialize`})]}),(0,m.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,m.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,m.jsx)(`span`,{className:`mem-setting-label`,children:`Delete all memories`}),(0,m.jsx)(`span`,{className:`mem-setting-desc`,children:`Permanently wipe all knowledge entries, conversation history, and tool logs. This cannot be undone.`})]}),cn?(0,m.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,m.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:async()=>{A(!0);try{let e=await ze();K(`Deleted ${e.knowledge} knowledge entries, ${e.conversations} conversations`,`info`),X()}catch(e){r.system.warn(`Failed to clear memory`,e),K(`Failed to clear memory`,`error`)}finally{A(!1),ln(!1)}},children:`Yes, delete all`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>ln(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,m.jsx)(`button`,{className:`mem-btn-danger`,disabled:k,onClick:()=>ln(!0),children:`Delete All`})]})]}),t&&(0,m.jsxs)(`div`,{className:`mem-db-footer`,children:[(0,m.jsxs)(`span`,{children:[`Database: `,Be(t.db_size_bytes),t.knowledge?.avg_confidence!=null&&` \u00B7 Avg confidence: ${t.knowledge.avg_confidence.toFixed(2)}`]}),(0,m.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[t.knowledge?.entity_count!=null&&t.knowledge.entity_count>0&&(0,m.jsxs)(`span`,{children:[t.knowledge.entity_count,` entities`]}),t.knowledge?.sensitive_count!=null&&t.knowledge.sensitive_count>0&&(0,m.jsxs)(`span`,{children:[(0,m.jsx)(d,{size:10}),` `,t.knowledge.sensitive_count,` sensitive`]})]})]})]})}),P===`profile`&&(0,m.jsxs)(`div`,{className:`mem-profile-grid`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,m.jsx)(oe,{size:16}),` System Discovery`]}),(0,m.jsx)(`p`,{className:`mem-profile-desc`,children:`Scan your system to discover apps, projects, and usage patterns.`}),(0,m.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:I===`running`||I===`saving`,onClick:wr,children:I===`running`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Discovery`}),Tn.length>0&&(0,m.jsx)(`div`,{className:`mem-log`,ref:On,children:Tn.map((e,t)=>(0,m.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(I===`review`||I===`saving`||I===`done`)&&z.length>0&&(0,m.jsxs)(`div`,{className:`mem-review-section`,children:[(0,m.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,m.jsx)(`div`,{className:`mem-review-list`,children:z.map((e,t)=>(0,m.jsxs)(`label`,{className:`mem-review-item`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:I===`saving`||I===`done`,onChange:()=>{B(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,m.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,m.jsx)(`span`,{className:`mem-source-badge`,children:e._source_name||e.category}),(0,m.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,m.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,m.jsx)(`button`,{className:`btn-primary`,disabled:I===`saving`||I===`done`||z.filter(e=>e._checked).length===0,onClick:Tr,children:I===`saving`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${z.filter(e=>e._checked).length})`}),(0,m.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,m.jsx)(`a`,{onClick:()=>B(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,m.jsx)(`a`,{onClick:()=>B(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),I===`done`&&En!==null&&(0,m.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,m.jsx)(l,{size:14}),` Saved `,En,` items to memory`]}),I===`review`&&z.length===0&&(0,m.jsx)(`div`,{className:`mem-profile-empty`,children:`No items discovered.`})]}),(0,m.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,m.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,m.jsx)(st,{size:16}),` AI Profile Inference`]}),(0,m.jsx)(`p`,{className:`mem-profile-desc`,children:`Use the local LLM to generate profile insights from your data.`}),(0,m.jsx)(`p`,{className:`mem-profile-note`,children:`Requires Lemonade Server running.`}),(0,m.jsxs)(`label`,{className:`mem-profile-checkbox`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:Nn,onChange:e=>Pn(e.target.checked),disabled:V===`running`||V===`saving`}),`Include browser history`]}),(0,m.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:V===`running`||V===`saving`,onClick:Er,children:V===`running`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Inference`}),An.length>0&&(0,m.jsx)(`div`,{className:`mem-log`,ref:Fn,children:An.map((e,t)=>(0,m.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(V===`review`||V===`saving`||V===`done`)&&W.length>0&&(0,m.jsxs)(`div`,{className:`mem-review-section`,children:[(0,m.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,m.jsx)(`div`,{className:`mem-review-list`,children:W.map((e,t)=>(0,m.jsxs)(`label`,{className:`mem-review-item`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:V===`saving`||V===`done`,onChange:()=>{G(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,m.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,m.jsx)(`span`,{className:`mem-domain-badge ${xt[e.domain]||`gray`}`,children:e.domain}),(0,m.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,m.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,m.jsx)(`button`,{className:`btn-primary`,disabled:V===`saving`||V===`done`||W.filter(e=>e._checked).length===0,onClick:Dr,children:V===`saving`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${W.filter(e=>e._checked).length})`}),(0,m.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,m.jsx)(`a`,{onClick:()=>G(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,m.jsx)(`a`,{onClick:()=>G(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),V===`done`&&jn!==null&&(0,m.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,m.jsx)(l,{size:14}),` Saved `,jn,` insights to memory`]}),V===`review`&&W.length===0&&(0,m.jsx)(`div`,{className:`mem-profile-empty`,children:`No insights generated.`})]})]}),P===`goals`&&(0,m.jsxs)(`div`,{className:`mem-goals-tab`,children:[(0,m.jsx)(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(e=>(0,m.jsxs)(`div`,{className:`mem-goals-stat-pill mem-goal-status-${e.replace(`_`,`-`)}`,children:[(0,m.jsx)(`span`,{className:`mem-goals-stat-n`,children:hn?.goals[e]??0}),(0,m.jsx)(`span`,{className:`mem-goals-stat-label`,children:e.replace(`_`,` `)})]},e))}),F.filter(e=>e.status===`pending_approval`).length>0&&(0,m.jsxs)(`div`,{className:`mem-goals-approval-banner`,children:[(0,m.jsxs)(`div`,{className:`mem-goals-approval-title`,children:[(0,m.jsx)(o,{size:14}),` Agent suggested `,F.filter(e=>e.status===`pending_approval`).length,` goal(s) — review before execution`]}),F.filter(e=>e.status===`pending_approval`).map(e=>(0,m.jsxs)(`div`,{className:`mem-goals-approval-item`,children:[(0,m.jsxs)(`div`,{className:`mem-goals-approval-text`,children:[(0,m.jsx)(`strong`,{children:e.title}),(0,m.jsx)(`span`,{children:e.description})]}),(0,m.jsxs)(`div`,{className:`mem-goals-approval-actions`,children:[(0,m.jsx)(`button`,{className:`btn-danger-sm`,onClick:async()=>{await re(e.id),Y()},children:`Reject`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:async()=>{await Se(e.id),Y()},children:`Accept`})]})]},e.id))]}),(0,m.jsx)(`div`,{className:`mem-goals-toolbar`,children:(0,m.jsxs)(`button`,{className:`btn-primary`,onClick:()=>Sn(e=>!e),children:[(0,m.jsx)(qe,{size:14}),` New Goal`]})}),xn&&(0,m.jsxs)(`div`,{className:`mem-goals-add-form`,children:[(0,m.jsx)(`input`,{className:`mem-input`,placeholder:`Goal title`,value:Cn.title,onChange:e=>wn(t=>({...t,title:e.target.value}))}),(0,m.jsx)(`textarea`,{className:`mem-input`,placeholder:`Description — what should the agent work toward?`,rows:2,value:Cn.description,onChange:e=>wn(t=>({...t,description:e.target.value}))}),(0,m.jsxs)(`div`,{className:`mem-goals-form-row`,children:[(0,m.jsxs)(`select`,{className:`mem-select`,value:Cn.priority,onChange:e=>wn(t=>({...t,priority:e.target.value})),children:[(0,m.jsx)(`option`,{value:`low`,children:`Low priority`}),(0,m.jsx)(`option`,{value:`medium`,children:`Medium priority`}),(0,m.jsx)(`option`,{value:`high`,children:`High priority`})]}),(0,m.jsx)(`button`,{className:`btn-primary`,onClick:async()=>{Cn.title.trim()&&(await Te(Cn),wn({title:``,description:``,priority:`medium`}),Sn(!1),Y())},children:`Create`}),(0,m.jsx)(`button`,{className:`btn-secondary`,onClick:()=>Sn(!1),children:`Cancel`})]})]}),_n?(0,m.jsxs)(`div`,{className:`mem-loading`,children:[(0,m.jsx)(`div`,{className:`mem-spinner`}),` Loading goals...`]}):F.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?(0,m.jsxs)(`div`,{className:`mem-empty`,children:[(0,m.jsx)(`div`,{className:`mem-empty-icon`,children:(0,m.jsx)(lt,{size:32})}),(0,m.jsx)(`p`,{children:`No goals yet. Create one or let the agent suggest goals in autonomous mode.`})]}):(0,m.jsx)(`div`,{className:`mem-goals-list`,children:F.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(e=>(0,m.jsxs)(`div`,{className:`mem-goal-card mem-goal-status-${e.status.replace(`_`,`-`)}`,children:[(0,m.jsxs)(`div`,{className:`mem-goal-header`,onClick:()=>bn(t=>t===e.id?null:e.id),children:[(0,m.jsxs)(`div`,{className:`mem-goal-header-left`,children:[(0,m.jsx)(`span`,{className:`mem-goal-status-dot status-${e.status.replace(`_`,`-`)}`}),(0,m.jsx)(`span`,{className:`mem-goal-title`,children:e.title}),(0,m.jsx)(`span`,{className:`mem-goal-priority mem-priority-${e.priority}`,children:e.priority}),e.source!==`user`&&(0,m.jsxs)(`span`,{className:`mem-goal-source-badge`,children:[(0,m.jsx)(o,{size:10}),` `,e.source.replace(`_`,` `)]})]}),(0,m.jsxs)(`div`,{className:`mem-goal-header-right`,children:[(0,m.jsxs)(`span`,{className:`mem-goal-task-count`,children:[(0,m.jsx)(ve,{size:12}),e.tasks.filter(e=>e.status===`completed`).length,`/`,e.tasks.length]}),e.status===`queued`&&(0,m.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:async t=>{t.stopPropagation(),await Fe(e.id),Y()},children:`Cancel`}),(0,m.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,onClick:async t=>{t.stopPropagation(),confirm(`Delete goal "${e.title}"?`)&&(await Ie(e.id),Y())},children:(0,m.jsx)(ie,{size:12})}),(0,m.jsx)(Ve,{size:14,className:yn===e.id?`mem-chevron-open`:``})]})]}),yn===e.id&&(0,m.jsxs)(`div`,{className:`mem-goal-body`,children:[e.description&&(0,m.jsx)(`p`,{className:`mem-goal-desc`,children:e.description}),e.progress_notes&&(0,m.jsx)(`p`,{className:`mem-goal-progress`,children:e.progress_notes}),e.tasks.length>0?(0,m.jsx)(`div`,{className:`mem-task-list`,children:e.tasks.map(e=>(0,m.jsxs)(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[(0,m.jsx)(`span`,{className:`mem-task-dot status-${e.status}`}),(0,m.jsx)(`span`,{className:`mem-task-desc`,children:e.description}),(0,m.jsx)(`span`,{className:`mem-task-status-label`,children:e.status}),e.result&&(0,m.jsx)(`span`,{className:`mem-task-result`,children:e.result})]},e.id))}):(0,m.jsx)(`p`,{className:`mem-goal-no-tasks`,children:`No tasks yet — the agent will break this down when it starts.`})]})]},e.id))})]})]}),jt.length>0&&(0,m.jsx)(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:jt.map(e=>(0,m.jsxs)(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&(0,m.jsx)(l,{size:14}),e.type===`error`&&(0,m.jsx)(me,{size:14}),e.type===`info`&&(0,m.jsx)(Re,{size:14}),(0,m.jsx)(`span`,{children:e.text})]},e.id))})]})}export{St as MemoryDashboard};
|