@amd-gaia/agent-ui 0.25.0-rc.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/tray-icon.png +0 -0
- package/assets/tray-icon@2x.png +0 -0
- package/bin/gaia-ui.cjs +37 -7
- package/dist/assets/AdvancedSettings-5cX0pGZc.js +1 -0
- package/dist/assets/{ConnectorsPane-KLjT1y3F.js → ConnectorsPane-CuWxzcBY.js} +1 -1
- package/dist/assets/DocumentLibrary-BdAKDe8H.js +1 -0
- package/dist/assets/FileBrowser-B8s6hKC5.js +4 -0
- package/dist/assets/MemoryDashboard-DQxtAW90.css +1 -0
- package/dist/assets/MemoryDashboard-DtolA-HZ.js +1 -0
- package/dist/assets/MobileAccessModal-C3nWkpWA.js +2 -0
- package/dist/assets/ScheduleManager-HHdD6sko.js +2 -0
- package/dist/assets/index-CFVpPQal.css +1 -0
- package/dist/assets/index-DEPbenxC.js +60 -0
- package/dist/assets/useEscapeToClose-B8fw5mn-.js +1 -0
- package/dist/index.html +2 -2
- package/main.cjs +19 -1
- package/package.json +1 -1
- package/services/backend-installer.cjs +188 -38
- package/services/tray-manager.cjs +10 -2
- package/dist/assets/AdvancedSettings-DabrR6sf.js +0 -1
- package/dist/assets/DocumentLibrary-CElkmNvc.js +0 -1
- package/dist/assets/FileBrowser-ROrpBhVm.js +0 -4
- package/dist/assets/MemoryDashboard-B-YH4b1Z.css +0 -1
- package/dist/assets/MemoryDashboard-DG9P8Bqf.js +0 -1
- package/dist/assets/MobileAccessModal-Jub4U6L2.js +0 -2
- package/dist/assets/ScheduleManager-BStuwsjn.js +0 -2
- package/dist/assets/index-B8E7IBmc.css +0 -1
- package/dist/assets/index-CXbVMk3u.js +0 -58
package/assets/tray-icon.png
CHANGED
|
Binary file
|
package/assets/tray-icon@2x.png
CHANGED
|
Binary file
|
package/bin/gaia-ui.cjs
CHANGED
|
@@ -141,11 +141,13 @@ function openBrowser(url) {
|
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
let shuttingDown = false;
|
|
145
|
+
|
|
144
146
|
/**
|
|
145
147
|
* Start the Python backend.
|
|
146
148
|
* Uses "chat --ui" for compatibility with all gaia versions.
|
|
147
149
|
*/
|
|
148
|
-
function startBackend(gaiaBin, port) {
|
|
150
|
+
function startBackend(gaiaBin, port, exit = process.exit) {
|
|
149
151
|
console.log(`Starting GAIA backend on port ${port}...`);
|
|
150
152
|
|
|
151
153
|
const child = spawn(
|
|
@@ -160,6 +162,9 @@ function startBackend(gaiaBin, port) {
|
|
|
160
162
|
],
|
|
161
163
|
{
|
|
162
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) },
|
|
163
168
|
detached: false,
|
|
164
169
|
}
|
|
165
170
|
);
|
|
@@ -176,13 +181,16 @@ function startBackend(gaiaBin, port) {
|
|
|
176
181
|
|
|
177
182
|
child.on("error", (err) => {
|
|
178
183
|
console.error(`Failed to start backend: ${err.message}`);
|
|
179
|
-
|
|
184
|
+
exit(1);
|
|
180
185
|
});
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
// The backend serves the UI, so once it is gone there is nothing to open.
|
|
188
|
+
child.on("exit", (code, signal) => {
|
|
189
|
+
if (shuttingDown) return;
|
|
190
|
+
console.error(
|
|
191
|
+
`Backend exited with ${code !== null ? `code ${code}` : signal} — see the [backend] lines above.`
|
|
192
|
+
);
|
|
193
|
+
exit(code ?? 1);
|
|
186
194
|
});
|
|
187
195
|
|
|
188
196
|
return child;
|
|
@@ -273,6 +281,26 @@ async function serveFrontend(port) {
|
|
|
273
281
|
return server;
|
|
274
282
|
}
|
|
275
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
|
+
|
|
276
304
|
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
277
305
|
|
|
278
306
|
async function main() {
|
|
@@ -313,6 +341,7 @@ async function main() {
|
|
|
313
341
|
try {
|
|
314
342
|
gaiaBin = await installer.ensureBackend({
|
|
315
343
|
version: GAIA_VERSION_OVERRIDE || undefined,
|
|
344
|
+
chooseLemonade: chooseLemonadeOnTerminal,
|
|
316
345
|
onProgress: (stage, percent, message) => {
|
|
317
346
|
// Simple CLI progress formatting
|
|
318
347
|
process.stdout.write(
|
|
@@ -358,6 +387,7 @@ async function main() {
|
|
|
358
387
|
|
|
359
388
|
// Graceful shutdown
|
|
360
389
|
function cleanup() {
|
|
390
|
+
shuttingDown = true;
|
|
361
391
|
if (backendProcess) {
|
|
362
392
|
console.log("\nShutting down GAIA...");
|
|
363
393
|
backendProcess.kill("SIGTERM");
|
|
@@ -385,4 +415,4 @@ if (require.main === module) {
|
|
|
385
415
|
});
|
|
386
416
|
}
|
|
387
417
|
|
|
388
|
-
module.exports = { npmDistTag, helpText };
|
|
418
|
+
module.exports = { npmDistTag, helpText, startBackend, chooseLemonadeOnTerminal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,r as n,t as r}from"./jsx-runtime-DVeaULmT.js";import{Kt as i,Ot as a,Pt as o,R as s,an as c,ct as l,dt as u,jt as d,kt as f,n as p,ot as m,r as h,rn as g,st as _,ut as v,xt as y,z as b}from"./index-DEPbenxC.js";var x=e(t(),1),S=r();function C(){return window.gaiaUpdater}function w({onClose:e}){let[t,n]=(0,x.useState)({kind:`loading`}),r=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=C();if(!e){n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`});return}e.listReleases().then(e=>{n(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})})},[]),(0,x.useEffect)(()=>{function t(t){t.key===`Escape`&&e()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),(0,x.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,x.useEffect)(()=>{let e=r.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function i(e,t){e.isCurrent||n({kind:`confirm`,release:e,releases:t})}async function a(t){n({kind:`installing`});let r=C();if(!r){n({kind:`error`,message:`Bridge unavailable — please restart the app.`});return}try{await r.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);n({kind:`error`,message:`Failed to start rollback: ${t}`})}}function o(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,S.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,S.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Roll back to a previous version`,ref:r,children:[(0,S.jsxs)(`div`,{className:`version-picker-header`,children:[(0,S.jsx)(`h3`,{children:`Roll back to a previous version`}),(0,S.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,S.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,S.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,S.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,S.jsxs)(`div`,{className:`version-picker-error`,children:[(0,S.jsx)(`p`,{children:t.message}),(0,S.jsx)(`p`,{children:(0,S.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,S.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":`${e.version}${e.isCurrent?` — installed`:``}${e.isPinned?` — pinned`:``}`,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>i(e,t.releases),disabled:e.isCurrent,children:[(0,S.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,S.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,S.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,S.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,S.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,S.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,S.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,S.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,S.jsxs)(`p`,{children:[`This will `,(0,S.jsxs)(`strong`,{children:[`downgrade to v`,t.release.version]}),` and restart the app.`]}),(0,S.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,S.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,S.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,S.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Confirm downgrade & restart`})]})]}),t.kind===`installing`&&(0,S.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,S.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}function T(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(null),[o,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null),[_,v]=(0,x.useState)(!1);(0,x.useEffect)(()=>{m().then(e=>{t(e),l(e.saved_base_url??e.base_url??``)}).catch(e=>r(e instanceof Error?e.message:String(e)))},[]);let y=(0,x.useCallback)(async e=>{p(!0),g(null);try{let n=await a(e);t(n),d(``),v(!1)}catch(e){v(s(e)),g(e instanceof Error?e.message:String(e))}finally{p(!1)}},[]),b=()=>void y({mode:`external`,base_url:o.trim(),api_key:u.trim()||void 0});if(n)return(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,S.jsx)(c,{size:14}),(0,S.jsxs)(`div`,{className:`model-warning-content`,children:[(0,S.jsx)(`strong`,{children:`Could not read which model server GAIA uses`}),(0,S.jsx)(`p`,{children:n})]})]})]});if(!e)return null;let C=e.mode===`external`;return(0,S.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsx)(`p`,{className:`model-override-desc`,role:`status`,children:e.source===`env`?(0,S.jsxs)(S.Fragment,{children:[`GAIA uses the Lemonade Server at `,(0,S.jsx)(`code`,{children:e.base_url}),`, set by `,(0,S.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),`.`]}):C?(0,S.jsxs)(S.Fragment,{children:[`GAIA uses your Lemonade Server at `,(0,S.jsx)(`code`,{children:e.base_url}),`.`]}):(0,S.jsx)(S.Fragment,{children:`GAIA uses its own Lemonade Server.`})}),e.source===`env`?(0,S.jsxs)(`p`,{className:`model-status-hint`,children:[`Unset `,(0,S.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),` and restart GAIA to change this here.`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.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,S.jsxs)(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,S.jsx)(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:o,onChange:e=>{l(e.target.value),g(null)},disabled:f,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Lemonade Server address`}),(0,S.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:u,onChange:e=>d(e.target.value),disabled:f,"aria-label":`Lemonade API key`}),(0,S.jsx)(`div`,{className:`model-btn-group`,children:(0,S.jsx)(`button`,{type:`submit`,className:`btn-model-save`,disabled:f||!o.trim(),children:f?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:13,className:`btn-spinner`}),` Checking…`]}):`Use this server`})})]}),C&&(0,S.jsx)(`div`,{className:`setting-actions`,children:(0,S.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:f,onClick:()=>void y({mode:`gaia`}),children:`Use GAIA’s own`})}),h&&(0,S.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,S.jsx)(c,{size:14}),(0,S.jsxs)(`div`,{className:`model-warning-content`,children:[(0,S.jsx)(`strong`,{children:_?`Needs the API key`:`Not switched`}),(0,S.jsx)(`p`,{children:h})]})]})]})]})}var E={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},D={gaia:`GAIA's own Lemonade`,user:`Your Lemonade`,remote:`Lemonade on another machine`};function O(e){return e?E[e]??e:`unknown`}function k(e){if(!e)return`unknown`;let t=O(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function A(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}function j({label:e,value:t,title:n}){return(0,S.jsxs)(`div`,{className:`status-row`,children:[(0,S.jsx)(`span`,{className:`status-label`,children:e}),(0,S.jsx)(`span`,{className:`status-value model-server-value`,title:n??t,children:t})]})}function M(){let e=o(e=>e.openSettings),[t,n]=(0,x.useState)(null),[r,a]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[u,d]=(0,x.useState)(null),[p,m]=(0,x.useState)(!1);(0,x.useEffect)(()=>{l().then(n).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let h=(0,x.useCallback)(async e=>{c(e),d(null);try{let t=await f(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{c(null)}},[]),g=t?.chat_model??null,_=(0,x.useCallback)(async()=>{if(g?.name){m(!0);try{await y(g.name,g.ctx_size??void 0),d({ok:!0,text:`Reloading ${g.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{m(!1)}}},[g]),v=(0,S.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(`model`),children:`Change model`});if(r)return(0,S.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]});if(!t)return(0,S.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsx)(`p`,{className:`loading-text`,children:`Checking the model server…`})]});if(!t.reachable)return(0,S.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsx)(`p`,{className:`settings-error`,role:`alert`,children:t.error}),v]});let b=t.available_backends??[],C=t.preferred_backend??null,w=[`auto`,...b.map(e=>e.name)];C&&!w.includes(C)&&w.push(C);let T=C??`auto`,E=b.filter(e=>e.state===`installable`).map(e=>O(e.name)),M=!!g?.name&&g.recipe===`llamacpp`;return(0,S.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,S.jsx)(`h4`,{children:`Model server`}),(0,S.jsxs)(`div`,{className:`status-grid`,children:[(0,S.jsx)(j,{label:`Server`,value:`${D[t.owner]??t.owner}${t.version?` v${t.version}`:``}`}),(0,S.jsx)(j,{label:`Address`,value:t.base_url}),(0,S.jsx)(j,{label:`Chat model`,value:g?.name??`None loaded`}),g&&(0,S.jsx)(j,{label:`Runs on`,value:k(g)}),g&&g.backend!==`remote`&&(0,S.jsx)(j,{label:`Context window`,value:A(g.ctx_size)}),(0,S.jsx)(j,{label:`Embedding model`,value:t.embedding_model?.name?`${t.embedding_model.name} · ${k(t.embedding_model)}`:`None loaded`})]}),t.embedding_note&&(0,S.jsx)(`p`,{className:`settings-hint`,children:t.embedding_note}),t.system_info_error&&(0,S.jsx)(`p`,{className:`settings-hint`,children:t.system_info_error}),(0,S.jsxs)(`div`,{className:`settings-field model-server-backend`,children:[(0,S.jsx)(`span`,{className:`settings-label`,children:`llama.cpp backend for chat models`}),b.length===0&&!C?(0,S.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,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":`llama.cpp backend`,children:w.map(e=>(0,S.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":T===e,className:T===e?`is-active`:``,disabled:s!==null,onClick:()=>{e!==T&&h(e)},children:[s===e?(0,S.jsx)(i,{size:12,className:`spin`}):null,e===`auto`?`Auto${t.default_backend?` (${O(t.default_backend)})`:``}`:O(e)]},e))}),(0,S.jsxs)(`span`,{className:`settings-hint`,children:[`Applies the next time a chat model loads. The embedding model keeps its own backend.`,E.length>0&&` ${E.join(`, `)} downloads on first use.`]})]}),u&&(0,S.jsx)(`p`,{className:u.ok?`settings-ok`:`settings-error`,role:u.ok?`status`:`alert`,children:u.text})]}),(0,S.jsxs)(`div`,{className:`settings-row`,children:[v,M&&(0,S.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void _(),disabled:p,children:[p?(0,S.jsx)(i,{size:13,className:`spin`}):null,`Reload chat model now`]})]})]})}function N(){let[e,t]=(0,x.useState)(null),[r,a]=(0,x.useState)(!0),[o,s]=(0,x.useState)([]),[l,f]=(0,x.useState)(!1),m=p(),[y,C]=(0,x.useState)(``),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(!1),[N,F]=(0,x.useState)(null),[I,L]=(0,x.useState)(!1),R=(0,x.useRef)(null),[z,B]=(0,x.useState)(!1),[V,ee]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,te]=(0,x.useState)(null);(0,x.useEffect)(()=>{n.system.info(`Checking system status...`);let e=n.system.time();u().then(r=>{t(r),n.system.timed(`System status received`,e,{lemonade:r.lemonade_running?`running`:`stopped`,model:r.model_loaded||`none`,embedding:r.embedding_model_loaded?`yes`:`no`,disk:`${r.disk_space_gb}GB free`,memory:r.memory_available_gb==null?`unknown`:`${r.memory_available_gb}GB available`}),r.lemonade_running||n.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{n.system.error(`Failed to get system status`,e),t(null)}).finally(()=>a(!1)),_().then(e=>s(e.servers)).catch(()=>{}),v().then(e=>{let t=e.custom_model??``;C(t),D(t),B(e.dynamic_tools),ee(e.dynamic_tools_locked)}).catch(e=>{n.system.error(`Failed to load settings`,e)}).finally(()=>k(!0))},[]),(0,x.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]);let ne=(0,x.useCallback)(async()=>{let e=y.trim(),t=e.length>0?e:``;j(!0),F(null),L(!1);try{n.system.info(`Saving custom_model override`,{custom_model:t});let e=(await d({custom_model:t})).custom_model??``;C(e),D(e),L(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>L(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);n.system.error(`Failed to save custom_model`,e),F(t)}finally{j(!1)}},[y]),re=(0,x.useCallback)(async()=>{if(V||H)return;let e=z,t=!e;B(t),U(!0),te(null);try{n.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await d({dynamic_tools:t});B(e.dynamic_tools),ee(e.dynamic_tools_locked)}catch(t){let r=t instanceof Error?t.message:String(t);n.system.error(`Failed to save dynamic_tools`,t),B(e),te(r)}finally{U(!1)}},[z,V,H]),ie=y.trim()!==E.trim(),G=e?e.default_model_name:b,{isLoadingModel:K,isDownloadingModel:q,loadModel:J,downloadModel:ae}=h(G??void 0),oe=[{label:`4K`,value:4096},{label:`8K`,value:8192},{label:`16K`,value:16384},{label:`32K`,value:32768}],Y=e?.model_context_size??null,[se,X]=(0,x.useState)(``);(0,x.useEffect)(()=>{Y!=null&&X(String(Y))},[Y]);let Z=(()=>{let e=parseInt(se,10);return Number.isFinite(e)&&e>0?e:null})(),ce=Z!=null&&Z!==Y,Q=e?.model_loaded??G,le=(0,x.useCallback)(async()=>{Z&&Q&&(n.system.info(`Reloading ${Q} with ctx_size=${Z}`),await J(Q,Z))},[Z,Q,J]),$=!!e?.default_model_is_cloud,ue=!$&&!!(e?.lemonade_running&&e.model_loaded&&e.expected_model_loaded===!1),de=!$&&!!(e?.lemonade_running&&e.model_loaded&&e.context_size_sufficient===!1),fe=!$&&!(!e?.lemonade_running||e.model_loaded||e.model_downloaded!==!1),pe=(ue||de)&&G!==null;return(0,S.jsxs)(`div`,{className:`settings-pane`,children:[(0,S.jsx)(`h2`,{className:`settings-pane-title`,children:`Advanced`}),(0,S.jsx)(M,{}),(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`Local model server`}),r?(0,S.jsx)(`p`,{className:`loading-text`,children:`Checking system...`}):e?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`status-grid`,children:[(0,S.jsx)(P,{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,S.jsx)(P,{label:`Model`,value:e.model_loaded||`None loaded`,ok:!!e.model_loaded&&($||e.expected_model_loaded!==!1),hint:e.model_loaded?!$&&e.expected_model_loaded===!1?`Expected: ${G}`:void 0:`None loaded yet — it loads with the first message.`}),e.model_size_gb!=null&&(0,S.jsx)(P,{label:`Model Size`,value:`${e.model_size_gb} GB`,ok:!0}),e.model_device&&!$&&(0,S.jsx)(P,{label:`Device`,value:e.model_device.toUpperCase(),ok:e.model_device!==`cpu`}),e.model_context_size!=null&&(0,S.jsx)(P,{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,S.jsx)(P,{label:`Capabilities`,value:e.model_labels.join(`, `),ok:!0}),(0,S.jsx)(P,{label:`Embedding Model`,value:e.embedding_model_loaded?`Available`:`Not loaded`,ok:e.embedding_model_loaded}),e.gpu_name&&(0,S.jsx)(P,{label:`GPU`,value:`${e.gpu_name}${e.gpu_vram_gb?` (${e.gpu_vram_gb} GB)`:``}`,ok:!0}),(0,S.jsx)(P,{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,S.jsx)(P,{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,S.jsx)(P,{label:`Processor`,value:e.processor_name,ok:!0})]}),fe&&(0,S.jsxs)(`div`,{className:`model-action-row model-action-row--download`,children:[(0,S.jsxs)(`div`,{className:`model-action-info`,children:[(0,S.jsx)(`span`,{className:`model-action-label`,children:`Model not downloaded.`}),(0,S.jsxs)(`span`,{className:`model-action-desc`,children:[(0,S.jsx)(`strong`,{children:G}),` is GAIA’s default local model (about 6 GB).`]})]}),(0,S.jsx)(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>ae(!1),disabled:q,children:q?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:13,className:`btn-spinner`}),` Downloading…`]}):`Download`})]}),pe&&(0,S.jsxs)(`div`,{className:`model-action-row model-action-row--load`,children:[(0,S.jsxs)(`div`,{className:`model-action-info`,children:[(0,S.jsx)(`span`,{className:`model-action-label`,children:ue?`Wrong model loaded.`:`Context window too small.`}),(0,S.jsxs)(`span`,{className:`model-action-desc`,children:[`Load `,(0,S.jsx)(`strong`,{children:G}),` with `,32 .toFixed(0),`K token context.`]})]}),(0,S.jsx)(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>J(),disabled:K,children:K?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:13,className:`btn-spinner`}),` Loading…`]}):`Load Model`})]}),e.lemonade_running&&G!==null&&!$&&(0,S.jsxs)(`div`,{className:`force-redownload-row`,children:[(0,S.jsx)(`span`,{className:`force-redownload-label`,children:`If the model file is corrupted:`}),(0,S.jsx)(`button`,{className:`btn-force-redownload`,onClick:()=>ae(!0),disabled:q,children:q?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:12,className:`btn-spinner`}),` Downloading…`]}):`Force Re-download`})]})]}):(0,S.jsx)(`div`,{className:`status-error`,children:(0,S.jsx)(`p`,{children:`Could not reach GAIA. Check that it is still running.`})})]}),(0,S.jsx)(T,{}),(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`Custom model ID`}),(0,S.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,S.jsxs)(`div`,{className:`model-input-row`,children:[(0,S.jsx)(`input`,{type:`text`,className:`model-input${E?` has-override`:``}`,placeholder:`Use the model chosen under Model`,value:y,onChange:e=>{C(e.target.value),F(null),L(!1)},onKeyDown:e=>{e.key===`Enter`&&!A&&ie&&O&&(e.preventDefault(),ne())},disabled:!O||A,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Custom model override`}),(0,S.jsx)(`div`,{className:`model-btn-group`,children:(0,S.jsx)(`button`,{className:`btn-model-save${I?` saved`:``}`,onClick:()=>{ne()},disabled:!O||A||!ie&&!I,"aria-label":`Save custom model`,children:A?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:13,className:`btn-spinner`}),` Saving…`]}):I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{size:13}),` Saved`]}):`Save`})})]}),(0,S.jsxs)(`p`,{className:`model-status-hint`,children:[`Accepts a Lemonade model ID (e.g. `,(0,S.jsx)(`code`,{children:`Qwen3-4B-Instruct-2507-GGUF`}),`)`,` `,`or a HuggingFace ID (e.g. `,(0,S.jsx)(`code`,{children:`unsloth/Qwen3-4B-GGUF`}),`).`]}),N&&(0,S.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,S.jsx)(c,{size:14}),(0,S.jsxs)(`div`,{className:`model-warning-content`,children:[(0,S.jsx)(`strong`,{children:`Could not save`}),(0,S.jsx)(`p`,{children:N})]})]})]}),!$&&(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`Context Size`}),(0,S.jsx)(`p`,{className:`model-override-desc`,children:`Reload the active model with a different context window. Larger contexts use more memory and slow inference; going past the model’s training length may degrade quality.`}),(0,S.jsx)(`div`,{className:`ctx-preset-row`,children:oe.map(e=>{let t=Z===e.value;return(0,S.jsx)(`button`,{className:`btn-ctx-preset${t?` active`:``}`,onClick:()=>X(String(e.value)),disabled:K,type:`button`,children:e.label},e.value)})}),(0,S.jsxs)(`div`,{className:`model-input-row`,children:[(0,S.jsx)(`input`,{type:`number`,className:`model-input`,placeholder:Y==null?`4096`:String(Y),value:se,min:512,step:1024,onChange:e=>X(e.target.value),disabled:K,"aria-label":`Context size in tokens`}),(0,S.jsx)(`div`,{className:`model-btn-group`,children:(0,S.jsx)(`button`,{className:`btn-model-save`,onClick:()=>{le()},disabled:K||!ce||!e?.lemonade_running,"aria-label":`Reload model with new context size`,children:K?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i,{size:13,className:`btn-spinner`}),` Reloading…`]}):`Apply`})})]}),(0,S.jsxs)(`p`,{className:`model-status-hint`,children:[`Current: `,(0,S.jsx)(`code`,{children:Y==null?`unknown`:`${Y.toLocaleString()} tokens`}),e?.model_loaded&&(0,S.jsxs)(S.Fragment,{children:[` on `,(0,S.jsx)(`code`,{children:e.model_loaded})]}),`.`]})]}),(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsxs)(`h4`,{children:[`Dynamic Tools `,(0,S.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,S.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,S.jsxs)(`label`,{className:`setting-row`,children:[(0,S.jsx)(`span`,{children:`Enable dynamic tool loading`}),(0,S.jsxs)(`span`,{className:`toggle-switch`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:z,onChange:()=>void re(),disabled:!O||H||V,"aria-label":z?`Disable dynamic tools`:`Enable dynamic tools`}),(0,S.jsx)(`span`,{className:`toggle-track`})]})]}),V&&(0,S.jsxs)(`p`,{className:`model-status-hint`,children:[`Controlled by `,(0,S.jsx)(`code`,{children:`GAIA_DYNAMIC_TOOLS`}),` — unset that environment variable to change this here.`]}),W&&(0,S.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,S.jsx)(c,{size:14}),(0,S.jsxs)(`div`,{className:`model-warning-content`,children:[(0,S.jsx)(`strong`,{children:`Could not save`}),(0,S.jsx)(`p`,{children:W})]})]})]}),o.length>0&&(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`MCP Servers`}),(0,S.jsx)(`div`,{className:`status-grid`,children:o.map(e=>(0,S.jsxs)(`div`,{className:`status-row`,children:[(0,S.jsx)(`span`,{className:`status-label`,children:e.name}),(0,S.jsx)(`div`,{className:`status-value-wrap`,children:e.connected?(0,S.jsxs)(`span`,{className:`status-value ok mcp-status-connected`,children:[(0,S.jsx)(g,{size:12}),e.tool_count,` tool`,e.tool_count===1?``:`s`]}):(0,S.jsxs)(`span`,{className:`status-value warn mcp-status-failed`,title:e.error??void 0,children:[(0,S.jsx)(c,{size:12}),`Failed`]})})]},e.name))})]}),(0,S.jsxs)(`section`,{className:`settings-section`,children:[(0,S.jsx)(`h4`,{children:`About`}),(0,S.jsxs)(`div`,{className:`about-info`,children:[(0,S.jsxs)(`p`,{children:[`GAIA v`,`0.25.0`,` `,(0,S.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,S.jsx)(`p`,{className:`about-sub`,children:`Privacy-first AI chat for AMD Ryzen AI PCs.`}),m.pinnedVersion&&(0,S.jsxs)(`p`,{className:`about-pinned-notice`,children:[`Auto-update paused (pinned to `,m.pinnedVersion,`).`,` `,(0,S.jsx)(`button`,{type:`button`,className:`about-resume-btn`,onClick:()=>{window.gaiaUpdater?.resumeUpdates().catch(e=>{n.system.error(`Resume updates failed`,e)})},children:`Resume updates`})]})]}),(0,S.jsx)(`div`,{className:`setting-actions`,children:(0,S.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>f(!0),children:`Roll back to a previous version`})})]}),l&&(0,S.jsx)(w,{onClose:()=>f(!1)})]})}function P({label:e,value:t,ok:n,hint:r}){return(0,S.jsxs)(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[(0,S.jsx)(`span`,{className:`status-label`,children:e}),(0,S.jsxs)(`div`,{className:`status-value-wrap`,children:[(0,S.jsx)(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&(0,S.jsx)(`span`,{className:`status-hint`,children:(0,S.jsx)(`code`,{children:r})})]})]})}export{N as AdvancedSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,n,o as r,r as i,t as a}from"./jsx-runtime-DVeaULmT.js";import{$t as o,Bt as s,G as c,Gt as l,K as u,Ot as d,St as f,U as p,Y as m,Z as h,Zt as g,et as _,ft as v,ht as y,mt as b,nt as x,pt as S,rt as C,tn as w,tt as T,ut as E}from"./index-CXbVMk3u.js";var D={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};D.node;var O=t(D),k={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};k.node;var A=t(k),j=a(),M=e(r(),1),N=i.api;function P(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;default:return null}}function F(e){let t=(0,M.useRef)(e);(0,M.useEffect)(()=>{t.current=e},[e]),(0,M.useEffect)(()=>{let e=`${n()}/connectors/events`,r=null,i=1e3,a=null,o=!1,s=()=>{o||(r=new EventSource(e),r.onopen=()=>{i=1e3},r.onmessage=e=>{try{let n=JSON.parse(e.data),r=P(n.type);if(r===null){N.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){N.warn(`connectors-sse: malformed event`,e)}},r.onerror=()=>{r?.close(),r=null,!o&&(a=setTimeout(s,i),i=Math.min(i*2,3e4))})};return s(),()=>{o=!0,a&&clearTimeout(a),r?.close()}},[])}function I(e){return e.type===`mcp_server`&&e.configured}function L({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);if((0,M.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;u.current&&!u.current.contains(t)&&d.current&&!d.current.contains(t)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=()=>{if(!u.current)return;let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),!I(e))return null;let f=e=>{e.stopPropagation(),e.preventDefault()},p=e=>{if(f(e),!n&&u.current){let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})}r(e=>!e)},m=async e=>{a(!0),s(null);try{await e(),r(!1),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`connector-tile-menu`,onClick:f,onKeyDown:f,children:[(0,j.jsx)(`button`,{ref:u,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:p,disabled:i,children:(0,j.jsx)(A,{size:14})}),n&&c&&(0,j.jsxs)(`div`,{ref:d,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:c.top,right:c.right},children:[e.enabled?(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>_(e.id)),disabled:i,children:`Disable`}):(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>x(e.id)),disabled:i,children:`Enable`}),(0,j.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void m(()=>T(e.id)),disabled:i,children:`Disconnect`}),o&&(0,j.jsx)(`div`,{className:`connector-tile-menu-error`,children:o})]})]})}var R={"https://www.googleapis.com/auth/gmail.readonly":`Read emails`,"https://www.googleapis.com/auth/gmail.modify":`Organize emails (archive, label, trash)`,"https://www.googleapis.com/auth/gmail.send":`Send emails on your behalf`,"https://www.googleapis.com/auth/gmail.compose":`Compose emails`,"https://www.googleapis.com/auth/calendar.readonly":`View calendar events`,"https://www.googleapis.com/auth/calendar.events":`Create & respond to calendar events`,"https://www.googleapis.com/auth/drive.readonly":`Read Google Drive files`,"https://www.googleapis.com/auth/drive.file":`Manage Drive files created by this app`,"https://www.googleapis.com/auth/spreadsheets.readonly":`Read Google Sheets`,"https://www.googleapis.com/auth/spreadsheets":`Edit Google Sheets`,openid:`Identify you`,email:`See your email address`,profile:`See your basic profile info`,"https://graph.microsoft.com/Mail.ReadWrite":`Read & organize Outlook mail (archive, label, trash)`,"https://graph.microsoft.com/Mail.Send":`Send Outlook mail on your behalf`,"https://graph.microsoft.com/Calendars.ReadWrite":`Create & respond to Outlook calendar events`,"https://graph.microsoft.com/Calendars.Read":`View Outlook calendar events`,"https://graph.microsoft.com/User.Read":`Read your basic Microsoft profile`};function z(e){return R[e]??e.split(/[/.:]/).pop()??e}var B=[`use`];function V(e){return!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_supported&&!e.revoked_remotely?`Disconnected locally, but the provider did not confirm the revoke (${String(e.revoke_error??`unknown error`)}). It may still show as connected in your account's app permissions.`:e.revoke_error?`Disconnected locally. ${String(e.revoke_error)}`:`Disconnected locally. This provider has no API to revoke access remotely — remove GAIA from your account's connected-apps page if you want to fully revoke it.`}function H(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(!0),[c,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(null),m=(0,M.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([y(),v()]);t(e),r(n),l(null)}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,M.useEffect)(()=>{m()},[m]);let h=e=>p(t=>t===e?null:e),g=(0,M.useCallback)(async e=>{try{let n=await C(e);t(t=>t.map(t=>t.id===e?n:t))}catch{m()}},[m]);return F((0,M.useCallback)(e=>{e.reason===`disconnected`&&d(V(e.payload)),e.connectorId?g(e.connectorId):m()},[g,m])),(0,j.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,j.jsx)(`p`,{className:`settings-help`,children:`Connect accounts and MCP servers so GAIA can use them on your behalf. Choose what GAIA may do with each one.`}),c&&(0,j.jsxs)(`div`,{className:`error-banner`,children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:c})]}),u&&(0,j.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>d(null),children:[(0,j.jsx)(o,{size:14}),(0,j.jsx)(`span`,{children:u})]}),i?(0,j.jsx)(`div`,{className:`connectors-loading`,children:(0,j.jsx)(s,{size:16,className:`spin`})}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,j.jsx)(U,{connector:e,expanded:f===e.id,onToggle:()=>h(e.id),onChanged:()=>void g(e.id)},e.id))}),n.length>0&&(0,j.jsx)(J,{servers:n,expanded:f,onToggle:h})]})]})}function U({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,j.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,j.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,j.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`connector-status ok`,children:[(0,j.jsx)(g,{size:12}),e.account_id??`Configured`]}):(0,j.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,j.jsx)(L,{connector:e,onChanged:r}),(0,j.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,j.jsx)(W,{connector:e,onChanged:r}):(0,j.jsx)(K,{connector:e,onChanged:r}),e.configured&&(0,j.jsx)(X,{connectorId:e.id,connectorType:e.type})]})]})}function W({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),[f,p]=(0,M.useState)({}),[h,g]=(0,M.useState)(null),{agents:_}=d(),v=_.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),y=v.map(e=>e.namespaced_agent_id).join(`,`),[b,x]=(0,M.useState)(()=>new Set);(0,M.useEffect)(()=>{x(new Set(v.map(e=>e.namespaced_agent_id)))},[y]);let S=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),C=()=>[...b];(0,M.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let w=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},E=async()=>{r(!0),a(null);try{let t=await c(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());w(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},D=async()=>{r(!0),a(null),g(null);try{let t=await u(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,C());g(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,M.useEffect)(()=>{e.configured&&g(null)},[e.configured]),F((0,M.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),g(null)):t.reason===`oauth_completed`&&g(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await T(e.id),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},k=async()=>{let n=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!f[e.key]?.trim()).map(e=>e.label);if(n.length){a(`Required: ${n.join(`, `)}`);return}r(!0),a(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await m(e.id,{...f,scopes:n,grant_agents:C()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&w(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},A=e.oauth_setup_fields??[],N=e.configurable===!1&&!e.configured&&A.length>0;return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),N&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsx)(`p`,{className:`connector-desc`,children:`First-time setup — provide your OAuth client credentials below. They’re stored encrypted in your OS keyring and reused for future connections.`}),A.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:f[e.key]??``,onChange:t=>p(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&v.length>0&&(0,j.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),v.map(e=>(0,j.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b.has(e.namespaced_agent_id),onChange:()=>S(e.namespaced_agent_id)}),(0,j.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!N&&(0,j.jsx)(G,{connector:e,onChanged:t}),i&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,i]}),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):`Disconnect`}):N?(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void k(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,j.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n||h!==null,onClick:()=>void E(),children:n?(0,j.jsx)(s,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l,{size:12}),` Connect`]})}),e.supports_device_code&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n||h!==null,onClick:()=>void D(),title:`Enter a short code at a URL — no browser redirect or app registration needed`,children:`Sign in with a code`})]}),(e.docs_url||e.product_url)&&(0,j.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,j.jsx)(l,{size:11})]})]}),h&&!e.configured&&(0,j.jsxs)(`div`,{className:`device-code-block`,children:[(0,j.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,j.jsx)(`a`,{href:h.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),w(h.verification_uri)},children:h.verification_uri}),` `,`and enter this code:`]}),(0,j.jsxs)(`div`,{className:`device-code-value`,children:[(0,j.jsx)(`code`,{children:h.user_code}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(h.user_code),title:`Copy code`,children:`Copy`})]}),(0,j.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,j.jsx)(s,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>g(null),children:`Cancel`})]})]})}function G({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)({}),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),h=e.oauth_setup_fields??[];if(h.length===0)return null;let _=e.oauth_client,v=_?.source===`keyring`?`Saved client: ${_.client_id}`:_?.source===`env`?`From environment: ${_.client_id}`:`No OAuth client configured`,y=async()=>{if(!i.client_id?.trim()){p(`Client ID is required.`);return}l(!0),p(null),d(!1);try{await m(e.id,{...Object.fromEntries(Object.entries(i).map(([e,t])=>[e,t.trim()])),save_only:!0}),d(!0),a({}),t(),setTimeout(()=>d(!1),2200)}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,j.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,j.jsx)(O,{size:12}):(0,j.jsx)(w,{size:12}),(0,j.jsx)(`span`,{children:`OAuth client`}),(0,j.jsx)(`span`,{className:`oauth-client-editor__status`,children:v})]}),n&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,j.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),h.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&_?.source===`keyring`&&_.has_secret?`••••••••`:e.placeholder,value:i[e.key]??``,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),f&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,f]}),(0,j.jsx)(`div`,{className:`configure-actions`,children:(0,j.jsx)(`button`,{className:`btn-model-save${u?` saved`:``}`,disabled:c||!i.client_id?.trim(),onClick:()=>void y(),children:c?(0,j.jsx)(s,{size:12,className:`spin`}):u?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save client`})})]})]})}function K({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,M.useState)(!1),[c,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(null);(0,M.useEffect)(()=>{r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let p=async()=>{let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.trim()!==``));if(Object.keys(r).length!==0){a(!0),f(null),u(!1);try{await m(e.id,r),u(!0),t(),setTimeout(()=>u(!1),2200)}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}}},h=async()=>{a(!0),f(null);try{await T(e.id),r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}},v=async()=>{a(!0),f(null);try{e.enabled?await _(e.id):await x(e.id),t()}catch(e){f(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),d&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(o,{size:12}),` `,d]}),e.configured&&(0,j.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,j.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void v(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,j.jsx)(`p`,{className:`connector-toggle-help`,children:`Credentials and per-agent grants are preserved. Re-enable to make this server's tools available again.`}),e.mcp_env_keys.map(t=>(0,j.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,j.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,j.jsx)(`input`,{type:`password`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:`Enter value`,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`})]},t)),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[(0,j.jsx)(`button`,{className:`btn-model-save${c?` saved`:``}`,disabled:i||Object.values(n).every(e=>e.trim()===``),onClick:()=>void p(),children:i?(0,j.jsx)(s,{size:12,className:`spin`}):c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(g,{size:12}),` Saved`]}):`Save`}),e.configured&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void h(),children:`Disconnect`}),e.product_url&&(0,j.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,j.jsx)(l,{size:11})]})]})]})}function q({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=e.required_connections?.find(e=>e.connector_id===t),a=e.namespaced_agent_id;if(!i||!a)return null;let[s,c]=(0,M.useState)(()=>new Set(n)),[l,u]=(0,M.useState)(null),[d,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{c(new Set(n))},[n.join(`,`)]);let m=async e=>{if(l!==null)return;let i=new Set(s);i.has(e)?i.delete(e):i.add(e),c(i),u(e),p(null);try{i.size===0?await f(t,a):await E(t,a,[...i]),r()}catch(e){c(new Set(n)),p(e instanceof Error?e.message:String(e))}finally{u(null)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:z(e)}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e),onChange:()=>void m(e),disabled:l!==null}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]},e))}),d&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,d]})]})}function J({servers:e,expanded:t,onToggle:n}){return(0,j.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,j.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,j.jsx)(Y,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function Y({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,j.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,j.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,j.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,j.jsx)(g,{size:11}),` Active`]}),(0,j.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,j.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,j.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,j.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,j.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,j.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function X({connectorId:e,connectorType:t}){let{agents:n}=d(),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({}),[s,c]=(0,M.useState)(!0),l=(0,M.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([b(e),S(e)]);i(t),o(n)}catch{i({}),o({})}finally{c(!1)}},[e]);if((0,M.useEffect)(()=>{l()},[l]),F((0,M.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&l()},[e,l])),s)return null;let u=n.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),f=t===`mcp_server`?n.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return(0,j.jsxs)(`div`,{className:`connection-grants`,children:[(0,j.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),u.length===0?(0,j.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):u.map(t=>(0,j.jsx)(q,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},t.namespaced_agent_id)),f.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,j.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),f.map(t=>(0,j.jsx)(Z,{agent:t,connectorId:e,active:!!a[t.namespaced_agent_id],grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void l()},`activation-${t.namespaced_agent_id}`))]})]})}function Z({agent:e,connectorId:t,active:n,grantedScopes:r,onChanged:i}){let a=e.required_connections?.find(e=>e.connector_id===t),s=e.namespaced_agent_id;if(!s)return null;let[c,l]=(0,M.useState)(n),[u,d]=(0,M.useState)(!1),[f,m]=(0,M.useState)(null);(0,M.useEffect)(()=>{l(n)},[n]);let g=async()=>{if(u)return;let e=!c;l(e),d(!0),m(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...B]:void 0;await p(t,s,e)}else await h(t,s);i()}catch(e){l(n),m(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:c?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>void g(),disabled:u}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]})}),f&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(o,{size:11}),` `,f]})]})}function Q(){return(0,j.jsxs)(`div`,{className:`settings-pane`,children:[(0,j.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,j.jsx)(H,{})]})}export{Q as ConnectorsPane};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,n,o as r,r as i,t as a}from"./jsx-runtime-DVeaULmT.js";import{Et as o,K as s,Kt as c,Pt as l,Q as u,W as d,X as f,Zt as p,_t as m,an as h,gt as g,ht as _,it as v,nt as y,pt as b,q as x,rn as S,rt as C,sn as w,tt as T,vt as E}from"./index-DEPbenxC.js";var D={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};D.node;var O=t(D),k={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};k.node;var A=t(k),j=a(),M=e(r(),1),N=i.api;function P(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;default:return null}}function F(e){let t=(0,M.useRef)(e);(0,M.useEffect)(()=>{t.current=e},[e]),(0,M.useEffect)(()=>{let e=`${n()}/connectors/events`,r=null,i=1e3,a=null,o=!1,s=()=>{o||(r=new EventSource(e),r.onopen=()=>{i=1e3},r.onmessage=e=>{try{let n=JSON.parse(e.data),r=P(n.type);if(r===null){N.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){N.warn(`connectors-sse: malformed event`,e)}},r.onerror=()=>{r?.close(),r=null,!o&&(a=setTimeout(s,i),i=Math.min(i*2,3e4))})};return s(),()=>{o=!0,a&&clearTimeout(a),r?.close()}},[])}function I(e){return e.type===`mcp_server`&&e.configured}function L({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);if((0,M.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;u.current&&!u.current.contains(t)&&d.current&&!d.current.contains(t)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,M.useEffect)(()=>{if(!n)return;let e=()=>{if(!u.current)return;let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),!I(e))return null;let f=e=>{e.stopPropagation(),e.preventDefault()},p=e=>{if(f(e),!n&&u.current){let e=u.current.getBoundingClientRect();l({top:e.bottom+4,right:window.innerWidth-e.right})}r(e=>!e)},m=async e=>{a(!0),s(null);try{await e(),r(!1),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`connector-tile-menu`,onClick:f,onKeyDown:f,children:[(0,j.jsx)(`button`,{ref:u,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:p,disabled:i,children:(0,j.jsx)(A,{size:14})}),n&&c&&(0,j.jsxs)(`div`,{ref:d,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:c.top,right:c.right},children:[e.enabled?(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>T(e.id)),disabled:i,children:`Disable`}):(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void m(()=>C(e.id)),disabled:i,children:`Enable`}),(0,j.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,j.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void m(()=>y(e.id)),disabled:i,children:`Disconnect`}),o&&(0,j.jsx)(`div`,{className:`connector-tile-menu-error`,children:o})]})]})}var R={"https://www.googleapis.com/auth/gmail.readonly":`Read emails`,"https://www.googleapis.com/auth/gmail.modify":`Organize emails (archive, label, trash)`,"https://www.googleapis.com/auth/gmail.send":`Send emails on your behalf`,"https://www.googleapis.com/auth/gmail.compose":`Compose emails`,"https://www.googleapis.com/auth/calendar.readonly":`View calendar events`,"https://www.googleapis.com/auth/calendar.events":`Create & respond to calendar events`,"https://www.googleapis.com/auth/drive.readonly":`Read Google Drive files`,"https://www.googleapis.com/auth/drive.file":`Manage Drive files created by this app`,"https://www.googleapis.com/auth/spreadsheets.readonly":`Read Google Sheets`,"https://www.googleapis.com/auth/spreadsheets":`Edit Google Sheets`,openid:`Identify you`,email:`See your email address`,profile:`See your basic profile info`,"https://graph.microsoft.com/Mail.ReadWrite":`Read & organize Outlook mail (archive, label, trash)`,"https://graph.microsoft.com/Mail.Send":`Send Outlook mail on your behalf`,"https://graph.microsoft.com/Calendars.ReadWrite":`Create & respond to Outlook calendar events`,"https://graph.microsoft.com/Calendars.Read":`View Outlook calendar events`,"https://graph.microsoft.com/User.Read":`Read your basic Microsoft profile`};function z(e){return R[e]??e.split(/[/.:]/).pop()??e}var B=[`use`];function V(e){return!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_supported&&!e.revoked_remotely?`Disconnected locally, but the provider did not confirm the revoke (${String(e.revoke_error??`unknown error`)}). It may still show as connected in your account's app permissions.`:e.revoke_error?`Disconnected locally. ${String(e.revoke_error)}`:`Disconnected locally. This provider has no API to revoke access remotely — remove GAIA from your account's connected-apps page if you want to fully revoke it.`}function H(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(!0),[o,s]=(0,M.useState)(null),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),p=(0,M.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([E(),_()]);t(e),r(n),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,M.useEffect)(()=>{p()},[p]);let m=e=>f(t=>t===e?null:e),g=(0,M.useCallback)(async e=>{try{let n=await v(e);t(t=>t.map(t=>t.id===e?n:t))}catch{p()}},[p]);return F((0,M.useCallback)(e=>{e.reason===`disconnected`&&u(V(e.payload)),e.connectorId?g(e.connectorId):p()},[g,p])),(0,j.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,j.jsx)(`p`,{className:`settings-help`,children:`Connect accounts and MCP servers so GAIA can use them on your behalf. Choose what GAIA may do with each one.`}),o&&(0,j.jsxs)(`div`,{className:`error-banner`,children:[(0,j.jsx)(h,{size:14}),(0,j.jsx)(`span`,{children:o})]}),l&&(0,j.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>u(null),children:[(0,j.jsx)(h,{size:14}),(0,j.jsx)(`span`,{children:l})]}),i?(0,j.jsx)(`div`,{className:`connectors-loading`,children:(0,j.jsx)(c,{size:16,className:`spin`})}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,j.jsx)(U,{connector:e,expanded:d===e.id,onToggle:()=>m(e.id),onChanged:()=>void g(e.id)},e.id))}),n.length>0&&(0,j.jsx)(J,{servers:n,expanded:d,onToggle:m})]})]})}function U({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,j.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,j.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,j.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`connector-status ok`,children:[(0,j.jsx)(S,{size:12}),e.account_id??`Configured`]}):(0,j.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,j.jsx)(L,{connector:e,onChanged:r}),(0,j.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,j.jsx)(W,{connector:e,onChanged:r}):(0,j.jsx)(K,{connector:e,onChanged:r}),e.configured&&(0,j.jsx)(X,{connectorId:e.id,connectorType:e.type})]})]})}function W({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),[o,u]=(0,M.useState)({}),[d,m]=(0,M.useState)(null),{agents:g}=l(),_=g.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),v=_.map(e=>e.namespaced_agent_id).join(`,`),[b,S]=(0,M.useState)(()=>new Set);(0,M.useEffect)(()=>{S(new Set(_.map(e=>e.namespaced_agent_id)))},[v]);let C=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),w=()=>[...b];(0,M.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let T=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},E=async()=>{r(!0),a(null);try{let t=await s(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,w());T(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},D=async()=>{r(!0),a(null),m(null);try{let t=await x(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,w());m(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,M.useEffect)(()=>{e.configured&&m(null)},[e.configured]),F((0,M.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),m(null)):t.reason===`oauth_completed`&&m(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await y(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 f(e.id,{...o,scopes:n,grant_agents:w()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&T(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},A=e.oauth_setup_fields??[],N=e.configurable===!1&&!e.configured&&A.length>0;return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),N&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsx)(`p`,{className:`connector-desc`,children:`First-time setup — provide your OAuth client credentials below. They’re stored encrypted in your OS keyring and reused for future connections.`}),A.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:o[e.key]??``,onChange:t=>u(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&_.length>0&&(0,j.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),_.map(e=>(0,j.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:b.has(e.namespaced_agent_id),onChange:()=>C(e.namespaced_agent_id)}),(0,j.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,j.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!N&&(0,j.jsx)(G,{connector:e,onChanged:t}),i&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(h,{size:12}),` `,i]}),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,j.jsx)(c,{size:12,className:`spin`}):`Disconnect`}):N?(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void k(),children:n?(0,j.jsx)(c,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(p,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,j.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{className:`btn-primary`,disabled:n||d!==null,onClick:()=>void E(),children:n?(0,j.jsx)(c,{size:12,className:`spin`}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(p,{size:12}),` Connect`]})}),e.supports_device_code&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:n||d!==null,onClick:()=>void D(),title:`Enter a short code at a URL — no browser redirect or app registration needed`,children:`Sign in with a code`})]}),(e.docs_url||e.product_url)&&(0,j.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,j.jsx)(p,{size:11})]})]}),d&&!e.configured&&(0,j.jsxs)(`div`,{className:`device-code-block`,children:[(0,j.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,j.jsx)(`a`,{href:d.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),T(d.verification_uri)},children:d.verification_uri}),` `,`and enter this code:`]}),(0,j.jsxs)(`div`,{className:`device-code-value`,children:[(0,j.jsx)(`code`,{children:d.user_code}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(d.user_code),title:`Copy code`,children:`Copy`})]}),(0,j.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,j.jsx)(c,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>m(null),children:`Cancel`})]})]})}function G({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)({}),[o,s]=(0,M.useState)(!1),[l,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)(null),m=e.oauth_setup_fields??[];if(m.length===0)return null;let g=e.oauth_client,_=g?.source===`keyring`?`Saved client: ${g.client_id}`:g?.source===`env`?`From environment: ${g.client_id}`:`No OAuth client configured`,v=async()=>{if(!i.client_id?.trim()){p(`Client ID is required.`);return}s(!0),p(null),u(!1);try{await f(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){p(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,j.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,j.jsx)(O,{size:12}):(0,j.jsx)(w,{size:12}),(0,j.jsx)(`span`,{children:`OAuth client`}),(0,j.jsx)(`span`,{className:`oauth-client-editor__status`,children:_})]}),n&&(0,j.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,j.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,j.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),m.map(e=>(0,j.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,j.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,j.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&g?.source===`keyring`&&g.has_secret?`••••••••`:e.placeholder,value:i[e.key]??``,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,j.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),d&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(h,{size:12}),` `,d]}),(0,j.jsx)(`div`,{className:`configure-actions`,children:(0,j.jsx)(`button`,{className:`btn-model-save${l?` saved`:``}`,disabled:o||!i.client_id?.trim(),onClick:()=>void v(),children:o?(0,j.jsx)(c,{size:12,className:`spin`}):l?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(S,{size:12}),` Saved`]}):`Save client`})})]})]})}function K({connector:e,onChanged:t}){let[n,r]=(0,M.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null);(0,M.useEffect)(()=>{r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let d=async()=>{let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.trim()!==``));if(Object.keys(r).length!==0){a(!0),u(null),s(!1);try{await f(e.id,r),s(!0),t(),setTimeout(()=>s(!1),2200)}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}}},m=async()=>{a(!0),u(null);try{await y(e.id),r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}},g=async()=>{a(!0),u(null);try{e.enabled?await T(e.id):await C(e.id),t()}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,j.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,j.jsx)(`p`,{className:`connector-desc`,children:e.description}),l&&(0,j.jsxs)(`div`,{className:`configure-error`,children:[(0,j.jsx)(h,{size:12}),` `,l]}),e.configured&&(0,j.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,j.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void g(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,j.jsx)(`p`,{className:`connector-toggle-help`,children:`Credentials and per-agent grants are preserved. Re-enable to make this server's tools available again.`}),e.mcp_env_keys.map(t=>(0,j.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,j.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,j.jsx)(`input`,{type:`password`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:`Enter value`,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`})]},t)),(0,j.jsxs)(`div`,{className:`configure-actions`,children:[(0,j.jsx)(`button`,{className:`btn-model-save${o?` saved`:``}`,disabled:i||Object.values(n).every(e=>e.trim()===``),onClick:()=>void d(),children:i?(0,j.jsx)(c,{size:12,className:`spin`}):o?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(S,{size:12}),` Saved`]}):`Save`}),e.configured&&(0,j.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void m(),children:`Disconnect`}),e.product_url&&(0,j.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,j.jsx)(p,{size:11})]})]})]})}function q({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=e.required_connections?.find(e=>e.connector_id===t),a=e.namespaced_agent_id;if(!i||!a)return null;let[s,c]=(0,M.useState)(()=>new Set(n)),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null);(0,M.useEffect)(()=>{c(new Set(n))},[n.join(`,`)]);let p=async e=>{if(l!==null)return;let i=new Set(s);i.has(e)?i.delete(e):i.add(e),c(i),u(e),f(null);try{i.size===0?await o(t,a):await b(t,a,[...i]),r()}catch(e){c(new Set(n)),f(e instanceof Error?e.message:String(e))}finally{u(null)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:z(e)}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e),onChange:()=>void p(e),disabled:l!==null}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]},e))}),d&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(h,{size:11}),` `,d]})]})}function J({servers:e,expanded:t,onToggle:n}){return(0,j.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,j.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,j.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,j.jsx)(Y,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function Y({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,j.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,j.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,j.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,j.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,j.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,j.jsx)(S,{size:11}),` Active`]}),(0,j.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,j.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,j.jsx)(O,{size:14}):(0,j.jsx)(w,{size:14})})]}),t&&(0,j.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,j.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,j.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,j.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,j.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function X({connectorId:e,connectorType:t}){let{agents:n}=l(),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({}),[s,c]=(0,M.useState)(!0),u=(0,M.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([m(e),g(e)]);i(t),o(n)}catch{i({}),o({})}finally{c(!1)}},[e]);if((0,M.useEffect)(()=>{u()},[u]),F((0,M.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&u()},[e,u])),s)return null;let d=n.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),f=t===`mcp_server`?n.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return(0,j.jsxs)(`div`,{className:`connection-grants`,children:[(0,j.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),d.length===0?(0,j.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):d.map(t=>(0,j.jsx)(q,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void u()},t.namespaced_agent_id)),f.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,j.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),f.map(t=>(0,j.jsx)(Z,{agent:t,connectorId:e,active:!!a[t.namespaced_agent_id],grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void u()},`activation-${t.namespaced_agent_id}`))]})]})}function Z({agent:e,connectorId:t,active:n,grantedScopes:r,onChanged:i}){let a=e.required_connections?.find(e=>e.connector_id===t),o=e.namespaced_agent_id;if(!o)return null;let[s,c]=(0,M.useState)(n),[l,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(null);(0,M.useEffect)(()=>{c(n)},[n]);let g=async()=>{if(l)return;let e=!s;c(e),f(!0),m(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...B]:void 0;await d(t,o,e)}else await u(t,o);i()}catch(e){c(n),m(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,j.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,j.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,j.jsx)(`div`,{className:`grant-scope-list`,children:(0,j.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,j.jsx)(`span`,{className:`grant-scope-label`,children:s?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,j.jsxs)(`span`,{className:`toggle-switch`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s,onChange:()=>void g(),disabled:l}),(0,j.jsx)(`span`,{className:`toggle-track`})]})]})}),p&&(0,j.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,j.jsx)(h,{size:11}),` `,p]})]})}function Q(){return(0,j.jsxs)(`div`,{className:`settings-pane`,children:[(0,j.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,j.jsx)(H,{})]})}export{Q as ConnectorsPane};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{$ as a,G as o,H as s,Jt as c,Lt as l,Mt as u,Nt as d,Pt as f,St as p,Tt as m,U as ee,Ut as te,V as ne,Vt as re,Xt as ie,Y as h,an as g,at as _,nn as v,t as y,yt as b,zt as x}from"./index-DEPbenxC.js";import{t as S}from"./useEscapeToClose-B8fw5mn-.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(n(),1),k=i();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:i,currentSessionId:C,sessions:T,updateSessionInList:E,draftDocumentIds:D,addDraftDocuments:j,removeDraftDocument:M}=f(),N=T.find(e=>e.id===C)??null,P=(0,O.useCallback)(()=>n(!1),[n]);S(!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)(()=>{r.doc.info(`Loading document library...`);let e=r.doc.time();b().then(n=>{let i=n.documents||[];t(i),r.doc.timed(`Loaded ${i.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{r.doc.error(`Failed to load documents`,e),t([])})},[t]);let J=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,O.useEffect)(()=>{if(!J)return;let e=f.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=f.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await _(n.id);if(e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){q.current.delete(n.id);let e=await b();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 b()).documents||[],n=f.getState().documents;(e.length!==n.length||e.some((e,t)=>{let r=n.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(t(e),r.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let 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 i=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;if(i&&!ee(i)){let t=s(i),n=t?t.message:`The file type "${i}" is not supported for indexing.`;r.doc.warn(`Unsupported file type: ${e} (${i})`),W({filename:e,error:n});return}r.doc.info(`Indexing document: ${e}`);let a=r.doc.time();R(!0),B(`Indexing ${e}...`),W(null);try{let i=await n();if(r.doc.timed(`Indexed "${e}": ${i?.chunk_count||`?`} chunks`,a),C&&i?.id)try{await o(C,i.id);let t=f.getState().sessions.find(e=>e.id===C)?.document_ids??[];t.includes(i.id)||E(C,{document_ids:[...t,i.id]}),r.doc.info(`Auto-attached "${e}" to session ${C}`)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}else i?.id&&(j([i.id]),r.doc.info(`"${e}" will be attached to the next new chat`));let s=await b();t(s.documents||[]),B(``)}catch(t){r.doc.error(`Failed to index "${e}"`,t);let n=t instanceof Error?t.message:`Upload failed`;W({filename:e,error:n}),B(``)}finally{R(!1)}},[C,E,t,j]),Z=(0,O.useCallback)(async(e,t)=>{await X(t,()=>d(e))},[X]),Q=(0,O.useCallback)(async e=>{await X(e.name,()=>u(e))},[X]),fe=(0,O.useCallback)(async e=>{e.preventDefault(),I(!1);let t=Array.from(e.dataTransfer.files);r.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),pe=(0,O.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Deleting document: ${i?.filename||n}`);try{await a(n),q.current.delete(n),M(n),t(e.filter(e=>e.id!==n)),r.doc.info(`Deleted document: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to delete document: ${i?.filename||n}`,e)}},[e,t,M]),me=(0,O.useCallback)(async(e,t)=>{r.doc.info(`Opening folder for: ${e}`);try{await p(e,!0)}catch(e){r.doc.error(`Failed to open folder for: ${t}`,e)}},[]),he=(0,O.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Cancelling indexing for: ${i?.filename||n}`);try{await h(n),q.current.delete(n);let e=await b();t(e.documents||[]),r.doc.info(`Cancelled indexing for: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to cancel indexing: ${i?.filename||n}`,e)}},[e,t]),ge=(0,O.useCallback)(async n=>{if(G.has(n))return;let i=e.find(e=>e.id===n);r.doc.info(`Reindexing document: ${i?.filename||n}`),K(e=>new Set(e).add(n));try{await m(n),r.doc.info(`Reindex complete for: ${i?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);r.doc.error(`Reindex failed for: ${i?.filename||n}`,e),W({filename:i?.filename||n,error:t})}finally{try{let e=await b();t(e.documents||[])}catch(e){r.doc.error(`Failed to refresh documents after reindex`,e)}K(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,G]),$=(0,O.useCallback)(async t=>{let n=e.find(e=>e.id===t);if(!C){j([t]),r.doc.info(`"${n?.filename||t}" will be attached to the next new chat`);return}r.doc.info(`Attaching document to session: ${n?.filename||t}`);try{await o(C,t);let e=f.getState().sessions.find(e=>e.id===C)?.document_ids??[];e.includes(t)||E(C,{document_ids:[...e,t]}),r.doc.info(`Attached "${n?.filename||t}" to session ${C}`)}catch(e){r.doc.error(`Failed to attach document to session: ${n?.filename||t}`,e)}},[C,e,E,j]),_e=(0,O.useCallback)(async e=>{e.preventDefault(),V.trim()&&(r.doc.info(`Indexing from path input: ${V.trim()}`),await Z(V.trim(),V.trim().split(/[\\/]/).pop()||`file`),H(``))},[V,Z]),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)(g,{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)(g,{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)(v,{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)(l,{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)(x,{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)(c,{size:16,className:`path-icon`}),(0,k.jsx)(`input`,{type:`text`,className:`path-input`,value:V,onChange:e=>H(e.target.value),placeholder:`Or enter file path: C:\\docs\\manual.pdf`,"aria-label":`File path to index`}),(0,k.jsx)(`button`,{type:`submit`,className:`btn-secondary`,disabled:!V.trim()||L,children:`Index`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(!1),i(!0)},title:`Browse files on this computer`,children:[(0,k.jsx)(te,{size:14}),`Browse Files`]})]}),U&&(0,k.jsx)(ne,{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)(ie,{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)(c,{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)(re,{size:14})})]})]},e.id))]})]})]})})}export{j as DocumentLibrary};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{Dt as a,G as o,H as s,J as c,Jt as l,Lt as u,Nt as d,Pt as f,Qt as p,U as m,Ut as ee,V as te,Xt as h,Yt as g,ln as ne,mt as _,on as re,t as ie,un as ae,wt as oe,yt as v,zt as se}from"./index-DEPbenxC.js";import{t as ce}from"./useEscapeToClose-B8fw5mn-.js";var y={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`}]]};y.node;var b=t(y),x={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};x.node;var le=t(x),S={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};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 ue=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:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};D.node;var O=t(D),k={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`}]]};k.node;var A=t(k),j=e(n(),1),M=i();function de(e){if(e.type===`folder`)return(0,M.jsx)(C,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?(0,M.jsx)(A,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?(0,M.jsx)(b,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?(0,M.jsx)(h,{size:16}):(0,M.jsx)(g,{size:16})}function fe(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 pe(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function me(e){switch(e){case`home`:return(0,M.jsx)(E,{size:14});case`desktop`:return(0,M.jsx)(O,{size:14});case`documents`:return(0,M.jsx)(h,{size:14});case`download`:return(0,M.jsx)(p,{size:14});default:return(0,M.jsx)(C,{size:14})}}var he=[{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 N(e,t,n,i){let a=[],s=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!m(e)?s.push(t):a.push(t)}let c=[],l=[],u=0,p=``,ee=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(ee.has(e)){let t=await _(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),n.length>0&&(n.forEach(e=>c.push(e)),l.push(e))}else{let t=await d(e);t?.id&&(c.push(t.id),l.push(e))}}catch(e){u++,p=e instanceof Error?e.message:`Unknown error`}if(n&&c.length>0){let e=[];for(let t of c)try{await o(n,t),e.push(t)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}let t=f.getState().sessions.find(e=>e.id===n)?.document_ids??[],a=e.filter(e=>!t.includes(e));a.length>0&&i(n,{document_ids:[...t,...a]})}else c.length>0&&f.getState().addDraftDocuments(c);if(c.length>0)try{let e=await v();f.getState().setDocuments(e.documents||[])}catch(e){r.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:c,supported:a,succeededFiles:l,unsupported:s,failed:u,lastError:p}}function P(){let{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n,setPendingPrompt:i}=f(),o=(0,j.useCallback)(()=>e(!1),[e]);ce(!0,o);let[d,p]=(0,j.useState)(``),[h,g]=(0,j.useState)(null),[_,v]=(0,j.useState)([]),[y,b]=(0,j.useState)([]),[x,S]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(``),[D,O]=(0,j.useState)(null),[k,A]=(0,j.useState)([]),[P,ge]=(0,j.useState)(!1),[F,I]=(0,j.useState)(!1),[L,_e]=(0,j.useState)(``),[R,z]=(0,j.useState)(new Set),[B,V]=(0,j.useState)(null),[ve,H]=(0,j.useState)(!1),[U,W]=(0,j.useState)(new Set),[G,K]=(0,j.useState)(null),q=(0,j.useRef)(null),[J,Y]=(0,j.useState)(null),X=(0,j.useCallback)(async e=>{S(!0),w(null),O(null),E(``),A([]);try{let t=await c(e);p(t.current_path),g(t.parent_path),v(t.entries),t.quick_links.length>0&&b(t.quick_links),r.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;w(t),r.ui.error(`Browse failed`,e)}finally{S(!1)}},[]);(0,j.useEffect)(()=>{X()},[X]),(0,j.useEffect)(()=>()=>{q.current&&clearTimeout(q.current)},[]);let Z=(0,j.useCallback)(async()=>{if(!T.trim()){O(null),A([]);return}I(!0),w(null);try{let e=await a(T.trim(),L||void 0,30);O(e.results),A(e.searched_locations??[]),ge(e.truncated===!0),r.ui.info(`Search "${T}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;w(t),r.ui.error(`Search failed`,e)}finally{I(!1)}},[T,L]),ye=e=>{e.key===`Enter`&&Z()},Q=(0,j.useCallback)(e=>{e.type===`folder`&&(X(e.path),z(new Set),V(null))},[X]),be=(0,j.useCallback)(async e=>{H(!0);try{let t=await oe(e);V(t)}catch(e){r.ui.error(`Preview failed`,e)}finally{H(!1)}},[]),$=(0,j.useCallback)(e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),xe=(0,j.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||m(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=s(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 N(e,_,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){r.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,_]),Se=(0,j.useCallback)(async()=>{if(R.size===0)return;let a=Array.from(R);Y(null),W(new Set(a)),K(`Indexing ${a.length} file(s) for analysis...`);try{let r=await N(a,_,t,n);if(r.supported.length===0){let e=a[0].lastIndexOf(`.`),t=e>0?a[0].slice(e).toLowerCase():``,n=s(t);Y({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(r.docIds.length===0){Y({filename:r.supported.length===1?r.supported[0].split(/[\\/]/).pop()||r.supported[0]:`${r.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}r.failed>0&&K(`Warning: ${r.failed} file(s) failed to index and will be excluded.`);let o=(r.succeededFiles.length>0?r.succeededFiles:r.supported).map(e=>e.split(/[\\/]/).pop()||e),c=o.length===1?`Please analyze this document for me: ${o[0]}`:`Please analyze these documents for me:\n${o.map(e=>`- ${e}`).join(`
|
|
2
|
+
`)}`;i(c),e(!1),z(new Set)}catch(e){r.doc.error(`Ask Agent failed`,e),Y({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{W(new Set),K(null)}},[R,t,n,_,i,e]),Ce=d?d.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],we=Ce.map((e,t)=>({label:e,path:Ce.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Te=pe(k),Ee=D?D.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):_;return(0,M.jsx)(`div`,{className:`modal-overlay`,onClick:()=>e(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File Browser`,children:(0,M.jsxs)(`div`,{className:`modal-panel file-browser-modal ${B?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`modal-header`,children:[(0,M.jsxs)(`h3`,{children:[(0,M.jsx)(l,{size:18}),` File Browser`]}),(0,M.jsx)(`button`,{className:`btn-icon`,onClick:()=>e(!1),"aria-label":`Close`,children:(0,M.jsx)(u,{size:18})})]}),(0,M.jsxs)(`div`,{className:`file-browser-body`,children:[(0,M.jsx)(`div`,{className:`fb-quick-links`,children:y.map(e=>(0,M.jsxs)(`button`,{className:`fb-quick-link`,onClick:()=>X(e.path),title:e.path,children:[me(e.icon),(0,M.jsx)(`span`,{children:e.name})]},e.path))}),(0,M.jsxs)(`div`,{className:`fb-search-bar`,children:[(0,M.jsxs)(`div`,{className:`fb-search-input-wrap`,children:[(0,M.jsx)(ee,{size:14,className:`fb-search-icon`}),(0,M.jsx)(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:T,onChange:e=>E(e.target.value),onKeyDown:ye,"aria-label":`Search files`}),T&&(0,M.jsx)(`button`,{className:`fb-search-clear`,onClick:()=>{E(``),O(null),A([])},"aria-label":`Clear search`,children:(0,M.jsx)(u,{size:12})})]}),(0,M.jsx)(`select`,{className:`fb-type-filter`,value:L,onChange:e=>_e(e.target.value),"aria-label":`File type filter`,children:he.map(e=>(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,M.jsx)(`button`,{className:`fb-search-btn`,onClick:Z,disabled:!T.trim()||F,children:F?`Searching...`:`Search`})]}),!D&&(0,M.jsxs)(`div`,{className:`fb-breadcrumb`,children:[(0,M.jsx)(`button`,{className:`fb-crumb`,onClick:()=>X(`/`),children:(0,M.jsx)(ue,{size:12})}),we.map((e,t)=>(0,M.jsxs)(`span`,{className:`fb-crumb-item`,children:[(0,M.jsx)(re,{size:12,className:`fb-crumb-sep`}),(0,M.jsx)(`button`,{className:`fb-crumb`,onClick:()=>X(e.path),children:e.label})]},t)),h&&(0,M.jsx)(`button`,{className:`fb-up-btn`,onClick:()=>X(h),title:`Go up`,children:(0,M.jsx)(ae,{size:14})})]}),D&&(0,M.jsxs)(`div`,{className:`fb-search-header`,children:[(0,M.jsxs)(`div`,{className:`fb-search-summary`,children:[(0,M.jsxs)(`span`,{children:[`Found `,D.length,` result(s) for "`,T,`"`]}),Te&&(0,M.jsxs)(`span`,{className:`fb-search-scope`,title:k.join(`
|
|
3
|
+
`),children:[`Searching in: `,(0,M.jsx)(`code`,{children:Te})]}),P&&(0,M.jsx)(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),(0,M.jsx)(`button`,{className:`fb-back-btn`,onClick:()=>{O(null),E(``),A([])},children:`Back to browsing`})]}),C&&(0,M.jsx)(`div`,{className:`fb-error`,children:C}),(0,M.jsxs)(`div`,{className:`fb-content`,children:[(0,M.jsxs)(`div`,{className:`fb-file-list`,children:[x&&(0,M.jsx)(`div`,{className:`fb-loading`,children:`Loading...`}),!x&&Ee.length===0&&(0,M.jsx)(`div`,{className:`fb-empty`,children:D?`No files found`:`This folder is empty`}),!x&&Ee.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!m(t),r=n?s(t):null;return(0,M.jsxs)(`div`,{className:`fb-entry ${e.type} ${R.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?Q(e):$(e.path),onDoubleClick:()=>e.type===`folder`?Q(e):void 0,title:n?`${r?.label||`This`} file type cannot be indexed`:e.path,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:R.has(e.path),onChange:()=>$(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),(0,M.jsx)(`span`,{className:`fb-entry-icon`,children:de(e)}),(0,M.jsx)(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&(0,M.jsx)(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&(0,M.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,M.jsx)(le,{size:14})}),(0,M.jsx)(`span`,{className:`fb-entry-size`,children:e.type===`file`?ie(e.size):``}),(0,M.jsx)(`span`,{className:`fb-entry-date`,children:fe(e.modified)})]},e.path)})]}),B&&(0,M.jsxs)(`div`,{className:`fb-preview`,children:[(0,M.jsxs)(`div`,{className:`fb-preview-header`,children:[(0,M.jsx)(`span`,{className:`fb-preview-name`,children:B.name}),(0,M.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>V(null),"aria-label":`Close preview`,children:(0,M.jsx)(u,{size:14})})]}),(0,M.jsxs)(`div`,{className:`fb-preview-meta`,children:[(0,M.jsx)(`span`,{children:B.size_display}),B.total_lines&&(0,M.jsxs)(`span`,{children:[B.total_lines,` lines`]}),B.columns&&(0,M.jsxs)(`span`,{children:[B.columns.length,` columns`]}),B.row_count!==null&&(0,M.jsxs)(`span`,{children:[B.row_count,` rows`]})]}),B.columns&&(0,M.jsxs)(`div`,{className:`fb-preview-columns`,children:[(0,M.jsx)(`strong`,{children:`Columns:`}),` `,B.columns.join(`, `)]}),ve?(0,M.jsx)(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):B.is_text&&B.preview_lines.length>0?(0,M.jsx)(`pre`,{className:`fb-preview-content`,children:B.preview_lines.slice(0,30).join(`
|
|
4
|
+
`)}):(0,M.jsx)(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),J&&(0,M.jsx)(te,{filename:J.filename,error:J.error,onDismiss:()=>Y(null)}),(0,M.jsxs)(`div`,{className:`fb-actions`,children:[(0,M.jsx)(`div`,{className:`fb-selection-info`,children:R.size>0?`${R.size} item(s) selected`:`Select files to index or analyze`}),G&&(0,M.jsx)(`span`,{className:`fb-index-status`,children:G}),(0,M.jsxs)(`div`,{className:`fb-action-btns`,children:[(0,M.jsxs)(`button`,{className:`fb-action-btn secondary`,onClick:xe,disabled:R.size===0||U.size>0,title:`Index selected files for RAG search`,children:[(0,M.jsx)(se,{size:14}),`Index Selected`]}),(0,M.jsxs)(`button`,{className:`fb-action-btn primary`,onClick:Se,disabled:R.size===0||U.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[(0,M.jsx)(ne,{size:14}),`Ask Agent`]})]})]})]})]})})}export{P as FileBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.memory-dashboard-page{background:var(--bg-primary);flex-direction:column;height:100%;display:flex;overflow:hidden}.memory-dashboard-header{border-bottom:1px solid var(--border-light);flex-shrink:0;justify-content:space-between;align-items:center;padding:16px 24px;display:flex}.memory-dashboard-header-left{align-items:center;gap:12px;display:flex}.memory-dashboard-header h1{font-size:15px;font-weight:600;font-family:var(--font-sans);color:var(--text-primary)}.memory-dashboard-header-actions{align-items:center;gap:6px;display:flex}.memory-dashboard-body{scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex:1;padding:24px;overflow-y:auto;container-type:inline-size}.memory-dashboard-body::-webkit-scrollbar{width:5px}.memory-dashboard-body::-webkit-scrollbar-track{background:0 0}.memory-dashboard-body::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--radius-full)}.mem-section{margin-bottom:28px}.mem-section:last-child{margin-bottom:0}.mem-section-title{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:2px;color:var(--text-muted);align-items:center;gap:8px;margin-bottom:14px;display:flex}.mem-section-title-row{justify-content:space-between}.mem-section-title-left{align-items:center;gap:8px;display:flex}.mem-section-note{letter-spacing:.5px;text-transform:none;opacity:.8;margin-left:8px;font-weight:400}.mem-section-count{background:var(--bg-tertiary);border:1px solid var(--border);border-radius:var(--radius-full);min-width:20px;height:18px;color:var(--text-muted);letter-spacing:0;font-size:10px;font-weight:700;font-family:var(--font-mono);justify-content:center;align-items:center;padding:0 6px;display:inline-flex}.mem-section-add-btn{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:.5px;border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-secondary);color:var(--text-secondary);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:4px 10px;display:inline-flex}.mem-section-add-btn:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-dim)}.mem-range-tabs{border:1px solid var(--border);border-radius:var(--radius-md);display:flex;overflow:hidden}.mem-range-tab{font-size:10px;font-weight:700;font-family:var(--font-mono);letter-spacing:.5px;color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);background:0 0;border:none;padding:3px 10px}.mem-range-tab+.mem-range-tab{border-left:1px solid var(--border)}.mem-range-tab:hover{color:var(--text-primary);background:var(--bg-hover)}.mem-range-tab.active{background:var(--accent-fill);color:var(--accent-fill-text)}.mem-disabled-banner{background:color-mix(in srgb, var(--accent) 8%, transparent);border:1px solid color-mix(in srgb, var(--accent) 25%, transparent);border-radius:var(--radius-md);color:var(--accent);font-size:12px;font-family:var(--font-sans);align-items:center;gap:10px;margin-bottom:20px;padding:10px 16px;display:flex}.mem-disabled-banner svg{flex-shrink:0}.mem-disabled-banner span{flex:1}.mem-disabled-banner-action{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:.5px;border-radius:var(--radius-md);border:1px solid color-mix(in srgb, var(--accent) 40%, transparent);color:var(--accent);cursor:pointer;transition:all var(--duration) var(--ease);background:0 0;flex-shrink:0;padding:4px 12px}.mem-disabled-banner-action:hover{background:color-mix(in srgb, var(--accent) 15%, transparent);border-color:var(--accent)}.mem-stat-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:28px;display:grid}.mem-stat-card{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);transition:border-color var(--duration) var(--ease), transform var(--duration) var(--ease);padding:18px 20px}.mem-stat-card:hover{border-color:var(--border);transform:translateY(-1px)}.mem-stat-value{font-size:28px;font-weight:700;font-family:var(--font-display);color:var(--text-primary);line-height:1.1}.mem-stat-label{color:var(--text-secondary);font-size:12px;font-weight:500;font-family:var(--font-sans);margin-top:4px}.mem-stat-sub{color:var(--text-muted);font-size:11px;font-family:var(--font-mono);margin-top:2px}.mem-stat-card[data-accent=purple] .mem-stat-value{color:var(--accent-purple)}.mem-stat-card[data-accent=blue] .mem-stat-value{color:var(--accent-blue)}.mem-stat-card[data-accent=green] .mem-stat-value{color:var(--accent-green)}.mem-stat-card[data-accent=red] .mem-stat-value{color:var(--accent)}.mem-stat-card[data-accent=gold] .mem-stat-value{color:var(--accent-yellow)}.mem-activity-chart{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);align-items:flex-end;gap:2px;height:120px;padding:14px 10px 28px;display:flex;position:relative;overflow:hidden}.mem-activity-bar-group{cursor:default;flex-direction:column;flex:1;justify-content:flex-end;align-items:center;gap:1px;height:100%;display:flex;position:relative}.mem-activity-bar{width:100%;min-height:0;transition:opacity var(--duration-fast) var(--ease);border-radius:2px 2px 0 0}.mem-activity-bar.conversations{background:var(--accent-blue);opacity:.85}.mem-activity-bar.tool_calls{background:var(--accent-green);opacity:.85}.mem-activity-bar.knowledge{background:var(--accent-purple);opacity:.85}.mem-activity-bar.errors{background:var(--danger);opacity:.85}.mem-activity-bar-group:hover .mem-activity-bar{opacity:1}.mem-activity-date-label{color:var(--text-muted);font-size:9px;font-family:var(--font-mono);white-space:nowrap;position:absolute;bottom:-22px}.mem-activity-legend{font-size:11px;font-family:var(--font-mono);color:var(--text-secondary);gap:16px;margin-top:10px;display:flex}.mem-activity-legend-item{align-items:center;gap:5px;display:flex}.mem-activity-legend-dot{border-radius:2px;width:8px;height:8px}.mem-activity-legend-dot.conversations{background:var(--accent-blue)}.mem-activity-legend-dot.tool_calls{background:var(--accent-green)}.mem-activity-legend-dot.knowledge{background:var(--accent-purple)}.mem-activity-legend-dot.errors{background:var(--danger)}.mem-activity-tooltip{background:var(--bg-tertiary);border:1px solid var(--border);border-radius:var(--radius-sm);font-size:11px;font-family:var(--font-mono);color:var(--text-primary);white-space:nowrap;pointer-events:none;z-index:10;box-shadow:var(--shadow-md);padding:6px 10px;position:absolute;bottom:calc(100% + 8px);left:50%;transform:translate(-50%)}.mem-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.mem-filter-select{font-size:12px;font-family:var(--font-mono);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);cursor:pointer;transition:border-color var(--duration) var(--ease);appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right 8px center;background-repeat:no-repeat;outline:none;padding:7px 28px 7px 12px}.mem-filter-select:focus{border-color:var(--accent)}.mem-category-pills{flex-wrap:wrap;align-items:center;gap:5px;display:flex}.mem-category-pill{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:.5px;border-radius:var(--radius-full);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);white-space:nowrap;background:0 0;padding:4px 11px;line-height:1.4}.mem-category-pill:hover{border-color:var(--text-secondary);color:var(--text-primary);background:var(--bg-hover)}.mem-category-pill:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.mem-category-pill.fact.active{background:color-mix(in srgb, var(--accent-blue) 12%, transparent);border-color:var(--accent-blue);color:var(--accent-blue)}.mem-category-pill.preference.active{background:color-mix(in srgb, var(--accent-purple) 12%, transparent);border-color:var(--accent-purple);color:var(--accent-purple)}.mem-category-pill.error.active{background:var(--danger-dim);border-color:var(--danger);color:var(--danger)}.mem-category-pill.skill.active{background:var(--accent-green-dim);border-color:var(--accent-green);color:var(--accent-green)}.mem-category-pill.note.active{background:color-mix(in srgb, var(--accent-yellow) 12%, transparent);border-color:var(--accent-yellow);color:var(--accent-yellow)}.mem-category-pill.reminder.active{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:var(--accent);color:var(--accent)}.mem-category-pill.clear{border-style:dashed}.mem-category-pill.clear:hover{border-color:var(--danger);color:var(--danger);background:var(--danger-dim);border-style:solid}.mem-filter-search{box-sizing:border-box;width:100%;min-width:180px;font-size:12px;font-family:var(--font-mono);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;flex:1;padding:7px 12px 7px 32px}.mem-filter-search:focus{border-color:var(--accent)}.mem-filter-search::placeholder{color:var(--text-muted)}.mem-filter-search-wrap{flex:1;min-width:180px;position:relative}.mem-filter-search-wrap .search-icon{color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:10px;transform:translateY(-50%)}.mem-knowledge-table{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}.mem-knowledge-table th{text-align:left;font-size:10px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1.5px;color:var(--text-muted);border-bottom:1px solid var(--border);white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:color var(--duration) var(--ease);padding:8px 12px}.mem-knowledge-table th:hover{color:var(--text-primary)}.mem-knowledge-table th.sorted{color:var(--accent)}.mem-sort-arrow{margin-left:4px;font-size:10px}.mem-knowledge-table td{border-bottom:1px solid var(--border-light);vertical-align:top;font-family:var(--font-sans);padding:10px 12px}.mem-knowledge-table tbody tr{transition:background var(--duration-fast) var(--ease)}.mem-knowledge-table tbody tr:hover{background:var(--tint-subtle)}.mem-cat-badge{font-size:10px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:.5px;border-radius:var(--radius-full);white-space:nowrap;padding:2px 8px;display:inline-block}.mem-cat-badge.fact{background:color-mix(in srgb, var(--accent-blue) 12%, transparent);color:var(--accent-blue)}.mem-cat-badge.preference{background:color-mix(in srgb, var(--accent-purple) 12%, transparent);color:var(--accent-purple)}.mem-cat-badge.error{background:var(--danger-dim);color:var(--danger)}.mem-cat-badge.skill{background:var(--accent-green-dim);color:var(--accent-green)}.mem-confidence{font-family:var(--font-mono);color:var(--text-secondary);align-items:center;gap:6px;font-size:12px;display:flex}.mem-confidence-bar{background:var(--border);border-radius:var(--radius-full);width:48px;height:4px;overflow:hidden}.mem-confidence-fill{border-radius:var(--radius-full);height:100%;transition:width .3s var(--ease)}.mem-confidence-fill.high{background:var(--accent-green)}.mem-confidence-fill.medium{background:var(--accent-yellow)}.mem-confidence-fill.low{background:var(--text-muted)}.mem-content-cell{text-overflow:ellipsis;white-space:nowrap;max-width:320px;overflow:hidden}.mem-sensitive-blur{filter:blur(4px);cursor:pointer;transition:filter var(--duration) var(--ease);-webkit-user-select:none;user-select:none}.mem-sensitive-blur:hover,.mem-sensitive-blur.revealed{filter:none}.mem-sensitive-badge{align-items:center;gap:3px;margin-right:4px;font-size:11px;display:inline-flex}.mem-entity-link{color:var(--accent-blue);cursor:pointer;font-size:11px;font-family:var(--font-mono);align-items:center;gap:3px;display:inline-flex}.mem-entity-link:hover{text-decoration:underline}.mem-due-badge{font-size:11px;font-family:var(--font-mono);white-space:nowrap}.mem-due-badge.overdue{color:var(--danger)}.mem-due-badge.upcoming{color:var(--accent-yellow)}.mem-due-badge.none{color:var(--text-muted)}.mem-date-cell{font-size:12px;font-family:var(--font-mono);color:var(--text-secondary);white-space:nowrap}.mem-row-actions{opacity:0;transition:opacity var(--duration-fast) var(--ease);gap:2px;display:flex}.mem-knowledge-table tbody tr:hover .mem-row-actions,.mem-knowledge-table tbody tr:focus-within .mem-row-actions{opacity:1}.mem-row-actions:has(.is-confirm){opacity:1}.mem-knowledge-table .mem-actions-cell{background:var(--bg-primary);position:sticky;right:0;box-shadow:-8px 0 8px -8px #00000059}.mem-knowledge-table tbody tr:hover .mem-actions-cell,.mem-knowledge-table .mem-expanded-row .mem-actions-cell{background:color-mix(in srgb, var(--text-primary) 3%, var(--bg-primary))}.mem-row-action-btn{border-radius:var(--radius-sm);width:26px;height:26px;color:var(--text-muted);transition:all var(--duration-fast) var(--ease);justify-content:center;align-items:center;display:flex}.mem-row-action-btn:hover{background:var(--bg-hover);color:var(--text-primary)}.mem-row-action-btn.delete:hover,.mem-row-action-btn.delete.is-confirm{color:var(--danger)}.mem-row-action-btn.is-confirm{width:auto;padding:0 6px}.mem-row-delete-label{font-size:11px;font-weight:600}.mem-pagination{font-size:12px;font-family:var(--font-mono);color:var(--text-muted);justify-content:space-between;align-items:center;margin-top:12px;display:flex}.mem-pagination-btns{gap:4px;display:flex}.mem-page-btn{border:1px solid var(--border);border-radius:var(--radius-sm);font-size:12px;font-family:var(--font-mono);color:var(--text-secondary);transition:all var(--duration) var(--ease);padding:4px 12px}.mem-page-btn:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}.mem-page-btn:disabled{opacity:.3;cursor:not-allowed}.mem-add-btn{border:1px dashed var(--border);border-radius:var(--radius-md);font-size:12px;font-family:var(--font-mono);color:var(--text-secondary);transition:all var(--duration) var(--ease);align-items:center;gap:6px;margin-top:8px;padding:7px 16px;display:inline-flex}.mem-add-btn:hover{border-color:var(--accent);color:var(--accent);border-style:solid}.mem-tool-table{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}.mem-tool-table th{text-align:left;font-size:10px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1.5px;color:var(--text-muted);border-bottom:1px solid var(--border);white-space:nowrap;padding:8px 12px}.mem-tool-table td{border-bottom:1px solid var(--border-light);font-family:var(--font-mono);padding:10px 12px;font-size:12px}.mem-tool-table tbody tr{transition:background var(--duration-fast) var(--ease);cursor:default}.mem-tool-table tbody tr:hover{background:var(--tint-subtle)}.mem-tool-name{color:var(--text-primary);font-weight:500}.mem-success-rate{font-weight:600}.mem-success-rate.high{color:var(--accent-green)}.mem-success-rate.medium{color:var(--accent-yellow)}.mem-success-rate.low{color:var(--danger)}.mem-tool-error{vertical-align:top;text-overflow:ellipsis;white-space:nowrap;max-width:260px;color:var(--text-muted);font-size:11px;display:inline-block;overflow:hidden}.mem-conv-search{margin-bottom:12px;position:relative}.mem-conv-search .search-icon{color:var(--text-muted);pointer-events:none;position:absolute;top:50%;left:10px;transform:translateY(-50%)}.mem-conv-search input{width:100%;font-size:12px;font-family:var(--font-mono);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;padding:8px 12px 8px 32px}.mem-conv-search input:focus{border-color:var(--accent)}.mem-conv-search input{padding-right:32px}.mem-search-clear{border-radius:var(--radius-full);background:var(--bg-tertiary);width:20px;height:20px;color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);border:none;justify-content:center;align-items:center;display:flex;position:absolute;top:50%;right:8px;transform:translateY(-50%)}.mem-search-clear:hover{background:var(--border);color:var(--text-primary)}.mem-delete-confirm{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mem-delete-confirm-label{color:var(--danger);font-size:12px;font-weight:600;font-family:var(--font-mono);white-space:nowrap}.mem-conv-list{flex-direction:column;gap:4px;display:flex}.mem-conv-item{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease), background var(--duration) var(--ease);cursor:pointer;justify-content:space-between;align-items:center;padding:10px 14px;display:flex}.mem-conv-item:hover{border-color:var(--border);background:var(--tint-subtle)}.mem-conv-info{flex:1;min-width:0}.mem-conv-session-id{color:var(--text-primary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:500;overflow:hidden}.mem-conv-preview{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;margin-top:2px;font-size:12px;overflow:hidden}.mem-conv-meta{font-size:11px;font-family:var(--font-mono);color:var(--text-muted);flex-shrink:0;gap:12px;margin-left:12px;display:flex}.mem-conv-detail-overlay{background:var(--bg-card);z-index:5;border-radius:var(--radius-xl);flex-direction:column;display:flex;position:absolute;inset:0}.mem-conv-detail-header{border-bottom:1px solid var(--border);flex-shrink:0;justify-content:space-between;align-items:center;padding:14px 20px;display:flex}.mem-conv-detail-header h2{color:var(--text-secondary);font-size:12px}.mem-conv-detail-actions{align-items:center;gap:8px;display:flex}.mem-conv-detail-body{flex:1;padding:16px 20px;overflow-y:auto}.mem-conv-turn{border-bottom:1px solid var(--border-light);padding:8px 0}.mem-conv-turn:last-child{border-bottom:none}.mem-conv-turn-header{justify-content:space-between;align-items:center;margin-bottom:4px;display:flex}.mem-conv-turn-time{color:var(--text-muted);font-size:10px;font-family:var(--font-mono);flex-shrink:0}.mem-conv-turn-role{font-size:10px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1px;margin-bottom:4px}.mem-conv-turn-role.user{color:var(--accent-blue)}.mem-conv-turn-role.assistant{color:var(--accent-green)}.mem-conv-turn-content{color:var(--text-primary);white-space:pre-wrap;word-break:break-word;font-size:13px;line-height:1.6}.mem-temporal-list{flex-direction:column;gap:6px;display:flex}.mem-temporal-item{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease);align-items:flex-start;gap:10px;padding:10px 14px;font-size:13px;display:flex}.mem-temporal-item:hover{border-color:var(--border)}.mem-temporal-item.overdue{border-left:3px solid var(--danger)}.mem-temporal-item.upcoming{border-left:3px solid var(--accent-yellow)}.mem-temporal-icon{flex-shrink:0;margin-top:1px;font-size:16px;line-height:1}.mem-temporal-content{flex:1;min-width:0}.mem-temporal-text{font-family:var(--font-sans);color:var(--text-primary)}.mem-temporal-date{font-size:11px;font-family:var(--font-mono);color:var(--text-muted);margin-top:2px}.mem-two-col{grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;display:grid}.mem-two-col>*{min-width:0}@container (width<=860px){.mem-two-col{grid-template-columns:minmax(0,1fr)}}@container (width<=640px){.mem-stat-cards{grid-template-columns:repeat(2,minmax(0,1fr))}}.mem-empty{text-align:center;color:var(--text-muted);font-size:13px;font-family:var(--font-sans);padding:32px 20px}.mem-empty-icon{opacity:.4;margin-bottom:8px;font-size:32px}.mem-loading{color:var(--text-muted);font-size:13px;font-family:var(--font-mono);justify-content:center;align-items:center;gap:10px;padding:40px;display:flex}.mem-spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:18px;height:18px;animation:.8s linear infinite spin}.mem-inline-form{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;gap:10px;margin-bottom:12px;padding:16px;display:flex}.mem-inline-form-row{align-items:center;gap:8px;display:flex}.mem-inline-form-row label{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1px;color:var(--text-muted);flex-shrink:0;width:80px}.mem-inline-form-row input,.mem-inline-form-row select,.mem-inline-form-row textarea{font-size:12px;font-family:var(--font-mono);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;flex:1;padding:7px 12px}.mem-inline-form-row input:focus,.mem-inline-form-row select:focus,.mem-inline-form-row textarea:focus{border-color:var(--accent)}.mem-inline-form-row textarea{resize:vertical;min-height:60px}.mem-inline-form-actions{justify-content:flex-end;gap:8px;display:flex}.mem-expanded-row{background:var(--tint-subtle)!important}.mem-detail-row td{border-bottom:1px solid var(--border)!important;padding:0!important}.mem-detail-panel{background:var(--bg-secondary);border-top:1px solid var(--border-light);animation:detailExpand .2s var(--ease);padding:14px 20px 16px}@keyframes detailExpand{0%{opacity:0;max-height:0}to{opacity:1;max-height:500px}}.mem-detail-grid{grid-template-columns:repeat(4,1fr);gap:10px 20px;margin-bottom:10px;display:grid}.mem-detail-field{flex-direction:column;gap:2px;display:flex}.mem-detail-field.mem-detail-full{grid-column:1/-1}.mem-detail-label{font-size:10px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1px;color:var(--text-muted)}.mem-detail-value{font-size:12px;font-family:var(--font-mono);color:var(--text-primary);word-break:break-all}.mem-detail-chain{color:var(--accent-blue)}.mem-detail-content-full{border-top:1px solid var(--border-light);margin-top:8px;padding-top:8px}.mem-detail-content-text{font-size:13px;font-family:var(--font-sans);color:var(--text-primary);white-space:pre-wrap;word-break:break-word;max-height:200px;margin-top:4px;line-height:1.6;overflow-y:auto}.mem-embedding-coverage{align-items:center;gap:8px;padding:0 8px;display:flex}.mem-embedding-bar{background:var(--border);border-radius:var(--radius-full);width:60px;height:5px;overflow:hidden}.mem-embedding-fill{background:var(--accent-green);border-radius:var(--radius-full);height:100%;transition:width .4s var(--ease)}.mem-embedding-label{font-size:11px;font-family:var(--font-mono);color:var(--text-secondary);white-space:nowrap}.mem-maintenance-wrap{position:relative}.mem-maintenance-wrap .btn-icon{align-items:center;gap:0;display:flex}.mem-maintenance-menu{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);min-width:220px;box-shadow:var(--shadow-lg);z-index:20;animation:modalPanelIn .15s var(--ease);padding:4px;position:absolute;top:calc(100% + 6px);right:0}.mem-maintenance-item{width:100%;font-size:12px;font-family:var(--font-mono);color:var(--text-primary);border-radius:var(--radius-md);transition:background var(--duration-fast) var(--ease);text-align:left;align-items:center;gap:10px;padding:9px 14px;display:flex}.mem-maintenance-item:hover:not(:disabled){background:var(--tint-subtle)}.mem-maintenance-item:disabled{opacity:.5;cursor:not-allowed}.mem-maintenance-divider{background:var(--border-light);height:1px;margin:4px 8px}.mem-spinner-sm{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:14px;height:14px;animation:.8s linear infinite spin}.mem-embed-dot{vertical-align:middle;align-items:center;margin-right:5px;display:inline-flex}.mem-embed-dot.embedded{color:var(--accent-green)}.mem-embed-dot.missing{color:var(--danger);opacity:.6}.mem-superseded-row{opacity:.55}.mem-superseded-text{color:var(--text-muted);text-decoration:line-through}.mem-filter-toggle{font-size:11px;font-family:var(--font-mono);color:var(--text-secondary);cursor:pointer;white-space:nowrap;border:1px solid var(--border);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease);align-items:center;gap:5px;padding:7px 10px;display:flex}.mem-filter-toggle:hover{border-color:var(--border)}.mem-filter-toggle input{cursor:pointer;margin:0}.mem-consolidated-badge{color:var(--accent-green);opacity:.7;vertical-align:middle;align-items:center;margin-left:6px;display:inline-flex}.mem-cat-badge.note{background:color-mix(in srgb, var(--accent-yellow) 12%, transparent);color:var(--accent-yellow)}.mem-cat-badge.reminder{background:color-mix(in srgb, var(--danger) 12%, transparent);color:var(--danger)}.mem-toast-container{z-index:200;pointer-events:none;flex-direction:column;gap:8px;display:flex;position:fixed;bottom:24px;right:24px}.mem-toast{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);font-size:12px;font-family:var(--font-mono);color:var(--text-primary);animation:toastIn .25s var(--ease);pointer-events:auto;align-items:center;gap:8px;padding:10px 18px;display:flex}.mem-toast-success{border-left:3px solid var(--accent-green)}.mem-toast-error{border-left:3px solid var(--danger)}.mem-toast-info{border-left:3px solid var(--accent-blue)}@keyframes toastIn{0%{opacity:0;transform:translateY(10px)scale(.96)}to{opacity:1;transform:none}}.mem-settings-row{justify-content:space-between;align-items:center;gap:16px;padding:10px 0;display:flex}.mem-settings-label{color:var(--text-primary);flex-direction:column;gap:3px;font-size:13px;display:flex}.mem-settings-hint{color:var(--text-muted);max-width:480px;font-size:11px}.mem-toggle{background:var(--border);cursor:pointer;width:40px;height:22px;transition:background var(--duration) var(--ease);border:none;border-radius:11px;flex-shrink:0;padding:0;position:relative}.mem-toggle:disabled{opacity:.5;cursor:not-allowed}.mem-toggle-on{background:var(--accent-green)}.mem-toggle-knob{background:var(--switch-knob);width:16px;height:16px;transition:transform var(--duration) var(--ease);border-radius:50%;position:absolute;top:3px;left:3px}.mem-toggle-on .mem-toggle-knob{transform:translate(18px)}.mem-setting-row{border-bottom:1px solid var(--border-light);justify-content:space-between;align-items:center;gap:16px;padding:10px 0;display:flex}.mem-setting-row:last-child{border-bottom:none}.mem-setting-info{flex-direction:column;flex:1;gap:3px;min-width:0;display:flex}.mem-setting-label{color:var(--text-primary);font-size:12px;font-weight:600}.mem-setting-desc{color:var(--text-muted);font-size:11px;line-height:1.4}.mem-setting-row-danger .mem-setting-label{color:var(--danger)}.mem-btn-danger{border:1px solid var(--danger);color:var(--danger);cursor:pointer;transition:background var(--duration) var(--ease), color var(--duration) var(--ease);white-space:nowrap;background:0 0;border-radius:6px;flex-shrink:0;padding:5px 12px;font-size:11px;font-weight:600}.mem-btn-danger:hover:not(:disabled){background:var(--danger);color:var(--text-inverse)}.mem-btn-danger:disabled{opacity:.5;cursor:not-allowed}.mem-db-footer{border-top:1px solid var(--border-light);font-size:11px;font-family:var(--font-mono);color:var(--text-muted);justify-content:space-between;align-items:center;margin-top:20px;padding-top:14px;display:flex}.mem-tab-bar{border-bottom:1px solid var(--border);background:var(--bg-card);flex-shrink:0;gap:0;padding:0 24px;display:flex}.mem-tab-btn{font-size:12px;font-weight:500;font-family:var(--font-mono);letter-spacing:.5px;color:var(--text-muted);cursor:pointer;transition:color var(--duration) var(--ease), border-color var(--duration) var(--ease);background:0 0;border:none;border-bottom:2px solid #0000;align-items:center;gap:6px;margin-bottom:-1px;padding:10px 18px;display:flex}.mem-tab-btn:hover{color:var(--text-secondary)}.mem-tab-active{color:var(--text-primary);border-bottom-color:var(--accent)}.mem-profile-grid{grid-template-columns:1fr 1fr;gap:20px;display:grid}.mem-profile-card{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);flex-direction:column;gap:10px;padding:20px;display:flex}.mem-profile-card-title{font-size:13px;font-weight:600;font-family:var(--font-mono);color:var(--text-primary);align-items:center;gap:8px;display:flex}.mem-profile-desc{color:var(--text-secondary);margin:0;font-size:12px;line-height:1.5}.mem-profile-note{color:var(--text-muted);margin:0;font-size:11px;font-style:italic}.mem-profile-checkbox{font-size:12px;font-family:var(--font-mono);color:var(--text-secondary);cursor:pointer;align-items:center;gap:6px;display:flex}.mem-profile-checkbox input{cursor:pointer;margin:0}.mem-profile-run-btn{align-self:flex-start;align-items:center;gap:6px;padding:8px 18px;font-size:12px;display:flex}.mem-log{background:var(--bg-code);border:1px solid var(--border-code);border-radius:var(--radius-md);max-height:200px;font-family:var(--font-mono);scrollbar-width:thin;scrollbar-color:var(--border-code) transparent;padding:8px;font-size:12px;line-height:1.6;overflow-y:auto}.mem-log::-webkit-scrollbar{width:4px}.mem-log::-webkit-scrollbar-track{background:0 0}.mem-log::-webkit-scrollbar-thumb{background:var(--border-code);border-radius:2px}.mem-log-line{white-space:pre-wrap;word-break:break-word;color:var(--text-code)}.mem-log-line.finding{color:var(--code-warning)}.mem-log-line.error{color:var(--code-danger)}.mem-review-section{flex-direction:column;gap:8px;display:flex}.mem-review-header{font-size:11px;font-weight:600;font-family:var(--font-mono);text-transform:uppercase;letter-spacing:1.5px;color:var(--text-muted)}.mem-review-list{scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.mem-review-list::-webkit-scrollbar{width:4px}.mem-review-list::-webkit-scrollbar-track{background:0 0}.mem-review-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}.mem-review-item{background:var(--bg-card);border:1px solid var(--border-light);border-radius:var(--radius-md);cursor:pointer;transition:border-color var(--duration) var(--ease);align-items:center;gap:8px;padding:6px 8px;display:flex}.mem-review-item:hover{border-color:var(--border)}.mem-review-item input{cursor:pointer;flex-shrink:0;margin:0}.mem-review-content{min-width:0;color:var(--text-primary);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:12px;overflow:hidden}.mem-conf-badge{font-size:10px;font-family:var(--font-mono);border-radius:var(--radius-sm);background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-muted);flex-shrink:0;padding:2px 6px}.mem-source-badge{font-size:10px;font-family:var(--font-mono);border-radius:var(--radius-sm);background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-secondary);flex-shrink:0;padding:2px 6px}.mem-domain-badge{font-size:10px;font-family:var(--font-mono);border-radius:var(--radius-sm);flex-shrink:0;padding:2px 8px;font-weight:600}.mem-domain-badge.blue{background:color-mix(in srgb, var(--accent-blue) 15%, transparent);color:var(--accent-blue)}.mem-domain-badge.purple{background:color-mix(in srgb, var(--accent-purple) 15%, transparent);color:var(--accent-purple)}.mem-domain-badge.green{background:color-mix(in srgb, var(--accent-green) 15%, transparent);color:var(--accent-green)}.mem-domain-badge.gray{background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-muted)}.mem-review-actions{align-items:center;gap:12px;margin-top:4px;display:flex}.mem-review-actions .btn-primary{align-items:center;gap:6px;padding:7px 16px;font-size:12px;display:flex}.mem-review-select-links{font-size:11px;font-family:var(--font-mono);color:var(--text-muted)}.mem-review-select-links a{color:var(--accent-blue);cursor:pointer;text-decoration:none}.mem-review-select-links a:hover{text-decoration:underline}.mem-profile-success{background:color-mix(in srgb, var(--accent-green) 10%, transparent);border:1px solid color-mix(in srgb, var(--accent-green) 25%, transparent);border-radius:var(--radius-md);font-size:12px;font-family:var(--font-mono);color:var(--accent-green);align-items:center;gap:6px;padding:8px 12px;display:flex}.mem-profile-empty{text-align:center;color:var(--text-muted);font-size:12px;font-family:var(--font-mono);padding:12px}@media (width<=768px){.memory-dashboard-header{padding-left:var(--sidebar-toggle-clearance)}}@media (width<=900px){.mem-stat-cards{grid-template-columns:repeat(2,1fr)}.mem-two-col{grid-template-columns:1fr}.mem-embedding-coverage{display:none}.mem-detail-grid{grid-template-columns:repeat(2,1fr)}.mem-profile-grid{grid-template-columns:1fr}}@media (width<=600px){.mem-stat-cards{grid-template-columns:1fr}.memory-dashboard-page{height:100%}.mem-knowledge-table{font-size:12px}.mem-filters{flex-direction:column}.mem-toast-container{bottom:12px;left:12px;right:12px}}.mem-goals-tab{flex-direction:column;gap:14px;padding:16px;display:flex}.mem-goals-stats-row{flex-wrap:wrap;gap:10px;display:flex}.mem-goals-stat-pill{background:var(--bg-hover);border:1px solid var(--border);border-radius:20px;align-items:center;gap:6px;padding:5px 12px;font-size:12px;font-weight:500;display:flex}.mem-goals-stat-n{font-size:16px;font-weight:700}.mem-goals-stat-label{opacity:.7;text-transform:capitalize}.mem-goal-status-queued{border-color:var(--accent-blue)!important}.mem-goal-status-in-progress{border-color:var(--accent-yellow)!important}.mem-goal-status-completed{border-color:var(--accent-green)!important}.mem-goal-status-failed{border-color:var(--danger)!important}.mem-goal-status-cancelled{opacity:.6;border-color:var(--border)!important}.mem-goals-approval-banner{background:color-mix(in srgb, var(--accent-yellow) 10%, transparent);border:1px solid color-mix(in srgb, var(--accent-yellow) 40%, transparent);border-radius:var(--radius-lg);flex-direction:column;gap:10px;padding:12px 14px;display:flex}.mem-goals-approval-title{opacity:.85;align-items:center;gap:6px;font-size:12px;font-weight:600;display:flex}.mem-goals-approval-item{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-md);justify-content:space-between;align-items:flex-start;gap:12px;padding:8px 10px;display:flex}.mem-goals-approval-text{flex-direction:column;gap:3px;font-size:13px;display:flex}.mem-goals-approval-text strong{font-weight:600}.mem-goals-approval-text span{opacity:.7;font-size:12px}.mem-goals-approval-actions{flex-shrink:0;gap:6px;display:flex}.btn-danger-sm{border-radius:var(--radius-md);background:color-mix(in srgb, var(--danger) 15%, transparent);border:1px solid color-mix(in srgb, var(--danger) 40%, transparent);color:var(--text-primary);cursor:pointer;padding:4px 10px;font-size:12px}.btn-danger-sm:hover{background:color-mix(in srgb, var(--danger) 25%, transparent)}.mem-goals-toolbar{gap:8px;display:flex}.mem-goals-add-form{background:var(--bg-hover);border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;gap:8px;padding:12px;display:flex}.mem-goals-form-row{align-items:center;gap:8px;display:flex}.mem-select{border-radius:var(--radius-md);background:var(--bg-card);border:1px solid var(--border);color:var(--text-primary);cursor:pointer;padding:6px 10px;font-size:13px}.mem-goals-list{flex-direction:column;gap:8px;display:flex}.mem-goal-card{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--bg-card);transition:border-color .15s;overflow:hidden}.mem-goal-header{cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:8px;padding:10px 14px;display:flex}.mem-goal-header:hover{background:var(--bg-hover)}.mem-goal-header-left{flex:1;align-items:center;gap:8px;min-width:0;display:flex}.mem-goal-header-right{flex-shrink:0;align-items:center;gap:8px;display:flex}.mem-goal-status-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.mem-goal-status-dot.status-queued{background:var(--accent-blue)}.mem-goal-status-dot.status-in-progress{background:var(--accent-yellow)}.mem-goal-status-dot.status-completed{background:var(--accent-green)}.mem-goal-status-dot.status-failed{background:var(--danger)}.mem-goal-title{white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:600;overflow:hidden}.mem-goal-priority{border-radius:10px;flex-shrink:0;padding:1px 6px;font-size:11px;font-weight:500}.mem-priority-high{background:color-mix(in srgb, var(--danger) 15%, transparent)}.mem-priority-medium{background:color-mix(in srgb, var(--accent-yellow) 15%, transparent)}.mem-priority-low{background:color-mix(in srgb, var(--accent-blue) 15%, transparent)}.mem-goal-source-badge{background:color-mix(in srgb, var(--accent-purple) 15%, transparent);border-radius:10px;flex-shrink:0;align-items:center;gap:3px;padding:1px 6px;font-size:10px;display:flex}.mem-goal-task-count{opacity:.6;align-items:center;gap:4px;font-size:12px;display:flex}.mem-goal-action-btn{border-radius:var(--radius-md);background:var(--bg-hover);border:1px solid var(--border);color:var(--text-primary);cursor:pointer;align-items:center;gap:4px;padding:3px 8px;font-size:11px;display:flex}.mem-goal-action-btn:hover{background:var(--bg-active)}.mem-goal-delete-btn:hover{background:color-mix(in srgb, var(--danger) 15%, transparent);border-color:color-mix(in srgb, var(--danger) 40%, transparent)}.mem-chevron-open{transition:transform .15s;transform:rotate(180deg)}.mem-goal-body{border-top:1px solid var(--border);flex-direction:column;gap:8px;padding:0 14px 12px;display:flex}.mem-goal-desc{opacity:.7;margin:8px 0 0;font-size:12px}.mem-goal-progress{background:var(--bg-hover);border-radius:var(--radius-md);opacity:.8;padding:6px 8px;font-size:12px}.mem-goal-no-tasks{opacity:.5;font-size:12px;font-style:italic}.mem-task-list{flex-direction:column;gap:4px;margin-top:4px;display:flex}.mem-task-row{border-radius:var(--radius-md);align-items:flex-start;gap:8px;padding:5px 8px;font-size:12px;display:flex}.mem-task-row:hover{background:var(--bg-hover)}.mem-task-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:7px;height:7px;margin-top:3px}.mem-task-dot.status-in-progress{background:var(--accent-yellow)}.mem-task-dot.status-completed{background:var(--accent-green)}.mem-task-dot.status-failed{background:var(--danger)}.mem-task-dot.status-blocked{background:var(--accent-purple)}.mem-task-desc{flex:1}.mem-task-status-label{opacity:.5;text-transform:capitalize;flex-shrink:0;font-size:10px}.mem-task-result{opacity:.6;text-overflow:ellipsis;white-space:nowrap;flex-shrink:0;max-width:200px;font-size:11px;overflow:hidden}.mem-tab-badge{background:var(--accent-yellow);min-width:16px;height:16px;color:var(--text-inverse);border-radius:8px;justify-content:center;align-items:center;margin-left:2px;padding:0 4px;font-size:10px;font-weight:700;display:inline-flex}
|