@amd-gaia/agent-ui 0.25.0-rc.8 → 0.25.1-rc.1

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.
Files changed (63) hide show
  1. package/assets/tray-icon.png +0 -0
  2. package/assets/tray-icon@2x.png +0 -0
  3. package/bin/gaia-ui.cjs +25 -1
  4. package/dist/assets/AdvancedSettings-D5VKpkPY.css +1 -0
  5. package/dist/assets/AdvancedSettings-a1nOM-rC.js +1 -0
  6. package/dist/assets/ConnectorsPane-DTThsQBD.js +1 -0
  7. package/dist/assets/ConnectorsPane-Dzu2DRTc.css +1 -0
  8. package/dist/assets/DocumentLibrary-BUpXL-MU.js +1 -0
  9. package/dist/assets/DocumentLibrary-Cj9MJ9yW.css +1 -0
  10. package/dist/assets/FileBrowser-CKiG031v.js +4 -0
  11. package/dist/assets/FileBrowser-D04I8Pvv.css +1 -0
  12. package/dist/assets/MemoryDashboard-BB849Xjw.js +1 -0
  13. package/dist/assets/MemoryDashboard-DgugVDad.css +1 -0
  14. package/dist/assets/MobileAccessModal-9bTRthf4.js +2 -0
  15. package/dist/assets/MobileAccessModal-DuVy9F1u.css +1 -0
  16. package/dist/assets/ScheduleManager-DUhiMn-U.js +2 -0
  17. package/dist/assets/ScheduleManager-GwVTsKQO.css +1 -0
  18. package/dist/assets/{jsx-runtime-DVeaULmT.js → apiBase-y00JgRBP.js} +1 -1
  19. package/dist/assets/eye-B6FejHNG.js +1 -0
  20. package/dist/assets/index-B3UtHCtQ.css +1 -0
  21. package/dist/assets/index-I_UyOSz2.js +71 -0
  22. package/dist/assets/inter-latin-C2S99t-D.woff2 +0 -0
  23. package/dist/assets/inter-latin-ext-CFHvXkgd.woff2 +0 -0
  24. package/dist/assets/message-square-Dwm7y3C0.js +1 -0
  25. package/dist/index.html +6 -6
  26. package/main-safety-net.cjs +54 -7
  27. package/main.cjs +236 -59
  28. package/package.json +3 -1
  29. package/preload.cjs +24 -0
  30. package/services/agent-process-manager.cjs +101 -13
  31. package/services/auto-updater.cjs +26 -2
  32. package/services/backend-installer-progress-dialog.cjs +9 -9
  33. package/services/backend-installer.cjs +156 -32
  34. package/services/keep-awake.cjs +52 -0
  35. package/services/notification-service.cjs +62 -0
  36. package/services/port-manager.cjs +14 -70
  37. package/services/process-tree.cjs +305 -0
  38. package/services/quit-cleanup.cjs +77 -0
  39. package/services/quit-guard.cjs +242 -0
  40. package/services/tray-icons.cjs +174 -0
  41. package/services/tray-manager.cjs +589 -82
  42. package/services/tray-state.cjs +231 -0
  43. package/services/window-keys.cjs +43 -0
  44. package/assets/tray-icon.ico +0 -0
  45. package/dist/assets/AdvancedSettings-Ce6EvcAe.css +0 -1
  46. package/dist/assets/AdvancedSettings-DNQod9tb.js +0 -1
  47. package/dist/assets/ConnectorsPane-CG7atLb2.css +0 -1
  48. package/dist/assets/ConnectorsPane-DXvmZT6E.js +0 -1
  49. package/dist/assets/DocumentLibrary-DrIP_032.css +0 -1
  50. package/dist/assets/DocumentLibrary-H6_dL1FQ.js +0 -1
  51. package/dist/assets/FileBrowser-Bj6aB6Ro.css +0 -1
  52. package/dist/assets/FileBrowser-JEScQZqn.js +0 -4
  53. package/dist/assets/MemoryDashboard-B-YH4b1Z.css +0 -1
  54. package/dist/assets/MemoryDashboard-CK5IZKJ8.js +0 -1
  55. package/dist/assets/MobileAccessModal-CV7e2cgI.js +0 -2
  56. package/dist/assets/MobileAccessModal-C_t8DG0n.css +0 -1
  57. package/dist/assets/ScheduleManager-A5eLWyGP.js +0 -2
  58. package/dist/assets/ScheduleManager-CIescbX6.css +0 -1
  59. package/dist/assets/dm-sans-latin-Xz1IZZA0.woff2 +0 -0
  60. package/dist/assets/index-B8E7IBmc.css +0 -1
  61. package/dist/assets/index-D00FJoXi.js +0 -58
  62. package/dist/assets/message-square-Ccmbk96j.js +0 -1
  63. package/dist/assets/space-mono-400-Co7bH5Hm.woff2 +0 -0
Binary file
Binary file
package/bin/gaia-ui.cjs CHANGED
@@ -162,6 +162,9 @@ function startBackend(gaiaBin, port, exit = process.exit) {
162
162
  ],
163
163
  {
164
164
  stdio: ["ignore", "pipe", "pipe"],
165
+ // GAIA_APP_PID: GAIA's daemon unloads its models once this launcher
166
+ // exits and no other GAIA client is using them.
167
+ env: { ...process.env, GAIA_APP_PID: String(process.pid) },
165
168
  detached: false,
166
169
  }
167
170
  );
@@ -278,6 +281,26 @@ async function serveFrontend(port) {
278
281
  return server;
279
282
  }
280
283
 
284
+ /**
285
+ * First install found a Lemonade already running: ask on the terminal.
286
+ * Null without a terminal; `gaia init` then installs GAIA's own and says how to switch.
287
+ */
288
+ function chooseLemonadeOnTerminal(found, { input = process.stdin, output = process.stdout } = {}) {
289
+ if (!input.isTTY) return Promise.resolve(null);
290
+ const readline = require("readline");
291
+ const rl = readline.createInterface({ input, output });
292
+ const question =
293
+ `\nA Lemonade Server (v${found.version}) is already running at ${found.url}.\n` +
294
+ "Use it instead of installing GAIA's own? This avoids running two servers " +
295
+ "and keeping two copies of each model. [Y/n] ";
296
+ return new Promise((resolve) => {
297
+ rl.question(question, (answer) => {
298
+ rl.close();
299
+ resolve(/^n(o)?$/i.test(answer.trim()) ? "gaia" : "external");
300
+ });
301
+ });
302
+ }
303
+
281
304
  // ── Main ──────────────────────────────────────────────────────────────────────
282
305
 
283
306
  async function main() {
@@ -318,6 +341,7 @@ async function main() {
318
341
  try {
319
342
  gaiaBin = await installer.ensureBackend({
320
343
  version: GAIA_VERSION_OVERRIDE || undefined,
344
+ chooseLemonade: chooseLemonadeOnTerminal,
321
345
  onProgress: (stage, percent, message) => {
322
346
  // Simple CLI progress formatting
323
347
  process.stdout.write(
@@ -391,4 +415,4 @@ if (require.main === module) {
391
415
  });
392
416
  }
393
417
 
394
- module.exports = { npmDistTag, helpText, startBackend };
418
+ module.exports = { npmDistTag, helpText, startBackend, chooseLemonadeOnTerminal };
@@ -0,0 +1 @@
1
+ .version-picker-overlay{background:var(--bg-modal-overlay);z-index:9000;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.version-picker-dialog{background:var(--bg-primary);border:1px solid var(--border);border-radius:10px;flex-direction:column;width:min(520px,94vw);max-height:80vh;display:flex;box-shadow:0 8px 32px #00000080}.version-picker-header{border-bottom:1px solid var(--border);flex-shrink:0;justify-content:space-between;align-items:center;padding:16px 20px;display:flex}.version-picker-header h3{color:var(--text-primary);margin:0;font-size:15px;font-weight:600}.version-picker-close{cursor:pointer;color:var(--text-secondary);transition:color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);background:0 0;border:none;border-radius:4px;padding:2px 6px;font-size:20px;line-height:1}.version-picker-close:hover{color:var(--text-primary);background:var(--bg-hover)}.version-picker-body{flex:1;padding:8px 0;overflow-y:auto}.version-picker-loading{color:var(--text-secondary);justify-content:center;align-items:center;gap:10px;padding:32px 20px;font-size:14px;display:flex}.version-picker-spinner{border:2px solid var(--border);border-top-color:var(--accent);width:18px;height:18px;animation:vp-spin var(--duration-spin) var(--ease-linear) infinite;border-radius:50%;flex-shrink:0}@keyframes vp-spin{to{transform:rotate(360deg)}}.version-picker-error{color:var(--text-secondary);padding:20px;font-size:13px;line-height:1.5}.version-picker-error a{color:var(--accent);text-decoration:underline}.version-picker-list{margin:0;padding:0;list-style:none}.version-picker-row{cursor:pointer;text-align:left;width:100%;color:var(--text-primary);transition:background var(--duration-fast) var(--ease);border:none;border-bottom:1px solid var(--border);background:0 0;align-items:center;gap:10px;padding:10px 20px;display:flex}.version-picker-row:last-child{border-bottom:none}.version-picker-row:hover:not([aria-disabled=true]){background:var(--bg-hover)}.version-picker-row[aria-disabled=true]{cursor:default;opacity:.65}.vp-version{min-width:70px;font-size:14px;font-weight:600;font-family:var(--font-mono)}.vp-date{color:var(--text-secondary);flex:1;font-size:12px}.vp-badge{white-space:nowrap;border-radius:4px;padding:2px 8px;font-size:11px;font-weight:500}.vp-badge-current{background:var(--accent-green-dim);color:var(--accent-green);border:1px solid var(--accent-green)}.vp-badge-pinned{background:var(--accent-dim);color:var(--accent);border:1px solid var(--accent)}.vp-arrow{color:var(--text-secondary);font-size:14px}.version-picker-more{color:var(--text-secondary);border-top:1px solid var(--border);margin:0;padding:10px 20px 14px;font-size:12px}.version-picker-more a{color:var(--accent);text-decoration:underline}.version-picker-confirm{flex-direction:column;gap:16px;padding:20px;display:flex}.version-picker-confirm p{color:var(--text-primary);margin:0;font-size:14px;line-height:1.5}.version-picker-confirm p strong{color:var(--accent)}.vp-confirm-note{font-size:12px;color:var(--text-secondary)!important}.vp-confirm-actions{justify-content:flex-end;gap:10px;display:flex}.vp-btn-cancel{border:1px solid var(--border);color:var(--text-secondary);cursor:pointer;transition:border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);background:0 0;border-radius:6px;padding:7px 16px;font-size:13px}.vp-btn-cancel:hover{border-color:var(--text-secondary);color:var(--text-primary)}.vp-btn-confirm{background:var(--accent-fill);color:var(--accent-fill-text);cursor:pointer;transition:opacity var(--duration-fast) var(--ease);border:none;border-radius:6px;padding:7px 18px;font-size:13px;font-weight:600}.vp-btn-confirm:hover:not(:disabled){opacity:.85}.vp-btn-confirm:disabled{opacity:.5;cursor:not-allowed}
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,o as n,s as r,u as i}from"./apiBase-y00JgRBP.js";import{$ as a,Ft as o,Q as s,R as c,W as l,Yt as u,_t as d,cn as f,ct as p,et as m,ht as h,mt as g,n as _,nt as v,r as y,rt as b,un as x,z as S}from"./index-I_UyOSz2.js";var C=e(i(),1),w=t();function T(){return window.gaiaUpdater}function E({onClose:e}){let[t,r]=(0,C.useState)({kind:`loading`}),i=(0,C.useRef)(null);(0,C.useEffect)(()=>{let e=T();if(!e){r({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=>{r(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{r({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})})},[]),n(!0,e),(0,C.useEffect)(()=>{let e=i.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,C.useEffect)(()=>{let e=i.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 a(e,t){e.isCurrent||r({kind:`confirm`,release:e,releases:t})}async function o(t){r({kind:`installing`});let n=T();if(!n){r({kind:`error`,message:`Bridge unavailable — please restart the app.`});return}try{await n.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);r({kind:`error`,message:`Failed to start rollback: ${t}`})}}function s(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,w.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,w.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Roll back to a previous version`,ref:i,children:[(0,w.jsxs)(`div`,{className:`version-picker-header`,children:[(0,w.jsx)(`h3`,{children:`Roll back to a previous version`}),(0,w.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,w.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,w.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,w.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,w.jsxs)(`div`,{className:`version-picker-error`,children:[(0,w.jsx)(`p`,{children:t.message}),(0,w.jsx)(`p`,{children:(0,w.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,w.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,w.jsx)(`li`,{children:(0,w.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:()=>a(e,t.releases),disabled:e.isCurrent,children:[(0,w.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,w.jsx)(`span`,{className:`vp-date`,children:s(e.date)}),e.isCurrent&&(0,w.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,w.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,w.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,w.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,w.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,w.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,w.jsxs)(`p`,{children:[`This will `,(0,w.jsxs)(`strong`,{children:[`downgrade to v`,t.release.version]}),` and restart the app.`]}),(0,w.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,w.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>r({kind:`list`,releases:t.releases}),children:`Back`}),(0,w.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>o(t.release),children:`Confirm downgrade & restart`})]})]}),t.kind===`installing`&&(0,w.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,w.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}function D(){let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)(``),[o,l]=(0,C.useState)(``),[d,f]=(0,C.useState)(!1),[p,m]=(0,C.useState)(null),[h,_]=(0,C.useState)(!1);(0,C.useEffect)(()=>{s().then(e=>{t(e),a(e.saved_base_url??e.base_url??``)}).catch(e=>r(e instanceof Error?e.message:String(e)))},[]);let v=(0,C.useCallback)(async e=>{f(!0),m(null);try{let n=await g(e);t(n),l(``),_(!1)}catch(e){_(c(e)),m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[]),y=()=>void v({mode:`external`,base_url:i.trim(),api_key:o.trim()||void 0});if(n)return(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,w.jsx)(x,{size:14}),(0,w.jsxs)(`div`,{className:`model-warning-content`,children:[(0,w.jsx)(`strong`,{children:`Could not read which model server GAIA uses`}),(0,w.jsx)(`p`,{children:n})]})]})]});if(!e)return null;let b=e.mode===`external`;return(0,w.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsx)(`p`,{className:`model-override-desc`,role:`status`,children:e.source===`env`?(0,w.jsxs)(w.Fragment,{children:[`GAIA uses the Lemonade Server at `,(0,w.jsx)(`code`,{children:e.base_url}),`, set by `,(0,w.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),`.`]}):b?(0,w.jsxs)(w.Fragment,{children:[`GAIA uses your Lemonade Server at `,(0,w.jsx)(`code`,{children:e.base_url}),`.`]}):(0,w.jsx)(w.Fragment,{children:`GAIA uses its own Lemonade Server.`})}),e.source===`env`?(0,w.jsxs)(`p`,{className:`model-status-hint`,children:[`Unset `,(0,w.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),` and restart GAIA to change this here.`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`p`,{className:`model-status-hint`,children:[`Already run Lemonade? Use it, so this PC keeps one server and one copy of each model.`,` `,e.what_gaia_does]}),(0,w.jsxs)(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,w.jsx)(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:i,onChange:e=>{a(e.target.value),m(null)},disabled:d,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Lemonade Server address`}),(0,w.jsx)(`input`,{type:`password`,className:`model-input`,autoComplete:`off`,placeholder:e.api_key_stored?`API key (blank keeps the saved one)`:`API key, if it needs one`,value:o,onChange:e=>l(e.target.value),disabled:d,"aria-label":`Lemonade API key`}),(0,w.jsx)(`div`,{className:`model-btn-group`,children:(0,w.jsx)(`button`,{type:`submit`,className:`btn-model-save`,disabled:d||!i.trim(),children:d?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u,{size:13,className:`btn-spinner`}),` Checking…`]}):`Use this server`})})]}),b&&(0,w.jsx)(`div`,{className:`setting-actions`,children:(0,w.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void v({mode:`gaia`}),children:`Use GAIA’s own`})}),p&&(0,w.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,w.jsx)(x,{size:14}),(0,w.jsxs)(`div`,{className:`model-warning-content`,children:[(0,w.jsx)(`strong`,{children:h?`Needs the API key`:`Not switched`}),(0,w.jsx)(`p`,{children:p})]})]})]})]})}var O={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},k={gaia:`GAIA's own Lemonade`,user:`Your Lemonade`,remote:`Lemonade on another machine`};function A(e){return e?O[e]??e:`unknown`}function j(e){if(!e)return`unknown`;let t=A(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function M(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}function N({label:e,value:t,title:n}){return(0,w.jsxs)(`div`,{className:`status-row`,children:[(0,w.jsx)(`span`,{className:`status-label`,children:e}),(0,w.jsx)(`span`,{className:`status-value model-server-value`,title:n??t,children:t})]})}function ee(){let e=o(e=>e.openSettings),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),[a,s]=(0,C.useState)(null),[c,d]=(0,C.useState)(null),[f,g]=(0,C.useState)(!1);(0,C.useEffect)(()=>{m().then(n).catch(e=>i(e instanceof Error?e.message:String(e)))},[]);let _=(0,C.useCallback)(async e=>{s(e),d(null);try{let t=await h(e);n(t),d({ok:!0,text:`Saved. It applies the next time the chat model loads.`})}catch(e){d({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{s(null)}},[]),v=t?.chat_model??null,y=(0,C.useCallback)(async()=>{if(v?.name){g(!0);try{if(!await p(v.name,v.ctx_size??void 0))return;d({ok:!0,text:`Reloading ${v.name}. Reopen this panel in a moment to see its backend.`})}catch(e){d({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{g(!1)}}},[v]),b=(0,w.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(`model`),children:`Change model`});if(r)return(0,w.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]});if(!t)return(0,w.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsx)(`p`,{className:`loading-text`,children:`Checking the model server…`})]});if(!t.reachable)return(0,w.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsx)(`p`,{className:`settings-error`,role:`alert`,children:t.error}),b]});let x=t.available_backends??[],S=t.preferred_backend??null,T=[`auto`,...x.map(e=>e.name)];S&&!T.includes(S)&&T.push(S);let E=S??`auto`,D=x.filter(e=>e.state===`installable`).map(e=>A(e.name)),O=!!v?.name&&v.recipe===`llamacpp`;return(0,w.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,w.jsx)(`h4`,{children:`Model server`}),(0,w.jsxs)(`div`,{className:`status-grid`,children:[(0,w.jsx)(N,{label:`Server`,value:`${k[t.owner]??t.owner}${t.version?` v${t.version}`:``}`}),(0,w.jsx)(N,{label:`Address`,value:t.base_url}),(0,w.jsx)(N,{label:`Chat model`,value:v?.name?l(v.name):`None loaded`,title:v?.name??void 0}),v&&(0,w.jsx)(N,{label:`Runs on`,value:j(v)}),v&&v.backend!==`remote`&&(0,w.jsx)(N,{label:`Context window`,value:M(v.ctx_size)}),(0,w.jsx)(N,{label:`Embedding model`,value:t.embedding_model?.name?`${t.embedding_model.name} · ${j(t.embedding_model)}`:`None loaded`})]}),t.embedding_note&&(0,w.jsx)(`p`,{className:`settings-hint`,children:t.embedding_note}),t.system_info_error&&(0,w.jsx)(`p`,{className:`settings-hint`,children:t.system_info_error}),(0,w.jsxs)(`div`,{className:`settings-field model-server-backend`,children:[(0,w.jsx)(`span`,{className:`settings-label`,children:`llama.cpp backend for chat models`}),x.length===0&&!S?(0,w.jsx)(`span`,{className:`settings-hint`,children:`This Lemonade does not report which backends this PC can run, so there is nothing to choose. Update Lemonade to pick one here.`}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":`llama.cpp backend`,children:T.map(e=>(0,w.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":E===e,className:E===e?`is-active`:``,disabled:a!==null,onClick:()=>{e!==E&&_(e)},children:[a===e?(0,w.jsx)(u,{size:12,className:`spin`}):null,e===`auto`?`Auto${t.default_backend?` (${A(t.default_backend)})`:``}`:A(e)]},e))}),(0,w.jsxs)(`span`,{className:`settings-hint`,children:[`Applies the next time a chat model loads. The embedding model keeps its own backend.`,D.length>0&&` ${D.join(`, `)} downloads on first use.`]})]}),c&&(0,w.jsx)(`p`,{className:c.ok?`settings-ok`:`settings-error`,role:c.ok?`status`:`alert`,children:c.text})]}),(0,w.jsxs)(`div`,{className:`settings-row`,children:[b,O&&(0,w.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void y(),disabled:f,children:[f?(0,w.jsx)(u,{size:13,className:`spin`}):null,`Reload chat model now`]})]})]})}function P(){let[e,t]=(0,C.useState)(null),[n,i]=(0,C.useState)(!0),[o,s]=(0,C.useState)([]),[c,l]=(0,C.useState)(!1),p=_(),[m,h]=(0,C.useState)(``),[g,T]=(0,C.useState)(``),[O,k]=(0,C.useState)(!1),[A,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(null),[P,I]=(0,C.useState)(!1),L=(0,C.useRef)(null),[R,z]=(0,C.useState)(!1),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(!1),[W,G]=(0,C.useState)(null);(0,C.useEffect)(()=>{r.system.info(`Checking system status...`);let e=r.system.time();b().then(n=>{t(n),r.system.timed(`System status received`,e,{lemonade:n.lemonade_running?`running`:`stopped`,model:n.model_loaded||`none`,embedding:n.embedding_model_loaded?`yes`:`no`,disk:`${n.disk_space_gb}GB free`,memory:n.memory_available_gb==null?`unknown`:`${n.memory_available_gb}GB available`}),n.lemonade_running||r.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{r.system.error(`Failed to get system status`,e),t(null)}).finally(()=>i(!1)),a().then(e=>s(e.servers)).catch(()=>{}),v().then(e=>{let t=e.custom_model??``;h(t),T(t),z(e.dynamic_tools),V(e.dynamic_tools_locked)}).catch(e=>{r.system.error(`Failed to load settings`,e)}).finally(()=>k(!0))},[]),(0,C.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let K=(0,C.useCallback)(async()=>{let e=m.trim(),t=e.length>0?e:``;j(!0),N(null),I(!1);try{r.system.info(`Saving custom_model override`,{custom_model:t});let e=(await d({custom_model:t})).custom_model??``;h(e),T(e),I(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>I(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);r.system.error(`Failed to save custom_model`,e),N(t)}finally{j(!1)}},[m]),te=(0,C.useCallback)(async()=>{if(B||H)return;let e=R,t=!e;z(t),U(!0),G(null);try{r.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await d({dynamic_tools:t});z(e.dynamic_tools),V(e.dynamic_tools_locked)}catch(t){let n=t instanceof Error?t.message:String(t);r.system.error(`Failed to save dynamic_tools`,t),z(e),G(n)}finally{U(!1)}},[R,B,H]),q=m.trim()!==g.trim(),J=e?e.default_model_name:S,{isLoadingModel:Y,isDownloadingModel:X,loadModel:ne,downloadModel:Z}=y(J??void 0),Q=!!e?.default_model_is_cloud,$=!Q&&!!(e?.lemonade_running&&e.model_loaded&&e.expected_model_loaded===!1),re=!Q&&!!(e?.lemonade_running&&e.model_loaded&&e.context_size_sufficient===!1),ie=!Q&&!(!e?.lemonade_running||e.model_loaded||e.model_downloaded!==!1),ae=($||re)&&J!==null;return(0,w.jsxs)(`div`,{className:`settings-pane`,children:[(0,w.jsx)(`h2`,{className:`settings-pane-title`,children:`Advanced`}),(0,w.jsx)(ee,{}),(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsx)(`h4`,{children:`Local model server`}),n?(0,w.jsx)(`p`,{className:`loading-text`,children:`Checking system...`}):e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`status-grid`,children:[(0,w.jsx)(F,{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,w.jsx)(F,{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: ${J}`:void 0:`None loaded yet — it loads with the first message.`}),e.model_size_gb!=null&&(0,w.jsx)(F,{label:`Model Size`,value:`${e.model_size_gb} GB`,ok:!0}),e.model_device&&!Q&&(0,w.jsx)(F,{label:`Device`,value:e.model_device.toUpperCase(),ok:e.model_device!==`cpu`}),e.model_context_size!=null&&(0,w.jsx)(F,{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,w.jsx)(F,{label:`Capabilities`,value:e.model_labels.join(`, `),ok:!0}),(0,w.jsx)(F,{label:`Embedding Model`,value:e.embedding_model_loaded?`Available`:`Not loaded`,ok:e.embedding_model_loaded}),e.gpu_name&&(0,w.jsx)(F,{label:`GPU`,value:`${e.gpu_name}${e.gpu_vram_gb?` (${e.gpu_vram_gb} GB)`:``}`,ok:!0}),(0,w.jsx)(F,{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,w.jsx)(F,{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,w.jsx)(F,{label:`Processor`,value:e.processor_name,ok:!0})]}),ie&&(0,w.jsxs)(`div`,{className:`model-action-row model-action-row--download`,children:[(0,w.jsxs)(`div`,{className:`model-action-info`,children:[(0,w.jsx)(`span`,{className:`model-action-label`,children:`Model not downloaded.`}),(0,w.jsxs)(`span`,{className:`model-action-desc`,children:[(0,w.jsx)(`strong`,{children:J}),` is GAIA’s default local model (about 6 GB).`]})]}),(0,w.jsx)(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>Z(!1),disabled:X,children:X?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u,{size:13,className:`btn-spinner`}),` Downloading…`]}):`Download`})]}),ae&&(0,w.jsxs)(`div`,{className:`model-action-row model-action-row--load`,children:[(0,w.jsxs)(`div`,{className:`model-action-info`,children:[(0,w.jsx)(`span`,{className:`model-action-label`,children:$?`Wrong model loaded.`:`Context window too small.`}),(0,w.jsxs)(`span`,{className:`model-action-desc`,children:[`Load `,(0,w.jsx)(`strong`,{children:J}),` with `,32 .toFixed(0),`K token context.`]})]}),(0,w.jsx)(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>ne(),disabled:Y,children:Y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u,{size:13,className:`btn-spinner`}),` Loading…`]}):`Load Model`})]}),e.lemonade_running&&J!==null&&!Q&&(0,w.jsxs)(`div`,{className:`force-redownload-row`,children:[(0,w.jsx)(`span`,{className:`force-redownload-label`,children:`If the model file is corrupted:`}),(0,w.jsx)(`button`,{className:`btn-force-redownload`,onClick:()=>Z(!0),disabled:X,children:X?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u,{size:12,className:`btn-spinner`}),` Downloading…`]}):`Force Re-download`})]})]}):(0,w.jsx)(`div`,{className:`status-error`,children:(0,w.jsx)(`p`,{children:`Could not reach GAIA. Check that it is still running.`})})]}),(0,w.jsx)(D,{}),(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsx)(`h4`,{children:`Custom model ID`}),(0,w.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,w.jsxs)(`div`,{className:`model-input-row`,children:[(0,w.jsx)(`input`,{type:`text`,className:`model-input${g?` has-override`:``}`,placeholder:`Use the model chosen under Model`,value:m,onChange:e=>{h(e.target.value),N(null),I(!1)},onKeyDown:e=>{e.key===`Enter`&&!A&&q&&O&&(e.preventDefault(),K())},disabled:!O||A,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Custom model override`}),(0,w.jsx)(`div`,{className:`model-btn-group`,children:(0,w.jsx)(`button`,{className:`btn-model-save${P?` saved`:``}`,onClick:()=>{K()},disabled:!O||A||!q&&!P,"aria-label":`Save custom model`,children:A?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u,{size:13,className:`btn-spinner`}),` Saving…`]}):P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(f,{size:13}),` Saved`]}):`Save`})})]}),(0,w.jsxs)(`p`,{className:`model-status-hint`,children:[`Accepts a Lemonade model ID (e.g. `,(0,w.jsx)(`code`,{children:`Qwen3-4B-Instruct-2507-GGUF`}),`)`,` `,`or a HuggingFace ID (e.g. `,(0,w.jsx)(`code`,{children:`unsloth/Qwen3-4B-GGUF`}),`).`]}),M&&(0,w.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,w.jsx)(x,{size:14}),(0,w.jsxs)(`div`,{className:`model-warning-content`,children:[(0,w.jsx)(`strong`,{children:`Could not save`}),(0,w.jsx)(`p`,{children:M})]})]})]}),(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsxs)(`h4`,{children:[`Dynamic Tools `,(0,w.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,w.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,w.jsxs)(`label`,{className:`setting-row`,children:[(0,w.jsx)(`span`,{children:`Enable dynamic tool loading`}),(0,w.jsxs)(`span`,{className:`toggle-switch`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:R,onChange:()=>void te(),disabled:!O||H||B,"aria-label":R?`Disable dynamic tools`:`Enable dynamic tools`}),(0,w.jsx)(`span`,{className:`toggle-track`})]})]}),B&&(0,w.jsxs)(`p`,{className:`model-status-hint`,children:[`Controlled by `,(0,w.jsx)(`code`,{children:`GAIA_DYNAMIC_TOOLS`}),` — unset that environment variable to change this here.`]}),W&&(0,w.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,w.jsx)(x,{size:14}),(0,w.jsxs)(`div`,{className:`model-warning-content`,children:[(0,w.jsx)(`strong`,{children:`Could not save`}),(0,w.jsx)(`p`,{children:W})]})]})]}),o.length>0&&(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsx)(`h4`,{children:`MCP Servers`}),(0,w.jsx)(`div`,{className:`status-grid`,children:o.map(e=>(0,w.jsxs)(`div`,{className:`status-row`,children:[(0,w.jsx)(`span`,{className:`status-label`,children:e.name}),(0,w.jsx)(`div`,{className:`status-value-wrap`,children:e.connected?(0,w.jsxs)(`span`,{className:`status-value ok mcp-status-connected`,children:[(0,w.jsx)(f,{size:12}),e.tool_count,` tool`,e.tool_count===1?``:`s`]}):(0,w.jsxs)(`span`,{className:`status-value warn mcp-status-failed`,title:e.error??void 0,children:[(0,w.jsx)(x,{size:12}),`Failed`]})})]},e.name))})]}),(0,w.jsxs)(`section`,{className:`settings-section`,children:[(0,w.jsx)(`h4`,{children:`About`}),(0,w.jsxs)(`div`,{className:`about-info`,children:[(0,w.jsxs)(`p`,{children:[`GAIA v`,`0.25.1rc1`,` `,(0,w.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,w.jsx)(`p`,{className:`about-sub`,children:`Privacy-first AI chat for AMD Ryzen AI PCs.`}),p.pinnedVersion&&(0,w.jsxs)(`p`,{className:`about-pinned-notice`,children:[`Auto-update paused (pinned to `,p.pinnedVersion,`).`,` `,(0,w.jsx)(`button`,{type:`button`,className:`about-resume-btn`,onClick:()=>{window.gaiaUpdater?.resumeUpdates().catch(e=>{r.system.error(`Resume updates failed`,e)})},children:`Resume updates`})]})]}),(0,w.jsx)(`div`,{className:`setting-actions`,children:(0,w.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l(!0),children:`Roll back to a previous version`})})]}),c&&(0,w.jsx)(E,{onClose:()=>l(!1)})]})}function F({label:e,value:t,ok:n,hint:r}){return(0,w.jsxs)(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[(0,w.jsx)(`span`,{className:`status-label`,children:e}),(0,w.jsxs)(`div`,{className:`status-value-wrap`,children:[(0,w.jsx)(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&(0,w.jsx)(`span`,{className:`status-hint`,children:(0,w.jsx)(`code`,{children:r})})]})]})}export{P as AdvancedSettings};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{l as t,n,o as r,s as i,t as a,u as o}from"./apiBase-y00JgRBP.js";import{At as s,Ct as c,Dt as l,Et as u,Ft as d,Mt as f,Nt as p,Ot as m,Pt as h,St as g,Tt as _,Yt as v,bt as y,cn as b,fn as x,jt as S,kt as C,tn as w,un as T,wt as E,xt as D}from"./index-I_UyOSz2.js";var O={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};O.node;var k=t(O),A={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`]};A.node;var j=t(A),M=n(),N=e(o(),1),P=i.api;function F(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 I(e){let t=(0,N.useRef)(e);(0,N.useEffect)(()=>{t.current=e},[e]),(0,N.useEffect)(()=>{let e=`${a()}/connectors/events`,n=null,r=1e3,i=null,o=!1,s=()=>{o||(n=new EventSource(e),n.onopen=()=>{r=1e3},n.onmessage=e=>{try{let n=JSON.parse(e.data),r=F(n.type);if(r===null){P.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){P.warn(`connectors-sse: malformed event`,e)}},n.onerror=()=>{n?.close(),n=null,!o&&(i=setTimeout(s,r),r=Math.min(r*2,3e4))})};return s(),()=>{o=!0,i&&clearTimeout(i),n?.close()}},[])}function L(e){return e.type===`mcp_server`&&e.configured}function R({connector:e,onChanged:t}){let[n,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(null),[d,f]=(0,N.useState)(null),p=(0,N.useRef)(null),m=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;p.current&&!p.current.contains(t)&&m.current&&!m.current.contains(t)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let h=(0,N.useCallback)(()=>i(!1),[]);if(r(n,h),(0,N.useEffect)(()=>{if(!n)return;let e=()=>{if(!p.current)return;let e=p.current.getBoundingClientRect();f({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]),!L(e))return null;let g=e=>{e.stopPropagation(),e.preventDefault()},v=e=>{if(g(e),!n&&p.current){let e=p.current.getBoundingClientRect();f({top:e.bottom+4,right:window.innerWidth-e.right})}i(e=>!e)},y=async e=>{o(!0),c(null);try{await e(),i(!1),t()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,M.jsxs)(`div`,{className:`connector-tile-menu`,onClick:g,onKeyDown:g,children:[(0,M.jsx)(`button`,{ref:p,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:v,disabled:a,children:(0,M.jsx)(j,{size:14})}),n&&d&&(0,M.jsxs)(`div`,{ref:m,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:d.top,right:d.right},children:[e.enabled?(0,M.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void y(()=>_(e.id)),disabled:a,children:`Disable`}):(0,M.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void y(()=>l(e.id)),disabled:a,children:`Enable`}),(0,M.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,M.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void y(()=>u(e.id)),disabled:a,children:`Disconnect`}),s&&(0,M.jsx)(`div`,{className:`connector-tile-menu-error`,children:s})]})]})}var z={"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 B(e){return z[e]??e.split(/[/.:]/).pop()??e}var V=[`use`];function H(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 U(){let[e,t]=(0,N.useState)([]),[n,r]=(0,N.useState)([]),[i,a]=(0,N.useState)(!0),[o,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(null),h=(0,N.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([p(),s()]);t(e),r(n),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,N.useEffect)(()=>{h()},[h]);let g=e=>f(t=>t===e?null:e),_=(0,N.useCallback)(async e=>{try{let n=await m(e);t(t=>t.map(t=>t.id===e?n:t))}catch{h()}},[h]);return I((0,N.useCallback)(e=>{e.reason===`disconnected`&&u(H(e.payload)),e.connectorId?_(e.connectorId):h()},[_,h])),(0,M.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,M.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.`}),o&&(0,M.jsxs)(`div`,{className:`error-banner`,children:[(0,M.jsx)(T,{size:14}),(0,M.jsx)(`span`,{children:o})]}),l&&(0,M.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>u(null),children:[(0,M.jsx)(T,{size:14}),(0,M.jsx)(`span`,{children:l})]}),i?(0,M.jsx)(`div`,{className:`connectors-loading`,children:(0,M.jsx)(v,{size:16,className:`spin`})}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,M.jsx)(W,{connector:e,expanded:d===e.id,onToggle:()=>g(e.id),onChanged:()=>void _(e.id)},e.id))}),n.length>0&&(0,M.jsx)(Y,{servers:n,expanded:d,onToggle:g})]})]})}function W({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,M.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,M.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,M.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,M.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,M.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,M.jsxs)(`span`,{className:`connector-status ok`,children:[(0,M.jsx)(b,{size:12}),e.account_id??`Configured`]}):(0,M.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,M.jsx)(R,{connector:e,onChanged:r}),(0,M.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,M.jsx)(k,{size:14}):(0,M.jsx)(x,{size:14})})]}),t&&(0,M.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,M.jsx)(G,{connector:e,onChanged:r}):(0,M.jsx)(q,{connector:e,onChanged:r}),e.configured&&(0,M.jsx)(Z,{connectorId:e.id,connectorType:e.type})]})]})}function G({connector:e,onChanged:t}){let[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)({}),[l,f]=(0,N.useState)(null),{agents:p}=d(),m=p.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),h=m.map(e=>e.namespaced_agent_id).join(`,`),[_,y]=(0,N.useState)(()=>new Set);(0,N.useEffect)(()=>{y(new Set(m.map(e=>e.namespaced_agent_id)))},[h]);let b=e=>y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=()=>[..._];(0,N.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let S=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},C=async()=>{r(!0),a(null);try{let t=await D(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,x());S(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},E=async()=>{r(!0),a(null),f(null);try{let t=await g(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,x());f(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,N.useEffect)(()=>{e.configured&&f(null)},[e.configured]),I((0,N.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),f(null)):t.reason===`oauth_completed`&&f(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await u(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&&!o[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 c(e.id,{...o,scopes:n,grant_agents:x()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&S(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},A=e.oauth_setup_fields??[],j=e.configurable===!1&&!e.configured&&A.length>0;return(0,M.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,M.jsx)(`p`,{className:`connector-desc`,children:e.description}),j&&(0,M.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,M.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,M.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,M.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,M.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:o[e.key]??``,onChange:t=>s(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,M.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&m.length>0&&(0,M.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,M.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),m.map(e=>(0,M.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:_.has(e.namespaced_agent_id),onChange:()=>b(e.namespaced_agent_id)}),(0,M.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,M.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!j&&(0,M.jsx)(K,{connector:e,onChanged:t}),i&&(0,M.jsxs)(`div`,{className:`configure-error`,children:[(0,M.jsx)(T,{size:12}),` `,i]}),(0,M.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,M.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,M.jsx)(v,{size:12,className:`spin`}):`Disconnect`}):j?(0,M.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void k(),children:n?(0,M.jsx)(v,{size:12,className:`spin`}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(w,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,M.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:`btn-primary`,disabled:n||l!==null,onClick:()=>void C(),children:n?(0,M.jsx)(v,{size:12,className:`spin`}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(w,{size:12}),` Connect`]})}),e.supports_device_code&&(0,M.jsx)(`button`,{className:`btn-secondary`,disabled:n||l!==null,onClick:()=>void E(),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,M.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,M.jsx)(w,{size:11})]})]}),l&&!e.configured&&(0,M.jsxs)(`div`,{className:`device-code-block`,children:[(0,M.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,M.jsx)(`a`,{href:l.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),S(l.verification_uri)},children:l.verification_uri}),` `,`and enter this code:`]}),(0,M.jsxs)(`div`,{className:`device-code-value`,children:[(0,M.jsx)(`code`,{children:l.user_code}),(0,M.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(l.user_code),title:`Copy code`,children:`Copy`})]}),(0,M.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,M.jsx)(v,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,M.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>f(null),children:`Cancel`})]})]})}function K({connector:e,onChanged:t}){let[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)({}),[o,s]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null),p=e.oauth_setup_fields??[];if(p.length===0)return null;let m=e.oauth_client,h=m?.source===`keyring`?`Saved client: ${m.client_id}`:m?.source===`env`?`From environment: ${m.client_id}`:`No OAuth client configured`,g=async()=>{if(!i.client_id?.trim()){f(`Client ID is required.`);return}s(!0),f(null),u(!1);try{await c(e.id,{...Object.fromEntries(Object.entries(i).map(([e,t])=>[e,t.trim()])),save_only:!0}),u(!0),a({}),t(),setTimeout(()=>u(!1),2200)}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,M.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,M.jsx)(k,{size:12}):(0,M.jsx)(x,{size:12}),(0,M.jsx)(`span`,{children:`OAuth client`}),(0,M.jsx)(`span`,{className:`oauth-client-editor__status`,children:h})]}),n&&(0,M.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,M.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,M.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),p.map(e=>(0,M.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,M.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,M.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&m?.source===`keyring`&&m.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,M.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),d&&(0,M.jsxs)(`div`,{className:`configure-error`,children:[(0,M.jsx)(T,{size:12}),` `,d]}),(0,M.jsx)(`div`,{className:`configure-actions`,children:(0,M.jsx)(`button`,{className:`btn-model-save${l?` saved`:``}`,disabled:o||!i.client_id?.trim(),onClick:()=>void g(),children:o?(0,M.jsx)(v,{size:12,className:`spin`}):l?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(b,{size:12}),` Saved`]}):`Save client`})})]})]})}function q({connector:e,onChanged:t}){let[n,r]=(0,N.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null);(0,N.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),s(!1);try{await c(e.id,r),s(!0),t(),setTimeout(()=>s(!1),2200)}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}}},m=async()=>{a(!0),f(null);try{await u(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)}},h=async()=>{a(!0),f(null);try{e.enabled?await _(e.id):await l(e.id),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,M.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,M.jsx)(`p`,{className:`connector-desc`,children:e.description}),d&&(0,M.jsxs)(`div`,{className:`configure-error`,children:[(0,M.jsx)(T,{size:12}),` `,d]}),e.configured&&(0,M.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,M.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,M.jsxs)(`span`,{className:`toggle-switch`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void h(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,M.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,M.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,M.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,M.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,M.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,M.jsxs)(`div`,{className:`configure-actions`,children:[(0,M.jsx)(`button`,{className:`btn-model-save${o?` saved`:``}`,disabled:i||Object.values(n).every(e=>e.trim()===``),onClick:()=>void p(),children:i?(0,M.jsx)(v,{size:12,className:`spin`}):o?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(b,{size:12}),` Saved`]}):`Save`}),e.configured&&(0,M.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void m(),children:`Disconnect`}),e.product_url&&(0,M.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,M.jsx)(w,{size:11})]})]})]})}function J({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[o,s]=(0,N.useState)(()=>new Set(n)),[c,l]=(0,N.useState)(null),[u,d]=(0,N.useState)(null);(0,N.useEffect)(()=>{s(new Set(n))},[n.join(`,`)]);let f=async e=>{if(c!==null)return;let i=new Set(o);i.has(e)?i.delete(e):i.add(e),s(i),l(e),d(null);try{i.size===0?await h(t,a):await C(t,a,[...i]),r()}catch(e){s(new Set(n)),d(e instanceof Error?e.message:String(e))}finally{l(null)}};return(0,M.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,M.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,M.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,M.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,M.jsx)(`span`,{className:`grant-scope-label`,children:B(e)}),(0,M.jsxs)(`span`,{className:`toggle-switch`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:o.has(e),onChange:()=>void f(e),disabled:c!==null}),(0,M.jsx)(`span`,{className:`toggle-track`})]})]},e))}),u&&(0,M.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,M.jsx)(T,{size:11}),` `,u]})]})}function Y({servers:e,expanded:t,onToggle:n}){return(0,M.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,M.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,M.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,M.jsx)(X,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function X({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,M.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,M.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,M.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,M.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,M.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,M.jsx)(b,{size:11}),` Active`]}),(0,M.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,M.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,M.jsx)(k,{size:14}):(0,M.jsx)(x,{size:14})})]}),t&&(0,M.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,M.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,M.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,M.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,M.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function Z({connectorId:e,connectorType:t}){let{agents:n}=d(),[r,i]=(0,N.useState)({}),[a,o]=(0,N.useState)({}),[s,c]=(0,N.useState)(!0),l=(0,N.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([f(e),S(e)]);i(t),o(n)}catch{i({}),o({})}finally{c(!1)}},[e]);if((0,N.useEffect)(()=>{l()},[l]),I((0,N.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)),p=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,M.jsxs)(`div`,{className:`connection-grants`,children:[(0,M.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),u.length===0?(0,M.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):u.map(t=>(0,M.jsx)(J,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},t.namespaced_agent_id)),p.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,M.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),p.map(t=>(0,M.jsx)(Q,{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 Q({agent:e,connectorId:t,active:n,grantedScopes:r,onChanged:i}){let a=e.required_connections?.find(e=>e.connector_id===t),o=e.namespaced_agent_id;if(!o)return null;let[s,c]=(0,N.useState)(n),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null);(0,N.useEffect)(()=>{c(n)},[n]);let p=async()=>{if(l)return;let e=!s;c(e),u(!0),f(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...V]:void 0;await y(t,o,e)}else await E(t,o);i()}catch(e){c(n),f(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,M.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,M.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,M.jsx)(`div`,{className:`grant-scope-list`,children:(0,M.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,M.jsx)(`span`,{className:`grant-scope-label`,children:s?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,M.jsxs)(`span`,{className:`toggle-switch`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:s,onChange:()=>void p(),disabled:l}),(0,M.jsx)(`span`,{className:`toggle-track`})]})]})}),d&&(0,M.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,M.jsx)(T,{size:11}),` `,d]})]})}function $(){return(0,M.jsxs)(`div`,{className:`settings-pane`,children:[(0,M.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,M.jsx)(U,{})]})}export{$ as ConnectorsPane};
@@ -0,0 +1 @@
1
+ .connectors-section .settings-help{color:var(--text-secondary);font-size:13px;line-height:1.5;font-family:var(--font-sans);margin-bottom:12px}.connectors-loading{color:var(--text-muted);justify-content:center;padding:20px;display:flex}.connectors-list{flex-direction:column;gap:6px;display:flex}.connector-tile{border:1px solid var(--border-light);border-radius:var(--radius-md);background:var(--bg-secondary);transition:border-color var(--duration) var(--ease);overflow:hidden}.connector-tile:hover,.connector-tile--open{border-color:var(--border)}.connector-tile-header{cursor:pointer;text-align:left;width:100%;font-family:var(--font-sans);color:var(--text-primary);background:0 0;border:none;align-items:center;gap:10px;padding:12px 16px;display:flex}.connector-tile-header:hover{background:var(--bg-hover)}[data-theme=dark] .connector-tile-header:hover{background:color-mix(in srgb, var(--text-primary) 4%, transparent)}.connector-tile-name{font-size:13px;font-weight:600}.connector-tile-type{font-size:var(--fs-caption);font-family:var(--font-sans);color:var(--text-muted);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:999px;flex-shrink:0;padding:1px 6px}.connector-status{font-size:12px;font-family:var(--font-sans);align-items:center;gap:4px;display:inline-flex}.connector-status.ok{color:var(--accent-green)}.connector-status.idle{color:var(--text-muted)}.connector-status.disabled{color:var(--text-muted);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:999px;padding:1px 8px;font-size:11px}.connector-tile-chevron{color:var(--text-muted);flex-shrink:0;margin-left:auto}.connector-detail{border-top:1px solid var(--border-light);padding:16px 18px}.connector-desc{color:var(--text-secondary);font-size:12px;line-height:1.5;font-family:var(--font-sans);margin-bottom:12px}.configure-error{color:var(--danger);background:color-mix(in srgb, var(--danger) 8%, transparent);border:1px solid color-mix(in srgb, var(--danger) 20%, transparent);border-radius:var(--radius-sm);font-size:12px;font-family:var(--font-sans);align-items:center;gap:6px;margin-bottom:10px;padding:6px 10px;display:flex}.configure-info{color:var(--text-secondary);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:var(--radius-sm);font-size:12px;font-family:var(--font-sans);align-items:flex-start;gap:6px;margin-bottom:10px;padding:6px 10px;line-height:1.4;display:flex}.configure-info svg{color:var(--text-muted);flex-shrink:0;margin-top:2px}.connector-setup-required{font-size:12px;font-family:var(--font-sans);color:var(--text-muted);background:var(--bg-tertiary);border:1px solid var(--border-light);cursor:default;border-radius:999px;align-items:center;gap:4px;padding:3px 10px;display:inline-flex}.configure-actions{align-items:center;gap:8px;margin-top:10px;display:flex}.oauth-setup-form{background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:6px;flex-direction:column;gap:12px;margin:8px 0 4px;padding:12px;display:flex}.oauth-setup-field{font-size:12px;font-family:var(--font-sans);flex-direction:column;gap:4px;display:flex}.oauth-setup-label{color:var(--text-primary);font-weight:500}.oauth-setup-input{border:1px solid var(--border-light);background:var(--bg-primary);color:var(--text-primary);font-family:var(--font-mono);border-radius:4px;padding:6px 8px;font-size:12px}.oauth-setup-input:focus{border-color:var(--accent);outline:none}.oauth-setup-help{color:var(--text-secondary);font-size:11px;line-height:1.4}.oauth-grant-onconnect{background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:6px;flex-direction:column;gap:6px;margin:8px 0 4px;padding:10px 12px;display:flex}.oauth-grant-onconnect-label{color:var(--text-primary);margin:0;font-size:12px;font-weight:500}.oauth-grant-onconnect-item{color:var(--text-primary);cursor:pointer;align-items:center;gap:8px;font-size:12px;display:flex}.oauth-grant-onconnect-help{color:var(--text-secondary);margin:2px 0 0;font-size:11px;line-height:1.4}.connector-product-link{color:var(--text-secondary);font-size:12px;font-family:var(--font-sans);align-items:center;gap:3px;margin-left:auto;text-decoration:none;display:inline-flex}.connector-product-link:hover{color:var(--accent);text-decoration:underline}.mcp-key-row{flex-direction:column;gap:4px;margin-bottom:10px;display:flex}.mcp-key-label{font-size:var(--fs-label);font-family:var(--font-sans);color:var(--text-secondary)}.mcp-key-input{font-size:13px;font-family:var(--font-mono);background:var(--bg-primary);border:1px solid var(--border-light);border-radius:var(--radius-md);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;padding:7px 10px}.mcp-key-input:focus{border-color:var(--accent)}.connection-grants{border-top:1px dashed var(--border-light);margin-top:12px;padding-top:12px}.grants-header{font-size:var(--fs-label);font-weight:600;font-family:var(--font-sans);color:var(--text-muted);margin-bottom:8px}.grants-empty{color:var(--text-muted);font-size:12px;font-family:var(--font-sans);font-style:italic}.grant-agent-card{border:1px solid var(--border-light);border-radius:var(--radius-sm);background:var(--bg-secondary);margin-top:6px;padding:10px 14px}.grant-agent-card-name{font-size:12px;font-weight:600;font-family:var(--font-sans);color:var(--text-primary);margin-bottom:10px}.grant-scope-list{border-top:1px solid var(--border-light);flex-direction:column;gap:2px;padding-top:8px;display:flex}.grant-scope-item{cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:12px;padding:5px 0;display:flex}.grant-scope-label{font-size:12px;font-family:var(--font-sans);color:var(--text-secondary);flex:1;line-height:1.3}.grant-scope-warning{font-size:11px;font-family:var(--font-sans);color:var(--text-muted);align-items:center;gap:5px;margin-top:7px;display:flex}.grant-scope-warning--error{color:var(--danger)}.error-banner{background:color-mix(in srgb, var(--danger) 8%, transparent);color:var(--danger);border-radius:var(--radius-md);border:1px solid color-mix(in srgb, var(--danger) 20%, transparent);font-size:12px;font-family:var(--font-sans);align-items:center;gap:6px;margin-bottom:10px;padding:8px 12px;display:flex}.spin{animation:spin var(--duration-spin) var(--ease-linear) infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.connector-toggle-row{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:6px;align-items:center;gap:12px;margin-bottom:10px;padding:10px 14px;display:flex}.connector-toggle-label{font-size:12px;font-family:var(--font-sans);color:var(--text-primary);flex:1}.connector-toggle-help{color:var(--text-muted);margin:-4px 0 10px 14px;font-size:11px;font-style:italic}.connector-tile-menu{flex-shrink:0;align-items:center;display:inline-flex;position:relative}.connector-tile-menu-trigger{color:var(--text-muted);cursor:pointer;background:0 0;border:none;border-radius:4px;padding:4px;line-height:0}.connector-tile-menu-trigger:hover{background:var(--bg-tertiary);color:var(--text-primary)}.connector-tile-menu-trigger:focus-visible{outline:2px solid var(--accent-blue);outline-offset:1px}.connector-tile-menu-trigger:disabled{opacity:.4;cursor:not-allowed}.connector-tile-menu-popup{z-index:1000;background:var(--bg-primary);border:1px solid var(--border);text-align:left;border-radius:4px;flex-direction:column;min-width:160px;padding:4px;display:flex;box-shadow:0 4px 12px #0000002e}.connector-tile-menu-item{font-size:12px;font-family:var(--font-sans);color:var(--text-primary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:3px;padding:6px 10px;line-height:1.4}.connector-tile-menu-item:hover{background:var(--bg-secondary)}.connector-tile-menu-item:disabled{opacity:.4;cursor:not-allowed}.connector-tile-menu-item--danger{color:var(--danger)}.connector-tile-menu-divider{background:var(--border-light);height:1px;margin:4px 0}.agent-mcps-section{margin-top:20px}.agent-mcps-section-header{font-size:var(--fs-label);font-weight:600;font-family:var(--font-sans);color:var(--text-muted);margin-bottom:8px}.agent-mcp-tile{border:1px solid var(--border-light);border-radius:var(--radius-md);background:var(--bg-secondary);transition:border-color var(--duration) var(--ease);overflow:hidden}.agent-mcp-tile:hover,.agent-mcp-tile--open{border-color:var(--border)}.agent-mcp-tile-header{cursor:pointer;text-align:left;width:100%;font-family:var(--font-sans);color:var(--text-primary);background:0 0;border:none;align-items:center;gap:10px;padding:10px 14px;display:flex}.agent-mcp-tile-header:hover{background:var(--bg-hover)}[data-theme=dark] .agent-mcp-tile-header:hover{background:color-mix(in srgb, var(--text-primary) 4%, transparent)}.agent-mcp-server-name{font-size:13px;font-weight:600}.agent-mcp-agent-label{font-size:11px;font-family:var(--font-sans);color:var(--text-muted);flex:1}.agent-mcp-status{font-size:11px;font-family:var(--font-sans);align-items:center;gap:4px;display:inline-flex}.agent-mcp-status.enabled{color:var(--accent-green)}.agent-mcp-status.disabled{color:var(--text-muted);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:999px;padding:1px 8px}.agent-mcp-readonly-badge{font-size:var(--fs-caption);font-family:var(--font-sans);color:var(--text-muted);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:999px;flex-shrink:0;padding:1px 6px}.agent-mcp-chevron{color:var(--text-muted);flex-shrink:0}.agent-mcp-detail{border-top:1px solid var(--border-light);padding:12px 16px}.agent-mcp-command-row{font-size:12px;font-family:var(--font-mono);color:var(--text-secondary);background:var(--bg-tertiary);border:1px solid var(--border-light);border-radius:var(--radius-sm);word-break:break-all;margin-bottom:8px;padding:6px 10px}.agent-mcp-config-path{font-size:11px;font-family:var(--font-mono);color:var(--text-muted);word-break:break-all;margin-bottom:4px}.agent-mcp-config-hint{font-size:11px;font-family:var(--font-sans);color:var(--text-muted);font-style:italic}.connector-tile-menu-error{color:var(--danger);border-top:1px solid var(--border-light);margin-top:4px;padding:6px 10px;font-size:11px}.oauth-client-editor{border:1px solid var(--border-light);border-radius:var(--radius-sm);margin:6px 0 8px}.oauth-client-editor__toggle{width:100%;color:var(--text-primary);cursor:pointer;text-align:left;background:0 0;border:none;align-items:center;gap:6px;padding:6px 8px;font-size:12px;display:flex}.oauth-client-editor__status{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;max-width:60%;margin-left:auto;font-size:11px;overflow:hidden}.oauth-client-editor .oauth-setup-form{padding:0 8px 8px}.device-code-block{border:1px solid var(--border);background:var(--bg-secondary);border-radius:8px;margin-top:10px;padding:12px}.device-code-instructions{color:var(--text-primary);margin:0 0 8px;font-size:12px}.device-code-value{align-items:center;gap:8px;margin-bottom:8px;display:flex}.device-code-value code{letter-spacing:2px;background:var(--bg-tertiary);color:var(--text-primary);-webkit-user-select:all;user-select:all;border-radius:6px;padding:4px 10px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:18px;font-weight:600}.device-code-waiting{color:var(--text-muted);align-items:center;gap:6px;margin:0 0 8px;font-size:12px;display:flex}
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{l as t,n,o as r,s as i,u as a}from"./apiBase-y00JgRBP.js";import{Bt as o,Ft as s,G as c,Gt as l,H as u,Qt as d,Rt as f,U as p,Ut as m,V as ee,Y as te,Z as ne,en as re,ft as ie,lt as h,on as g,ot as _,q as v,t as y,un as b,vt as x,yt as S}from"./index-I_UyOSz2.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 ae=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 oe=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 se=t(D),O=e(a(),1),k=n();function ce(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function le(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 A(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 j(){let{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:a,currentSessionId:C,sessions:T,updateSessionInList:E,draftDocumentIds:D,addDraftDocuments:j,removeDraftDocument:M}=s(),N=T.find(e=>e.id===C)??null,P=(0,O.useCallback)(()=>n(!1),[n]);r(!0,P);let[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),[,ue]=(0,O.useState)(0);(0,O.useEffect)(()=>{i.doc.info(`Loading document library...`);let e=i.doc.time();_().then(n=>{let r=n.documents||[];t(r),i.doc.timed(`Loaded ${r.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{i.doc.error(`Failed to load documents`,e),t([])})},[t]);let J=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,O.useEffect)(()=>{if(!J)return;let e=s.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(ue(e=>e+1),!n){n=!0;try{let e=s.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await ne(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=s.getState().documents;(e.length!==n.length||e.some((e,t)=>{let r=n.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(t(e),i.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let de=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 r=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;if(r&&!p(r)){let t=u(r),n=t?t.message:`The file type "${r}" is not supported for indexing.`;i.doc.warn(`Unsupported file type: ${e} (${r})`),W({filename:e,error:n});return}i.doc.info(`Indexing document: ${e}`);let a=i.doc.time();R(!0),B(`Indexing ${e}...`),W(null);try{let r=await n();if(i.doc.timed(`Indexed "${e}": ${r?.chunk_count||`?`} chunks`,a),C&&r?.id)try{await c(C,r.id);let t=s.getState().sessions.find(e=>e.id===C)?.document_ids??[];t.includes(r.id)||E(C,{document_ids:[...t,r.id]}),i.doc.info(`Auto-attached "${e}" to session ${C}`)}catch(e){i.doc.warn(`Could not attach document to session: ${e}`)}else r?.id&&(j([r.id]),i.doc.info(`"${e}" will be attached to the next new chat`));let o=await _();t(o.documents||[]),B(``)}catch(t){i.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,j]),Z=(0,O.useCallback)(async(e,t)=>{await X(t,()=>S(e))},[X]),Q=(0,O.useCallback)(async e=>{await X(e.name,()=>x(e))},[X]),fe=(0,O.useCallback)(async e=>{e.preventDefault(),I(!1);let t=Array.from(e.dataTransfer.files);i.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),pe=(0,O.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Deleting document: ${r?.filename||n}`);try{await te(n),q.current.delete(n),M(n),t(e.filter(e=>e.id!==n)),i.doc.info(`Deleted document: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to delete document: ${r?.filename||n}`,e)}},[e,t,M]),me=(0,O.useCallback)(async(e,t)=>{i.doc.info(`Opening folder for: ${e}`);try{await h(e,!0)}catch(e){i.doc.error(`Failed to open folder for: ${t}`,e)}},[]),he=(0,O.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Cancelling indexing for: ${r?.filename||n}`);try{await v(n),q.current.delete(n);let e=await _();t(e.documents||[]),i.doc.info(`Cancelled indexing for: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to cancel indexing: ${r?.filename||n}`,e)}},[e,t]),ge=(0,O.useCallback)(async n=>{if(G.has(n))return;let r=e.find(e=>e.id===n);i.doc.info(`Reindexing document: ${r?.filename||n}`),K(e=>new Set(e).add(n));try{await ie(n),i.doc.info(`Reindex complete for: ${r?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.doc.error(`Reindex failed for: ${r?.filename||n}`,e),W({filename:r?.filename||n,error:t})}finally{try{let e=await _();t(e.documents||[])}catch(e){i.doc.error(`Failed to refresh documents after reindex`,e)}K(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,G]),$=(0,O.useCallback)(async t=>{let n=e.find(e=>e.id===t);if(!C){j([t]),i.doc.info(`"${n?.filename||t}" will be attached to the next new chat`);return}i.doc.info(`Attaching document to session: ${n?.filename||t}`);try{await c(C,t);let e=s.getState().sessions.find(e=>e.id===C)?.document_ids??[];e.includes(t)||E(C,{document_ids:[...e,t]}),i.doc.info(`Attached "${n?.filename||t}" to session ${C}`)}catch(e){i.doc.error(`Failed to attach document to session: ${n?.filename||t}`,e)}},[C,e,E,j]),_e=(0,O.useCallback)(async e=>{e.preventDefault(),V.trim()&&(i.doc.info(`Indexing from path input: ${V.trim()}`),await Z(V.trim(),V.trim().split(/[\\/]/).pop()||`file`),H(``))},[V,Z]),ve=e=>{let t=e.indexing_status||`complete`,n=q.current.get(e.id),r=e.indexed_at?le(e.indexed_at):``,i=e.indexed_at?A(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)(oe,{size:12,className:`doc-spin`}),`Indexing`,n?` (${ce(n)})`:`...`]})]}),(0,k.jsxs)(`button`,{className:`btn-cancel`,onClick:t=>{t.stopPropagation(),he(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)(b,{size:12}),` Failed`]}),(0,k.jsxs)(`button`,{className:`btn-retry`,onClick:t=>{t.stopPropagation(),ge(e.id)},title:`Retry indexing`,"aria-label":`Retry indexing ${e.filename}`,disabled:G.has(e.id),children:[(0,k.jsx)(se,{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)(b,{size:12}),` File missing`]});default:return(0,k.jsxs)(`span`,{className:`doc-meta`,children:[y(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)(f,{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:fe,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)(o,{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:_e,children:[(0,k.jsx)(d,{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),a(!0)},title:`Browse files on this computer`,children:[(0,k.jsx)(l,{size:14}),`Browse files`]})]}),U&&(0,k.jsx)(ee,{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:y(de)})]}),(0,k.jsxs)(`div`,{className:`doc-list`,children:[e.length===0&&!L&&(0,k.jsxs)(`div`,{className:`empty-docs`,children:[(0,k.jsx)(re,{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}),ve(e)]}),(0,k.jsxs)(`div`,{className:`doc-row-actions`,children:[e.filepath&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>me(e.filepath,e.filename),title:`Open folder: ${e.filepath}`,"aria-label":`Open containing folder for ${e.filename}`,children:(0,k.jsx)(d,{size:14})}),e.indexing_status===`complete`&&!(C?N?.document_ids?.includes(e.id):D.includes(e.id))&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>$(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)(ae,{size:14})}),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`&&(0,k.jsx)(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>pe(e.id),title:`Remove`,"aria-label":`Remove ${e.filename}`,children:(0,k.jsx)(m,{size:14})})]})]},e.id))]})]})]})})}export{j as DocumentLibrary};
@@ -0,0 +1 @@
1
+ .doc-modal{width:640px}.drop-zone{border:2px dashed var(--border);border-radius:var(--radius-lg);text-align:center;cursor:pointer;color:var(--text-secondary);transition:all var(--duration) var(--ease);flex-direction:column;justify-content:center;align-items:center;margin-bottom:18px;padding:36px;display:flex}.drop-zone:hover,.drop-zone.drag-over{border-color:var(--accent);background:var(--accent-dim2);color:var(--accent);transform:translateY(-1px)}.drop-zone.uploading{border-color:var(--accent);cursor:default}.drop-zone p{font-size:14px;font-weight:500;font-family:var(--font-sans);margin-top:10px}.drop-hint{color:var(--text-muted);font-size:12px;font-family:var(--font-sans);margin-top:4px}.upload-spinner{border:3px solid var(--border);border-top-color:var(--accent);width:28px;height:28px;animation:spin var(--duration-spin) var(--ease-linear) infinite;border-radius:50%}.path-input-form{align-items:center;gap:8px;margin-bottom:16px;display:flex}.path-icon{color:var(--text-muted);flex-shrink:0}.path-input{border:1px solid var(--border);border-radius:var(--radius-md);font-size:13px;font-family:var(--font-mono);transition:border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);outline:none;flex:1;padding:9px 14px}.path-input:focus{border-color:var(--accent)}.path-input::placeholder{color:var(--text-muted)}.doc-stats{color:var(--text-muted);align-items:center;gap:8px;margin-bottom:12px;padding:0 2px;font-size:12px;display:flex}.doc-list{flex-direction:column;gap:4px;display:flex}.doc-row{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease), background var(--duration) var(--ease);justify-content:space-between;align-items:center;padding:12px 14px;display:flex}.doc-row:hover{border-color:var(--accent-light);background:var(--tint-subtle)}.doc-info{flex:1;min-width:0}.doc-name{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;display:block;overflow:hidden}.doc-meta{color:var(--text-muted);font-size:12px}.doc-timestamp{border-left:1px solid var(--border-light);color:var(--text-muted);cursor:default;align-items:center;gap:3px;margin-left:6px;padding-left:6px;font-size:11px;display:inline-flex}.doc-timestamp svg{opacity:.6;flex-shrink:0}.doc-status-badge{font-size:var(--fs-caption);border-radius:var(--radius-sm);font-family:var(--font-sans);align-items:center;gap:4px;padding:2px 8px;display:inline-flex}.doc-status-failed{color:var(--danger);background:var(--danger-dim)}.doc-status-cancelled{color:var(--text-muted);background:color-mix(in srgb, var(--text-muted) 8%, transparent)}.doc-status-missing{color:var(--accent-yellow);background:var(--accent-yellow-dim)}.doc-row-actions{opacity:0;transition:opacity var(--duration-fast) var(--ease);flex-shrink:0;align-items:center;gap:2px;display:flex}.doc-row:hover .doc-row-actions{opacity:1}.doc-open-folder{color:var(--text-muted)}.doc-open-folder:hover{color:var(--accent-blue)}.doc-delete{color:var(--text-muted)}.doc-delete:hover{color:var(--danger)}.empty-docs{color:var(--text-muted);text-align:center;flex-direction:column;align-items:center;padding:32px;display:flex}.empty-docs p{margin-top:8px;font-size:14px}.empty-docs span{margin-top:4px;font-size:12px}.doc-indexing-status{align-items:center;gap:8px;display:inline-flex}.btn-retry{color:var(--text-muted);cursor:pointer;transition:background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);background:0 0;border:none;border-radius:4px;align-items:center;gap:4px;padding:2px 6px;font-size:11px;display:inline-flex}.btn-retry:hover{background:var(--danger-dim);color:var(--danger)}.btn-retry:disabled{opacity:.6;cursor:default;color:var(--text-muted);background:0 0}
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{l as t,n,o as r,s as i,u as a}from"./apiBase-y00JgRBP.js";import{t as o}from"./eye-B6FejHNG.js";import{$t as s,Bt as c,Ft as l,G as u,Gt as d,H as f,Jt as p,K as ee,Qt as te,Rt as m,U as h,V as ne,Zt as g,at as _,dn as re,dt as ie,en as v,hn as ae,mn as oe,nn as y,ot as b,pt as se,t as ce,yt as x}from"./index-I_UyOSz2.js";var S={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`}]]};S.node;var C=t(S),w={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`}]]};w.node;var le=t(w),T={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`]};T.node;var E=t(T),D={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`}]]};D.node;var O=t(D),k=e(a(),1),A=n();function ue(e){if(e.type===`folder`)return(0,A.jsx)(g,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?(0,A.jsx)(O,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?(0,A.jsx)(C,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?(0,A.jsx)(v,{size:16}):(0,A.jsx)(s,{size:16})}function de(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 fe(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function pe(e){switch(e){case`home`:return(0,A.jsx)(E,{size:14});case`desktop`:return(0,A.jsx)(p,{size:14});case`documents`:return(0,A.jsx)(v,{size:14});case`download`:return(0,A.jsx)(y,{size:14});default:return(0,A.jsx)(g,{size:14})}}var me=[{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 j(e,t,n,r){let a=[],o=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!h(e)?o.push(t):a.push(t)}let s=[],c=[],d=0,f=``,p=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(p.has(e)){let t=await _(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),n.length>0&&(n.forEach(e=>s.push(e)),c.push(e))}else{let t=await x(e);t?.id&&(s.push(t.id),c.push(e))}}catch(e){d++,f=e instanceof Error?e.message:`Unknown error`}if(n&&s.length>0){let e=[];for(let t of s)try{await u(n,t),e.push(t)}catch(e){i.doc.warn(`Could not attach document to session: ${e}`)}let t=l.getState().sessions.find(e=>e.id===n)?.document_ids??[],a=e.filter(e=>!t.includes(e));a.length>0&&r(n,{document_ids:[...t,...a]})}else s.length>0&&l.getState().addDraftDocuments(s);if(s.length>0)try{let e=await b();l.getState().setDocuments(e.documents||[])}catch(e){i.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:s,supported:a,succeededFiles:c,unsupported:o,failed:d,lastError:f}}function M(){let{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n,setPendingPrompt:a}=l(),s=(0,k.useCallback)(()=>e(!1),[e]);r(!0,s);let[u,p]=(0,k.useState)(``),[g,_]=(0,k.useState)(null),[v,y]=(0,k.useState)([]),[b,x]=(0,k.useState)([]),[S,C]=(0,k.useState)(!1),[w,T]=(0,k.useState)(null),[E,D]=(0,k.useState)(``),[O,M]=(0,k.useState)(null),[N,P]=(0,k.useState)([]),[he,ge]=(0,k.useState)(!1),[F,I]=(0,k.useState)(!1),[L,_e]=(0,k.useState)(``),[R,z]=(0,k.useState)(new Set),[B,V]=(0,k.useState)(null),[ve,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)(new Set),[G,K]=(0,k.useState)(null),q=(0,k.useRef)(null),[J,Y]=(0,k.useState)(null),X=(0,k.useCallback)(async e=>{C(!0),T(null),M(null),D(``),P([]);try{let t=await ee(e);p(t.current_path),_(t.parent_path),y(t.entries),t.quick_links.length>0&&x(t.quick_links),i.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;T(t),i.ui.error(`Browse failed`,e)}finally{C(!1)}},[]);(0,k.useEffect)(()=>{X()},[X]),(0,k.useEffect)(()=>()=>{q.current&&clearTimeout(q.current)},[]);let Z=(0,k.useCallback)(async()=>{if(!E.trim()){M(null),P([]);return}I(!0),T(null);try{let e=await se(E.trim(),L||void 0,30);M(e.results),P(e.searched_locations??[]),ge(e.truncated===!0),i.ui.info(`Search "${E}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;T(t),i.ui.error(`Search failed`,e)}finally{I(!1)}},[E,L]),ye=e=>{e.key===`Enter`&&Z()},Q=(0,k.useCallback)(e=>{e.type===`folder`&&(X(e.path),z(new Set),V(null))},[X]),be=(0,k.useCallback)(async e=>{H(!0);try{let t=await ie(e);V(t)}catch(e){i.ui.error(`Preview failed`,e)}finally{H(!1)}},[]),xe=(0,k.useCallback)(e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Se=(0,k.useCallback)(async()=>{if(R.size===0)return;let e=Array.from(R);if(Y(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||h(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=f(r);Y({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`});return}W(new Set(e)),K(`Indexing ${e.length} file(s)...`);try{let r=await j(e,v,t,n);if(r.failed>0)K(`Done: ${r.docIds.length} indexed, ${r.failed} failed`),Y({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)`:``;K(`Successfully indexed ${r.docIds.length} file(s)${e}`)}q.current&&clearTimeout(q.current),q.current=setTimeout(()=>K(null),5e3),z(new Set)}catch(t){i.doc.error(`Index selected failed`,t),Y({filename:e.length===1?e[0].split(/[\\/]/).pop()||e[0]:`${e.length} files`,error:t instanceof Error?t.message:`An unexpected error occurred.`})}finally{W(new Set)}},[R,t,n,v]),Ce=(0,k.useCallback)(async()=>{if(R.size===0)return;let r=Array.from(R);Y(null),W(new Set(r)),K(`Indexing ${r.length} file(s) for analysis...`);try{let i=await j(r,v,t,n);if(i.supported.length===0){let e=r[0].lastIndexOf(`.`),t=e>0?r[0].slice(e).toLowerCase():``,n=f(t);Y({filename:r.length===1?r[0].split(/[\\/]/).pop()||r[0]:`${r.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(i.docIds.length===0){Y({filename:i.supported.length===1?i.supported[0].split(/[\\/]/).pop()||i.supported[0]:`${i.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}i.failed>0&&K(`Warning: ${i.failed} file(s) failed to index and will be excluded.`);let o=(i.succeededFiles.length>0?i.succeededFiles:i.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
+ `)}`;a(s),e(!1),z(new Set)}catch(e){i.doc.error(`Ask Agent failed`,e),Y({filename:r.length===1?r[0].split(/[\\/]/).pop()||r[0]:`${r.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{W(new Set),K(null)}},[R,t,n,v,a,e]),we=u?u.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],Te=we.map((e,t)=>({label:e,path:we.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Ee=fe(N),$=O?O.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):v;return(0,A.jsx)(`div`,{className:`modal-overlay`,onClick:()=>e(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File browser`,children:(0,A.jsxs)(`div`,{className:`modal-panel file-browser-modal ${B?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`modal-header`,children:[(0,A.jsxs)(`h3`,{children:[(0,A.jsx)(te,{size:18}),` File browser`]}),(0,A.jsx)(`button`,{className:`btn-icon`,onClick:()=>e(!1),"aria-label":`Close`,children:(0,A.jsx)(m,{size:18})})]}),(0,A.jsxs)(`div`,{className:`file-browser-body`,children:[(0,A.jsx)(`div`,{className:`fb-quick-links`,children:b.map(e=>(0,A.jsxs)(`button`,{className:`fb-quick-link`,onClick:()=>X(e.path),title:e.path,children:[pe(e.icon),(0,A.jsx)(`span`,{children:e.name})]},e.path))}),(0,A.jsxs)(`div`,{className:`fb-search-bar`,children:[(0,A.jsxs)(`div`,{className:`fb-search-input-wrap`,children:[(0,A.jsx)(d,{size:14,className:`fb-search-icon`}),(0,A.jsx)(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:E,onChange:e=>D(e.target.value),onKeyDown:ye,"aria-label":`Search files`}),E&&(0,A.jsx)(`button`,{className:`fb-search-clear`,onClick:()=>{D(``),M(null),P([])},"aria-label":`Clear search`,children:(0,A.jsx)(m,{size:12})})]}),(0,A.jsx)(`select`,{className:`fb-type-filter`,value:L,onChange:e=>_e(e.target.value),"aria-label":`File type filter`,children:me.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,A.jsx)(`button`,{className:`fb-search-btn`,onClick:Z,disabled:!E.trim()||F,children:F?`Searching...`:`Search`})]}),!O&&(0,A.jsxs)(`div`,{className:`fb-breadcrumb`,children:[(0,A.jsx)(`button`,{className:`fb-crumb`,onClick:()=>X(`/`),children:(0,A.jsx)(le,{size:12})}),Te.map((e,t)=>(0,A.jsxs)(`span`,{className:`fb-crumb-item`,children:[(0,A.jsx)(re,{size:12,className:`fb-crumb-sep`}),(0,A.jsx)(`button`,{className:`fb-crumb`,onClick:()=>X(e.path),children:e.label})]},t)),g&&(0,A.jsx)(`button`,{className:`fb-up-btn`,onClick:()=>X(g),title:`Go up`,children:(0,A.jsx)(ae,{size:14})})]}),O&&(0,A.jsxs)(`div`,{className:`fb-search-header`,children:[(0,A.jsxs)(`div`,{className:`fb-search-summary`,children:[(0,A.jsxs)(`span`,{children:[`Found `,O.length,` result(s) for "`,E,`"`]}),Ee&&(0,A.jsxs)(`span`,{className:`fb-search-scope`,title:N.join(`
3
+ `),children:[`Searching in: `,(0,A.jsx)(`code`,{children:Ee})]}),he&&(0,A.jsx)(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),(0,A.jsx)(`button`,{className:`fb-back-btn`,onClick:()=>{M(null),D(``),P([])},children:`Back to browsing`})]}),w&&(0,A.jsx)(`div`,{className:`fb-error`,children:w}),(0,A.jsxs)(`div`,{className:`fb-content`,children:[(0,A.jsxs)(`div`,{className:`fb-file-list`,children:[S&&(0,A.jsx)(`div`,{className:`fb-loading`,children:`Loading...`}),!S&&$.length===0&&(0,A.jsx)(`div`,{className:`fb-empty`,children:O?`No files found`:`This folder is empty`}),!S&&$.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!h(t),r=n?f(t):null;return(0,A.jsxs)(`div`,{className:`fb-entry ${e.type} ${R.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?Q(e):xe(e.path),onDoubleClick:()=>e.type===`folder`?Q(e):void 0,title:n?`${r?.label||`This`} file type cannot be indexed`:e.path,children:[(0,A.jsx)(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:R.has(e.path),onChange:()=>xe(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),(0,A.jsx)(`span`,{className:`fb-entry-icon`,children:ue(e)}),(0,A.jsx)(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&(0,A.jsx)(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&(0,A.jsx)(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),be(e.path)},"aria-label":`Preview ${e.name}`,title:`Preview file`,children:(0,A.jsx)(o,{size:14})}),(0,A.jsx)(`span`,{className:`fb-entry-size`,children:e.type===`file`?ce(e.size):``}),(0,A.jsx)(`span`,{className:`fb-entry-date`,children:de(e.modified)})]},e.path)})]}),B&&(0,A.jsxs)(`div`,{className:`fb-preview`,children:[(0,A.jsxs)(`div`,{className:`fb-preview-header`,children:[(0,A.jsx)(`span`,{className:`fb-preview-name`,children:B.name}),(0,A.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>V(null),"aria-label":`Close preview`,children:(0,A.jsx)(m,{size:14})})]}),(0,A.jsxs)(`div`,{className:`fb-preview-meta`,children:[(0,A.jsx)(`span`,{children:B.size_display}),B.total_lines&&(0,A.jsxs)(`span`,{children:[B.total_lines,` lines`]}),B.columns&&(0,A.jsxs)(`span`,{children:[B.columns.length,` columns`]}),B.row_count!==null&&(0,A.jsxs)(`span`,{children:[B.row_count,` rows`]})]}),B.columns&&(0,A.jsxs)(`div`,{className:`fb-preview-columns`,children:[(0,A.jsx)(`strong`,{children:`Columns:`}),` `,B.columns.join(`, `)]}),ve?(0,A.jsx)(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):B.is_text&&B.preview_lines.length>0?(0,A.jsx)(`pre`,{className:`fb-preview-content`,children:B.preview_lines.slice(0,30).join(`
4
+ `)}):(0,A.jsx)(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),J&&(0,A.jsx)(ne,{filename:J.filename,error:J.error,onDismiss:()=>Y(null)}),(0,A.jsxs)(`div`,{className:`fb-actions`,children:[(0,A.jsx)(`div`,{className:`fb-selection-info`,children:R.size>0?`${R.size} item(s) selected`:`Select files to index or analyze`}),G&&(0,A.jsx)(`span`,{className:`fb-index-status`,children:G}),(0,A.jsxs)(`div`,{className:`fb-action-btns`,children:[(0,A.jsxs)(`button`,{className:`fb-action-btn secondary`,onClick:Se,disabled:R.size===0||U.size>0,title:`Index selected files for RAG search`,children:[(0,A.jsx)(c,{size:14}),`Index Selected`]}),(0,A.jsxs)(`button`,{className:`fb-action-btn primary`,onClick:Ce,disabled:R.size===0||U.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[(0,A.jsx)(oe,{size:14}),`Ask Agent`]})]})]})]})]})})}export{M as FileBrowser};
@@ -0,0 +1 @@
1
+ .file-browser-modal{flex-direction:column;width:min(95vw,1000px);max-height:85vh;display:flex}.file-browser-modal.has-preview{width:min(95vw,1200px)}.file-browser-body{flex-direction:column;flex:1;gap:10px;padding:0 16px 16px;display:flex;overflow:hidden}.fb-quick-links{flex-wrap:wrap;gap:6px;padding:4px 0;display:flex}.fb-quick-link{border-radius:var(--radius-sm);border:1px solid var(--border-light);background:var(--bg-secondary);color:var(--text-secondary);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:5px 10px;font-size:12px;display:flex}.fb-quick-link:hover{background:var(--bg-hover);color:var(--text-primary);border-color:var(--border)}.fb-search-bar{align-items:center;gap:8px;display:flex}.fb-search-input-wrap{flex:1;align-items:center;display:flex;position:relative}.fb-search-icon{color:var(--text-muted);pointer-events:none;position:absolute;left:10px}.fb-search-input{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);width:100%;color:var(--text-primary);font-size:13px;font-family:var(--font-sans);transition:border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);outline:none;padding:8px 30px 8px 32px}.fb-search-input:focus{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-clear{color:var(--text-muted);cursor:pointer;background:0 0;border:none;padding:2px;display:flex;position:absolute;right:8px}.fb-type-filter{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);color:var(--text-primary);font-size:12px;font-family:var(--font-sans);outline:none;min-width:110px;padding:8px}.fb-type-filter:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-btn{border-radius:var(--radius-md);border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text);font-size:var(--fs-label);font-weight:600;font-family:var(--font-sans);cursor:pointer;white-space:nowrap;transition:all var(--duration) var(--ease);padding:8px 14px}.fb-search-btn:hover{background:var(--accent-fill-hover)}.fb-search-btn:disabled{opacity:.4;cursor:not-allowed;box-shadow:none}.fb-breadcrumb{color:var(--text-secondary);flex-wrap:nowrap;align-items:center;gap:2px;padding:4px 0;font-size:12px;display:flex;overflow-x:auto}.fb-crumb{color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);white-space:nowrap;transition:all var(--duration) var(--ease);background:0 0;border:none;padding:2px 4px;font-size:12px}.fb-crumb:hover{background:var(--bg-hover);color:var(--text-primary)}.fb-crumb-item{align-items:center;display:flex}.fb-crumb-sep{color:var(--text-muted);flex-shrink:0}.fb-up-btn{border:1px solid var(--border);color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);transition:all var(--duration) var(--ease);background:0 0;align-items:center;margin-left:auto;padding:3px 6px;display:flex}.fb-up-btn:hover{background:var(--bg-hover);border-color:var(--accent);color:var(--accent)}.fb-search-header{color:var(--text-secondary);justify-content:space-between;align-items:center;gap:12px;padding:4px 0;font-size:12px;display:flex}.fb-search-summary{flex-direction:column;gap:3px;min-width:0;display:flex}.fb-search-scope{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.fb-search-scope code{color:var(--text-secondary);font-family:var(--font-mono)}.fb-back-btn{color:var(--accent);cursor:pointer;transition:color var(--duration) var(--ease);background:0 0;border:none;font-size:12px}.fb-back-btn:hover{color:var(--accent-light)}.fb-content{flex:1;gap:12px;min-height:300px;display:flex;overflow:hidden}.fb-file-list{border:1px solid var(--border);border-radius:var(--radius-lg);scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex:1;min-width:250px;overflow-y:auto}.fb-file-list::-webkit-scrollbar{width:5px}.fb-file-list::-webkit-scrollbar-track{background:0 0}.fb-file-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--radius-full)}.fb-file-list::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}.fb-entry{cursor:pointer;border-bottom:1px solid var(--border-light);transition:background var(--duration-fast) var(--ease);font-size:13px;font-family:var(--font-sans);align-items:center;gap:8px;padding:8px 10px;display:flex}.fb-entry:hover{background:var(--bg-hover)}.fb-entry.selected{background:var(--accent-dim2);border-color:color-mix(in srgb, var(--accent) 12%, transparent)}.fb-entry.folder .fb-entry-icon{color:var(--text-secondary)}.fb-entry .fb-entry-icon{color:var(--text-muted);flex-shrink:0}.fb-entry-name{text-overflow:ellipsis;white-space:nowrap;color:var(--text-primary);flex:1;overflow:hidden}.fb-entry.folder .fb-entry-name{font-weight:500}.fb-entry-size,.fb-entry-date{font-size:var(--fs-caption);color:var(--text-muted);white-space:nowrap;font-family:var(--font-sans);font-variant-numeric:tabular-nums;flex-shrink:0}.fb-entry-size{text-align:right;min-width:55px}.fb-entry-date{text-align:right;min-width:65px}.fb-entry-checkbox{cursor:pointer;width:16px;min-width:16px;height:16px;min-height:16px;accent-color:var(--accent);flex-shrink:0}.fb-entry-preview-btn{width:24px;min-width:24px;height:24px;color:var(--text-muted);cursor:pointer;border-radius:var(--radius-sm);opacity:0;transition:opacity var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);background:0 0;border:none;flex-shrink:0;justify-content:center;align-items:center;padding:0;display:inline-flex}.fb-entry:hover .fb-entry-preview-btn,.fb-entry.selected .fb-entry-preview-btn{opacity:1}.fb-entry-preview-btn:hover{color:var(--text-primary);background:var(--bg-hover)}.fb-entry-preview-btn:focus-visible{opacity:1;outline:2px solid var(--accent);outline-offset:1px}.fb-preview{border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;flex-shrink:0;width:280px;display:flex;overflow:hidden}.fb-preview-header{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;padding:8px 12px;display:flex}.fb-preview-name{color:var(--text-primary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;overflow:hidden}.fb-preview-meta{font-size:var(--fs-caption);color:var(--text-muted);border-bottom:1px solid var(--border-light);font-family:var(--font-sans);font-variant-numeric:tabular-nums;gap:10px;padding:6px 12px;display:flex}.fb-preview-columns{color:var(--text-secondary);border-bottom:1px solid var(--border-light);word-break:break-word;padding:6px 12px;font-size:11px}.fb-preview-content{font-size:11px;font-family:var(--font-mono);color:var(--text-code);white-space:pre-wrap;word-break:break-all;background:var(--bg-code);scrollbar-width:thin;scrollbar-color:var(--border-code) transparent;flex:1;margin:0;padding:10px 12px;line-height:1.5;overflow:auto}.fb-preview-content::-webkit-scrollbar{width:5px;height:5px}.fb-preview-content::-webkit-scrollbar-track{background:0 0}.fb-preview-content::-webkit-scrollbar-thumb{background:var(--border-code);border-radius:var(--radius-full)}.fb-preview-content::-webkit-scrollbar-thumb:hover{background:var(--text-code-dim)}.fb-preview-loading,.fb-preview-binary{text-align:center;color:var(--text-muted);padding:20px;font-size:12px}.fb-actions{border-top:1px solid var(--border);align-items:center;gap:10px;padding-top:12px;display:flex}.fb-selection-info{color:var(--text-muted);flex:1;font-size:12px}.fb-index-status{font-size:var(--fs-caption);color:var(--accent);font-family:var(--font-sans)}.fb-action-btns{gap:8px;display:flex}.fb-action-btn{border-radius:var(--radius-md);font-size:12px;font-weight:500;font-family:var(--font-sans);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:8px 16px;display:flex}.fb-action-btn.secondary{border:1px solid var(--border);color:var(--text-primary);background:0 0}.fb-action-btn.secondary:hover{background:var(--bg-hover);border-color:var(--text-muted)}.fb-action-btn.primary{border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text)}.fb-action-btn.primary:hover{background:var(--accent-fill-hover)}.fb-action-btn:disabled{opacity:.4;cursor:not-allowed}.fb-loading,.fb-empty,.fb-error{text-align:center;color:var(--text-muted);padding:30px;font-size:13px}.fb-error{color:var(--danger);background:var(--danger-dim2);border-radius:var(--radius-md);padding:10px}@media (width<=768px){.file-browser-modal{border-radius:0;width:100vw;max-height:100vh}.fb-preview{display:none}.fb-search-bar{flex-wrap:wrap}.fb-type-filter{min-width:100%}}
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{l as t,n,o as r,s as i,u as a}from"./apiBase-y00JgRBP.js";import{t as o}from"./eye-B6FejHNG.js";import{t as s}from"./message-square-Dwm7y3C0.js";import{A as c,C as ee,D as te,E as ne,F as l,Ft as re,Gt as ie,Ht as ae,I as oe,Kt as se,L as u,Lt as d,M as ce,N as le,O as ue,P as de,Rt as f,S as fe,T as p,Ut as pe,Vt as m,Xt as me,_ as he,a as ge,an as _e,b as ve,c as ye,d as be,dn as xe,f as Se,fn as Ce,g as we,h as Te,in as Ee,j as De,k as Oe,l as ke,ln as Ae,m as je,mn as Me,o as Ne,on as Pe,p as Fe,qt as Ie,rn as Le,s as Re,sn as ze,t as Be,u as Ve,v as He,w as Ue,x as We,y as Ge,zt as Ke}from"./index-I_UyOSz2.js";var qe={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};qe.node;var Je=t(qe),h={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};h.node;var Ye=t(h),Xe={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};Xe.node;var Ze=t(Xe),g={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`}]]};g.node;var Qe=t(g),$e={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`}]]};$e.node;var et=t($e),tt={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`}]]};tt.node;var nt=t(tt),rt={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`]};rt.node;var it=t(rt),at={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`}]]};at.node;var ot=t(at),st={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`}]]};st.node;var ct=t(st),lt={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`}]]};lt.node;var ut=t(lt),_=e(a(),1),v=n(),dt=[{title:`Preferences`,categories:[`preference`]},{title:`About you`,categories:[`fact`,`profile`,`skill`]},{title:`Reminders`,categories:[`reminder`]},{title:`Notes`,categories:[`note`]}];function y(e){switch(e){case`user`:return`You added this`;case`tool`:return`You asked GAIA to remember this`;case`llm_extract`:return`Picked up in a chat`;case`consolidation`:return`From an older chat`;case`inferred`:return`From your profile setup`;case`discovery`:return`Found on this PC during profile setup`;default:return`Saved`}}function ft(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Math.floor((Date.now()-t.getTime())/864e5);return n<=0?`today`:n===1?`yesterday`:n<30?`${n} days ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function pt({memoryEnabled:e,reloadKey:t,onChanged:n,onOpenAdvanced:r,showToast:a}){let[s,c]=(0,_.useState)(null),[ee,te]=(0,_.useState)(null),[ne,l]=(0,_.useState)(null),[re,ie]=(0,_.useState)(``),[ae,oe]=(0,_.useState)([]),[se,u]=(0,_.useState)(new Set),[d,ce]=(0,_.useState)(``),[le,ue]=(0,_.useState)(`fact`),[de,f]=(0,_.useState)(null),fe=(0,_.useRef)(0),p=(0,_.useCallback)(async()=>{let e=++fe.current;try{let t=await ve({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,limit:200});if(e!==fe.current)return;c(t.items),te(null)}catch(t){if(e!==fe.current)return;i.system.warn(`Failed to load what GAIA knows about the user`,t),te(t instanceof Error?t.message:String(t))}},[]);(0,_.useEffect)(()=>{p()},[p,t]);let me=(0,_.useCallback)(async e=>{let t=re.trim();if(!t||t===e.content){l(null);return}f(e.id);try{await Te(e.id,{content:t}),l(null),a(`Updated`,`success`),await p(),n()}catch(e){i.system.error(`Failed to edit memory`,e),a(`Couldn't save the change: ${e instanceof Error?e.message:e}`,`error`)}finally{f(null)}},[re,p,n,a]),he=(0,_.useCallback)(async e=>{f(e.id);try{await je(e.id),fe.current++,c(t=>(t??[]).filter(t=>t.id!==e.id)),oe(t=>[e,...t]),n()}catch(e){i.system.error(`Failed to forget memory`,e),a(`Couldn't forget that: ${e instanceof Error?e.message:e}`,`error`)}finally{f(null)}},[n,a]),ge=(0,_.useCallback)(async e=>{f(e.id);try{await Se({content:e.content,category:e.category,domain:e.domain??void 0,context:e.context,entity:e.entity??void 0,sensitive:e.sensitive}),oe(t=>t.filter(t=>t.id!==e.id)),await p(),n()}catch(e){i.system.error(`Failed to restore memory`,e),a(`Couldn't restore it: ${e instanceof Error?e.message:e}`,`error`)}finally{f(null)}},[p,n,a]),_e=(0,_.useCallback)(async()=>{let e=d.trim();if(e){f(`new`);try{await Se({content:e,category:le}),ce(``),a(`Saved`,`success`),await p(),n()}catch(e){i.system.error(`Failed to add memory`,e),a(`Couldn't save it: ${e instanceof Error?e.message:e}`,`error`)}finally{f(null)}}},[d,le,p,n,a]);if(!e)return(0,v.jsxs)(`div`,{className:`mem-about`,children:[(0,v.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsx)(`p`,{children:`Memory is off, so GAIA isn't saving anything about you.`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:r,children:`Turn it on in Advanced`})]})]});let ye=dt.map(e=>({...e,rows:(s??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return(0,v.jsxs)(`div`,{className:`mem-about`,children:[(0,v.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,v.jsx)(`p`,{className:`mem-about-intro`,children:`GAIA uses these in every chat. Edit anything that's wrong, or forget it so GAIA stops using it.`}),(0,v.jsxs)(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),_e()},children:[(0,v.jsx)(`input`,{className:`mem-input`,placeholder:`Tell GAIA something about you, e.g. “I prefer short answers”`,"aria-label":`Something GAIA should know about you`,value:d,onChange:e=>ce(e.target.value)}),(0,v.jsxs)(`select`,{className:`mem-select`,"aria-label":`Kind`,value:le,onChange:e=>ue(e.target.value),children:[(0,v.jsx)(`option`,{value:`fact`,children:`About you`}),(0,v.jsx)(`option`,{value:`preference`,children:`Preference`}),(0,v.jsx)(`option`,{value:`reminder`,children:`Reminder`}),(0,v.jsx)(`option`,{value:`note`,children:`Note`})]}),(0,v.jsxs)(`button`,{className:`btn-primary`,type:`submit`,disabled:!d.trim()||de===`new`,children:[(0,v.jsx)(Ie,{size:14}),` Add`]})]}),ae.map(e=>(0,v.jsxs)(`div`,{className:`mem-about-forgotten`,role:`status`,children:[(0,v.jsxs)(`span`,{children:[`Forgotten: `,e.sensitive?`a sensitive memory`:`“${e.content}”`,` — GAIA won't learn it again from old chats.`]}),(0,v.jsxs)(`button`,{className:`mem-about-link`,disabled:de===e.id,onClick:()=>ge(e),children:[(0,v.jsx)(m,{size:12}),` Undo`]})]},e.id)),ee?(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsxs)(`p`,{children:[`Couldn't load your memories: `,ee]}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:p,children:`Try again`})]}):s===null?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),` Loading…`]}):ye.length===0?(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsx)(`p`,{children:`GAIA hasn't saved anything about you yet.`}),(0,v.jsx)(`p`,{className:`mem-about-hint`,children:`Tell it in a chat (“remember that I live in Calgary”) or add something above.`})]}):ye.map(e=>(0,v.jsxs)(`section`,{className:`mem-about-group`,"aria-label":e.title,children:[(0,v.jsx)(`h3`,{className:`mem-about-group-title`,children:e.title}),(0,v.jsx)(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let t=e.sensitive&&!se.has(e.id);return(0,v.jsx)(`li`,{className:`mem-about-item`,children:ne===e.id?(0,v.jsxs)(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),me(e)},children:[(0,v.jsx)(`textarea`,{className:`mem-input`,"aria-label":`Edit memory`,rows:2,autoFocus:!0,value:re,onChange:e=>ie(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),l(null)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),me(e))}}),(0,v.jsxs)(`div`,{className:`mem-about-edit-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,type:`submit`,disabled:de===e.id,children:`Save`}),(0,v.jsx)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>l(null),children:`Cancel`})]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mem-about-text`,children:[t?(0,v.jsxs)(`button`,{className:`mem-about-link`,onClick:()=>u(t=>new Set(t).add(e.id)),children:[(0,v.jsx)(o,{size:12}),` Sensitive — show`]}):e.content,(0,v.jsxs)(`span`,{className:`mem-about-meta`,children:[y(e.source),` · `,ft(e.updated_at)]})]}),(0,v.jsxs)(`div`,{className:`mem-about-actions`,children:[(0,v.jsx)(`button`,{className:`mem-about-btn`,"aria-label":`Edit: ${t?`sensitive memory`:e.content}`,title:`Edit`,onClick:()=>{l(e.id),ie(e.content)},children:(0,v.jsx)(Qe,{size:14})}),(0,v.jsxs)(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":`Forget: ${t?`sensitive memory`:e.content}`,title:`Forget`,disabled:de===e.id,onClick:()=>he(e),children:[(0,v.jsx)(pe,{size:14}),` Forget`]})]})]})},e.id)})})]},e.title))]})}function mt(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 b(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 x(e){if(!e)return`—`;try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=Date.now(),r=t.getTime()-n,i=Math.abs(r),a=Math.floor(i/1e3),o=Math.floor(i/6e4),s=Math.floor(i/36e5),c=Math.floor(i/864e5);return r<0?a<5?`just now`:a<60?`${a}s ago`:s===0?`${o}m ago`:c===0?`${s}h ago`:c===1?`yesterday`:c<30?`${c}d ago`:b(e):a<5?`now`:a<60?`in ${a}s`:s===0?`in ${o}m`:c===0?`in ${s}h`:c===1?`tomorrow`:c<30?`in ${c}d`:b(e)}catch{return`—`}}function ht(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function gt(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function _t(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function vt(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function yt(e,t){let n=mt(e),r=mt(t);return n===`—`&&r===`—`?``:n===r?n:`${n} \u2013 ${r}`}function bt(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 xt=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],St={work:`blue`,technical:`purple`,personal:`green`,general:`gray`};function Ct(){let{setShowMemoryDashboard:e,sessions:t,setCurrentSession:n}=re(),a=(0,_.useMemo)(()=>new Map(t.map(e=>[e.id,e.title])),[t]),o=e=>a.get(e)||`${e.slice(0,8)}...`,[m,qe]=(0,_.useState)(null),[h,Xe]=(0,_.useState)([]),[g,$e]=(0,_.useState)(null),[tt,rt]=(0,_.useState)([]),[at,st]=(0,_.useState)([]),[lt,dt]=(0,_.useState)([]),[y,ft]=(0,_.useState)(null),[mt,Ct]=(0,_.useState)([]),[wt,Tt]=(0,_.useState)(!0),[Et,Dt]=(0,_.useState)(null),[Ot,kt]=(0,_.useState)(null),[At,S]=(0,_.useState)(!1),[jt,Mt]=(0,_.useState)(null),[Nt,Pt]=(0,_.useState)([]),Ft=(0,_.useRef)(0),[C,It]=(0,_.useState)([]),[Lt,Rt]=(0,_.useState)(``),[zt,Bt]=(0,_.useState)(``),[Vt,Ht]=(0,_.useState)(``),[w,Ut]=(0,_.useState)(`updated_at`),[Wt,Gt]=(0,_.useState)(`desc`),[T,E]=(0,_.useState)(0),[Kt,qt]=(0,_.useState)(!1),[Jt,Yt]=(0,_.useState)(``),[Xt,Zt]=(0,_.useState)(null),Qt=(0,_.useRef)(null),[D,$t]=(0,_.useState)(null),[en,tn]=(0,_.useState)(!1),[O,nn]=(0,_.useState)(null),[k,A]=(0,_.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[rn,an]=(0,_.useState)(new Set),[j,on]=(0,_.useState)(!1),[sn,cn]=(0,_.useState)(!1),[ln,un]=(0,_.useState)(!1),[M,N]=(0,_.useState)(!1),[dn,fn]=(0,_.useState)(!1),[P,pn]=(0,_.useState)(null),[mn,hn]=(0,_.useState)(!1),[gn,F]=(0,_.useState)(null),[I,L]=(0,_.useState)(`about`),[_n,vn]=(0,_.useState)(0),[R,yn]=(0,_.useState)([]),[bn,xn]=(0,_.useState)(null),[Sn,Cn]=(0,_.useState)(!1),[wn,Tn]=(0,_.useState)(null),[En,Dn]=(0,_.useState)(null),[On,kn]=(0,_.useState)(!1),[An,jn]=(0,_.useState)({title:``,description:``,priority:`medium`}),[z,B]=(0,_.useState)(`idle`),[Mn,V]=(0,_.useState)([]),[H,U]=(0,_.useState)([]),[Nn,Pn]=(0,_.useState)(null),Fn=(0,_.useRef)(null),In=(0,_.useRef)(null),[W,G]=(0,_.useState)(`idle`),[Ln,K]=(0,_.useState)([]),[q,J]=(0,_.useState)([]),[Rn,zn]=(0,_.useState)(null),[Bn,Vn]=(0,_.useState)(!1),Hn=(0,_.useRef)(null),Un=(0,_.useRef)(null),[Wn,Gn]=(0,_.useState)(30),[Kn,qn]=(0,_.useState)(!1),[Jn,Yn]=(0,_.useState)(!1),[Xn,Zn]=(0,_.useState)(!1),[Qn,$n]=(0,_.useState)(!1),[er,tr]=(0,_.useState)(!1),[nr,rr]=(0,_.useState)(!1),ir=(0,_.useRef)(null),ar=(0,_.useRef)(null),or=(0,_.useRef)(null),Y=(0,_.useCallback)((e,t=`info`)=>{let n=++Ft.current;Pt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Pt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,_.useEffect)(()=>{if(!At)return;let e=e=>{ar.current&&!ar.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[At]),r(!0,()=>{gn?F(null):dn?fn(!1):mn?hn(!1):D?$t(null):At?S(!1):en||O?(tn(!1),nn(null)):jt?Mt(null):e(!1)}),(0,_.useEffect)(()=>{if(!gn)return;let e=or.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()}},[gn]);let sr=(0,_.useCallback)(async()=>{try{let e=await Ue();qe(e)}catch(e){i.system.warn(`Failed to load memory stats`,e)}},[]),cr=(0,_.useCallback)(async()=>{try{let e=await We(Wn);Xe(e)}catch(e){i.system.warn(`Failed to load memory activity`,e)}},[Wn]),X=(0,_.useCallback)(async()=>{try{let e=await ve({category:C.length>0?C:void 0,context:Lt||void 0,entity:zt||void 0,search:Vt||void 0,sort_by:w,order:Wt,offset:T,limit:15,include_sensitive:!0,include_superseded:Kt});$e(e)}catch(e){i.system.warn(`Failed to load knowledge`,e)}},[C,Lt,zt,Vt,w,Wt,T,Kt]),lr=(0,_.useCallback)(async()=>{try{let e=await p();rt(e)}catch(e){i.system.warn(`Failed to load tool summary`,e)}},[]),ur=(0,_.useCallback)(async()=>{try{let e=await fe(20);st(e)}catch(e){i.system.warn(`Failed to load conversations`,e)}},[]),dr=(0,_.useCallback)(async()=>{try{let e=await ne(7);dt(e)}catch(e){i.system.warn(`Failed to load upcoming items`,e)}},[]),Z=(0,_.useCallback)(async()=>{try{let e=await he();ft(e)}catch(e){i.system.warn(`Failed to load embedding coverage`,e)}},[]),fr=(0,_.useCallback)(async()=>{try{let e=await He();Ct(e||[])}catch(e){i.system.warn(`Failed to load entities`,e)}},[]),pr=(0,_.useCallback)(async()=>{try{let e=await ee();cn(e.mcp_memory_enabled),on(e.memory_enabled),un(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to load memory settings`,e)}},[]),mr=(0,_.useCallback)(async()=>{Cn(!0);try{let[e,t]=await Promise.all([te(),Ge()]);yn(e.goals),xn(t)}catch(e){i.system.warn(`Failed to load goals`,e)}finally{Cn(!1)}},[]),hr=(0,_.useCallback)(async(e,t)=>{try{await e()}catch(e){i.system.error(t,e),Y(`${t}: ${e instanceof Error?e.message:e}`,`error`);return}mr()},[mr,Y]);(0,_.useEffect)(()=>{if(!En)return;let e=setTimeout(()=>Dn(null),3e3);return()=>clearTimeout(e)},[En]);let Q=(0,_.useCallback)(async()=>{Tt(!0),Dt(null);try{await Promise.all([sr(),cr(),X(),lr(),ur(),dr(),Z(),fr(),pr(),mr()]),vn(e=>e+1)}catch(e){Dt(`Failed to load memory data. Is the backend running?`),i.system.error(`Memory dashboard load failed`,e)}finally{Tt(!1)}},[sr,cr,X,lr,ur,dr,Z,fr,pr,mr]);(0,_.useEffect)(()=>{Q()},[Q]),(0,_.useEffect)(()=>{X()},[X]);let gr=(0,_.useRef)(!0);(0,_.useEffect)(()=>{if(gr.current){gr.current=!1;return}cr()},[cr]);let _r=(0,_.useCallback)(e=>{Ht(e),rr(!0),ir.current&&clearTimeout(ir.current),ir.current=setTimeout(()=>{E(0),rr(!1)},300)},[]),vr=(0,_.useCallback)(()=>{X(),sr(),Z(),dr(),fr()},[X,sr,Z,dr,fr]),$=(0,_.useCallback)(()=>{vr(),vn(e=>e+1)},[vr]),yr=(0,_.useCallback)(async()=>{if(k.content.trim())try{let e=await Se({content:k.content,category:k.category,domain:k.domain||void 0,context:k.context,entity:k.entity||void 0,sensitive:k.sensitive,due_at:k.due_at||void 0});tn(!1),A({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Created new knowledge entry`),e?.embedded===!1?Y(e.embed_error??`Saved, but not embedded`,`error`):Y(`Memory created successfully`,`success`)}catch(e){i.system.error(`Failed to create knowledge`,e),Y(`Failed to create memory`,`error`)}},[k,$,Y]),br=(0,_.useCallback)(async()=>{if(O&&k.content.trim())try{let e=await Te(O,{content:k.content,category:k.category,domain:k.domain||void 0,context:k.context,entity:k.entity||void 0,sensitive:k.sensitive,due_at:k.due_at||void 0});nn(null),A({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Updated knowledge ${O}`),e?.embedded===!1?Y(e.embed_error??`Saved, but not embedded`,`error`):Y(`Memory updated`,`success`)}catch(e){i.system.error(`Failed to update knowledge`,e),Y(`Failed to update memory`,`error`)}},[O,k,$,Y]),xr=(0,_.useCallback)(async e=>{if(P!==e){pn(e);return}pn(null);try{await je(e),$(),i.ui.info(`Deleted knowledge ${e}`),Y(`Memory deleted`,`info`)}catch(e){i.system.error(`Failed to delete knowledge`,e),Y(`Failed to delete memory`,`error`)}},[P,$,Y]);(0,_.useEffect)(()=>{if(!P)return;let e=setTimeout(()=>pn(null),3e3);return()=>clearTimeout(e)},[P]);let Sr=(0,_.useCallback)(async e=>{try{await Te(e.id,{sensitive:!e.sensitive}),X(),i.ui.info(`Toggled sensitive for ${e.id}: ${!e.sensitive}`),Y(e.sensitive?`Unmarked as sensitive`:`Marked as sensitive`,`info`)}catch(e){i.system.error(`Failed to toggle sensitive`,e),Y(`Failed to toggle sensitive flag`,`error`)}},[X,Y]),Cr=(0,_.useCallback)(e=>{nn(e.id),tn(!1),A({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),wr=(0,_.useCallback)(e=>{navigator.clipboard.writeText(e).catch(()=>{}),i.ui.info(`Copied knowledge ID: ${e}`),Y(`ID copied to clipboard`,`info`)},[Y]),Tr=(0,_.useCallback)(e=>{if(Yt(e),Qt.current&&clearTimeout(Qt.current),!e.trim()){Zt(null);return}Qt.current=setTimeout(async()=>{try{let t=await oe(e.trim(),20);Zt(t)}catch(e){i.system.warn(`Conversation search failed`,e)}},300)},[]),Er=(0,_.useCallback)(async e=>{try{let t=await we(e);$t({sessionId:e,turns:t})}catch(e){i.system.error(`Failed to load conversation detail`,e)}},[]),Dr=(0,_.useCallback)(e=>{It(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),E(0)},[]),Or=(0,_.useCallback)(e=>{w===e?Gt(e=>e===`desc`?`asc`:`desc`):(Ut(e),Gt(`desc`)),E(0)},[w]),kr=(0,_.useCallback)(async()=>{qn(!0),S(!1);try{let e=await Ve();await Q(),Y(`Consolidated ${e.consolidated??0} sessions, extracted ${e.extracted_items??0} items`,`success`)}catch(e){i.system.error(`Failed to consolidate sessions`,e),Y(`Failed to consolidate sessions`,`error`)}finally{qn(!1)}},[Q,Y]),Ar=(0,_.useCallback)(async()=>{Yn(!0),S(!1);try{let e=await c();await Z(),Y(`Backfilled ${e.backfilled??0} embeddings${e.total_without?` (${e.total_without} were missing)`:``}`,`success`)}catch(e){i.system.error(`Failed to rebuild embeddings`,e),Y(`Failed to rebuild embeddings`,`error`)}finally{Yn(!1)}},[Z,Y]),jr=(0,_.useCallback)(async()=>{Zn(!0),S(!1);try{let e=await ce();await Q(),Y(`Checked ${e.pairs_checked??0} pairs: ${e.reinforced??0} reinforced, ${e.contradicted??0} contradicted`,`success`)}catch(e){i.system.error(`Failed to reconcile memory`,e),Y(`Failed to reconcile memory`,`error`)}finally{Zn(!1)}},[Q,Y]),Mr=(0,_.useCallback)(async()=>{$n(!0),S(!1);try{await De(),await Q(),Y(`FTS indexes rebuilt successfully`,`success`)}catch(e){i.system.error(`Failed to rebuild FTS index`,e),Y(`Failed to rebuild FTS indexes`,`error`)}finally{$n(!1)}},[Q,Y]),Nr=(0,_.useCallback)(async()=>{tr(!0),S(!1);try{let e=await le();await Q(),e.skipped?Y(`System context collection is disabled — enable it in settings`,`error`):Y(`System context refreshed: ${e.stored} facts updated`,`success`)}catch(e){i.system.error(`Failed to refresh system context`,e),Y(`Failed to refresh system context`,`error`)}finally{tr(!1)}},[Q,Y]),Pr=Kn||Jn||Xn||Qn||er,Fr=(0,_.useCallback)(()=>{B(`running`),V([]),U([]),Pn(null);let e=ue();In.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)V(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`finding`){let e=n.item;V(t=>[...t,{text:` Found: ${e.content}`,kind:`finding`}]),U(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?V(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),In.current=null,V(e=>[...e,{text:`Done. ${n.total??0} items discovered.`,kind:`log`}]),B(`review`))}catch{V(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),In.current=null,V(e=>[...e,{text:`Connection error. Is the GAIA server running?`,kind:`error`}]),U(e=>(B(e.length>0?`review`:`idle`),e))}},[]),Ir=(0,_.useCallback)(async()=>{let e=H.filter(e=>e._checked);if(e.length!==0){B(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await ye(t);Pn(n.stored),B(`done`),$(),Y(`Saved ${n.stored} items to memory`,`success`)}catch(e){i.system.error(`Failed to commit discovery items`,e),Y(`Failed to save discovery items`,`error`),B(`review`)}}},[H,$,Y]),Lr=(0,_.useCallback)(()=>{G(`running`),K([]),J([]),zn(null);let e=Oe(Bn);Un.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)K(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`insight`){let e=n.item;K(t=>[...t,{text:` Insight: ${e.content}`,kind:`finding`}]),J(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?K(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),Un.current=null,K(e=>[...e,{text:`Done. ${n.total??0} insights generated.`,kind:`log`}]),G(`review`))}catch{K(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),Un.current=null,K(e=>[...e,{text:`Connection error. Is Lemonade Server running?`,kind:`error`}]),J(e=>(G(e.length>0?`review`:`idle`),e))}},[Bn]),Rr=(0,_.useCallback)(async()=>{let e=q.filter(e=>e._checked);if(e.length!==0){G(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await ke(t);zn(n.stored),G(`done`),$(),Y(`Saved ${n.stored} insights to memory`,`success`)}catch(e){i.system.error(`Failed to commit inference insights`,e),Y(`Failed to save inference insights`,`error`),G(`review`)}}},[q,$,Y]);(0,_.useEffect)(()=>{Fn.current&&(Fn.current.scrollTop=Fn.current.scrollHeight)},[Mn]),(0,_.useEffect)(()=>{Hn.current&&(Hn.current.scrollTop=Hn.current.scrollHeight)},[Ln]),(0,_.useEffect)(()=>()=>{In.current&&=(In.current.close(),null),Un.current&&=(Un.current.close(),null)},[]);let zr=e=>w===e?(0,v.jsx)(`span`,{className:`mem-sort-arrow`,children:Wt===`desc`?`↓`:`↑`}):null,Br=Math.max(1,...h.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),Vr=m?.knowledge?.by_context?Object.keys(m.knowledge.by_context):[];return(0,v.jsxs)(`div`,{className:`memory-dashboard-page`,children:[(0,v.jsxs)(`div`,{className:`memory-dashboard-header`,children:[(0,v.jsxs)(`div`,{className:`memory-dashboard-header-left`,children:[(0,v.jsx)(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>e(!1),"aria-label":`Back`,children:(0,v.jsx)(Je,{size:18})}),(0,v.jsxs)(`h1`,{children:[`Memory `,(0,v.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,v.jsxs)(`div`,{className:`memory-dashboard-header-actions`,children:[I===`advanced`&&(0,v.jsxs)(v.Fragment,{children:[y&&y.total_items>0&&(0,v.jsxs)(`div`,{className:`mem-embedding-coverage`,title:`${y.with_embedding} of ${y.total_items} entries embedded`,children:[(0,v.jsx)(`div`,{className:`mem-embedding-bar`,children:(0,v.jsx)(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(y.coverage_pct)}%`}})}),(0,v.jsxs)(`span`,{className:`mem-embedding-label`,children:[Math.round(y.coverage_pct),`% embedded`]})]}),(0,v.jsxs)(`div`,{className:`mem-maintenance-wrap`,ref:ar,children:[(0,v.jsxs)(`button`,{className:`btn-icon ${Pr?`mem-spinning`:``}`,onClick:()=>S(e=>!e),title:`Maintenance actions`,"aria-label":`Maintenance actions`,"aria-expanded":At,children:[Pr?(0,v.jsx)(`div`,{className:`mem-spinner-sm`}):(0,v.jsx)(Le,{size:16}),(0,v.jsx)(Ce,{size:10,style:{marginLeft:2}})]}),At&&(0,v.jsxs)(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:kr,disabled:Kn,role:`menuitem`,children:[(0,v.jsx)(Ze,{size:14}),Kn?`Consolidating...`:`Consolidate Sessions`]}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Ar,disabled:Jn,role:`menuitem`,children:[(0,v.jsx)(d,{size:14}),Jn?`Rebuilding...`:`Rebuild Embeddings`]}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:jr,disabled:Xn,role:`menuitem`,children:[(0,v.jsx)(Ae,{size:14}),Xn?`Reconciling...`:`Reconcile Memory`]}),(0,v.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Nr,disabled:er,role:`menuitem`,children:[(0,v.jsx)(se,{size:14}),er?`Refreshing...`:`Refresh System Context`]}),(0,v.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Mr,disabled:Qn,role:`menuitem`,children:[(0,v.jsx)(ie,{size:14}),Qn?`Rebuilding...`:`Rebuild FTS Indexes`]})]})]})]}),(0,v.jsx)(`button`,{className:`btn-icon`,onClick:Q,title:`Refresh`,"aria-label":`Refresh dashboard`,children:(0,v.jsx)(se,{size:16})})]})]}),(0,v.jsxs)(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[(0,v.jsxs)(`button`,{className:`mem-tab-btn${I===`about`?` mem-tab-active`:``}`,onClick:()=>L(`about`),role:`tab`,"aria-selected":I===`about`,children:[(0,v.jsx)(ut,{size:14}),` About you`]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${I===`goals`?` mem-tab-active`:``}`,onClick:()=>{L(`goals`),mr()},role:`tab`,"aria-selected":I===`goals`,children:[(0,v.jsx)(ot,{size:14}),` Goals`,bn&&(bn.goals.pending_approval??0)>0&&(0,v.jsx)(`span`,{className:`mem-tab-badge`,children:bn.goals.pending_approval})]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${I===`profile`?` mem-tab-active`:``}`,onClick:()=>L(`profile`),role:`tab`,"aria-selected":I===`profile`,children:[(0,v.jsx)(it,{size:14}),` Profile setup`]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${I===`advanced`?` mem-tab-active`:``}`,onClick:()=>L(`advanced`),role:`tab`,"aria-selected":I===`advanced`,children:[(0,v.jsx)(Me,{size:14}),` Advanced`]})]}),(0,v.jsxs)(`div`,{className:`memory-dashboard-body`,children:[I===`about`&&(0,v.jsx)(pt,{memoryEnabled:j,reloadKey:_n,onChanged:vr,onOpenAdvanced:()=>L(`advanced`),showToast:Y}),I===`advanced`&&(0,v.jsx)(v.Fragment,{children:wt&&!m?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),`Loading memory data...`]}):Et?(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(ae,{size:32})}),(0,v.jsx)(`p`,{children:Et}),(0,v.jsxs)(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[(0,v.jsx)(se,{size:14}),` Retry`]})]}):(0,v.jsxs)(v.Fragment,{children:[!j&&(0,v.jsxs)(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:(0,v.jsx)(nt,{size:32})}),(0,v.jsx)(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:`Memory is off. Turn it on in Settings below to let GAIA remember what you tell it.`})]}),j&&(0,v.jsxs)(v.Fragment,{children:[m?.embedding_error&&(0,v.jsxs)(`div`,{className:`mem-advanced-error`,role:`alert`,children:[(0,v.jsx)(ae,{size:14}),` `,m.embedding_error]}),(0,v.jsxs)(`div`,{className:`mem-stat-cards`,children:[(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.knowledge?.total??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Stored`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:(()=>{let e=bt(h);return e>0?`+${e} today`:m?.knowledge?.by_category?Object.entries(m.knowledge.by_category).slice(0,3).map(([e,t])=>`${t} ${e}s`).join(`, `):`No entries`})()})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.knowledge?.total_retrievals??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Retrieved`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:m?.knowledge?.total&&m?.knowledge?.total_retrievals?`avg ${(m.knowledge.total_retrievals/m.knowledge.total).toFixed(1)}x per memory`:`No recalls yet`})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.conversations?.total_sessions??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Sessions`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:yt(m?.conversations?.first_session??null,m?.conversations?.last_session??null)||`${m?.conversations?.total_turns??0} total turns`})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.tools?.total_calls??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Tool Calls`}),(0,v.jsxs)(`div`,{className:`mem-stat-sub`,title:`Memory tools (remember, recall, ...) are not logged`,children:[m?.tools?.unique_tools??0,` tools, excl. memory`]})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.tools?.overall_success_rate!=null&&(m.tools.total_calls??0)>0?`${Math.round(m.tools.overall_success_rate*100)}%`:`—`}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Success Rate`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:(m?.tools?.total_calls??0)>0?`${m?.tools?.total_errors??0} errors`:`No tool calls yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,v.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,v.jsx)(ct,{size:14}),` Activity`]}),(0,v.jsx)(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":`Activity range`,children:[1,7,30].map(e=>(0,v.jsx)(`button`,{className:`mem-range-tab${Wn===e?` active`:``}`,onClick:()=>Gn(e),children:e===1?`1D`:e===7?`7D`:`30D`},e))})]}),h.length>0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-activity-chart`,children:h.map((e,t)=>{let n=e.conversations+e.tool_calls+e.knowledge_added+e.errors,r=t===0||t===h.length-1||t%7==0,i=new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,v.jsxs)(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>kt(t),onMouseLeave:()=>kt(null),children:[e.errors>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar errors`,style:{height:`${e.errors/Br*100}%`}}),e.knowledge_added>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${e.knowledge_added/Br*100}%`}}),e.tool_calls>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${e.tool_calls/Br*100}%`}}),e.conversations>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar conversations`,style:{height:`${e.conversations/Br*100}%`}}),r&&(0,v.jsx)(`span`,{className:`mem-activity-date-label`,children:i}),Ot===t&&n>0&&(0,v.jsxs)(`div`,{className:`mem-activity-tooltip`,children:[(0,v.jsx)(`strong`,{children:i}),(0,v.jsx)(`br`,{}),e.conversations>0&&(0,v.jsxs)(v.Fragment,{children:[e.conversations,` conversations`,(0,v.jsx)(`br`,{})]}),e.tool_calls>0&&(0,v.jsxs)(v.Fragment,{children:[e.tool_calls,` tool calls`,(0,v.jsx)(`br`,{})]}),e.knowledge_added>0&&(0,v.jsxs)(v.Fragment,{children:[e.knowledge_added,` learned`,(0,v.jsx)(`br`,{})]}),e.errors>0&&(0,v.jsxs)(v.Fragment,{children:[e.errors,` errors`]})]})]},e.date)})}),(0,v.jsxs)(`div`,{className:`mem-activity-legend`,children:[(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot conversations`}),` Conversations`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot tool_calls`}),` Tool Calls`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot knowledge`}),` Knowledge`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot errors`}),` Errors`]})]})]}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(ct,{size:28})}),(0,v.jsx)(`p`,{children:`No activity data yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,v.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,v.jsx)(Me,{size:14}),` Knowledge Browser`,g&&g.total>0&&(0,v.jsx)(`span`,{className:`mem-section-count`,children:g.total})]}),!en&&!O&&(0,v.jsxs)(`button`,{className:`mem-section-add-btn`,onClick:()=>tn(!0),title:`Add a memory entry`,children:[(0,v.jsx)(Ie,{size:13}),` Add`]})]}),(0,v.jsxs)(`div`,{className:`mem-filters`,children:[(0,v.jsxs)(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":`Filter by category`,children:[xt.map(e=>(0,v.jsx)(`button`,{className:`mem-category-pill ${e}${C.includes(e)?` active`:``}`,onClick:()=>Dr(e),"aria-pressed":C.includes(e),children:e},e)),C.length>0&&(0,v.jsx)(`button`,{className:`mem-category-pill clear`,onClick:()=>{It([]),E(0)},"aria-label":`Clear category filters`,children:`✕ Clear`})]}),(0,v.jsxs)(`select`,{className:`mem-filter-select`,value:Lt,onChange:e=>{Rt(e.target.value),E(0)},"aria-label":`Filter by context`,children:[(0,v.jsx)(`option`,{value:``,children:`All Contexts`}),Vr.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsxs)(`select`,{className:`mem-filter-select`,value:zt,onChange:e=>{Bt(e.target.value),E(0)},"aria-label":`Filter by entity`,children:[(0,v.jsx)(`option`,{value:``,children:`All Entities`}),mt.map(e=>(0,v.jsxs)(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),(0,v.jsxs)(`div`,{className:`mem-filter-search-wrap`,children:[nr?(0,v.jsx)(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):(0,v.jsx)(ie,{size:13,className:`search-icon`}),(0,v.jsx)(`input`,{className:`mem-filter-search`,type:`text`,placeholder:`Search memories...`,value:Vt,onChange:e=>_r(e.target.value),"aria-label":`Search memories`})]}),(0,v.jsxs)(`label`,{className:`mem-filter-toggle`,title:`Show entries that have been superseded by newer versions`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:Kt,onChange:e=>qt(e.target.checked)}),(0,v.jsx)(`span`,{children:`Superseded`})]})]}),(en||O)&&(0,v.jsxs)(`div`,{className:`mem-inline-form`,children:[(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Content`}),(0,v.jsx)(`textarea`,{value:k.content,onChange:e=>A(t=>({...t,content:e.target.value})),placeholder:`What should the agent remember?`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Category`}),(0,v.jsx)(`select`,{value:k.category,onChange:e=>A(t=>({...t,category:e.target.value})),children:xt.map(e=>(0,v.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Context`}),(0,v.jsx)(`input`,{type:`text`,value:k.context,onChange:e=>A(t=>({...t,context:e.target.value})),placeholder:`global`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Domain`}),(0,v.jsx)(`input`,{type:`text`,value:k.domain,onChange:e=>A(t=>({...t,domain:e.target.value})),placeholder:`e.g., python, frontend`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Entity`}),(0,v.jsx)(`input`,{type:`text`,value:k.entity,onChange:e=>A(t=>({...t,entity:e.target.value})),placeholder:`e.g., person:sarah_chen`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Due At`}),(0,v.jsx)(`input`,{type:`text`,value:k.due_at,onChange:e=>A(t=>({...t,due_at:e.target.value})),placeholder:`ISO 8601 (e.g., 2026-03-25T09:00:00-07:00)`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Sensitive`}),(0,v.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:k.sensitive,onChange:e=>A(t=>({...t,sensitive:e.target.checked}))}),`Mark as sensitive (excluded from system prompt)`]})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-actions`,children:[(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{tn(!1),nn(null)},children:`Cancel`}),(0,v.jsx)(`button`,{className:`btn-primary`,onClick:O?br:yr,style:{padding:`8px 20px`,fontSize:13},children:O?`Update`:`Save`})]})]}),g&&g.items.length>0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{style:{overflowX:`auto`},children:(0,v.jsxs)(`table`,{className:`mem-knowledge-table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsxs)(`th`,{onClick:()=>Or(`category`),className:w===`category`?`sorted`:``,children:[`Category`,zr(`category`)]}),(0,v.jsx)(`th`,{children:`Content`}),(0,v.jsxs)(`th`,{onClick:()=>Or(`context`),className:w===`context`?`sorted`:``,children:[`Context`,zr(`context`)]}),(0,v.jsx)(`th`,{children:`Entity`}),(0,v.jsxs)(`th`,{onClick:()=>Or(`confidence`),className:w===`confidence`?`sorted`:``,children:[`Confidence`,zr(`confidence`)]}),(0,v.jsx)(`th`,{children:`Source`}),(0,v.jsxs)(`th`,{onClick:()=>Or(`updated_at`),className:w===`updated_at`?`sorted`:``,children:[`Updated`,zr(`updated_at`)]}),(0,v.jsxs)(`th`,{onClick:()=>Or(`created_at`),className:w===`created_at`?`sorted`:``,children:[`Created`,zr(`created_at`)]}),(0,v.jsx)(`th`,{children:`Due`}),(0,v.jsx)(`th`,{className:`mem-actions-cell`})]})}),(0,v.jsx)(`tbody`,{children:g.items.map(e=>{let t=jt===e.id,n=e.has_embedding;return(0,v.jsxs)(_.Fragment,{children:[(0,v.jsxs)(`tr`,{className:`${e.superseded_by?`mem-superseded-row`:``} ${t?`mem-expanded-row`:``}`,onClick:()=>Mt(t?null:e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),Mt(t?null:e.id))},tabIndex:0,role:`row`,"aria-expanded":t,style:{cursor:`pointer`},children:[(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-cat-badge ${e.category}`,children:e.category})}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-content-cell`,title:e.content,children:[n!==void 0&&(0,v.jsx)(`span`,{className:`mem-embed-dot ${n?`embedded`:`missing`}`,title:n?`Embedded`:`Embedding missing`,children:(0,v.jsx)(ze,{size:6,fill:`currentColor`})}),e.sensitive&&(0,v.jsx)(`span`,{className:`mem-sensitive-badge`,title:`Sensitive`,children:(0,v.jsx)(nt,{size:11})}),(0,v.jsx)(`span`,{className:e.sensitive&&!rn.has(e.id)?`mem-sensitive-blur`:e.superseded_by?`mem-superseded-text`:``,onClick:t=>{e.sensitive&&(t.stopPropagation(),an(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}))},children:e.content})]})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,children:e.context})}),(0,v.jsx)(`td`,{children:e.entity?(0,v.jsx)(`span`,{className:`mem-entity-link`,onClick:t=>{t.stopPropagation(),Bt(e.entity),E(0)},title:`Filter by ${e.entity}`,children:e.entity}):(0,v.jsx)(`span`,{className:`mem-date-cell`,children:`—`})}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-confidence`,children:[(0,v.jsx)(`div`,{className:`mem-confidence-bar`,children:(0,v.jsx)(`div`,{className:`mem-confidence-fill ${_t(e.confidence)}`,style:{width:`${e.confidence*100}%`}})}),e.confidence.toFixed(2)]})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,children:e.source||`—`})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.updated_at),children:x(e.updated_at)})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.created_at),children:x(e.created_at)})}),(0,v.jsx)(`td`,{children:e.due_at?(0,v.jsx)(`span`,{className:`mem-due-badge ${gt(e.due_at)?`overdue`:`upcoming`}`,title:b(e.due_at),children:x(e.due_at)}):(0,v.jsx)(`span`,{className:`mem-due-badge none`,children:`—`})}),(0,v.jsx)(`td`,{className:`mem-actions-cell`,children:(0,v.jsxs)(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Cr(e),title:`Edit`,children:(0,v.jsx)(Qe,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Sr(e),title:e.sensitive?`Unmark sensitive`:`Mark sensitive`,children:e.sensitive?(0,v.jsx)(et,{size:13}):(0,v.jsx)(nt,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>wr(e.id),title:`Copy ID`,children:(0,v.jsx)(_e,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn delete${P===e.id?` is-confirm`:``}`,onClick:()=>xr(e.id),title:P===e.id?`Click again to delete`:`Delete`,"aria-label":P===e.id?`Confirm delete memory`:`Delete memory`,children:P===e.id?(0,v.jsx)(`span`,{className:`mem-row-delete-label`,children:`Delete?`}):(0,v.jsx)(pe,{size:13})})]})})]}),t&&(0,v.jsx)(`tr`,{className:`mem-detail-row`,children:(0,v.jsx)(`td`,{colSpan:10,children:(0,v.jsxs)(`div`,{className:`mem-detail-panel`,children:[(0,v.jsxs)(`div`,{className:`mem-detail-grid`,children:[(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`ID`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.id})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Domain`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.domain||`—`})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Source`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.source||`—`})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Use Count`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.use_count??0})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Created`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.created_at)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Updated`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.updated_at)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Last Used`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.last_used)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Reminded At`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.reminded_at)})]}),e.superseded_by&&(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Superseded By`}),(0,v.jsx)(`span`,{className:`mem-detail-value mem-detail-chain`,children:e.superseded_by})]}),e.metadata&&(0,v.jsxs)(`div`,{className:`mem-detail-field mem-detail-full`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Metadata`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:typeof e.metadata==`object`?JSON.stringify(e.metadata,null,2):e.metadata})]})]}),(0,v.jsxs)(`div`,{className:`mem-detail-content-full`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Full Content`}),(0,v.jsx)(`div`,{className:`mem-detail-content-text`,children:e.content})]})]})})})]},e.id)})})]})}),(0,v.jsxs)(`div`,{className:`mem-pagination`,children:[(0,v.jsxs)(`span`,{children:[T+1,`–`,Math.min(T+15,g.total),` of `,g.total]}),(0,v.jsxs)(`div`,{className:`mem-pagination-btns`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Previous page`,disabled:T===0,onClick:()=>E(Math.max(0,T-15)),children:(0,v.jsx)(Ye,{size:14})}),(0,v.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Next page`,disabled:T+15>=g.total,onClick:()=>E(T+15),children:(0,v.jsx)(xe,{size:14})})]})]})]}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(Me,{size:28})}),(0,v.jsx)(`p`,{children:Vt||C.length>0||Lt||zt?`No matching memories`:`No memories stored yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-two-col`,children:[(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(Ke,{size:14}),` Tool Performance`,(0,v.jsx)(`span`,{className:`mem-section-note`,title:`remember, recall, update_memory, forget and search_past_conversations are not logged`,children:`excludes memory tools`})]}),tt.length>0?(0,v.jsx)(`div`,{style:{overflowX:`auto`},children:(0,v.jsxs)(`table`,{className:`mem-tool-table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Tool`}),(0,v.jsx)(`th`,{children:`Calls`}),(0,v.jsx)(`th`,{children:`Success`}),(0,v.jsx)(`th`,{children:`Avg Time`}),(0,v.jsx)(`th`,{children:`Last Used`}),(0,v.jsx)(`th`,{children:`Last Error`})]})}),(0,v.jsx)(`tbody`,{children:tt.map(e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-tool-name`,children:e.tool_name})}),(0,v.jsx)(`td`,{children:e.total_calls}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-confidence`,children:[(0,v.jsx)(`div`,{className:`mem-confidence-bar`,style:{width:40},children:(0,v.jsx)(`div`,{className:`mem-confidence-fill ${vt(e.success_rate)}`,style:{width:`${e.success_rate*100}%`}})}),(0,v.jsxs)(`span`,{className:`mem-success-rate ${vt(e.success_rate)}`,children:[Math.round(e.success_rate*100),`%`]})]})}),(0,v.jsx)(`td`,{children:ht(e.avg_duration_ms)}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.last_used),children:x(e.last_used)})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-tool-error`,title:e.last_error||``,children:e.last_error||`—`})})]},e.tool_name))})]})}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(Ke,{size:28})}),(0,v.jsx)(`p`,{children:`No tool calls recorded yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(Pe,{size:14}),` Upcoming & Overdue`]}),lt.length>0?(0,v.jsx)(`div`,{className:`mem-temporal-list`,children:lt.map(e=>{let t=gt(e.due_at);return(0,v.jsxs)(`div`,{className:`mem-temporal-item ${t?`overdue`:`upcoming`}`,children:[(0,v.jsx)(`span`,{className:`mem-temporal-icon`,children:t?(0,v.jsx)(ae,{size:16}):(0,v.jsx)(Pe,{size:16})}),(0,v.jsxs)(`div`,{className:`mem-temporal-content`,children:[(0,v.jsx)(`div`,{className:`mem-temporal-text`,children:e.content}),(0,v.jsxs)(`div`,{className:`mem-temporal-date`,children:[t?`OVERDUE`:`Due`,`: `,x(e.due_at),e.context!==`global`&&` \u00B7 ${e.context}`]})]})]},e.id)})}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(Ae,{size:28})}),(0,v.jsx)(`p`,{children:`Nothing upcoming or overdue`})]})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(s,{size:14}),` Conversation History`]}),(0,v.jsxs)(`div`,{className:`mem-conv-search`,children:[(0,v.jsx)(ie,{size:13,className:`search-icon`}),(0,v.jsx)(`input`,{type:`text`,placeholder:`Search conversations...`,value:Jt,onChange:e=>Tr(e.target.value),"aria-label":`Search conversations`}),Jt&&(0,v.jsx)(`button`,{className:`mem-search-clear`,onClick:()=>{Yt(``),Zt(null)},"aria-label":`Clear search`,children:(0,v.jsx)(f,{size:12})})]}),Xt===null?at.length>0?(0,v.jsx)(`div`,{className:`mem-conv-list`,children:at.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Er(e.session_id),children:[(0,v.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-session-id`,children:[o(e.session_id),e.consolidated&&(0,v.jsx)(`span`,{className:`mem-consolidated-badge`,title:`Consolidated`,children:(0,v.jsx)(Ze,{size:11})})]}),e.first_message&&(0,v.jsx)(`div`,{className:`mem-conv-preview`,children:e.first_message})]}),(0,v.jsxs)(`div`,{className:`mem-conv-meta`,children:[(0,v.jsxs)(`span`,{children:[e.turn_count,` turns`]}),(0,v.jsx)(`span`,{children:x(e.last_activity)})]})]},e.session_id))}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(s,{size:28})}),(0,v.jsx)(`p`,{children:`No conversation history in memory`})]}):Xt.length>0?(0,v.jsx)(`div`,{className:`mem-conv-list`,children:Xt.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Er(e.session_id),children:[(0,v.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-session-id`,children:[(0,v.jsx)(`span`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),` `,o(e.session_id)]}),(0,v.jsx)(`div`,{className:`mem-conv-preview`,children:e.content})]}),(0,v.jsx)(`div`,{className:`mem-conv-meta`,children:(0,v.jsx)(`span`,{children:x(e.timestamp)})})]},e.id))}):(0,v.jsx)(`div`,{className:`mem-empty`,children:(0,v.jsxs)(`p`,{children:[`No conversations match “`,Jt,`”`]})})]}),D&&(0,v.jsxs)(`div`,{className:`mem-conv-detail-overlay`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-detail-header`,children:[(0,v.jsx)(`h2`,{children:o(D.sessionId)}),(0,v.jsxs)(`div`,{className:`mem-conv-detail-actions`,children:[a.has(D.sessionId)&&(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>n(D.sessionId),children:`Open chat`}),(0,v.jsx)(`button`,{className:`btn-icon`,onClick:()=>$t(null),"aria-label":`Close conversation`,children:(0,v.jsx)(f,{size:16})})]})]}),(0,v.jsxs)(`div`,{className:`mem-conv-detail-body`,children:[D.turns.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-turn`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-turn-header`,children:[(0,v.jsx)(`div`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),(0,v.jsx)(`span`,{className:`mem-conv-turn-time`,title:b(e.timestamp),children:x(e.timestamp)})]}),(0,v.jsx)(`div`,{className:`mem-conv-turn-content`,children:e.content})]},e.id)),D.turns.length===0&&(0,v.jsx)(`div`,{className:`mem-empty`,children:`No turns found`})]})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(nt,{size:14}),` Settings `,(0,v.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,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Memory enabled`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`When disabled, no knowledge or conversation data is stored during any session (global incognito).`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${j?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!j){F(`memory`);return}N(!0);try{let e=await u({memory_enabled:!1});on(e.memory_enabled)}catch(e){i.system.warn(`Failed to disable memory`,e)}finally{N(!1)}},"aria-pressed":j,"aria-label":`Memory is ${j?`enabled`:`disabled`}`,children:j?`On`:`Off`})]}),gn&&(()=>{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 u({memory_enabled:!0});on(e.memory_enabled),Y(`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 u({mcp_memory_enabled:!0});cn(e.mcp_memory_enabled),Y(`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 u({system_discovery_consent:!0});if(un(e.system_discovery_consent),e.system_context_error)Y(`System discovery enabled but scan failed: ${e.system_context_error}`,`error`);else{let t=e.system_context_refresh?.stored??0;Y(`System discovery enabled — ${t} system facts collected`,`info`)}Q()}}}[gn];return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>F(null)}),(0,v.jsxs)(`div`,{ref:or,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mem-beta-confirm-title`,"aria-describedby":`mem-beta-confirm-desc`,tabIndex:-1,style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:9999,background:`var(--bg-card)`,border:`1px solid var(--border)`,borderRadius:12,padding:`28px 32px`,maxWidth:420,width:`90vw`,boxShadow:`var(--shadow-lg)`},children:[(0,v.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[(0,v.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,v.jsx)(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e.title})]}),(0,v.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,v.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,v.jsx)(`li`,{children:e.map((e,t)=>t%2==1?(0,v.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:e},t):(0,v.jsx)(`span`,{children:e},t))},t))}),(0,v.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>F(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:`Cancel`}),(0,v.jsx)(`button`,{disabled:M,onClick:async()=>{N(!0);try{await e.onConfirm()}catch(e){i.system.warn(`Failed to update setting`,e),Y(`Failed to update setting. Please try again.`,`error`)}finally{N(!1),F(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,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`MCP memory access`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Expose read-only memory tools to MCP clients (for debug/troubleshooting). Requires MCP server restart.`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${sn?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!sn){F(`mcp`);return}N(!0);try{let e=await u({mcp_memory_enabled:!1});cn(e.mcp_memory_enabled)}catch(e){i.system.warn(`Failed to update memory settings`,e)}finally{N(!1)}},"aria-label":`Toggle MCP memory access`,"aria-pressed":sn,children:sn?`On`:`Off`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`System discovery`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Allow GAIA to scan your system for hardware, software, and environment information to personalize responses.`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${ln?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!ln){F(`discovery`);return}N(!0);try{let e=await u({system_discovery_consent:!1});un(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to update system discovery setting`,e)}finally{N(!1)}},"aria-label":`Toggle system discovery`,"aria-pressed":ln,children:ln?`On`:`Off`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Re-initialize memory`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Wipe all memories, conversations, and tool logs, then re-collect system information. This cannot be undone.`})]}),mn?(0,v.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,v.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:async()=>{N(!0);try{let e=await de();e.system_context.error?Y(e.system_context.error,`error`):Y(`Re-initialized: cleared ${e.cleared.knowledge} entries, restored ${e.system_context.stored} system facts`,`info`),Q()}catch(e){i.system.warn(`Failed to reinitialize memory`,e),Y(`Failed to re-initialize memory`,`error`)}finally{N(!1),hn(!1)}},children:`Yes, re-initialize`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>hn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:()=>hn(!0),children:`Re-initialize`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Delete all memories`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Permanently wipe all knowledge entries, conversation history, and tool logs. This cannot be undone.`})]}),dn?(0,v.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,v.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:async()=>{N(!0);try{let e=await Re();Y(`Deleted ${e.knowledge} knowledge entries, ${e.conversations} conversations`,`info`),Q()}catch(e){i.system.warn(`Failed to clear memory`,e),Y(`Failed to clear memory`,`error`)}finally{N(!1),fn(!1)}},children:`Yes, delete all`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>fn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:()=>fn(!0),children:`Delete All`})]})]}),m&&(0,v.jsxs)(`div`,{className:`mem-db-footer`,children:[(0,v.jsxs)(`span`,{children:[`Database: `,Be(m.db_size_bytes),m.knowledge?.avg_confidence!=null&&` \u00B7 Avg confidence: ${m.knowledge.avg_confidence.toFixed(2)}`]}),(0,v.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[m.knowledge?.entity_count!=null&&m.knowledge.entity_count>0&&(0,v.jsxs)(`span`,{children:[m.knowledge.entity_count,` entities`]}),m.knowledge?.sensitive_count!=null&&m.knowledge.sensitive_count>0&&(0,v.jsxs)(`span`,{children:[(0,v.jsx)(nt,{size:10}),` `,m.knowledge.sensitive_count,` sensitive`]})]})]})]})}),I===`profile`&&(0,v.jsxs)(`div`,{className:`mem-profile-grid`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,v.jsx)(Ee,{size:16}),` System Discovery`]}),(0,v.jsx)(`p`,{className:`mem-profile-desc`,children:`Scan your system to discover apps, projects, and usage patterns.`}),(0,v.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:z===`running`||z===`saving`,onClick:Fr,children:z===`running`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Discovery`}),Mn.length>0&&(0,v.jsx)(`div`,{className:`mem-log`,ref:Fn,children:Mn.map((e,t)=>(0,v.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(z===`review`||z===`saving`||z===`done`)&&H.length>0&&(0,v.jsxs)(`div`,{className:`mem-review-section`,children:[(0,v.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,v.jsx)(`div`,{className:`mem-review-list`,children:H.map((e,t)=>(0,v.jsxs)(`label`,{className:`mem-review-item`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:z===`saving`||z===`done`,onChange:()=>{U(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,v.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,v.jsx)(`span`,{className:`mem-source-badge`,children:e._source_name||e.category}),(0,v.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,v.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,disabled:z===`saving`||z===`done`||H.filter(e=>e._checked).length===0,onClick:Ir,children:z===`saving`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${H.filter(e=>e._checked).length})`}),(0,v.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>U(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>U(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),z===`done`&&Nn!==null&&(0,v.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,v.jsx)(Ae,{size:14}),` Saved `,Nn,` items to memory`]}),z===`review`&&H.length===0&&(0,v.jsx)(`div`,{className:`mem-profile-empty`,children:`No items discovered.`})]}),(0,v.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,v.jsx)(it,{size:16}),` AI Profile Inference`]}),(0,v.jsx)(`p`,{className:`mem-profile-desc`,children:`Use the local LLM to generate profile insights from your data.`}),(0,v.jsx)(`p`,{className:`mem-profile-note`,children:`Requires Lemonade Server running.`}),(0,v.jsxs)(`label`,{className:`mem-profile-checkbox`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:Bn,onChange:e=>Vn(e.target.checked),disabled:W===`running`||W===`saving`}),`Include browser history`]}),(0,v.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:W===`running`||W===`saving`,onClick:Lr,children:W===`running`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Inference`}),Ln.length>0&&(0,v.jsx)(`div`,{className:`mem-log`,ref:Hn,children:Ln.map((e,t)=>(0,v.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(W===`review`||W===`saving`||W===`done`)&&q.length>0&&(0,v.jsxs)(`div`,{className:`mem-review-section`,children:[(0,v.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,v.jsx)(`div`,{className:`mem-review-list`,children:q.map((e,t)=>(0,v.jsxs)(`label`,{className:`mem-review-item`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:W===`saving`||W===`done`,onChange:()=>{J(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,v.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,v.jsx)(`span`,{className:`mem-domain-badge ${St[e.domain]||`gray`}`,children:e.domain}),(0,v.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,v.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,disabled:W===`saving`||W===`done`||q.filter(e=>e._checked).length===0,onClick:Rr,children:W===`saving`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${q.filter(e=>e._checked).length})`}),(0,v.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>J(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>J(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),W===`done`&&Rn!==null&&(0,v.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,v.jsx)(Ae,{size:14}),` Saved `,Rn,` insights to memory`]}),W===`review`&&q.length===0&&(0,v.jsx)(`div`,{className:`mem-profile-empty`,children:`No insights generated.`})]})]}),I===`goals`&&(0,v.jsxs)(`div`,{className:`mem-goals-tab`,children:[(0,v.jsx)(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(e=>(0,v.jsxs)(`div`,{className:`mem-goals-stat-pill mem-goal-status-${e.replace(`_`,`-`)}`,children:[(0,v.jsx)(`span`,{className:`mem-goals-stat-n`,children:bn?.goals[e]??0}),(0,v.jsx)(`span`,{className:`mem-goals-stat-label`,children:e.replace(`_`,` `)})]},e))}),R.filter(e=>e.status===`pending_approval`).length>0&&(0,v.jsxs)(`div`,{className:`mem-goals-approval-banner`,children:[(0,v.jsxs)(`div`,{className:`mem-goals-approval-title`,children:[(0,v.jsx)(d,{size:14}),` Agent suggested `,R.filter(e=>e.status===`pending_approval`).length,` goal(s) — review before execution`]}),R.filter(e=>e.status===`pending_approval`).map(e=>(0,v.jsxs)(`div`,{className:`mem-goals-approval-item`,children:[(0,v.jsxs)(`div`,{className:`mem-goals-approval-text`,children:[(0,v.jsx)(`strong`,{children:e.title}),(0,v.jsx)(`span`,{children:e.description})]}),(0,v.jsxs)(`div`,{className:`mem-goals-approval-actions`,children:[(0,v.jsx)(`button`,{className:`btn-danger-sm`,onClick:()=>hr(()=>l(e.id),`Couldn't reject the goal`),children:`Reject`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>hr(()=>ge(e.id),`Couldn't accept the goal`),children:`Accept`})]})]},e.id))]}),(0,v.jsx)(`div`,{className:`mem-goals-toolbar`,children:(0,v.jsxs)(`button`,{className:`btn-primary`,onClick:()=>kn(e=>!e),children:[(0,v.jsx)(Ie,{size:14}),` New Goal`]})}),On&&(0,v.jsxs)(`div`,{className:`mem-goals-add-form`,children:[(0,v.jsx)(`input`,{className:`mem-input`,placeholder:`Goal title`,value:An.title,onChange:e=>jn(t=>({...t,title:e.target.value}))}),(0,v.jsx)(`textarea`,{className:`mem-input`,placeholder:`Description — what should the agent work toward?`,rows:2,value:An.description,onChange:e=>jn(t=>({...t,description:e.target.value}))}),(0,v.jsxs)(`div`,{className:`mem-goals-form-row`,children:[(0,v.jsxs)(`select`,{className:`mem-select`,value:An.priority,onChange:e=>jn(t=>({...t,priority:e.target.value})),children:[(0,v.jsx)(`option`,{value:`low`,children:`Low priority`}),(0,v.jsx)(`option`,{value:`medium`,children:`Medium priority`}),(0,v.jsx)(`option`,{value:`high`,children:`High priority`})]}),(0,v.jsx)(`button`,{className:`btn-primary`,onClick:()=>{An.title.trim()&&hr(async()=>{await be(An),jn({title:``,description:``,priority:`medium`}),kn(!1)},`Couldn't create the goal`)},children:`Create`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>kn(!1),children:`Cancel`})]})]}),Sn?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),` Loading goals...`]}):R.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(ot,{size:32})}),(0,v.jsx)(`p`,{children:`No goals yet. Create one or let the agent suggest goals in autonomous mode.`})]}):(0,v.jsx)(`div`,{className:`mem-goals-list`,children:R.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(e=>(0,v.jsxs)(`div`,{className:`mem-goal-card mem-goal-status-${e.status.replace(`_`,`-`)}`,children:[(0,v.jsxs)(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":wn===e.id,onClick:()=>Tn(t=>t===e.id?null:e.id),onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Tn(t=>t===e.id?null:e.id))},children:[(0,v.jsxs)(`div`,{className:`mem-goal-header-left`,children:[(0,v.jsx)(`span`,{className:`mem-goal-status-dot status-${e.status.replace(`_`,`-`)}`}),(0,v.jsx)(`span`,{className:`mem-goal-title`,children:e.title}),(0,v.jsx)(`span`,{className:`mem-goal-priority mem-priority-${e.priority}`,children:e.priority}),e.source!==`user`&&(0,v.jsxs)(`span`,{className:`mem-goal-source-badge`,children:[(0,v.jsx)(d,{size:10}),` `,e.source.replace(`_`,` `)]})]}),(0,v.jsxs)(`div`,{className:`mem-goal-header-right`,children:[(0,v.jsxs)(`span`,{className:`mem-goal-task-count`,children:[(0,v.jsx)(me,{size:12}),e.tasks.filter(e=>e.status===`completed`).length,`/`,e.tasks.length]}),e.status===`queued`&&(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:t=>{t.stopPropagation(),hr(()=>Ne(e.id),`Couldn't cancel the goal`)},children:`Cancel`}),En===e.id?(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:t=>{t.stopPropagation(),Dn(null),hr(()=>Fe(e.id),`Couldn't delete the goal`)},children:`Delete?`}):(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":`Delete goal ${e.title}`,onClick:t=>{t.stopPropagation(),Dn(e.id)},children:(0,v.jsx)(pe,{size:12})}),(0,v.jsx)(Ce,{size:14,className:wn===e.id?`mem-chevron-open`:``})]})]}),wn===e.id&&(0,v.jsxs)(`div`,{className:`mem-goal-body`,children:[e.description&&(0,v.jsx)(`p`,{className:`mem-goal-desc`,children:e.description}),e.progress_notes&&(0,v.jsx)(`p`,{className:`mem-goal-progress`,children:e.progress_notes}),e.tasks.length>0?(0,v.jsx)(`div`,{className:`mem-task-list`,children:e.tasks.map(e=>(0,v.jsxs)(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[(0,v.jsx)(`span`,{className:`mem-task-dot status-${e.status}`}),(0,v.jsx)(`span`,{className:`mem-task-desc`,children:e.description}),(0,v.jsx)(`span`,{className:`mem-task-status-label`,children:e.status}),e.result&&(0,v.jsx)(`span`,{className:`mem-task-result`,children:e.result})]},e.id))}):(0,v.jsx)(`p`,{className:`mem-goal-no-tasks`,children:`No tasks yet — the agent will break this down when it starts.`})]})]},e.id))})]})]}),Nt.length>0&&(0,v.jsx)(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:Nt.map(e=>(0,v.jsxs)(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&(0,v.jsx)(Ae,{size:14}),e.type===`error`&&(0,v.jsx)(ae,{size:14}),e.type===`info`&&(0,v.jsx)(Me,{size:14}),(0,v.jsx)(`span`,{children:e.text})]},e.id))})]})}export{Ct as MemoryDashboard};