@amd-gaia/agent-ui 0.25.3 → 0.25.4-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AdvancedSettings-B4MY5XPH.js +1 -0
- package/dist/assets/ConnectorsPane-B71QL-Kl.js +1 -0
- package/dist/assets/DocumentLibrary-CM6o8j2T.css +1 -0
- package/dist/assets/DocumentLibrary-c78Y6arz.js +4 -0
- package/dist/assets/FileBrowser-Cna3BsT7.css +1 -0
- package/dist/assets/FileBrowser-DwEPODjV.js +4 -0
- package/dist/assets/MemoryDashboard-BQhg3t2B.js +1 -0
- package/dist/assets/{MemoryDashboard-Mo721-BI.css → MemoryDashboard-Dt6zI60b.css} +1 -1
- package/dist/assets/MobileAccessModal-RI4HtcYe.js +2 -0
- package/dist/assets/ScheduleManager-tcyjbGY9.js +2 -0
- package/dist/assets/apiBase-DRtaTd8u.js +1 -0
- package/dist/assets/index-C9zLn8zo.css +1 -0
- package/dist/assets/index-CKOG_8jk.js +78 -0
- package/dist/assets/{zap-BogJn9oN.js → zap-BdhDcjhB.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +4 -3
- package/services/agent-seeder.cjs +22 -13
- package/services/backend-installer.cjs +2 -2
- package/dist/assets/AdvancedSettings-DERzP9Jc.js +0 -1
- package/dist/assets/ConnectorsPane-s0fFxmus.js +0 -1
- package/dist/assets/DocumentLibrary-CIKp6qld.css +0 -1
- package/dist/assets/DocumentLibrary-DqapN_Tr.js +0 -4
- package/dist/assets/FileBrowser-Dil1lZJ4.css +0 -1
- package/dist/assets/FileBrowser-vAJV41RT.js +0 -4
- package/dist/assets/MemoryDashboard-CP5wVWkY.js +0 -1
- package/dist/assets/MobileAccessModal-B31mPs50.js +0 -2
- package/dist/assets/ScheduleManager-b0gTAf2R.js +0 -2
- package/dist/assets/apiBase-CS6zLsJY.js +0 -1
- package/dist/assets/index-C-EM_5yl.css +0 -1
- package/dist/assets/index-Cae5Fje-.js +0 -78
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{w as e}from"./apiBase-DRtaTd8u.js";var t={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};t.node;var n=e(t),r={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};r.node;var i=e(r);export{n,i as t};
|
package/dist/index.html
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
<meta name="theme-color" content="#1A1917" />
|
|
9
9
|
<link rel="icon" type="image/png" href="./favicon.png" />
|
|
10
10
|
<title>GAIA Agent UI</title>
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-CKOG_8jk.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="./assets/apiBase-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/apiBase-DRtaTd8u.js">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="./assets/index-C9zLn8zo.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amd-gaia/agent-ui",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.4-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"productName": "GAIA Agent UI",
|
|
6
6
|
"description": "Chat with the GAIA agent - local and private by default on AMD Ryzen AI, cloud models when you choose them",
|
|
@@ -51,15 +51,16 @@
|
|
|
51
51
|
"build": "tsc && vite build",
|
|
52
52
|
"preview": "vite preview",
|
|
53
53
|
"start": "electron .",
|
|
54
|
-
"package": "npm run build && electron-builder --config electron-builder.yml",
|
|
54
|
+
"package": "npm run build && node scripts/strip-appimage-copyleft.cjs && electron-builder --config electron-builder.yml",
|
|
55
55
|
"make": "npm run package",
|
|
56
56
|
"package:win": "npm run build && electron-builder --win --config electron-builder.yml",
|
|
57
57
|
"package:mac": "npm run build && electron-builder --mac --config electron-builder.yml",
|
|
58
|
-
"package:linux": "npm run build && electron-builder --linux --config electron-builder.yml",
|
|
58
|
+
"package:linux": "npm run build && node scripts/strip-appimage-copyleft.cjs && electron-builder --linux --config electron-builder.yml",
|
|
59
59
|
"prepublishOnly": "npm run build",
|
|
60
60
|
"test": "vitest run",
|
|
61
61
|
"test:watch": "vitest",
|
|
62
62
|
"test:visual": "vite build && playwright test -c visual/playwright.config.ts",
|
|
63
|
+
"test:rtl": "vite build && playwright test -c visual/playwright.config.ts rtl --project=light",
|
|
63
64
|
"gen:api-types": "node scripts/gen-api-types.mjs"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
* Recovery: to get a deleted bundled agent back, remove
|
|
42
42
|
* `~/.gaia/seeder/<id>.seeded` and relaunch.
|
|
43
43
|
*
|
|
44
|
-
* Legacy cleanup: the retired `zoo-agent`
|
|
45
|
-
* ~/.gaia/agents/ when
|
|
46
|
-
* present, no file newer than its seededAt (+5s slack), never
|
|
47
|
-
* symlink
|
|
44
|
+
* Legacy cleanup: the retired `zoo-agent` and `example-agent` demos are
|
|
45
|
+
* removed from ~/.gaia/agents/ when provably an unmodified seeded copy —
|
|
46
|
+
* sentinel present, no file newer than its seededAt (+5s slack), never
|
|
47
|
+
* through a symlink, and never while this build still bundles that id.
|
|
48
|
+
* Removed ids are reported via the additive `cleaned` array.
|
|
48
49
|
*
|
|
49
50
|
* Behaviour:
|
|
50
51
|
* - `process.resourcesPath` unset (dev / Jest) → empty result, no error,
|
|
@@ -310,7 +311,7 @@ function seedOneAgent(sourceDir, targetRoot, id) {
|
|
|
310
311
|
// ── Legacy cleanup ───────────────────────────────────────────────────────
|
|
311
312
|
|
|
312
313
|
// Retired bundled ids removed from user machines when provably unmodified.
|
|
313
|
-
const LEGACY_CLEANUP_IDS = ["zoo-agent"];
|
|
314
|
+
const LEGACY_CLEANUP_IDS = ["zoo-agent", "example-agent"];
|
|
314
315
|
|
|
315
316
|
// Filesystem mtime granularity + copy latency headroom for the
|
|
316
317
|
// modified-since-seed check.
|
|
@@ -334,20 +335,28 @@ function listFilesRecursive(dir) {
|
|
|
334
335
|
}
|
|
335
336
|
|
|
336
337
|
/**
|
|
337
|
-
* Remove retired seeded demo agents (
|
|
338
|
+
* Remove retired seeded demo agents (LEGACY_CLEANUP_IDS) from
|
|
338
339
|
* ~/.gaia/agents/. Deletes ONLY when the dir is provably an unmodified
|
|
339
|
-
* seeded copy; anything ambiguous is left in place.
|
|
340
|
+
* seeded copy; anything ambiguous is left in place. An id the current
|
|
341
|
+
* installer still bundles is skipped: deleting it would leave a marker
|
|
342
|
+
* that blocks the re-seed, so the bundled agent would vanish for good. Failures are logged
|
|
340
343
|
* and retried on the next launch (the sentinel keys the retry — no marker
|
|
341
344
|
* is involved, since a retired id can never be re-seeded anyway).
|
|
342
345
|
*
|
|
346
|
+
* @param {string} sourceDir `<resourcesPath>/agents` of this build.
|
|
343
347
|
* @returns {string[]} ids actually removed (verified gone from disk).
|
|
344
348
|
*/
|
|
345
|
-
function cleanupLegacyAgents() {
|
|
349
|
+
function cleanupLegacyAgents(sourceDir) {
|
|
346
350
|
const cleaned = [];
|
|
347
351
|
|
|
348
352
|
for (const id of LEGACY_CLEANUP_IDS) {
|
|
349
353
|
const target = path.join(agentsTargetRoot(), id);
|
|
350
354
|
|
|
355
|
+
if (sourceDir && isDirectory(path.join(sourceDir, id))) {
|
|
356
|
+
log("INFO", `Legacy "${id}" is still bundled by this build — not removing it`);
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
|
|
351
360
|
let st;
|
|
352
361
|
try {
|
|
353
362
|
st = fs.lstatSync(target);
|
|
@@ -467,13 +476,13 @@ async function seedBundledAgents() {
|
|
|
467
476
|
return result;
|
|
468
477
|
}
|
|
469
478
|
|
|
470
|
-
// Legacy cleanup runs before the missing-source guard: an upgraded
|
|
471
|
-
// install must shed the retired zoo-agent even if this build ships no
|
|
472
|
-
// bundled agents.
|
|
473
|
-
result.cleaned = cleanupLegacyAgents();
|
|
474
|
-
|
|
475
479
|
const sourceDir = path.join(process.resourcesPath, "agents");
|
|
476
480
|
|
|
481
|
+
// Legacy cleanup runs before the missing-source guard: an upgraded
|
|
482
|
+
// install must shed retired demos even if this build ships no bundled
|
|
483
|
+
// agents.
|
|
484
|
+
result.cleaned = cleanupLegacyAgents(sourceDir);
|
|
485
|
+
|
|
477
486
|
if (!fs.existsSync(sourceDir) || !isDirectory(sourceDir)) {
|
|
478
487
|
// Not an error — a build might simply ship without bundled agents.
|
|
479
488
|
// In a packaged Electron app the directory is expected to exist, so raise
|
|
@@ -672,7 +672,7 @@ function isFileLockedError(output) {
|
|
|
672
672
|
/**
|
|
673
673
|
* Detect a transient network failure in `uv pip install` output so the
|
|
674
674
|
* install stage can retry instead of failing the whole bootstrap. The
|
|
675
|
-
* install stage downloads transitive deps (numpy, faiss,
|
|
675
|
+
* install stage downloads transitive deps (numpy, faiss, pypdfium2, …) from
|
|
676
676
|
* PyPI; a single mid-stream hiccup ("stream closed because of a broken pipe")
|
|
677
677
|
* otherwise fails the entire backend install — and, in the release pipeline,
|
|
678
678
|
* the whole AppImage smoke test that gates publishing.
|
|
@@ -1799,7 +1799,7 @@ async function installBackend(opts = {}) {
|
|
|
1799
1799
|
GAIA_PYTHON_BIN,
|
|
1800
1800
|
];
|
|
1801
1801
|
// Retry the install on transient PyPI/network failures. The transitive
|
|
1802
|
-
// deps (numpy, faiss,
|
|
1802
|
+
// deps (numpy, faiss, pypdfium2, …) are fetched live from PyPI even
|
|
1803
1803
|
// when the gaia wheel itself is local, so a single broken-pipe mid-download
|
|
1804
1804
|
// would otherwise fail the whole bootstrap (and block a release). File-lock
|
|
1805
1805
|
// failures (Windows os-error-32) are NOT retried — they need user action.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,o as n,r}from"./apiBase-CS6zLsJY.js";import{Ft as i,G as a,J as o,Yt as s,a as c,ct as l,dn as u,et as d,gt as f,ht as p,it as m,mt as h,nt as g,o as _,pn as v,r as y,rt as b,tt as x}from"./index-Cae5Fje-.js";var S=e(n(),1),C=t();function w(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(``),[o,l]=(0,S.useState)(``),[u,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(null),[g,_]=(0,S.useState)(!1);(0,S.useEffect)(()=>{d().then(e=>{t(e),a(e.saved_base_url??e.base_url??``)}).catch(e=>r(e instanceof Error?e.message:String(e)))},[]);let y=(0,S.useCallback)(async e=>{f(!0),m(null);try{let n=await h(e);t(n),l(``),_(!1)}catch(e){_(c(e)),m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[]),b=()=>void y({mode:`external`,base_url:i.trim(),api_key:o.trim()||void 0});if(n)return(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,C.jsx)(v,{size:14}),(0,C.jsxs)(`div`,{className:`model-warning-content`,children:[(0,C.jsx)(`strong`,{children:`Could not read which model server GAIA uses`}),(0,C.jsx)(`p`,{children:n})]})]})]});if(!e)return null;let x=e.mode===`external`;return(0,C.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsx)(`p`,{className:`model-override-desc`,role:`status`,children:e.source===`env`?(0,C.jsxs)(C.Fragment,{children:[`GAIA uses the Lemonade Server at `,(0,C.jsx)(`code`,{children:e.base_url}),`, set by `,(0,C.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),`.`]}):x?(0,C.jsxs)(C.Fragment,{children:[`GAIA uses your Lemonade Server at `,(0,C.jsx)(`code`,{children:e.base_url}),`.`]}):(0,C.jsx)(C.Fragment,{children:`GAIA uses its own Lemonade Server.`})}),e.source===`env`?(0,C.jsxs)(`p`,{className:`model-status-hint`,children:[`Unset `,(0,C.jsx)(`code`,{children:`LEMONADE_BASE_URL`}),` and restart GAIA to change this here.`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.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,C.jsxs)(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,C.jsx)(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:i,onChange:e=>{a(e.target.value),m(null)},disabled:u,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Lemonade Server address`}),(0,C.jsx)(`input`,{type:`password`,className:`model-input`,autoComplete:`off`,placeholder:e.api_key_stored?`API key (blank keeps the saved one)`:`API key, if it needs one`,value:o,onChange:e=>l(e.target.value),disabled:u,"aria-label":`Lemonade API key`}),(0,C.jsx)(`div`,{className:`model-btn-group`,children:(0,C.jsx)(`button`,{type:`submit`,className:`btn-model-save`,disabled:u||!i.trim(),children:u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(s,{size:13,className:`btn-spinner`}),` Checking…`]}):`Use this server`})})]}),x&&(0,C.jsx)(`div`,{className:`setting-actions`,children:(0,C.jsx)(`button`,{type:`button`,className:`btn-secondary`,disabled:u,onClick:()=>void y({mode:`gaia`}),children:`Use GAIA’s own`})}),p&&(0,C.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,C.jsx)(v,{size:14}),(0,C.jsxs)(`div`,{className:`model-warning-content`,children:[(0,C.jsx)(`strong`,{children:g?`Needs the API key`:`Not switched`}),(0,C.jsx)(`p`,{children:p})]})]})]})]})}var T={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},E={gaia:`GAIA's own Lemonade`,user:`Your Lemonade`,remote:`Lemonade on another machine`};function D(e){return e?T[e]??e:`unknown`}function O(e){if(!e)return`unknown`;let t=D(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function k(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}function A({label:e,value:t,title:n}){return(0,C.jsxs)(`div`,{className:`status-row`,children:[(0,C.jsx)(`span`,{className:`status-label`,children:e}),(0,C.jsx)(`span`,{className:`status-value model-server-value`,title:n??t,children:t})]})}function j(){let e=i(e=>e.openSettings),[t,n]=(0,S.useState)(null),[r,a]=(0,S.useState)(null),[c,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),[m,h]=(0,S.useState)(!1);(0,S.useEffect)(()=>{g().then(n).catch(e=>a(e instanceof Error?e.message:String(e)))},[]);let _=(0,S.useCallback)(async e=>{u(e),f(null);try{let t=await p(e);n(t),f({ok:!0,text:`Saved. It applies the next time the chat model loads.`})}catch(e){f({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{u(null)}},[]),v=t?.chat_model??null,y=(0,S.useCallback)(async()=>{if(v?.name){h(!0);try{if(!await l(v.name,v.ctx_size??void 0))return;f({ok:!0,text:`Reloading ${v.name}. Reopen this panel in a moment to see its backend.`})}catch(e){f({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{h(!1)}}},[v]),b=(0,C.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(`model`),children:`Change model`});if(r)return(0,C.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsx)(`p`,{className:`settings-error`,role:`alert`,children:r})]});if(!t)return(0,C.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsx)(`p`,{className:`loading-text`,children:`Checking the model server…`})]});if(!t.reachable)return(0,C.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsx)(`p`,{className:`settings-error`,role:`alert`,children:t.error}),b]});let x=t.available_backends??[],w=t.preferred_backend??null,T=[`auto`,...x.map(e=>e.name)];w&&!T.includes(w)&&T.push(w);let j=w??`auto`,M=x.filter(e=>e.state===`installable`).map(e=>D(e.name)),N=!!v?.name&&v.recipe===`llamacpp`;return(0,C.jsxs)(`section`,{className:`settings-section`,"aria-label":`Model server`,children:[(0,C.jsx)(`h4`,{children:`Model server`}),(0,C.jsxs)(`div`,{className:`status-grid`,children:[(0,C.jsx)(A,{label:`Server`,value:`${E[t.owner]??t.owner}${t.version?` v${t.version}`:``}`}),(0,C.jsx)(A,{label:`Address`,value:t.base_url}),(0,C.jsx)(A,{label:`Chat model`,value:v?.name?o(v.name):`None loaded`,title:v?.name??void 0}),v&&(0,C.jsx)(A,{label:`Runs on`,value:O(v)}),v&&v.backend!==`remote`&&(0,C.jsx)(A,{label:`Context window`,value:k(v.ctx_size)}),(0,C.jsx)(A,{label:`Embedding model`,value:t.embedding_model?.name?`${t.embedding_model.name} · ${O(t.embedding_model)}`:`None loaded`})]}),t.embedding_note&&(0,C.jsx)(`p`,{className:`settings-hint`,children:t.embedding_note}),t.system_info_error&&(0,C.jsx)(`p`,{className:`settings-hint`,children:t.system_info_error}),(0,C.jsxs)(`div`,{className:`settings-field model-server-backend`,children:[(0,C.jsx)(`span`,{className:`settings-label`,children:`llama.cpp backend for chat models`}),x.length===0&&!w?(0,C.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,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":`llama.cpp backend`,children:T.map(e=>(0,C.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":j===e,className:j===e?`is-active`:``,disabled:c!==null,onClick:()=>{e!==j&&_(e)},children:[c===e?(0,C.jsx)(s,{size:12,className:`spin`}):null,e===`auto`?`Auto${t.default_backend?` (${D(t.default_backend)})`:``}`:D(e)]},e))}),(0,C.jsxs)(`span`,{className:`settings-hint`,children:[`Applies the next time a chat model loads. The embedding model keeps its own backend.`,M.length>0&&` ${M.join(`, `)} downloads on first use.`]})]}),d&&(0,C.jsx)(`p`,{className:d.ok?`settings-ok`:`settings-error`,role:d.ok?`status`:`alert`,children:d.text})]}),(0,C.jsxs)(`div`,{className:`settings-row`,children:[b,N&&(0,C.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void y(),disabled:m,children:[m?(0,C.jsx)(s,{size:13,className:`spin`}):null,`Reload chat model now`]})]})]})}function M(){let[e,t]=(0,S.useState)(null),[n,i]=(0,S.useState)(!0),[o,c]=(0,S.useState)([]),[l,d]=(0,S.useState)(``),[p,h]=(0,S.useState)(``),[g,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(!1),[O,k]=(0,S.useState)(null),[A,M]=(0,S.useState)(!1),P=(0,S.useRef)(null),[F,I]=(0,S.useState)(!1),[L,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null);(0,S.useEffect)(()=>{r.system.info(`Checking system status...`);let e=r.system.time();m().then(n=>{t(n),r.system.timed(`System status received`,e,{lemonade:n.lemonade_running?`running`:`stopped`,model:n.model_loaded||`none`,embedding:n.embedding_model_loaded?`yes`:`no`,disk:`${n.disk_space_gb}GB free`,memory:n.memory_available_gb==null?`unknown`:`${n.memory_available_gb}GB available`}),n.lemonade_running||r.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{r.system.error(`Failed to get system status`,e),t(null)}).finally(()=>i(!1)),x().then(e=>c(e.servers)).catch(()=>{}),b().then(e=>{let t=e.custom_model??``;d(t),h(t),I(e.dynamic_tools),R(e.dynamic_tools_locked)}).catch(e=>{r.system.error(`Failed to load settings`,e)}).finally(()=>T(!0))},[]),(0,S.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let U=(0,S.useCallback)(async()=>{let e=l.trim(),t=e.length>0?e:``;D(!0),k(null),M(!1);try{r.system.info(`Saving custom_model override`,{custom_model:t});let e=(await f({custom_model:t})).custom_model??``;d(e),h(e),M(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>M(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);r.system.error(`Failed to save custom_model`,e),k(t)}finally{D(!1)}},[l]),W=(0,S.useCallback)(async()=>{if(L||z)return;let e=F,t=!e;I(t),B(!0),H(null);try{r.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await f({dynamic_tools:t});I(e.dynamic_tools),R(e.dynamic_tools_locked)}catch(t){let n=t instanceof Error?t.message:String(t);r.system.error(`Failed to save dynamic_tools`,t),I(e),H(n)}finally{B(!1)}},[F,L,z]),G=l.trim()!==p.trim(),K=e?e.default_model_name:a,{isLoadingModel:q,isDownloadingModel:J,loadModel:Y,downloadModel:X}=y(K??void 0),Z=!!e?.default_model_is_cloud,Q=!Z&&!!(e?.lemonade_running&&e.model_loaded&&e.expected_model_loaded===!1),$=!Z&&!!(e?.lemonade_running&&e.model_loaded&&e.context_size_sufficient===!1),ee=!Z&&!(!e?.lemonade_running||e.model_loaded||e.model_downloaded!==!1),te=(Q||$)&&K!==null;return(0,C.jsxs)(`div`,{className:`settings-pane`,children:[(0,C.jsx)(`h2`,{className:`settings-pane-title`,children:`Advanced`}),(0,C.jsx)(j,{}),(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h4`,{children:`Local model server`}),n?(0,C.jsx)(`p`,{className:`loading-text`,children:`Checking system...`}):e?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`status-grid`,children:[(0,C.jsx)(N,{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,C.jsx)(N,{label:`Model`,value:e.model_loaded||`None loaded`,ok:!!e.model_loaded&&(Z||e.expected_model_loaded!==!1),hint:e.model_loaded?!Z&&e.expected_model_loaded===!1?`Expected: ${K}`:void 0:`None loaded yet — it loads with the first message.`}),e.model_size_gb!=null&&(0,C.jsx)(N,{label:`Model Size`,value:`${e.model_size_gb} GB`,ok:!0}),e.model_device&&!Z&&(0,C.jsx)(N,{label:`Device`,value:e.model_device.toUpperCase(),ok:e.model_device!==`cpu`}),e.model_context_size!=null&&(0,C.jsx)(N,{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,C.jsx)(N,{label:`Capabilities`,value:e.model_labels.join(`, `),ok:!0}),(0,C.jsx)(N,{label:`Embedding Model`,value:e.embedding_model_loaded?`Available`:`Not loaded`,ok:e.embedding_model_loaded}),e.gpu_name&&(0,C.jsx)(N,{label:`GPU`,value:`${e.gpu_name}${e.gpu_vram_gb?` (${_(e.gpu_vram_gb)})`:``}`,ok:!0}),(0,C.jsx)(N,{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,C.jsx)(N,{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,C.jsx)(N,{label:`Processor`,value:e.processor_name,ok:!0})]}),ee&&(0,C.jsxs)(`div`,{className:`model-action-row model-action-row--download`,children:[(0,C.jsxs)(`div`,{className:`model-action-info`,children:[(0,C.jsx)(`span`,{className:`model-action-label`,children:`Model not downloaded.`}),(0,C.jsxs)(`span`,{className:`model-action-desc`,children:[(0,C.jsx)(`strong`,{children:K}),` is GAIA’s default local model (about 6 GB).`]})]}),(0,C.jsx)(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>X(!1),disabled:J,children:J?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(s,{size:13,className:`btn-spinner`}),` Downloading…`]}):`Download`})]}),te&&(0,C.jsxs)(`div`,{className:`model-action-row model-action-row--load`,children:[(0,C.jsxs)(`div`,{className:`model-action-info`,children:[(0,C.jsx)(`span`,{className:`model-action-label`,children:Q?`Wrong model loaded.`:`Context window too small.`}),(0,C.jsxs)(`span`,{className:`model-action-desc`,children:[`Load `,(0,C.jsx)(`strong`,{children:K}),` with `,32 .toFixed(0),`K token context.`]})]}),(0,C.jsx)(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>Y(),disabled:q,children:q?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(s,{size:13,className:`btn-spinner`}),` Loading…`]}):`Load Model`})]}),e.lemonade_running&&K!==null&&!Z&&(0,C.jsxs)(`div`,{className:`force-redownload-row`,children:[(0,C.jsx)(`span`,{className:`force-redownload-label`,children:`If the model file is corrupted:`}),(0,C.jsx)(`button`,{className:`btn-force-redownload`,onClick:()=>X(!0),disabled:J,children:J?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(s,{size:12,className:`btn-spinner`}),` Downloading…`]}):`Force Re-download`})]})]}):(0,C.jsx)(`div`,{className:`status-error`,children:(0,C.jsx)(`p`,{children:`Could not reach GAIA. Check that it is still running.`})})]}),(0,C.jsx)(w,{}),(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h4`,{children:`Custom model ID`}),(0,C.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,C.jsxs)(`div`,{className:`model-input-row`,children:[(0,C.jsx)(`input`,{type:`text`,className:`model-input${p?` has-override`:``}`,placeholder:`Use the model chosen under Model`,value:l,onChange:e=>{d(e.target.value),k(null),M(!1)},onKeyDown:e=>{e.key===`Enter`&&!E&&G&&g&&(e.preventDefault(),U())},disabled:!g||E,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Custom model override`}),(0,C.jsx)(`div`,{className:`model-btn-group`,children:(0,C.jsx)(`button`,{className:`btn-model-save${A?` saved`:``}`,onClick:()=>{U()},disabled:!g||E||!G&&!A,"aria-label":`Save custom model`,children:E?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(s,{size:13,className:`btn-spinner`}),` Saving…`]}):A?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(u,{size:13}),` Saved`]}):`Save`})})]}),(0,C.jsxs)(`p`,{className:`model-status-hint`,children:[`Accepts a Lemonade model ID (e.g. `,(0,C.jsx)(`code`,{children:`Qwen3-4B-Instruct-2507-GGUF`}),`)`,` `,`or a HuggingFace ID (e.g. `,(0,C.jsx)(`code`,{children:`unsloth/Qwen3-4B-GGUF`}),`).`]}),O&&(0,C.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,C.jsx)(v,{size:14}),(0,C.jsxs)(`div`,{className:`model-warning-content`,children:[(0,C.jsx)(`strong`,{children:`Could not save`}),(0,C.jsx)(`p`,{children:O})]})]})]}),(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsxs)(`h4`,{children:[`Dynamic Tools `,(0,C.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,C.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,C.jsxs)(`label`,{className:`setting-row`,children:[(0,C.jsx)(`span`,{children:`Enable dynamic tool loading`}),(0,C.jsxs)(`span`,{className:`toggle-switch`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:F,onChange:()=>void W(),disabled:!g||z||L,"aria-label":F?`Disable dynamic tools`:`Enable dynamic tools`}),(0,C.jsx)(`span`,{className:`toggle-track`})]})]}),L&&(0,C.jsxs)(`p`,{className:`model-status-hint`,children:[`Controlled by `,(0,C.jsx)(`code`,{children:`GAIA_DYNAMIC_TOOLS`}),` — unset that environment variable to change this here.`]}),V&&(0,C.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,C.jsx)(v,{size:14}),(0,C.jsxs)(`div`,{className:`model-warning-content`,children:[(0,C.jsx)(`strong`,{children:`Could not save`}),(0,C.jsx)(`p`,{children:V})]})]})]}),o.length>0&&(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h4`,{children:`MCP Servers`}),(0,C.jsx)(`div`,{className:`status-grid`,children:o.map(e=>(0,C.jsxs)(`div`,{className:`status-row`,children:[(0,C.jsx)(`span`,{className:`status-label`,children:e.name}),(0,C.jsx)(`div`,{className:`status-value-wrap`,children:e.connected?(0,C.jsxs)(`span`,{className:`status-value ok mcp-status-connected`,children:[(0,C.jsx)(u,{size:12}),e.tool_count,` tool`,e.tool_count===1?``:`s`]}):(0,C.jsxs)(`span`,{className:`status-value warn mcp-status-failed`,title:e.error??void 0,children:[(0,C.jsx)(v,{size:12}),`Failed`]})})]},e.name))})]}),(0,C.jsxs)(`section`,{className:`settings-section`,children:[(0,C.jsx)(`h4`,{children:`About`}),(0,C.jsxs)(`div`,{className:`about-info`,children:[(0,C.jsxs)(`p`,{children:[`GAIA v`,`0.25.3`,` `,(0,C.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,C.jsx)(`p`,{className:`about-sub`,children:`Privacy-first AI chat for AMD Ryzen AI PCs.`})]})]})]})}function N({label:e,value:t,ok:n,hint:r}){return(0,C.jsxs)(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[(0,C.jsx)(`span`,{className:`status-label`,children:e}),(0,C.jsxs)(`div`,{className:`status-value-wrap`,children:[(0,C.jsx)(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&(0,C.jsx)(`span`,{className:`status-hint`,children:(0,C.jsx)(`code`,{children:r})})]})]})}export{M as AdvancedSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,o as n,r,t as i}from"./apiBase-CS6zLsJY.js";import{At as a,Ct as o,Dt as s,Et as c,Ft as l,Mt as u,Nt as d,Ot as f,Pt as p,St as m,Tt as h,Yt as g,bt as _,dn as v,gn as y,in as b,jt as x,kt as S,mn as C,pn as w,rn as T,wt as E,xt as D,yt as O}from"./index-Cae5Fje-.js";var k=t(),A=e(n(),1),j=r.api;function M(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 N(e){let t=(0,A.useRef)(e);(0,A.useEffect)(()=>{t.current=e},[e]),(0,A.useEffect)(()=>{let e=`${i()}/connectors/events`,n=null,r=1e3,a=null,o=!1,s=()=>{o||(n=new EventSource(e),n.onopen=()=>{r=1e3},n.onmessage=e=>{try{let n=JSON.parse(e.data),r=M(n.type);if(r===null){j.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){j.warn(`connectors-sse: malformed event`,e)}},n.onerror=()=>{n?.close(),n=null,!o&&(a=setTimeout(s,r),r=Math.min(r*2,3e4))})};return s(),()=>{o=!0,a&&clearTimeout(a),n?.close()}},[])}function P(e){return e.type===`mcp_server`&&e.configured}function F({connector:e,onChanged:t}){let[n,r]=(0,A.useState)(!1),[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(null),[l,u]=(0,A.useState)(null),d=(0,A.useRef)(null),f=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&f.current&&!f.current.contains(t)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let m=(0,A.useCallback)(()=>r(!1),[]);if(p(n,m),(0,A.useEffect)(()=>{if(!n)return;let e=()=>{if(!d.current)return;let e=d.current.getBoundingClientRect();u({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]),!P(e))return null;let g=e=>{e.stopPropagation(),e.preventDefault()},_=e=>{if(g(e),!n&&d.current){let e=d.current.getBoundingClientRect();u({top:e.bottom+4,right:window.innerWidth-e.right})}r(e=>!e)},v=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,k.jsxs)(`div`,{className:`connector-tile-menu`,onClick:g,onKeyDown:g,children:[(0,k.jsx)(`button`,{ref:d,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Connector actions`,onClick:_,disabled:i,children:(0,k.jsx)(b,{size:14})}),n&&l&&(0,k.jsxs)(`div`,{ref:f,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:l.top,right:l.right},children:[e.enabled?(0,k.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void v(()=>E(e.id)),disabled:i,children:`Disable`}):(0,k.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void v(()=>c(e.id)),disabled:i,children:`Enable`}),(0,k.jsx)(`div`,{className:`connector-tile-menu-divider`}),(0,k.jsx)(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void v(()=>h(e.id)),disabled:i,children:`Disconnect`}),o&&(0,k.jsx)(`div`,{className:`connector-tile-menu-error`,children:o})]})]})}var I={"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 L(e){return I[e]??e.split(/[/.:]/).pop()??e}var R=[`use`];function z(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 B(){let[e,t]=(0,A.useState)([]),[n,r]=(0,A.useState)([]),[i,a]=(0,A.useState)(!0),[o,c]=(0,A.useState)(null),[l,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),m=(0,A.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:n}]=await Promise.all([u(),S()]);t(e),r(n),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,A.useEffect)(()=>{m()},[m]);let h=e=>p(t=>t===e?null:e),_=(0,A.useCallback)(async e=>{try{let n=await s(e);t(t=>t.map(t=>t.id===e?n:t))}catch{m()}},[m]);return N((0,A.useCallback)(e=>{e.reason===`disconnected`&&d(z(e.payload)),e.connectorId?_(e.connectorId):m()},[_,m])),(0,k.jsxs)(`section`,{className:`connectors-section`,"aria-label":`Connectors`,children:[(0,k.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,k.jsxs)(`div`,{className:`error-banner`,children:[(0,k.jsx)(w,{size:14}),(0,k.jsx)(`span`,{children:o})]}),l&&(0,k.jsxs)(`div`,{className:`error-banner`,role:`status`,onClick:()=>d(null),children:[(0,k.jsx)(w,{size:14}),(0,k.jsx)(`span`,{children:l})]}),i?(0,k.jsx)(`div`,{className:`connectors-loading`,children:(0,k.jsx)(g,{size:16,className:`spin`})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>(0,k.jsx)(V,{connector:e,expanded:f===e.id,onToggle:()=>h(e.id),onChanged:()=>void _(e.id)},e.id))}),n.length>0&&(0,k.jsx)(K,{servers:n,expanded:f,onToggle:h})]})]})}function V({connector:e,expanded:t,onToggle:n,onChanged:r}){return(0,k.jsxs)(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[(0,k.jsxs)(`button`,{className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[(0,k.jsx)(`span`,{className:`connector-tile-name`,children:e.display_name}),(0,k.jsx)(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?(0,k.jsx)(`span`,{className:`connector-status disabled`,children:`Disabled`}):(0,k.jsxs)(`span`,{className:`connector-status ok`,children:[(0,k.jsx)(v,{size:12}),e.account_id??`Configured`]}):(0,k.jsx)(`span`,{className:`connector-status idle`,children:`Not configured`}),(0,k.jsx)(F,{connector:e,onChanged:r}),(0,k.jsx)(`span`,{className:`connector-tile-chevron`,children:t?(0,k.jsx)(C,{size:14}):(0,k.jsx)(y,{size:14})})]}),t&&(0,k.jsxs)(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?(0,k.jsx)(H,{connector:e,onChanged:r}):(0,k.jsx)(W,{connector:e,onChanged:r}),e.configured&&(0,k.jsx)(J,{connectorId:e.id,connectorType:e.type})]})]})}function H({connector:e,onChanged:t}){let[n,r]=(0,A.useState)(!1),[i,a]=(0,A.useState)(null),[o,s]=(0,A.useState)({}),[c,u]=(0,A.useState)(null),{agents:d}=l(),f=d.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),p=f.map(e=>e.namespaced_agent_id).join(`,`),[v,y]=(0,A.useState)(()=>new Set);(0,A.useEffect)(()=>{y(new Set(f.map(e=>e.namespaced_agent_id)))},[p]);let b=e=>y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=()=>[...v];(0,A.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let S=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},C=async()=>{r(!0),a(null);try{let t=await _(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,x());S(t.authorization_url)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},E=async()=>{r(!0),a(null),u(null);try{let t=await D(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,x());u(t)}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}};(0,A.useEffect)(()=>{e.configured&&u(null)},[e.configured]),N((0,A.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(a(String(t.payload.error??`Device sign-in failed.`)),u(null)):t.reason===`oauth_completed`&&u(null))},[e.id]));let O=async()=>{r(!0),a(null);try{await h(e.id),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},j=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(`, `)}`);else{r(!0),a(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await m(e.id,{...o,scopes:n,grant_agents:x()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&S(i),t()}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}}},M=e.oauth_setup_fields??[],P=e.configurable===!1&&!e.configured&&M.length>0;return(0,k.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,k.jsx)(`p`,{className:`connector-desc`,children:e.description}),P&&(0,k.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,k.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.`}),M.map(e=>(0,k.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,k.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,k.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:o[e.key]??``,onChange:t=>s(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&(0,k.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key))]}),!e.configured&&f.length>0&&(0,k.jsxs)(`div`,{className:`oauth-grant-onconnect`,children:[(0,k.jsx)(`p`,{className:`oauth-grant-onconnect-label`,children:`Grant access to these agents when you connect:`}),f.map(e=>(0,k.jsxs)(`label`,{className:`oauth-grant-onconnect-item`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:v.has(e.namespaced_agent_id),onChange:()=>b(e.namespaced_agent_id)}),(0,k.jsx)(`span`,{children:e.name})]},e.namespaced_agent_id)),(0,k.jsx)(`p`,{className:`oauth-grant-onconnect-help`,children:`You can change these any time under Per-agent grants below.`})]}),!P&&(0,k.jsx)(U,{connector:e,onChanged:t}),i&&(0,k.jsxs)(`div`,{className:`configure-error`,children:[(0,k.jsx)(w,{size:12}),` `,i]}),(0,k.jsxs)(`div`,{className:`configure-actions`,children:[e.configured?(0,k.jsx)(`button`,{className:`btn-secondary`,disabled:n,onClick:()=>void O(),children:n?(0,k.jsx)(g,{size:12,className:`spin`}):`Disconnect`}):P?(0,k.jsx)(`button`,{className:`btn-primary`,disabled:n,onClick:()=>void j(),children:n?(0,k.jsx)(g,{size:12,className:`spin`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(T,{size:12}),` Save & Connect`]})}):e.configurable===!1?(0,k.jsx)(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:`Setup required`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{className:`btn-primary`,disabled:n||c!==null,onClick:()=>void C(),children:n?(0,k.jsx)(g,{size:12,className:`spin`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(T,{size:12}),` Connect`]})}),e.supports_device_code&&(0,k.jsx)(`button`,{className:`btn-secondary`,disabled:n||c!==null,onClick:()=>void E(),title:`Enter a short code at a URL — no browser redirect or app registration needed`,children:`Sign in with a code`})]}),(e.docs_url||e.product_url)&&(0,k.jsxs)(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Learn more `,(0,k.jsx)(T,{size:11})]})]}),c&&!e.configured&&(0,k.jsxs)(`div`,{className:`device-code-block`,children:[(0,k.jsxs)(`p`,{className:`device-code-instructions`,children:[`Go to`,` `,(0,k.jsx)(`a`,{href:c.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),S(c.verification_uri)},children:c.verification_uri}),` `,`and enter this code:`]}),(0,k.jsxs)(`div`,{className:`device-code-value`,children:[(0,k.jsx)(`code`,{children:c.user_code}),(0,k.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(c.user_code),title:`Copy code`,children:`Copy`})]}),(0,k.jsxs)(`p`,{className:`device-code-waiting`,children:[(0,k.jsx)(g,{size:12,className:`spin`}),` Waiting for sign-in…`]}),(0,k.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>u(null),children:`Cancel`})]})]})}function U({connector:e,onChanged:t}){let[n,r]=(0,A.useState)(!1),[i,a]=(0,A.useState)({}),[o,s]=(0,A.useState)(!1),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=e.oauth_setup_fields??[];if(f.length===0)return null;let p=e.oauth_client,h=p?.source===`keyring`?`Saved client: ${p.client_id}`:p?.source===`env`?`From environment: ${p.client_id}`:`No OAuth client configured`,_=async()=>{if(!i.client_id?.trim())d(`Client ID is required.`);else{s(!0),d(null),l(!1);try{await m(e.id,{...Object.fromEntries(Object.entries(i).map(([e,t])=>[e,t.trim()])),save_only:!0}),l(!0),a({}),t(),setTimeout(()=>l(!1),2200)}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}}};return(0,k.jsxs)(`div`,{className:`oauth-client-editor`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?(0,k.jsx)(C,{size:12}):(0,k.jsx)(y,{size:12}),(0,k.jsx)(`span`,{children:`OAuth client`}),(0,k.jsx)(`span`,{className:`oauth-client-editor__status`,children:h})]}),n&&(0,k.jsxs)(`div`,{className:`oauth-setup-form`,children:[(0,k.jsxs)(`p`,{className:`connector-desc`,children:[`Bring your own OAuth client — saved encrypted in your OS keyring (same store as`,` `,(0,k.jsx)(`code`,{children:`gaia connectors configure`}),`) and reused for future connections. Environment variables are only used when no saved client exists.`]}),f.map(e=>(0,k.jsxs)(`label`,{className:`oauth-setup-field`,children:[(0,k.jsx)(`span`,{className:`oauth-setup-label`,children:e.label}),(0,k.jsx)(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&p?.source===`keyring`&&p.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,k.jsx)(`span`,{className:`oauth-setup-help`,children:e.help_md})]},e.key)),u&&(0,k.jsxs)(`div`,{className:`configure-error`,children:[(0,k.jsx)(w,{size:12}),` `,u]}),(0,k.jsx)(`div`,{className:`configure-actions`,children:(0,k.jsx)(`button`,{className:`btn-model-save${c?` saved`:``}`,disabled:o||!i.client_id?.trim(),onClick:()=>void _(),children:o?(0,k.jsx)(g,{size:12,className:`spin`}):c?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(v,{size:12}),` Saved`]}):`Save client`})})]})]})}function W({connector:e,onChanged:t}){let[n,r]=(0,A.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);(0,A.useEffect)(()=>{r(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let d=e.mcp_env_keys.length===0,f=Object.values(n).every(e=>e.trim()===``),p=async()=>{let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.trim()!==``));if(d||Object.keys(r).length!==0){a(!0),u(null),s(!1);try{await m(e.id,r),s(!0),t(),setTimeout(()=>s(!1),2200)}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}}},_=async()=>{a(!0),u(null);try{await h(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)}},y=async()=>{a(!0),u(null);try{e.enabled?await E(e.id):await c(e.id),t()}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,k.jsxs)(`div`,{className:`configure-body`,children:[e.description&&(0,k.jsx)(`p`,{className:`connector-desc`,children:e.description}),l&&(0,k.jsxs)(`div`,{className:`configure-error`,children:[(0,k.jsx)(w,{size:12}),` `,l]}),e.configured&&(0,k.jsxs)(`div`,{className:`connector-toggle-row`,children:[(0,k.jsx)(`span`,{className:`connector-toggle-label`,children:`Active`}),(0,k.jsxs)(`span`,{className:`toggle-switch`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void y(),disabled:i,"aria-label":e.enabled?`Disable this MCP server`:`Enable this MCP server`}),(0,k.jsx)(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&(0,k.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,k.jsxs)(`div`,{className:`mcp-key-row`,children:[(0,k.jsx)(`label`,{className:`mcp-key-label`,children:t}),(0,k.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,k.jsxs)(`div`,{className:`configure-actions`,children:[!(d&&e.configured)&&(0,k.jsx)(`button`,{className:`btn-model-save${o?` saved`:``}`,disabled:i||!d&&f,onClick:()=>void p(),children:i?(0,k.jsx)(g,{size:12,className:`spin`}):o?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(v,{size:12}),` Saved`]}):d?`Connect`:`Save`}),e.configured&&(0,k.jsx)(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void _(),children:`Disconnect`}),e.product_url&&(0,k.jsxs)(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[`Docs `,(0,k.jsx)(T,{size:11})]})]})]})}function G({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=e.required_connections?.find(e=>e.connector_id===t),a=e.namespaced_agent_id;if(!i||!a)return null;let[o,s]=(0,A.useState)(()=>new Set(n)),[c,l]=(0,A.useState)(null),[u,p]=(0,A.useState)(null);(0,A.useEffect)(()=>{s(new Set(n))},[n.join(`,`)]);let m=async e=>{if(c!==null)return;let i=new Set(o);i.has(e)?i.delete(e):i.add(e),s(i),l(e),p(null);try{i.size===0?await d(t,a):await f(t,a,[...i]),r()}catch(e){s(new Set(n)),p(e instanceof Error?e.message:String(e))}finally{l(null)}};return(0,k.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,k.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,k.jsx)(`div`,{className:`grant-scope-list`,children:i.scopes.map(e=>(0,k.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,k.jsx)(`span`,{className:`grant-scope-label`,children:L(e)}),(0,k.jsxs)(`span`,{className:`toggle-switch`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:o.has(e),onChange:()=>void m(e),disabled:c!==null}),(0,k.jsx)(`span`,{className:`toggle-track`})]})]},e))}),u&&(0,k.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,k.jsx)(w,{size:11}),` `,u]})]})}function K({servers:e,expanded:t,onToggle:n}){return(0,k.jsxs)(`div`,{className:`agent-mcps-section`,children:[(0,k.jsx)(`div`,{className:`agent-mcps-section-header`,children:`Custom agent servers`}),(0,k.jsx)(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return(0,k.jsx)(q,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})]})}function q({server:e,expanded:t,onToggle:n}){let r=[e.command,...e.args].join(` `);return(0,k.jsxs)(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[(0,k.jsx)(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),(0,k.jsxs)(`span`,{className:`agent-mcp-agent-label`,children:[`via `,e.agent_name]}),e.disabled?(0,k.jsx)(`span`,{className:`agent-mcp-status disabled`,children:`Disabled`}):(0,k.jsxs)(`span`,{className:`agent-mcp-status enabled`,children:[(0,k.jsx)(v,{size:11}),` Active`]}),(0,k.jsx)(`span`,{className:`agent-mcp-readonly-badge`,children:`read-only`}),(0,k.jsx)(`span`,{className:`agent-mcp-chevron`,children:t?(0,k.jsx)(C,{size:14}):(0,k.jsx)(y,{size:14})})]}),t&&(0,k.jsxs)(`div`,{className:`agent-mcp-detail`,children:[r&&(0,k.jsx)(`div`,{className:`agent-mcp-command-row`,children:r}),(0,k.jsx)(`div`,{className:`agent-mcp-config-path`,children:e.config_path}),(0,k.jsxs)(`div`,{className:`agent-mcp-config-hint`,children:[`Edit the agent's `,(0,k.jsx)(`code`,{children:`mcp_servers.json`}),` to change this server.`]})]})]})}function J({connectorId:e,connectorType:t}){let{agents:n}=l(),[r,i]=(0,A.useState)({}),[o,s]=(0,A.useState)({}),[c,u]=(0,A.useState)(!0),d=(0,A.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([x(e),a(e)]);i(t),s(n)}catch{i({}),s({})}finally{u(!1)}},[e]);if((0,A.useEffect)(()=>{d()},[d]),N((0,A.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&d()},[e,d])),c)return null;let f=n.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),p=t===`mcp_server`?n.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return(0,k.jsxs)(`div`,{className:`connection-grants`,children:[(0,k.jsx)(`div`,{className:`grants-header`,children:`Per-agent grants`}),f.length===0?(0,k.jsx)(`div`,{className:`grants-empty`,children:`No agents require access to this connector.`}):f.map(t=>(0,k.jsx)(G,{agent:t,connectorId:e,grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void d()},t.namespaced_agent_id)),p.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`grants-header grants-header--activations`,children:`Active for`}),(0,k.jsx)(`div`,{className:`grants-help`,children:`Activations gate which agents see this connector's tools. Activating without a prior grant auto-creates one.`}),p.map(t=>(0,k.jsx)(Y,{agent:t,connectorId:e,active:!!o[t.namespaced_agent_id],grantedScopes:r[t.namespaced_agent_id]??[],onChanged:()=>void d()},`activation-${t.namespaced_agent_id}`))]})]})}function Y({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,A.useState)(n),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(null);(0,A.useEffect)(()=>{l(n)},[n]);let m=async()=>{if(u)return;let e=!c;l(e),d(!0),p(null);try{if(e){let e=r.length===0?a?[...a.scopes]:[...R]:void 0;await O(t,s,e)}else await o(t,s);i()}catch(e){l(n),p(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,k.jsxs)(`div`,{className:`grant-agent-card`,children:[(0,k.jsx)(`div`,{className:`grant-agent-card-name`,children:e.name}),(0,k.jsx)(`div`,{className:`grant-scope-list`,children:(0,k.jsxs)(`label`,{className:`grant-scope-item`,children:[(0,k.jsx)(`span`,{className:`grant-scope-label`,children:c?`Tools visible to this agent`:`Tools hidden from this agent`}),(0,k.jsxs)(`span`,{className:`toggle-switch`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:c,onChange:()=>void m(),disabled:u}),(0,k.jsx)(`span`,{className:`toggle-track`})]})]})}),f&&(0,k.jsxs)(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[(0,k.jsx)(w,{size:11}),` `,f]})]})}function X(){return(0,k.jsxs)(`div`,{className:`settings-pane`,children:[(0,k.jsx)(`h2`,{className:`settings-pane-title`,children:`Connectors`}),(0,k.jsx)(B,{})]})}export{X as ConnectorsPane};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.doc-modal{width:640px}.doc-target{color:var(--text-secondary);flex-direction:column;gap:4px;margin-bottom:14px;font-size:13px;display:flex}.doc-target-choice{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.doc-target-choice select{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-primary);max-width:100%;color:var(--text-primary);cursor:pointer;padding:4px 8px;font-size:13px}.doc-target-choice select:focus-visible{border-color:var(--accent);outline:none}.doc-target-hint{color:var(--text-muted);font-size:12px}.doc-target-notice{color:var(--text-secondary);margin:-6px 0 12px;font-size:12.5px}.drop-zone{border:2px dashed var(--border);border-radius:var(--radius-lg);text-align:center;cursor:pointer;color:var(--text-secondary);transition:all var(--duration) var(--ease);flex-direction:column;justify-content:center;align-items:center;margin-bottom:18px;padding:36px;display:flex}.drop-zone:hover,.drop-zone.drag-over{border-color:var(--accent);background:var(--accent-dim2);color:var(--accent);transform:translateY(-1px)}.drop-zone.uploading{border-color:var(--accent);cursor:default}.drop-zone p{font-size:14px;font-weight:500;font-family:var(--font-sans);margin-top:10px}.drop-hint{color:var(--text-muted);font-size:12px;font-family:var(--font-sans);margin-top:4px}.upload-spinner{border:3px solid var(--border);border-top-color:var(--accent);width:28px;height:28px;animation:spin var(--duration-spin) var(--ease-linear) infinite;border-radius:50%}.path-input-form{align-items:center;gap:8px;margin-bottom:16px;display:flex}.path-icon{color:var(--text-muted);flex-shrink:0}.path-input{border:1px solid var(--border);border-radius:var(--radius-md);font-size:13px;font-family:var(--font-mono);transition:border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);outline:none;flex:1;padding:9px 14px}.path-input:focus{border-color:var(--accent)}.path-input::placeholder{color:var(--text-muted)}.doc-stats{color:var(--text-muted);align-items:center;gap:8px;margin-bottom:12px;padding:0 2px;font-size:12px;display:flex}.doc-list{flex-direction:column;gap:4px;display:flex}.doc-row{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease), background var(--duration) var(--ease);justify-content:space-between;align-items:center;padding:12px 14px;display:flex}.doc-row:hover{border-color:var(--accent-light);background:var(--tint-subtle)}.doc-info{flex:1;min-width:0}.doc-name{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;display:block;overflow:hidden}.doc-meta{color:var(--text-muted);font-size:12px}.doc-timestamp{border-left:1px solid var(--border-light);color:var(--text-muted);cursor:default;align-items:center;gap:3px;margin-left:6px;padding-left:6px;font-size:11px;display:inline-flex}.doc-timestamp svg{opacity:.6;flex-shrink:0}.doc-status-badge{font-size:var(--fs-caption);border-radius:var(--radius-sm);font-family:var(--font-sans);align-items:center;gap:4px;padding:2px 8px;display:inline-flex}.doc-status-failed{color:var(--danger);background:var(--danger-dim)}.doc-status-cancelled{color:var(--text-muted);background:color-mix(in srgb, var(--text-muted) 8%, transparent)}.doc-status-missing{color:var(--accent-yellow);background:var(--accent-yellow-dim)}.doc-row-actions{opacity:0;transition:opacity var(--duration-fast) var(--ease);flex-shrink:0;align-items:center;gap:2px;display:flex}.doc-row:hover .doc-row-actions{opacity:1}.doc-open-folder{color:var(--text-muted)}.doc-open-folder:hover{color:var(--accent-blue)}.doc-delete{color:var(--text-muted)}.doc-delete:hover{color:var(--danger)}.empty-docs{color:var(--text-muted);text-align:center;flex-direction:column;align-items:center;padding:32px;display:flex}.empty-docs p{margin-top:8px;font-size:14px}.empty-docs span{margin-top:4px;font-size:12px}.doc-indexing-status{align-items:center;gap:8px;display:inline-flex}.btn-retry{color:var(--text-muted);cursor:pointer;transition:background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);background:0 0;border:none;border-radius:4px;align-items:center;gap:4px;padding:2px 6px;font-size:11px;display:inline-flex}.btn-retry:hover{background:var(--danger-dim);color:var(--danger)}.btn-retry:disabled{opacity:.6;cursor:default;color:var(--text-muted);background:0 0}.doc-failure{flex-direction:column;gap:4px;min-width:0;display:flex}.doc-failure-hint,.doc-failure-reason{overflow-wrap:anywhere;margin:0;font-size:12px;line-height:1.4}.doc-failure-hint{color:var(--text-secondary)}.doc-failure-reason{color:var(--text-muted)}.doc-failure-reason summary{cursor:pointer}.doc-failure-reason p{white-space:pre-line;margin:4px 0 0}.btn-retry-quiet{opacity:.8;font-size:10px}.doc-folder-notice{color:var(--text-secondary);background:var(--bg-secondary);border-radius:6px;align-items:flex-start;gap:8px;margin:8px 0;padding:8px 10px;font-size:12px;line-height:1.4;display:flex}.doc-folder-notice>span{overflow-wrap:anywhere;flex:1;min-width:0}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{$ as a,$t as o,B as s,Ft as c,H as l,It as u,Pt as ee,Q as te,Rt as ne,U as re,V as ie,Vt as d,W as f,Wt as ae,Y as p,Z as oe,Zt as se,_t as ce,fn as le,ft as ue,ln as de,lt as fe,ot as pe,pn as m,q as me,st as h,t as g,tn as he,vt as ge}from"./index-Cae5Fje-.js";var _={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`]};_.node;var v=t(_),y={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};y.node;var _e=t(y),b={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};b.node;var ve=t(b),x=e(r(),1),S=n();function ye(e){let[t,...n]=e.replace(/^RAG indexing failed for [^:]+:\s*/,``).trim().split(`
|
|
2
|
-
`);return{summary:t.trim(),more:n.join(`
|
|
3
|
-
`).trim()}}function be(e,t){let n=t.skipped??0,r=[];if(t.indexed>0?r.push(`Indexed ${t.indexed} file${t.indexed===1?``:`s`} from "${e}".`):t.failed===0&&r.push(`"${e}" has no documents GAIA can index.`),n>0&&r.push(`Skipped ${n} file${n===1?``:`s`} of a type GAIA doesn't index.`),t.failed>0){let e=t.errors[0]?` ${t.errors[0].split(`
|
|
4
|
-
`)[0]}`:``;r.push(`${t.failed} file${t.failed===1?``:`s`} couldn't be indexed.${e}`)}return r.push(`Subfolders aren't included.`),r.join(` `)}function xe(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Se(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 Ce(e){try{let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function C(){let{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:r,currentSessionId:_,sessions:y,updateSessionInList:b,draftDocumentIds:C,addDraftDocuments:w,removeDraftDocument:T}=c(),E=y.find(e=>e.id===_)??null,[D,we]=(0,x.useState)(_?`chat`:`next`),O=D===`chat`?_:null,k=`“${E?.title||`Untitled chat`}”`,[A,j]=(0,x.useState)(``),Te=(0,x.useCallback)(()=>n(!1),[n]);ee(!0,Te);let M=(0,x.useRef)(null);f(M,!0);let[Ee,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(!1),[De,I]=(0,x.useState)(``),[L,R]=(0,x.useState)(``),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(new Set),G=(0,x.useRef)(new Map),[,Oe]=(0,x.useState)(0);(0,x.useEffect)(()=>{i.doc.info(`Loading document library...`);let e=i.doc.time();h().then(n=>{let r=n.documents||[];t(r),i.doc.timed(`Loaded ${r.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{i.doc.error(`Failed to load documents`,e),t([])})},[t]);let K=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,x.useEffect)(()=>{if(!K)return;let e=c.getState().documents;for(let t of e)(t.indexing_status===`indexing`||t.indexing_status===`pending`)&&!G.current.has(t.id)&&G.current.set(t.id,Date.now());let n=!1,r=setInterval(async()=>{if(Oe(e=>e+1),!n){n=!0;try{let e=c.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await a(n.id);if(e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){G.current.delete(n.id);let e=await h();t(e.documents||[]);break}}catch{}}finally{n=!1}}},2e3);return()=>clearInterval(r)},[K,t]),(0,x.useEffect)(()=>{let t=new Set(e.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let e of G.current.keys())t.has(e)||G.current.delete(e)},[e]),(0,x.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await h()).documents||[],n=c.getState().documents;(e.length!==n.length||e.some((e,t)=>{let r=n.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(t(e),i.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let ke=e.reduce((e,t)=>e+t.file_size,0),q=e.reduce((e,t)=>e+t.chunk_count,0),J=(0,x.useCallback)(async(e,t)=>{if(!O){w([e]),j(`${t} will be attached to your next new chat.`),i.doc.info(`"${t}" will be attached to the next new chat`);return}await p(O,e);let n=c.getState().sessions.find(e=>e.id===O)?.document_ids??[];n.includes(e)||b(O,{document_ids:[...n,e]}),j(`Attached ${t} to ${k}.`),i.doc.info(`Attached "${t}" to session ${O}`)},[O,k,b,w]),Y=(0,x.useCallback)(async(e,t)=>{if(e.length===0)return;if(!O){w(e),i.doc.info(`"${t}" will be attached to the next new chat`);return}let n=[];for(let t of e)try{await p(O,t),n.push(t)}catch(e){i.doc.warn(`Could not attach document to session: ${e}`)}let r=c.getState().sessions.find(e=>e.id===O)?.document_ids??[],a=n.filter(e=>!r.includes(e));a.length>0&&b(O,{document_ids:[...r,...a]}),i.doc.info(`Attached "${t}" to session ${O}`)},[O,b,w]),X=(0,x.useCallback)(async(e,n,r)=>{let a=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,o=a&&!re(a)?l(a)?.message??`The file type "${a}" is not supported for indexing.`:null;if(o&&!r){i.doc.warn(`Unsupported file type: ${e} (${a})`),B({filename:e,error:o});return}i.doc.info(`Indexing document: ${e}`);let s=i.doc.time();F(!0),I(`Indexing ${e}...`),B(null),H(null),j(``);try{let r=await n();if(i.doc.timed(`Indexed "${e}": ${r?.chunk_count||`?`} chunks`,s),r?.id)try{await J(r.id,r.filename||e)}catch(t){i.doc.error(`Could not attach "${e}" to ${k}`,t),B({filename:e,error:`Indexed, but not attached to ${k}: ${t instanceof Error?t.message:t}`})}let a=await h();t(a.documents||[]),I(``)}catch(t){let{httpStatus:n,reason:a}=t??{};if(a===`is_folder`&&r){await r();return}i.doc.error(`Failed to index "${e}"`,t);let s=n===400&&o?o:t instanceof Error?t.message:`Upload failed`;B({filename:e,error:s,status:n,kind:a}),I(``)}finally{F(!1)}},[J,k,t]),Z=(0,x.useCallback)(async(e,n)=>{i.doc.info(`"${e}" is a folder; indexing its documents`),I(`Indexing the documents in ${n}...`);try{let r=await pe(e,!1);await Y(r.documents.map(e=>e.id).filter(Boolean),n),H(be(n,r));let i=await h();t(i.documents||[])}catch(t){i.doc.error(`Failed to index folder "${e}"`,t);let r=t instanceof Error?t.message:`Folder indexing failed`,{httpStatus:a}=t??{};B({filename:n,error:r,status:a})}finally{I(``)}},[Y,t]),Q=(0,x.useCallback)(async(e,t)=>{await X(t,()=>ge(e),()=>Z(e,t))},[X,Z]),$=(0,x.useCallback)(async e=>{await X(e.name,()=>ce(e))},[X]),Ae=(0,x.useCallback)(async e=>{e.preventDefault(),N(!1);let t=Array.from(e.dataTransfer.files);i.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await $(e)},[$]),je=(0,x.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Deleting document: ${r?.filename||n}`);try{await te(n),G.current.delete(n),T(n),t(e.filter(e=>e.id!==n)),i.doc.info(`Deleted document: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to delete document: ${r?.filename||n}`,e)}},[e,t,T]),Me=(0,x.useCallback)(async(e,t)=>{i.doc.info(`Opening folder for: ${e}`);try{await fe(e,!0)}catch(e){i.doc.error(`Failed to open folder for: ${t}`,e)}},[]),Ne=(0,x.useCallback)(async n=>{let r=e.find(e=>e.id===n);i.doc.info(`Cancelling indexing for: ${r?.filename||n}`);try{await oe(n),G.current.delete(n);let e=await h();t(e.documents||[]),i.doc.info(`Cancelled indexing for: ${r?.filename||n}`)}catch(e){i.doc.error(`Failed to cancel indexing: ${r?.filename||n}`,e)}},[e,t]),Pe=(0,x.useCallback)(async n=>{if(U.has(n))return;let r=e.find(e=>e.id===n);i.doc.info(`Reindexing document: ${r?.filename||n}`),W(e=>new Set(e).add(n));try{await ue(n),i.doc.info(`Reindex complete for: ${r?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.doc.error(`Reindex failed for: ${r?.filename||n}`,e),B({filename:r?.filename||n,error:t})}finally{try{let e=await h();t(e.documents||[])}catch(e){i.doc.error(`Failed to refresh documents after reindex`,e)}W(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,U]),Fe=(0,x.useCallback)(async t=>{let n=e.find(e=>e.id===t)?.filename||t;j(``);try{await J(t,n)}catch(e){i.doc.error(`Failed to attach ${n} to ${k}`,e),B({filename:n,error:`Not attached to ${k}: ${e instanceof Error?e.message:e}`})}},[e,J,k]),Ie=(0,x.useCallback)(async e=>{if(e.preventDefault(),!L.trim())return;let t=L.trim();i.doc.info(`Indexing from path input: ${t}`),await Q(t,t.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||`file`),R(``)},[L,Q]),Le=e=>{let t=e.indexing_status||`complete`,n=G.current.get(e.id),r=e.indexed_at?Se(e.indexed_at):``,i=e.indexed_at?Ce(e.indexed_at):``;switch(t){case`indexing`:case`pending`:return(0,S.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,S.jsxs)(`div`,{className:`doc-indexing-bar`,children:[(0,S.jsx)(`div`,{className:`doc-indexing-bar-track`,children:(0,S.jsx)(`div`,{className:`doc-indexing-bar-fill`})}),(0,S.jsxs)(`span`,{className:`doc-indexing-label`,children:[(0,S.jsx)(_e,{size:12,className:`doc-spin`}),`Indexing`,n?` (${xe(n)})`:`...`]})]}),(0,S.jsxs)(`button`,{className:`btn-cancel`,onClick:t=>{t.stopPropagation(),Ne(e.id)},title:`Cancel indexing`,"aria-label":`Cancel indexing ${e.filename}`,children:[(0,S.jsx)(v,{size:14}),`Cancel`]})]});case`failed`:{let t=e.error_kind?s[e.error_kind]:void 0,n=e.last_error?ye(e.last_error):null;return(0,S.jsxs)(`div`,{className:`doc-failure`,children:[(0,S.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-failed`,title:e.last_error||void 0,"aria-label":e.last_error?`Failed: ${e.last_error}`:`Indexing failed`,children:[(0,S.jsx)(m,{size:12}),` `,t?`Can't be read`:`Failed`]}),(0,S.jsxs)(`button`,{className:t?`btn-retry btn-retry-quiet`:`btn-retry`,onClick:t=>{t.stopPropagation(),Pe(e.id)},title:t?`Retry indexing (fix the file first, or this fails again)`:`Retry indexing`,"aria-label":`Retry indexing ${e.filename}`,disabled:U.has(e.id),children:[(0,S.jsx)(ve,{size:t?12:14}),U.has(e.id)?`Retrying…`:`Retry`]})]}),t&&(0,S.jsx)(`p`,{className:`doc-failure-hint`,children:t}),n&&(n.more?(0,S.jsxs)(`details`,{className:`doc-failure-reason`,children:[(0,S.jsx)(`summary`,{children:n.summary}),(0,S.jsx)(`p`,{children:n.more})]}):(0,S.jsx)(`p`,{className:`doc-failure-reason`,children:n.summary})),!n&&!t&&(0,S.jsx)(`p`,{className:`doc-failure-reason`,children:`GAIA didn't record why. Retry to see the error.`})]})}case`cancelled`:return(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[(0,S.jsx)(v,{size:12}),` Cancelled`]});case`missing`:return(0,S.jsxs)(`span`,{className:`doc-status-badge doc-status-missing`,children:[(0,S.jsx)(m,{size:12}),` File missing`]});default:return(0,S.jsxs)(`span`,{className:`doc-meta`,children:[g(e.file_size),` · `,e.chunk_count,` chunk`,e.chunk_count===1?``:`s`,r&&(0,S.jsxs)(`span`,{className:`doc-timestamp`,title:`Indexed: ${i}`,children:[(0,S.jsx)(de,{size:10}),r]})]})}};return(0,S.jsx)(`div`,{ref:M,className:`modal-overlay`,onClick:()=>n(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`Document library`,children:(0,S.jsxs)(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`modal-header`,children:[(0,S.jsx)(`h3`,{children:`Document library`}),(0,S.jsx)(`button`,{className:`btn-icon`,onClick:()=>n(!1),"aria-label":`Close document library`,children:(0,S.jsx)(u,{size:18})})]}),(0,S.jsxs)(`div`,{className:`modal-body`,children:[(0,S.jsxs)(`div`,{className:`doc-target`,children:[_?(0,S.jsxs)(`label`,{className:`doc-target-choice`,children:[`Add documents to`,(0,S.jsxs)(`select`,{value:D,onChange:e=>{we(e.target.value),j(``)},children:[(0,S.jsxs)(`option`,{value:`chat`,children:[`This chat: `,k]}),(0,S.jsx)(`option`,{value:`next`,children:`Your next new chat`})]})]}):(0,S.jsx)(`span`,{children:`Documents you add here are attached to your next new chat.`}),(0,S.jsx)(`span`,{className:`doc-target-hint`,children:`A chat searches only the documents attached to it.`})]}),(0,S.jsx)(`div`,{className:`drop-zone ${Ee?`drag-over`:``} ${P?`uploading`:``}`,onDragOver:e=>{e.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:Ae,children:P?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`upload-spinner`}),(0,S.jsx)(`p`,{children:De})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(ne,{size:32,strokeWidth:1.5}),(0,S.jsx)(`p`,{children:`Drop files here to index`}),(0,S.jsx)(`span`,{className:`drop-hint`,children:`PDF, TXT, MD, code files, and 50+ formats`})]})}),(0,S.jsxs)(`form`,{className:`path-input-form`,onSubmit:Ie,children:[(0,S.jsx)(o,{size:16,className:`path-icon`}),(0,S.jsx)(`input`,{type:`text`,className:`path-input`,value:L,onChange:e=>R(e.target.value),placeholder:`Or enter a file or folder path: ${me()}`,"aria-label":`File path to index`}),(0,S.jsx)(`button`,{type:`submit`,className:`btn-secondary`,disabled:!L.trim()||P,children:`Index`}),(0,S.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(!1),r(!0)},title:`Browse files on this computer`,children:[(0,S.jsx)(ae,{size:14}),`Browse files`]})]}),A&&(0,S.jsx)(`p`,{className:`doc-target-notice`,role:`status`,children:A}),z&&(0,S.jsx)(ie,{filename:z.filename,error:z.error,status:z.status,kind:z.kind,onDismiss:()=>B(null)}),V&&(0,S.jsxs)(`div`,{className:`doc-folder-notice`,role:`status`,children:[(0,S.jsx)(le,{size:14}),(0,S.jsx)(`span`,{children:V}),(0,S.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>H(null),"aria-label":`Dismiss folder indexing result`,children:(0,S.jsx)(u,{size:12})})]}),e.length>0&&(0,S.jsxs)(`div`,{className:`doc-stats`,children:[(0,S.jsxs)(`span`,{children:[e.length,` document`,e.length===1?``:`s`]}),(0,S.jsx)(`span`,{children:`·`}),(0,S.jsxs)(`span`,{children:[q,` chunk`,q===1?``:`s`]}),(0,S.jsx)(`span`,{children:`·`}),(0,S.jsx)(`span`,{children:g(ke)})]}),(0,S.jsxs)(`div`,{className:`doc-list`,children:[e.length===0&&!P&&(0,S.jsxs)(`div`,{className:`empty-docs`,children:[(0,S.jsx)(he,{size:32,strokeWidth:1}),(0,S.jsx)(`p`,{children:`No documents indexed yet`}),(0,S.jsx)(`span`,{children:`Drop files above or enter a file path`})]}),e.map(e=>(0,S.jsxs)(`div`,{className:`doc-row ${e.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[(0,S.jsxs)(`div`,{className:`doc-info`,children:[(0,S.jsx)(`span`,{className:`doc-name`,children:e.filename}),Le(e)]}),(0,S.jsxs)(`div`,{className:`doc-row-actions`,children:[e.filepath&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>Me(e.filepath,e.filename),title:`Open folder: ${e.filepath}`,"aria-label":`Open containing folder for ${e.filename}`,children:(0,S.jsx)(o,{size:14})}),e.indexing_status===`complete`&&!(O?E?.document_ids?.includes(e.id):C.includes(e.id))&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>Fe(e.id),title:O?`Use in ${k}`:`Use in your next chat`,"aria-label":O?`Attach ${e.filename} to ${k}`:`Attach ${e.filename} to your next chat`,children:(0,S.jsx)(se,{size:14})}),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`&&(0,S.jsx)(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>je(e.id),title:`Remove`,"aria-label":`Remove ${e.filename}`,children:(0,S.jsx)(d,{size:14})})]})]},e.id))]})]})]})})}export{C as DocumentLibrary};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.file-browser-modal{flex-direction:column;width:min(95vw,1000px);max-height:85vh;display:flex}.file-browser-modal.has-preview{width:min(95vw,1200px)}.file-browser-body{flex-direction:column;flex:1;gap:10px;padding:0 16px 16px;display:flex;overflow:hidden}.fb-quick-links{flex-wrap:wrap;gap:6px;padding:4px 0;display:flex}.fb-quick-link{border-radius:var(--radius-sm);border:1px solid var(--border-light);background:var(--bg-secondary);color:var(--text-secondary);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:5px 10px;font-size:12px;display:flex}.fb-quick-link:hover{background:var(--bg-hover);color:var(--text-primary);border-color:var(--border)}.fb-search-bar{align-items:center;gap:8px;display:flex}.fb-search-input-wrap{flex:1;align-items:center;display:flex;position:relative}.fb-search-icon{color:var(--text-muted);pointer-events:none;position:absolute;left:10px}.fb-search-input{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);width:100%;color:var(--text-primary);font-size:13px;font-family:var(--font-sans);transition:border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);outline:none;padding:8px 30px 8px 32px}.fb-search-input:focus{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-clear{color:var(--text-muted);cursor:pointer;background:0 0;border:none;padding:2px;display:flex;position:absolute;right:8px}.fb-type-filter{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);color:var(--text-primary);font-size:12px;font-family:var(--font-sans);outline:none;min-width:110px;padding:8px}.fb-type-filter:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-btn{border-radius:var(--radius-md);border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text);font-size:var(--fs-label);font-weight:600;font-family:var(--font-sans);cursor:pointer;white-space:nowrap;transition:all var(--duration) var(--ease);padding:8px 14px}.fb-search-btn:hover{background:var(--accent-fill-hover)}.fb-search-btn:disabled{opacity:.4;cursor:not-allowed;box-shadow:none}.fb-pathbar{align-items:center;gap:12px;display:flex}.fb-pathbar .fb-breadcrumb{flex:1;min-width:0}.fb-hidden-toggle{color:var(--text-secondary);cursor:pointer;flex-shrink:0;align-items:center;gap:6px;font-size:12px;display:flex}.fb-breadcrumb{color:var(--text-secondary);flex-wrap:nowrap;align-items:center;gap:2px;padding:4px 0;font-size:12px;display:flex;overflow-x:auto}.fb-crumb{color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);white-space:nowrap;transition:all var(--duration) var(--ease);background:0 0;border:none;padding:2px 4px;font-size:12px}.fb-crumb:hover{background:var(--bg-hover);color:var(--text-primary)}.fb-crumb-item{align-items:center;display:flex}.fb-crumb-sep{color:var(--text-muted);flex-shrink:0}.fb-up-btn{border:1px solid var(--border);color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);transition:all var(--duration) var(--ease);background:0 0;align-items:center;margin-left:auto;padding:3px 6px;display:flex}.fb-up-btn:hover{background:var(--bg-hover);border-color:var(--accent);color:var(--accent)}.fb-search-header{color:var(--text-secondary);justify-content:space-between;align-items:center;gap:12px;padding:4px 0;font-size:12px;display:flex}.fb-search-summary{flex-direction:column;gap:3px;min-width:0;display:flex}.fb-search-scope{color:var(--text-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.fb-search-scope code{color:var(--text-secondary);font-family:var(--font-mono)}.fb-back-btn{color:var(--accent);cursor:pointer;transition:color var(--duration) var(--ease);background:0 0;border:none;font-size:12px}.fb-back-btn:hover{color:var(--accent-light)}.fb-content{flex:1;gap:12px;min-height:300px;display:flex;overflow:hidden}.fb-file-list{border:1px solid var(--border);border-radius:var(--radius-lg);scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex:1;min-width:250px;overflow-y:auto}.fb-file-list::-webkit-scrollbar{width:5px}.fb-file-list::-webkit-scrollbar-track{background:0 0}.fb-file-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--radius-full)}.fb-file-list::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}.fb-entry{cursor:pointer;border-bottom:1px solid var(--border-light);transition:background var(--duration-fast) var(--ease);font-size:13px;font-family:var(--font-sans);align-items:center;gap:8px;padding:8px 10px;display:flex}.fb-entry:hover{background:var(--bg-hover)}.fb-entry.selected{background:var(--accent-dim2);border-color:color-mix(in srgb, var(--accent) 12%, transparent)}.fb-entry.folder .fb-entry-icon{color:var(--text-secondary)}.fb-entry .fb-entry-icon{color:var(--text-muted);flex-shrink:0}.fb-entry-name{text-overflow:ellipsis;white-space:nowrap;color:var(--text-primary);flex:1;overflow:hidden}.fb-entry.folder .fb-entry-name{font-weight:500}.fb-entry-size,.fb-entry-date{font-size:var(--fs-caption);color:var(--text-muted);white-space:nowrap;font-family:var(--font-sans);font-variant-numeric:tabular-nums;flex-shrink:0}.fb-entry-size{text-align:right;min-width:55px}.fb-entry-date{text-align:right;min-width:65px}.fb-entry-checkbox{cursor:pointer;width:16px;min-width:16px;height:16px;min-height:16px;accent-color:var(--accent);flex-shrink:0}.fb-entry-preview-btn{width:24px;min-width:24px;height:24px;color:var(--text-muted);cursor:pointer;border-radius:var(--radius-sm);opacity:0;transition:opacity var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);background:0 0;border:none;flex-shrink:0;justify-content:center;align-items:center;padding:0;display:inline-flex}.fb-entry:hover .fb-entry-preview-btn,.fb-entry.selected .fb-entry-preview-btn{opacity:1}.fb-entry-preview-btn:hover{color:var(--text-primary);background:var(--bg-hover)}.fb-entry-preview-btn:focus-visible{opacity:1;outline:2px solid var(--accent);outline-offset:1px}.fb-preview{border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;flex-shrink:0;width:280px;display:flex;overflow:hidden}.fb-preview-header{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;padding:8px 12px;display:flex}.fb-preview-name{color:var(--text-primary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;overflow:hidden}.fb-preview-meta{font-size:var(--fs-caption);color:var(--text-muted);border-bottom:1px solid var(--border-light);font-family:var(--font-sans);font-variant-numeric:tabular-nums;gap:10px;padding:6px 12px;display:flex}.fb-preview-columns{color:var(--text-secondary);border-bottom:1px solid var(--border-light);word-break:break-word;padding:6px 12px;font-size:11px}.fb-preview-content{font-size:11px;font-family:var(--font-mono);color:var(--text-code);white-space:pre-wrap;word-break:break-all;background:var(--bg-code);scrollbar-width:thin;scrollbar-color:var(--border-code) transparent;flex:1;margin:0;padding:10px 12px;line-height:1.5;overflow:auto}.fb-preview-content::-webkit-scrollbar{width:5px;height:5px}.fb-preview-content::-webkit-scrollbar-track{background:0 0}.fb-preview-content::-webkit-scrollbar-thumb{background:var(--border-code);border-radius:var(--radius-full)}.fb-preview-content::-webkit-scrollbar-thumb:hover{background:var(--text-code-dim)}.fb-preview-loading,.fb-preview-binary{text-align:center;color:var(--text-muted);padding:20px;font-size:12px}.fb-actions{border-top:1px solid var(--border);align-items:center;gap:10px;padding-top:12px;display:flex}.fb-selection-info{color:var(--text-muted);flex:1;font-size:12px}.fb-index-status{font-size:var(--fs-caption);color:var(--accent);font-family:var(--font-sans)}.fb-action-btns{gap:8px;display:flex}.fb-action-btn{border-radius:var(--radius-md);font-size:12px;font-weight:500;font-family:var(--font-sans);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:8px 16px;display:flex}.fb-action-btn.secondary{border:1px solid var(--border);color:var(--text-primary);background:0 0}.fb-action-btn.secondary:hover{background:var(--bg-hover);border-color:var(--text-muted)}.fb-action-btn.primary{border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text)}.fb-action-btn.primary:hover{background:var(--accent-fill-hover)}.fb-action-btn:disabled{opacity:.4;cursor:not-allowed}.fb-loading,.fb-empty,.fb-error{text-align:center;color:var(--text-muted);padding:30px;font-size:13px}.fb-error{color:var(--danger);background:var(--danger-dim2);border-radius:var(--radius-md);padding:10px}@media (width<=768px){.file-browser-modal{border-radius:0;width:100vw;max-height:100vh}.fb-preview{display:none}.fb-search-bar{flex-wrap:wrap}.fb-type-filter{min-width:100%}}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{$t as a,Ft as o,H as s,It as c,Jt as l,Pt as u,Qt as d,Rt as f,U as p,V as ee,W as te,Wt as ne,X as re,Y as m,an as h,dt as ie,en as ae,hn as oe,nn as se,ot as g,pt as ce,st as _,t as le,tn as v,vn as ue,vt as y,yn as de}from"./index-Cae5Fje-.js";var b={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};b.node;var fe=t(b),x={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`}]]};x.node;var pe=t(x),S={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`]};S.node;var C=t(S),w={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`}]]};w.node;var T=t(w),E=e(r(),1),D=n();function me(e){if(e.type===`folder`)return(0,D.jsx)(d,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?(0,D.jsx)(T,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?(0,D.jsx)(fe,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?(0,D.jsx)(v,{size:16}):(0,D.jsx)(ae,{size:16})}function he(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 ge(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function _e(e){switch(e){case`home`:return(0,D.jsx)(C,{size:14});case`desktop`:return(0,D.jsx)(l,{size:14});case`documents`:return(0,D.jsx)(v,{size:14});case`download`:return(0,D.jsx)(h,{size:14});default:return(0,D.jsx)(d,{size:14})}}var ve=[{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 O(e,t,n,r){let a=[],s=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!p(e)?s.push(t):a.push(t)}let c=[],l=[],u=0,d=``,f=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(f.has(e)){let t=await g(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 y(e);t?.id&&(c.push(t.id),l.push(e))}}catch(e){u++,d=e instanceof Error?e.message:`Unknown error`}if(n&&c.length>0){let e=[];for(let t of c)try{await m(n,t),e.push(t)}catch(e){i.doc.warn(`Could not attach document to session: ${e}`)}let t=o.getState().sessions.find(e=>e.id===n)?.document_ids??[],a=e.filter(e=>!t.includes(e));a.length>0&&r(n,{document_ids:[...t,...a]})}else c.length>0&&o.getState().addDraftDocuments(c);if(c.length>0)try{let e=await _();o.getState().setDocuments(e.documents||[])}catch(e){i.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:c,supported:a,succeededFiles:l,unsupported:s,failed:u,lastError:d}}var k=e=>e.startsWith(`.`);function A({onStartChat:e}){let{setShowFileBrowser:t,currentSessionId:n,updateSessionInList:r,setPendingPrompt:l}=o(),d=(0,E.useCallback)(()=>t(!1),[t]);u(!0,d);let m=(0,E.useRef)(null);te(m,!0);let[h,ae]=(0,E.useState)(``),[g,_]=(0,E.useState)(null),[v,y]=(0,E.useState)([]),[b,fe]=(0,E.useState)([]),[x,S]=(0,E.useState)(!1),[C,w]=(0,E.useState)(null),[T,A]=(0,E.useState)(!1),[j,M]=(0,E.useState)(``),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)([]),[ye,be]=(0,E.useState)(!1),[L,R]=(0,E.useState)(!1),[z,xe]=(0,E.useState)(``),[B,V]=(0,E.useState)(new Set),[H,U]=(0,E.useState)(null),[Se,W]=(0,E.useState)(!1),[G,K]=(0,E.useState)(new Set),[Ce,q]=(0,E.useState)(null),J=(0,E.useRef)(null),[Y,X]=(0,E.useState)(null),Z=(0,E.useCallback)(async e=>{S(!0),w(null),P(null),M(``),I([]);try{let t=await re(e);ae(t.current_path),_(t.parent_path),y(t.entries),t.quick_links.length>0&&fe(t.quick_links),i.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;w(t),i.ui.error(`Browse failed`,e)}finally{S(!1)}},[]);(0,E.useEffect)(()=>{Z()},[Z]),(0,E.useEffect)(()=>()=>{J.current&&clearTimeout(J.current)},[]);let we=(0,E.useCallback)(async()=>{if(!j.trim())P(null),I([]);else{R(!0),w(null);try{let e=await ce(j.trim(),z||void 0,30);P(e.results),I(e.searched_locations??[]),be(e.truncated===!0),i.ui.info(`Search "${j}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;w(t),i.ui.error(`Search failed`,e)}finally{R(!1)}}},[j,z]),Te=e=>{e.key===`Enter`&&we()},Ee=(0,E.useCallback)(e=>{e.type===`folder`&&(Z(e.path),V(new Set),U(null))},[Z]),De=(0,E.useCallback)(async e=>{W(!0);try{let t=await ie(e);U(t)}catch(e){i.ui.error(`Preview failed`,e)}finally{W(!1)}},[]),Oe=(0,E.useCallback)(e=>{V(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ke=(0,E.useCallback)(async()=>{if(B.size===0)return;let e=Array.from(B);if(X(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||p(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=s(r);X({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`})}else{K(new Set(e)),q(`Indexing ${e.length} file(s)...`);try{let t=await O(e,v,n,r);if(t.failed>0)q(`Done: ${t.docIds.length} indexed, ${t.failed} failed`),X({filename:`${t.failed} file(s)`,error:t.lastError||`Indexing failed for some files`});else{let e=t.unsupported.length>0?` (${t.unsupported.length} skipped — unsupported type)`:``;q(`Successfully indexed ${t.docIds.length} file(s)${e}`)}J.current&&clearTimeout(J.current),J.current=setTimeout(()=>q(null),5e3),V(new Set)}catch(t){i.doc.error(`Index selected failed`,t),X({filename:e.length===1?e[0].split(/[\\/]/).pop()||e[0]:`${e.length} files`,error:t instanceof Error?t.message:`An unexpected error occurred.`})}finally{K(new Set)}}},[B,n,r,v]),Q=(0,E.useRef)(!1),Ae=(0,E.useCallback)(async()=>{if(B.size===0||Q.current)return;Q.current=!0;let a=Array.from(B);X(null),K(new Set(a)),q(`Indexing ${a.length} file(s) for analysis...`);try{let i=await O(a,v,n,r);if(i.supported.length===0){let e=a[0].lastIndexOf(`.`),t=e>0?a[0].slice(e).toLowerCase():``,n=s(t);X({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(i.docIds.length===0){X({filename:i.supported.length===1?i.supported[0].split(/[\\/]/).pop()||i.supported[0]:`${i.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}i.failed>0&&q(`Warning: ${i.failed} file(s) failed to index and will be excluded.`);let o=(i.succeededFiles.length>0?i.succeededFiles:i.supported).map(e=>e.split(/[\\/]/).pop()||e),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
|
-
`)}`;n?l({sessionId:n,text:c}):await e(c),t(!1),V(new Set)}catch(e){i.doc.error(`Ask Agent failed`,e),X({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{Q.current=!1,K(new Set),q(null)}},[B,n,r,v,l,t,e]),je=h?h.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],Me=je.map((e,t)=>({label:e,path:je.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Ne=ge(F),Pe=v.filter(e=>!k(e.name)),$=N?N.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):T?v:Pe,Fe=v.length-Pe.length;return(0,E.useEffect)(()=>{T||N||V(e=>{let t=[...e].filter(e=>!k(e.split(/[\\/]/).pop()??``));return t.length===e.size?e:new Set(t)})},[T,N]),(0,D.jsx)(`div`,{ref:m,className:`modal-overlay`,onClick:()=>t(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File browser`,children:(0,D.jsxs)(`div`,{className:`modal-panel file-browser-modal ${H?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`modal-header`,children:[(0,D.jsxs)(`h3`,{children:[(0,D.jsx)(a,{size:18}),` File browser`]}),(0,D.jsx)(`button`,{className:`btn-icon`,onClick:()=>t(!1),"aria-label":`Close`,children:(0,D.jsx)(c,{size:18})})]}),(0,D.jsxs)(`div`,{className:`file-browser-body`,children:[(0,D.jsx)(`div`,{className:`fb-quick-links`,children:b.map(e=>(0,D.jsxs)(`button`,{className:`fb-quick-link`,onClick:()=>Z(e.path),title:e.path,children:[_e(e.icon),(0,D.jsx)(`span`,{children:e.name})]},e.path))}),(0,D.jsxs)(`div`,{className:`fb-search-bar`,children:[(0,D.jsxs)(`div`,{className:`fb-search-input-wrap`,children:[(0,D.jsx)(ne,{size:14,className:`fb-search-icon`}),(0,D.jsx)(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:j,onChange:e=>M(e.target.value),onKeyDown:Te,"aria-label":`Search files`}),j&&(0,D.jsx)(`button`,{className:`fb-search-clear`,onClick:()=>{M(``),P(null),I([])},"aria-label":`Clear search`,children:(0,D.jsx)(c,{size:12})})]}),(0,D.jsx)(`select`,{className:`fb-type-filter`,value:z,onChange:e=>xe(e.target.value),"aria-label":`File type filter`,children:ve.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,D.jsx)(`button`,{className:`fb-search-btn`,onClick:we,disabled:!j.trim()||L,children:L?`Searching...`:`Search`})]}),!N&&(0,D.jsxs)(`div`,{className:`fb-pathbar`,children:[(0,D.jsxs)(`div`,{className:`fb-breadcrumb`,children:[(0,D.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Z(`/`),children:(0,D.jsx)(pe,{size:12})}),Me.map((e,t)=>(0,D.jsxs)(`span`,{className:`fb-crumb-item`,children:[(0,D.jsx)(oe,{size:12,className:`fb-crumb-sep`}),(0,D.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Z(e.path),children:e.label})]},t)),g&&(0,D.jsx)(`button`,{className:`fb-up-btn`,onClick:()=>Z(g),title:`Go up`,children:(0,D.jsx)(de,{size:14})})]}),(0,D.jsxs)(`label`,{className:`fb-hidden-toggle`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>A(e.target.checked)}),`Show hidden`]})]}),N&&(0,D.jsxs)(`div`,{className:`fb-search-header`,children:[(0,D.jsxs)(`div`,{className:`fb-search-summary`,children:[(0,D.jsxs)(`span`,{children:[`Found `,N.length,` result(s) for "`,j,`"`]}),Ne&&(0,D.jsxs)(`span`,{className:`fb-search-scope`,title:F.join(`
|
|
3
|
-
`),children:[`Searching in: `,(0,D.jsx)(`code`,{children:Ne})]}),ye&&(0,D.jsx)(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),(0,D.jsx)(`button`,{className:`fb-back-btn`,onClick:()=>{P(null),M(``),I([])},children:`Back to browsing`})]}),C&&(0,D.jsx)(`div`,{className:`fb-error`,children:C}),(0,D.jsxs)(`div`,{className:`fb-content`,children:[(0,D.jsxs)(`div`,{className:`fb-file-list`,children:[x&&(0,D.jsx)(`div`,{className:`fb-loading`,children:`Loading...`}),!x&&$.length===0&&(0,D.jsx)(`div`,{className:`fb-empty`,children:N?`No files found`:Fe>0?`Only hidden items here. Turn on Show hidden to see them.`:`This folder is empty`}),!x&&$.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!p(t),r=n?s(t):null;return(0,D.jsxs)(`div`,{className:`fb-entry ${e.type} ${B.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?Ee(e):Oe(e.path),onDoubleClick:()=>e.type===`folder`?Ee(e):void 0,title:n?`${r?.label||`This`} file type cannot be indexed`:e.path,children:[(0,D.jsx)(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:B.has(e.path),onChange:()=>Oe(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),(0,D.jsx)(`span`,{className:`fb-entry-icon`,children:me(e)}),(0,D.jsx)(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&(0,D.jsx)(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&(0,D.jsx)(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),De(e.path)},"aria-label":`Preview ${e.name}`,title:`Preview file`,children:(0,D.jsx)(se,{size:14})}),(0,D.jsx)(`span`,{className:`fb-entry-size`,children:e.type===`file`?le(e.size):``}),(0,D.jsx)(`span`,{className:`fb-entry-date`,children:he(e.modified)})]},e.path)})]}),H&&(0,D.jsxs)(`div`,{className:`fb-preview`,children:[(0,D.jsxs)(`div`,{className:`fb-preview-header`,children:[(0,D.jsx)(`span`,{className:`fb-preview-name`,children:H.name}),(0,D.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>U(null),"aria-label":`Close preview`,children:(0,D.jsx)(c,{size:14})})]}),(0,D.jsxs)(`div`,{className:`fb-preview-meta`,children:[(0,D.jsx)(`span`,{children:H.size_display}),H.total_lines&&(0,D.jsxs)(`span`,{children:[H.total_lines,` lines`]}),H.columns&&(0,D.jsxs)(`span`,{children:[H.columns.length,` columns`]}),H.row_count!==null&&(0,D.jsxs)(`span`,{children:[H.row_count,` rows`]})]}),H.columns&&(0,D.jsxs)(`div`,{className:`fb-preview-columns`,children:[(0,D.jsx)(`strong`,{children:`Columns:`}),` `,H.columns.join(`, `)]}),Se?(0,D.jsx)(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):H.is_text&&H.preview_lines.length>0?(0,D.jsx)(`pre`,{className:`fb-preview-content`,children:H.preview_lines.slice(0,30).join(`
|
|
4
|
-
`)}):(0,D.jsx)(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),Y&&(0,D.jsx)(ee,{filename:Y.filename,error:Y.error,onDismiss:()=>X(null)}),(0,D.jsxs)(`div`,{className:`fb-actions`,children:[(0,D.jsx)(`div`,{className:`fb-selection-info`,children:B.size>0?`${B.size} item(s) selected`:`Select files to index or analyze`}),Ce&&(0,D.jsx)(`span`,{className:`fb-index-status`,children:Ce}),(0,D.jsxs)(`div`,{className:`fb-action-btns`,children:[(0,D.jsxs)(`button`,{className:`fb-action-btn secondary`,onClick:ke,disabled:B.size===0||G.size>0,title:`Index selected files for RAG search`,children:[(0,D.jsx)(f,{size:14}),`Index Selected`]}),(0,D.jsxs)(`button`,{className:`fb-action-btn primary`,onClick:Ae,disabled:B.size===0||G.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[(0,D.jsx)(ue,{size:14}),`Ask Agent`]})]})]})]})]})})}export{A as FileBrowser};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{n as a,t as o}from"./zap-BogJn9oN.js";import{A as s,Bt as c,C as ee,D as te,E as l,F as ne,Ft as re,Gt as ie,Ht as ae,I as oe,It as se,Kt as ce,L as u,Lt as le,M as ue,N as de,O as fe,P as d,Pt as pe,R as f,S as me,T as he,Vt as ge,W as _e,Wt as ve,Xt as ye,_ as be,b as xe,c as Se,cn as Ce,d as we,f as Te,fn as Ee,g as De,gn as Oe,h as ke,hn as Ae,j as je,k as Me,l as Ne,ln as Pe,m as Fe,nn as Ie,on as Le,p as Re,qt as ze,s as Be,sn as Ve,t as He,u as Ue,un as We,v as Ge,vn as Ke,w as qe,x as Je,y as Ye,z as p,zt as m}from"./index-Cae5Fje-.js";var Xe={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Xe.node;var Ze=t(Xe),h={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};h.node;var Qe=t(h),$e={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};$e.node;var et=t($e),g={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};g.node;var tt=t(g),nt={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};nt.node;var rt=t(nt),it={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};it.node;var at=t(it),ot={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};ot.node;var st=t(ot),ct={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};ct.node;var lt=t(ct),_=e(r(),1),v=n(),ut=[{title:`Preferences`,categories:[`preference`]},{title:`About you`,categories:[`fact`,`profile`,`skill`]},{title:`Reminders`,categories:[`reminder`]},{title:`Notes`,categories:[`note`]}];function dt(e){switch(e){case`user`:return`You added this`;case`tool`:return`You asked GAIA to remember this`;case`llm_extract`:return`Picked up in a chat`;case`consolidation`:return`From an older chat`;case`inferred`:return`From your profile setup`;case`discovery`:return`Found on this PC during profile setup`;default:return`Saved`}}function ft(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Math.floor((Date.now()-t.getTime())/864e5);return n<=0?`today`:n===1?`yesterday`:n<30?`${n} days ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function y(e,t=new Date){let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),r=n?new Date(+n[1],n[2]-1,+n[3]):new Date(e);if(Number.isNaN(r.getTime()))return null;let i=r.getHours()===0&&r.getMinutes()===0&&r.getSeconds()===0,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),o=i?r.getTime()<a:r.getTime()<t.getTime(),s=r.toLocaleString(void 0,{weekday:`short`,month:`short`,day:`numeric`,...r.getFullYear()===t.getFullYear()?{}:{year:`numeric`},...i?{}:{hour:`numeric`,minute:`2-digit`}});return{text:`${o?`Was due`:`Due`} ${s}`,past:o}}function pt({memoryEnabled:e,reloadKey:t,onChanged:n,onOpenAdvanced:r,showToast:a}){let[o,s]=(0,_.useState)(null),[c,ee]=(0,_.useState)(null),[te,l]=(0,_.useState)(null),[ne,re]=(0,_.useState)(``),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)(new Set),[u,le]=(0,_.useState)(``),[ue,de]=(0,_.useState)(`fact`),[fe,d]=(0,_.useState)(null),pe=(0,_.useRef)(0),f=(0,_.useCallback)(async()=>{let e=++pe.current;try{let t=await me({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,limit:200});if(e!==pe.current)return;s(t.items),ee(null)}catch(t){if(e!==pe.current)return;i.system.warn(`Failed to load what GAIA knows about the user`,t),ee(t instanceof Error?t.message:String(t))}},[]);(0,_.useEffect)(()=>{f()},[f,t]);let he=(0,_.useCallback)(async e=>{let t=ne.trim();if(!t||t===e.content)l(null);else{d(e.id);try{await be(e.id,{content:t}),l(null),a(`Updated`,`success`),await f(),n()}catch(e){i.system.error(`Failed to edit memory`,e),a(`Couldn't save the change: ${e instanceof Error?e.message:e}`,`error`)}finally{d(null)}}},[ne,f,n,a]),_e=(0,_.useCallback)(async e=>{d(e.id);try{await De(e.id),pe.current++,s(t=>(t??[]).filter(t=>t.id!==e.id)),ae(t=>[e,...t]),n()}catch(e){i.system.error(`Failed to forget memory`,e),a(`Couldn't forget that: ${e instanceof Error?e.message:e}`,`error`)}finally{d(null)}},[n,a]),ve=(0,_.useCallback)(async e=>{d(e.id);try{await Fe({content:e.content,category:e.category,domain:e.domain??void 0,context:e.context,entity:e.entity??void 0,sensitive:e.sensitive,due_at:e.due_at??void 0}),ae(t=>t.filter(t=>t.id!==e.id)),await f(),n()}catch(e){i.system.error(`Failed to restore memory`,e),a(`Couldn't restore it: ${e instanceof Error?e.message:e}`,`error`)}finally{d(null)}},[f,n,a]),ye=(0,_.useCallback)(async()=>{let e=u.trim();if(e){d(`new`);try{await Fe({content:e,category:ue}),le(``),a(`Saved`,`success`),await f(),n()}catch(e){i.system.error(`Failed to add memory`,e),a(`Couldn't save it: ${e instanceof Error?e.message:e}`,`error`)}finally{d(null)}}},[u,ue,f,n,a]);if(!e)return(0,v.jsxs)(`div`,{className:`mem-about`,children:[(0,v.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsx)(`p`,{children:`Memory is off, so GAIA isn't saving anything about you.`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:r,children:`Turn it on in Advanced`})]})]});let xe=ut.map(e=>({...e,rows:(o??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return(0,v.jsxs)(`div`,{className:`mem-about`,children:[(0,v.jsx)(`h2`,{className:`mem-about-title`,children:`What GAIA knows about you`}),(0,v.jsx)(`p`,{className:`mem-about-intro`,children:`GAIA uses these in every chat. Edit anything that's wrong, or forget it so GAIA stops using it.`}),(0,v.jsxs)(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),ye()},children:[(0,v.jsx)(`input`,{className:`mem-input`,placeholder:`Tell GAIA something about you, e.g. “I prefer short answers”`,"aria-label":`Something GAIA should know about you`,value:u,onChange:e=>le(e.target.value)}),(0,v.jsxs)(`select`,{className:`mem-select`,"aria-label":`Kind`,value:ue,onChange:e=>de(e.target.value),children:[(0,v.jsx)(`option`,{value:`fact`,children:`About you`}),(0,v.jsx)(`option`,{value:`preference`,children:`Preference`}),(0,v.jsx)(`option`,{value:`reminder`,children:`Reminder`}),(0,v.jsx)(`option`,{value:`note`,children:`Note`})]}),(0,v.jsxs)(`button`,{className:`btn-primary`,type:`submit`,disabled:!u.trim()||fe===`new`,children:[(0,v.jsx)(ce,{size:14}),` Add`]})]}),ie.map(e=>(0,v.jsxs)(`div`,{className:`mem-about-forgotten`,role:`status`,children:[(0,v.jsxs)(`span`,{children:[`Forgotten: `,e.sensitive?`a sensitive memory`:`“${e.content}”`,` — GAIA won't learn it again from old chats.`]}),(0,v.jsxs)(`button`,{className:`mem-about-link`,disabled:fe===e.id,onClick:()=>ve(e),children:[(0,v.jsx)(m,{size:12}),` Undo`]})]},e.id)),c?(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsxs)(`p`,{children:[`Couldn't load your memories: `,c]}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:f,children:`Try again`})]}):o===null?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),` Loading…`]}):xe.length===0?(0,v.jsxs)(`div`,{className:`mem-about-empty`,children:[(0,v.jsx)(`p`,{children:`GAIA hasn't saved anything about you yet.`}),(0,v.jsx)(`p`,{className:`mem-about-hint`,children:`Tell it in a chat (“remember that I live in Calgary”) or add something above.`})]}):xe.map(e=>(0,v.jsxs)(`section`,{className:`mem-about-group`,"aria-label":e.title,children:[(0,v.jsx)(`h3`,{className:`mem-about-group-title`,children:e.title}),(0,v.jsx)(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let t=e.sensitive&&!oe.has(e.id),n=e.due_at?y(e.due_at):null;return(0,v.jsx)(`li`,{className:`mem-about-item`,children:te===e.id?(0,v.jsxs)(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),he(e)},children:[(0,v.jsx)(`textarea`,{className:`mem-input`,"aria-label":`Edit memory`,rows:2,autoFocus:!0,value:ne,onChange:e=>re(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),l(null)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),he(e))}}),(0,v.jsxs)(`div`,{className:`mem-about-edit-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,type:`submit`,disabled:fe===e.id,children:`Save`}),(0,v.jsx)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>l(null),children:`Cancel`})]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mem-about-text`,children:[t?(0,v.jsxs)(`button`,{className:`mem-about-link`,onClick:()=>se(t=>new Set(t).add(e.id)),children:[(0,v.jsx)(Ie,{size:12}),` Sensitive — show`]}):e.content,n&&(0,v.jsx)(`span`,{className:`mem-about-due${n.past?` is-overdue`:``}`,children:n.text}),(0,v.jsxs)(`span`,{className:`mem-about-meta`,children:[dt(e.source),` · `,ft(e.updated_at)]})]}),(0,v.jsxs)(`div`,{className:`mem-about-actions`,children:[(0,v.jsx)(`button`,{className:`mem-about-btn`,"aria-label":`Edit: ${t?`sensitive memory`:e.content}`,title:`Edit`,onClick:()=>{l(e.id),re(e.content)},children:(0,v.jsx)(ze,{size:14})}),(0,v.jsxs)(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":`Forget: ${t?`sensitive memory`:e.content}`,title:`Forget`,disabled:fe===e.id,onClick:()=>_e(e),children:[(0,v.jsx)(ge,{size:14}),` Forget`]})]})]})},e.id)})})]},e.title))]})}function mt(e){if(!e)return`—`;try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n={month:`short`,day:`numeric`};return t.getFullYear()!==new Date().getFullYear()&&(n.year=`numeric`),t.toLocaleDateString(void 0,n)}catch{return`—`}}function b(e){if(!e)return``;try{let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function x(e){if(!e)return`—`;try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=Date.now(),r=t.getTime()-n,i=Math.abs(r),a=Math.floor(i/1e3),o=Math.floor(i/6e4),s=Math.floor(i/36e5),c=Math.floor(i/864e5);return r<0?a<5?`just now`:a<60?`${a}s ago`:s===0?`${o}m ago`:c===0?`${s}h ago`:c===1?`yesterday`:c<30?`${c}d ago`:b(e):a<5?`now`:a<60?`in ${a}s`:s===0?`in ${o}m`:c===0?`in ${s}h`:c===1?`tomorrow`:c<30?`in ${c}d`:b(e)}catch{return`—`}}function ht(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function gt(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function _t(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function vt(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function yt(e,t){let n=mt(e),r=mt(t);return n===`—`&&r===`—`?``:n===r?n:`${n} \u2013 ${r}`}function bt(e){if(e.length===0)return 0;let t=new Date().toISOString().slice(0,10),n=e.find(e=>e.date===t);return n?n.knowledge_added:0}var xt=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],St={work:`blue`,technical:`purple`,personal:`green`,general:`gray`};function Ct(){let{setShowMemoryDashboard:e,sessions:t,setCurrentSession:n}=re(),r=(0,_.useMemo)(()=>new Map(t.map(e=>[e.id,e.title])),[t]),Ie=e=>r.get(e)||`${e.slice(0,8)}...`,[m,Xe]=(0,_.useState)(null),[h,$e]=(0,_.useState)([]),[g,nt]=(0,_.useState)(null),[it,ot]=(0,_.useState)([]),[ct,ut]=(0,_.useState)([]),[dt,ft]=(0,_.useState)([]),[y,mt]=(0,_.useState)(null),[Ct,wt]=(0,_.useState)([]),[Tt,Et]=(0,_.useState)(!0),[Dt,Ot]=(0,_.useState)(null),[kt,At]=(0,_.useState)(null),[jt,S]=(0,_.useState)(!1),[Mt,Nt]=(0,_.useState)(null),[Pt,Ft]=(0,_.useState)([]),It=(0,_.useRef)(0),[C,Lt]=(0,_.useState)([]),[Rt,zt]=(0,_.useState)(``),[Bt,Vt]=(0,_.useState)(``),[Ht,Ut]=(0,_.useState)(``),[w,Wt]=(0,_.useState)(`updated_at`),[Gt,Kt]=(0,_.useState)(`desc`),[T,E]=(0,_.useState)(0),[qt,Jt]=(0,_.useState)(!1),[Yt,Xt]=(0,_.useState)(``),[Zt,Qt]=(0,_.useState)(null),$t=(0,_.useRef)(null),[D,en]=(0,_.useState)(null),[tn,nn]=(0,_.useState)(!1),[O,rn]=(0,_.useState)(null),[k,A]=(0,_.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[an,on]=(0,_.useState)(new Set),[j,sn]=(0,_.useState)(!1),[cn,ln]=(0,_.useState)(!1),[un,dn]=(0,_.useState)(!1),[M,N]=(0,_.useState)(!1),[fn,pn]=(0,_.useState)(!1),[P,mn]=(0,_.useState)(null),[hn,gn]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(`about`),[_n,vn]=(0,_.useState)(0),[yn,bn]=(0,_.useState)([]),[xn,Sn]=(0,_.useState)(null),[Cn,wn]=(0,_.useState)(!1),[Tn,En]=(0,_.useState)(null),[Dn,On]=(0,_.useState)(null),[kn,An]=(0,_.useState)(!1),[jn,Mn]=(0,_.useState)({title:``,description:``,priority:`medium`}),[z,B]=(0,_.useState)(`idle`),[Nn,V]=(0,_.useState)([]),[H,U]=(0,_.useState)([]),[Pn,Fn]=(0,_.useState)(null),In=(0,_.useRef)(null),Ln=(0,_.useRef)(null),[W,G]=(0,_.useState)(`idle`),[Rn,K]=(0,_.useState)([]),[q,J]=(0,_.useState)([]),[zn,Bn]=(0,_.useState)(null),[Vn,Hn]=(0,_.useState)(!1),Un=(0,_.useRef)(null),Wn=(0,_.useRef)(null),[Gn,Kn]=(0,_.useState)(30),[qn,Jn]=(0,_.useState)(!1),[Yn,Xn]=(0,_.useState)(!1),[Zn,Qn]=(0,_.useState)(!1),[$n,er]=(0,_.useState)(!1),[tr,nr]=(0,_.useState)(!1),[rr,ir]=(0,_.useState)(!1),ar=(0,_.useRef)(null),or=(0,_.useRef)(null),sr=(0,_.useRef)(null),Y=(0,_.useCallback)((e,t=`info`)=>{let n=++It.current;Ft(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Ft(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,_.useEffect)(()=>{if(!jt)return;let e=e=>{or.current&&!or.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[jt]),pe(!0,()=>{F?I(null):fn?pn(!1):hn?gn(!1):D?en(null):jt?S(!1):tn||O?(nn(!1),rn(null)):Mt?Nt(null):e(!1)}),_e(sr,!!F),(0,_.useEffect)(()=>{if(!F)return;let e=sr.current;if(!e)return;let t=document.activeElement;return e.focus(),()=>{t?.focus()}},[F]);let cr=(0,_.useCallback)(async()=>{try{let e=await l();Xe(e)}catch(e){i.system.warn(`Failed to load memory stats`,e)}},[]),lr=(0,_.useCallback)(async()=>{try{let e=await ee(Gn);$e(e)}catch(e){i.system.warn(`Failed to load memory activity`,e)}},[Gn]),X=(0,_.useCallback)(async()=>{try{let e=await me({category:C.length>0?C:void 0,context:Rt||void 0,entity:Bt||void 0,search:Ht||void 0,sort_by:w,order:Gt,offset:T,limit:15,include_sensitive:!0,include_superseded:qt});nt(e)}catch(e){i.system.warn(`Failed to load knowledge`,e)}},[C,Rt,Bt,Ht,w,Gt,T,qt]),ur=(0,_.useCallback)(async()=>{try{let e=await te();ot(e)}catch(e){i.system.warn(`Failed to load tool summary`,e)}},[]),dr=(0,_.useCallback)(async()=>{try{let e=await qe(20);ut(e)}catch(e){i.system.warn(`Failed to load conversations`,e)}},[]),fr=(0,_.useCallback)(async()=>{try{let e=await fe(7);ft(e)}catch(e){i.system.warn(`Failed to load upcoming items`,e)}},[]),Z=(0,_.useCallback)(async()=>{try{let e=await Ye();mt(e)}catch(e){i.system.warn(`Failed to load embedding coverage`,e)}},[]),pr=(0,_.useCallback)(async()=>{try{let e=await xe();wt(e||[])}catch(e){i.system.warn(`Failed to load entities`,e)}},[]),mr=(0,_.useCallback)(async()=>{try{let e=await he();ln(e.mcp_memory_enabled),sn(e.memory_enabled),dn(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to load memory settings`,e)}},[]),hr=(0,_.useCallback)(async()=>{wn(!0);try{let[e,t]=await Promise.all([Me(),Je()]);bn(e.goals),Sn(t)}catch(e){i.system.warn(`Failed to load goals`,e)}finally{wn(!1)}},[]),gr=(0,_.useCallback)(async(e,t)=>{try{await e()}catch(e){i.system.error(t,e),Y(`${t}: ${e instanceof Error?e.message:e}`,`error`);return}hr()},[hr,Y]);(0,_.useEffect)(()=>{if(!Dn)return;let e=setTimeout(()=>On(null),3e3);return()=>clearTimeout(e)},[Dn]);let Q=(0,_.useCallback)(async()=>{Et(!0),Ot(null);try{await Promise.all([cr(),lr(),X(),ur(),dr(),fr(),Z(),pr(),mr(),hr()]),vn(e=>e+1)}catch(e){Ot(`Failed to load memory data. Is the backend running?`),i.system.error(`Memory dashboard load failed`,e)}finally{Et(!1)}},[cr,lr,X,ur,dr,fr,Z,pr,mr,hr]);(0,_.useEffect)(()=>{Q()},[Q]),(0,_.useEffect)(()=>{X()},[X]);let _r=(0,_.useRef)(!0);(0,_.useEffect)(()=>{_r.current?_r.current=!1:lr()},[lr]);let vr=(0,_.useCallback)(e=>{Ut(e),ir(!0),ar.current&&clearTimeout(ar.current),ar.current=setTimeout(()=>{E(0),ir(!1)},300)},[]),yr=(0,_.useCallback)(()=>{X(),cr(),Z(),fr(),pr()},[X,cr,Z,fr,pr]),$=(0,_.useCallback)(()=>{yr(),vn(e=>e+1)},[yr]),br=(0,_.useCallback)(async()=>{if(k.content.trim())try{let e=await Fe({content:k.content,category:k.category,domain:k.domain||void 0,context:k.context,entity:k.entity||void 0,sensitive:k.sensitive,due_at:k.due_at||void 0});nn(!1),A({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Created new knowledge entry`),e?.embedded===!1?Y(e.embed_error??`Saved, but not embedded`,`error`):Y(`Memory created successfully`,`success`)}catch(e){i.system.error(`Failed to create knowledge`,e),Y(`Failed to create memory`,`error`)}},[k,$,Y]),xr=(0,_.useCallback)(async()=>{if(O&&k.content.trim())try{let e=await be(O,{content:k.content,category:k.category,domain:k.domain||void 0,context:k.context,entity:k.entity||void 0,sensitive:k.sensitive,due_at:k.due_at||void 0});rn(null),A({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Updated knowledge ${O}`),e?.embedded===!1?Y(e.embed_error??`Saved, but not embedded`,`error`):Y(`Memory updated`,`success`)}catch(e){i.system.error(`Failed to update knowledge`,e),Y(`Failed to update memory`,`error`)}},[O,k,$,Y]),Sr=(0,_.useCallback)(async e=>{if(P!==e)mn(e);else{mn(null);try{await De(e),$(),i.ui.info(`Deleted knowledge ${e}`),Y(`Memory deleted`,`info`)}catch(e){i.system.error(`Failed to delete knowledge`,e),Y(`Failed to delete memory`,`error`)}}},[P,$,Y]);(0,_.useEffect)(()=>{if(!P)return;let e=setTimeout(()=>mn(null),3e3);return()=>clearTimeout(e)},[P]);let Cr=(0,_.useCallback)(async e=>{try{await be(e.id,{sensitive:!e.sensitive}),X(),i.ui.info(`Toggled sensitive for ${e.id}: ${!e.sensitive}`),Y(e.sensitive?`Unmarked as sensitive`:`Marked as sensitive`,`info`)}catch(e){i.system.error(`Failed to toggle sensitive`,e),Y(`Failed to toggle sensitive flag`,`error`)}},[X,Y]),wr=(0,_.useCallback)(e=>{rn(e.id),nn(!1),A({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``})},[]),Tr=(0,_.useCallback)(e=>{navigator.clipboard.writeText(e).catch(()=>{}),i.ui.info(`Copied knowledge ID: ${e}`),Y(`ID copied to clipboard`,`info`)},[Y]),Er=(0,_.useCallback)(e=>{Xt(e),$t.current&&clearTimeout($t.current),e.trim()?$t.current=setTimeout(async()=>{try{let t=await f(e.trim(),20);Qt(t)}catch(e){i.system.warn(`Conversation search failed`,e)}},300):Qt(null)},[]),Dr=(0,_.useCallback)(async e=>{try{let t=await Ge(e);en({sessionId:e,turns:t})}catch(e){i.system.error(`Failed to load conversation detail`,e)}},[]),Or=(0,_.useCallback)(e=>{Lt(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),E(0)},[]),kr=(0,_.useCallback)(e=>{w===e?Kt(e=>e===`desc`?`asc`:`desc`):(Wt(e),Kt(`desc`)),E(0)},[w]),Ar=(0,_.useCallback)(async()=>{Jn(!0),S(!1);try{let e=await Te();await Q(),Y(`Consolidated ${e.consolidated??0} sessions, extracted ${e.extracted_items??0} items`,`success`)}catch(e){i.system.error(`Failed to consolidate sessions`,e),Y(`Failed to consolidate sessions`,`error`)}finally{Jn(!1)}},[Q,Y]),jr=(0,_.useCallback)(async()=>{Xn(!0),S(!1);try{let e=await ue();await Z(),Y(`Backfilled ${e.backfilled??0} embeddings${e.total_without?` (${e.total_without} were missing)`:``}`,`success`)}catch(e){i.system.error(`Failed to rebuild embeddings`,e),Y(`Failed to rebuild embeddings`,`error`)}finally{Xn(!1)}},[Z,Y]),Mr=(0,_.useCallback)(async()=>{Qn(!0),S(!1);try{let e=await d();await Q(),Y(`Checked ${e.pairs_checked??0} pairs: ${e.reinforced??0} reinforced, ${e.contradicted??0} contradicted`,`success`)}catch(e){i.system.error(`Failed to reconcile memory`,e),Y(`Failed to reconcile memory`,`error`)}finally{Qn(!1)}},[Q,Y]),Nr=(0,_.useCallback)(async()=>{er(!0),S(!1);try{await de(),await Q(),Y(`FTS indexes rebuilt successfully`,`success`)}catch(e){i.system.error(`Failed to rebuild FTS index`,e),Y(`Failed to rebuild FTS indexes`,`error`)}finally{er(!1)}},[Q,Y]),Pr=(0,_.useCallback)(async()=>{nr(!0),S(!1);try{let e=await ne();await Q(),e.skipped?Y(`System context collection is disabled — enable it in settings`,`error`):Y(`System context refreshed: ${e.stored} facts updated`,`success`)}catch(e){i.system.error(`Failed to refresh system context`,e),Y(`Failed to refresh system context`,`error`)}finally{nr(!1)}},[Q,Y]),Fr=qn||Yn||Zn||$n||tr,Ir=(0,_.useCallback)(()=>{B(`running`),V([]),U([]),Fn(null);let e=s();Ln.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)V(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`finding`){let e=n.item;V(t=>[...t,{text:` Found: ${e.content}`,kind:`finding`}]),U(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?V(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),Ln.current=null,V(e=>[...e,{text:`Done. ${n.total??0} items discovered.`,kind:`log`}]),B(`review`))}catch{V(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),Ln.current=null,V(e=>[...e,{text:`Connection error. Is the GAIA server running?`,kind:`error`}]),U(e=>(B(e.length>0?`review`:`idle`),e))}},[]),Lr=(0,_.useCallback)(async()=>{let e=H.filter(e=>e._checked);if(e.length!==0){B(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await Ue(t);Fn(n.stored),B(`done`),$(),Y(`Saved ${n.stored} items to memory`,`success`)}catch(e){i.system.error(`Failed to commit discovery items`,e),Y(`Failed to save discovery items`,`error`),B(`review`)}}},[H,$,Y]),Rr=(0,_.useCallback)(()=>{G(`running`),K([]),J([]),Bn(null);let e=je(Vn);Wn.current=e,e.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.type===`log`)K(e=>[...e,{text:n.message,kind:`log`}]);else if(n.type===`insight`){let e=n.item;K(t=>[...t,{text:` Insight: ${e.content}`,kind:`finding`}]),J(t=>[...t,{...e,_checked:!0}])}else n.type===`error`?K(e=>[...e,{text:` Error: ${n.message}`,kind:`error`}]):n.type===`done`&&(e.close(),Wn.current=null,K(e=>[...e,{text:`Done. ${n.total??0} insights generated.`,kind:`log`}]),G(`review`))}catch{K(e=>[...e,{text:`Failed to parse event data.`,kind:`error`}])}},e.onerror=()=>{e.close(),Wn.current=null,K(e=>[...e,{text:`Connection error. Is Lemonade Server running?`,kind:`error`}]),J(e=>(G(e.length>0?`review`:`idle`),e))}},[Vn]),zr=(0,_.useCallback)(async()=>{let e=q.filter(e=>e._checked);if(e.length!==0){G(`saving`);try{let t=e.map(({_checked:e,...t})=>t),n=await we(t);Bn(n.stored),G(`done`),$(),Y(`Saved ${n.stored} insights to memory`,`success`)}catch(e){i.system.error(`Failed to commit inference insights`,e),Y(`Failed to save inference insights`,`error`),G(`review`)}}},[q,$,Y]);(0,_.useEffect)(()=>{In.current&&(In.current.scrollTop=In.current.scrollHeight)},[Nn]),(0,_.useEffect)(()=>{Un.current&&(Un.current.scrollTop=Un.current.scrollHeight)},[Rn]),(0,_.useEffect)(()=>()=>{Ln.current&&=(Ln.current.close(),null),Wn.current&&=(Wn.current.close(),null)},[]);let Br=e=>w===e?(0,v.jsx)(`span`,{className:`mem-sort-arrow`,children:Gt===`desc`?`↓`:`↑`}):null,Vr=Math.max(1,...h.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),Hr=m?.knowledge?.by_context?Object.keys(m.knowledge.by_context):[];return(0,v.jsxs)(`div`,{className:`memory-dashboard-page`,children:[(0,v.jsxs)(`div`,{className:`memory-dashboard-header`,children:[(0,v.jsxs)(`div`,{className:`memory-dashboard-header-left`,children:[(0,v.jsx)(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>e(!1),"aria-label":`Back`,children:(0,v.jsx)(Ze,{size:18})}),(0,v.jsxs)(`h1`,{children:[`Memory `,(0,v.jsx)(`span`,{style:{fontSize:11,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`2px 8px`,borderRadius:4,marginLeft:8,verticalAlign:`middle`,letterSpacing:`0.5px`},children:`BETA`})]})]}),(0,v.jsxs)(`div`,{className:`memory-dashboard-header-actions`,children:[L===`advanced`&&(0,v.jsxs)(v.Fragment,{children:[y&&y.total_items>0&&(0,v.jsxs)(`div`,{className:`mem-embedding-coverage`,title:`${y.with_embedding} of ${y.total_items} entries embedded`,children:[(0,v.jsx)(`div`,{className:`mem-embedding-bar`,children:(0,v.jsx)(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(y.coverage_pct)}%`}})}),(0,v.jsxs)(`span`,{className:`mem-embedding-label`,children:[Math.round(y.coverage_pct),`% embedded`]})]}),(0,v.jsxs)(`div`,{className:`mem-maintenance-wrap`,ref:or,children:[(0,v.jsxs)(`button`,{className:`btn-icon ${Fr?`mem-spinning`:``}`,onClick:()=>S(e=>!e),title:`Maintenance actions`,"aria-label":`Maintenance actions`,"aria-expanded":jt,children:[Fr?(0,v.jsx)(`div`,{className:`mem-spinner-sm`}):(0,v.jsx)(Le,{size:16}),(0,v.jsx)(Oe,{size:10,style:{marginLeft:2}})]}),jt&&(0,v.jsxs)(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Ar,disabled:qn,role:`menuitem`,children:[(0,v.jsx)(et,{size:14}),qn?`Consolidating...`:`Consolidate Sessions`]}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:jr,disabled:Yn,role:`menuitem`,children:[(0,v.jsx)(o,{size:14}),Yn?`Rebuilding...`:`Rebuild Embeddings`]}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Mr,disabled:Zn,role:`menuitem`,children:[(0,v.jsx)(Ee,{size:14}),Zn?`Reconciling...`:`Reconcile Memory`]}),(0,v.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Pr,disabled:tr,role:`menuitem`,children:[(0,v.jsx)(ie,{size:14}),tr?`Refreshing...`:`Refresh System Context`]}),(0,v.jsx)(`div`,{className:`mem-maintenance-divider`}),(0,v.jsxs)(`button`,{className:`mem-maintenance-item`,onClick:Nr,disabled:$n,role:`menuitem`,children:[(0,v.jsx)(ve,{size:14}),$n?`Rebuilding...`:`Rebuild FTS Indexes`]})]})]})]}),(0,v.jsx)(`button`,{className:`btn-icon`,onClick:Q,title:`Refresh`,"aria-label":`Refresh dashboard`,children:(0,v.jsx)(ie,{size:16})})]})]}),(0,v.jsxs)(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[(0,v.jsxs)(`button`,{className:`mem-tab-btn${L===`about`?` mem-tab-active`:``}`,onClick:()=>R(`about`),role:`tab`,"aria-selected":L===`about`,children:[(0,v.jsx)(lt,{size:14}),` About you`]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${L===`goals`?` mem-tab-active`:``}`,onClick:()=>{R(`goals`),hr()},role:`tab`,"aria-selected":L===`goals`,children:[(0,v.jsx)(at,{size:14}),` Goals`,xn&&(xn.goals.pending_approval??0)>0&&(0,v.jsx)(`span`,{className:`mem-tab-badge`,children:xn.goals.pending_approval})]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${L===`profile`?` mem-tab-active`:``}`,onClick:()=>R(`profile`),role:`tab`,"aria-selected":L===`profile`,children:[(0,v.jsx)(ae,{size:14}),` Profile setup`]}),(0,v.jsxs)(`button`,{className:`mem-tab-btn${L===`advanced`?` mem-tab-active`:``}`,onClick:()=>R(`advanced`),role:`tab`,"aria-selected":L===`advanced`,children:[(0,v.jsx)(Ke,{size:14}),` Advanced`]})]}),(0,v.jsxs)(`div`,{className:`memory-dashboard-body`,children:[L===`about`&&(0,v.jsx)(pt,{memoryEnabled:j,reloadKey:_n,onChanged:yr,onOpenAdvanced:()=>R(`advanced`),showToast:Y}),L===`advanced`&&(0,v.jsx)(v.Fragment,{children:Tt&&!m?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),`Loading memory data...`]}):Dt?(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(c,{size:32})}),(0,v.jsx)(`p`,{children:Dt}),(0,v.jsxs)(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[(0,v.jsx)(ie,{size:14}),` Retry`]})]}):(0,v.jsxs)(v.Fragment,{children:[!j&&(0,v.jsxs)(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:(0,v.jsx)(rt,{size:32})}),(0,v.jsx)(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:`Memory is off. Turn it on in Settings below to let GAIA remember what you tell it.`})]}),j&&(0,v.jsxs)(v.Fragment,{children:[m?.embedding_error&&(0,v.jsxs)(`div`,{className:`mem-advanced-error`,role:`alert`,children:[(0,v.jsx)(c,{size:14}),` `,m.embedding_error]}),(0,v.jsxs)(`div`,{className:`mem-stat-cards`,children:[(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`purple`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.knowledge?.total??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Stored`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:(()=>{let e=bt(h);return e>0?`+${e} today`:m?.knowledge?.by_category?Object.entries(m.knowledge.by_category).slice(0,3).map(([e,t])=>`${t} ${e}${t===1?``:`s`}`).join(`, `):`No entries`})()})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`gold`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.knowledge?.total_retrievals??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Retrieved`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:m?.knowledge?.total&&m?.knowledge?.total_retrievals?`avg ${(m.knowledge.total_retrievals/m.knowledge.total).toFixed(1)}x per memory`:`No recalls yet`})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`blue`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.conversations?.total_sessions??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Sessions`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:yt(m?.conversations?.first_session??null,m?.conversations?.last_session??null)||`${m?.conversations?.total_turns??0} total turns`})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`green`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.tools?.total_calls??0}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Tool Calls`}),(0,v.jsxs)(`div`,{className:`mem-stat-sub`,title:`Memory tools (remember, recall, ...) are not logged`,children:[m?.tools?.unique_tools??0,` tools, excl. memory`]})]}),(0,v.jsxs)(`div`,{className:`mem-stat-card`,"data-accent":`red`,children:[(0,v.jsx)(`div`,{className:`mem-stat-value`,children:m?.tools?.overall_success_rate!=null&&(m.tools.total_calls??0)>0?`${Math.round(m.tools.overall_success_rate*100)}%`:`—`}),(0,v.jsx)(`div`,{className:`mem-stat-label`,children:`Success Rate`}),(0,v.jsx)(`div`,{className:`mem-stat-sub`,children:(m?.tools?.total_calls??0)>0?`${m?.tools?.total_errors??0} errors`:`No tool calls yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,v.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,v.jsx)(st,{size:14}),` Activity`]}),(0,v.jsx)(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":`Activity range`,children:[1,7,30].map(e=>(0,v.jsx)(`button`,{className:`mem-range-tab${Gn===e?` active`:``}`,onClick:()=>Kn(e),children:e===1?`1D`:e===7?`7D`:`30D`},e))})]}),h.length>0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-activity-chart`,children:h.map((e,t)=>{let n=e.conversations+e.tool_calls+e.knowledge_added+e.errors,r=t===0||t===h.length-1||t%7==0,i=new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`});return(0,v.jsxs)(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>At(t),onMouseLeave:()=>At(null),children:[e.errors>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar errors`,style:{height:`${e.errors/Vr*100}%`}}),e.knowledge_added>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${e.knowledge_added/Vr*100}%`}}),e.tool_calls>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${e.tool_calls/Vr*100}%`}}),e.conversations>0&&(0,v.jsx)(`div`,{className:`mem-activity-bar conversations`,style:{height:`${e.conversations/Vr*100}%`}}),r&&(0,v.jsx)(`span`,{className:`mem-activity-date-label`,children:i}),kt===t&&n>0&&(0,v.jsxs)(`div`,{className:`mem-activity-tooltip`,children:[(0,v.jsx)(`strong`,{children:i}),(0,v.jsx)(`br`,{}),e.conversations>0&&(0,v.jsxs)(v.Fragment,{children:[e.conversations,` conversations`,(0,v.jsx)(`br`,{})]}),e.tool_calls>0&&(0,v.jsxs)(v.Fragment,{children:[e.tool_calls,` tool calls`,(0,v.jsx)(`br`,{})]}),e.knowledge_added>0&&(0,v.jsxs)(v.Fragment,{children:[e.knowledge_added,` learned`,(0,v.jsx)(`br`,{})]}),e.errors>0&&(0,v.jsxs)(v.Fragment,{children:[e.errors,` errors`]})]})]},e.date)})}),(0,v.jsxs)(`div`,{className:`mem-activity-legend`,children:[(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot conversations`}),` Conversations`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot tool_calls`}),` Tool Calls`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot knowledge`}),` Knowledge`]}),(0,v.jsxs)(`span`,{className:`mem-activity-legend-item`,children:[(0,v.jsx)(`span`,{className:`mem-activity-legend-dot errors`}),` Errors`]})]})]}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(st,{size:28})}),(0,v.jsx)(`p`,{children:`No activity data yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title mem-section-title-row`,children:[(0,v.jsxs)(`span`,{className:`mem-section-title-left`,children:[(0,v.jsx)(Ke,{size:14}),` Knowledge Browser`,g&&g.total>0&&(0,v.jsx)(`span`,{className:`mem-section-count`,children:g.total})]}),!tn&&!O&&(0,v.jsxs)(`button`,{className:`mem-section-add-btn`,onClick:()=>nn(!0),title:`Add a memory entry`,children:[(0,v.jsx)(ce,{size:13}),` Add`]})]}),(0,v.jsxs)(`div`,{className:`mem-filters`,children:[(0,v.jsxs)(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":`Filter by category`,children:[xt.map(e=>(0,v.jsx)(`button`,{className:`mem-category-pill ${e}${C.includes(e)?` active`:``}`,onClick:()=>Or(e),"aria-pressed":C.includes(e),children:e},e)),C.length>0&&(0,v.jsx)(`button`,{className:`mem-category-pill clear`,onClick:()=>{Lt([]),E(0)},"aria-label":`Clear category filters`,children:`✕ Clear`})]}),(0,v.jsxs)(`select`,{className:`mem-filter-select`,value:Rt,onChange:e=>{zt(e.target.value),E(0)},"aria-label":`Filter by context`,children:[(0,v.jsx)(`option`,{value:``,children:`All Contexts`}),Hr.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsxs)(`select`,{className:`mem-filter-select`,value:Bt,onChange:e=>{Vt(e.target.value),E(0)},"aria-label":`Filter by entity`,children:[(0,v.jsx)(`option`,{value:``,children:`All Entities`}),Ct.map(e=>(0,v.jsxs)(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),(0,v.jsxs)(`div`,{className:`mem-filter-search-wrap`,children:[rr?(0,v.jsx)(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):(0,v.jsx)(ve,{size:13,className:`search-icon`}),(0,v.jsx)(`input`,{className:`mem-filter-search`,type:`text`,placeholder:`Search memories...`,value:Ht,onChange:e=>vr(e.target.value),"aria-label":`Search memories`})]}),(0,v.jsxs)(`label`,{className:`mem-filter-toggle`,title:`Show entries that have been superseded by newer versions`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:qt,onChange:e=>Jt(e.target.checked)}),(0,v.jsx)(`span`,{children:`Superseded`})]})]}),(tn||O)&&(0,v.jsxs)(`div`,{className:`mem-inline-form`,children:[(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Content`}),(0,v.jsx)(`textarea`,{value:k.content,onChange:e=>A(t=>({...t,content:e.target.value})),placeholder:`What should the agent remember?`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Category`}),(0,v.jsx)(`select`,{value:k.category,onChange:e=>A(t=>({...t,category:e.target.value})),children:xt.map(e=>(0,v.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Context`}),(0,v.jsx)(`input`,{type:`text`,value:k.context,onChange:e=>A(t=>({...t,context:e.target.value})),placeholder:`global`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Domain`}),(0,v.jsx)(`input`,{type:`text`,value:k.domain,onChange:e=>A(t=>({...t,domain:e.target.value})),placeholder:`e.g., python, frontend`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Entity`}),(0,v.jsx)(`input`,{type:`text`,value:k.entity,onChange:e=>A(t=>({...t,entity:e.target.value})),placeholder:`e.g., person:sarah_chen`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Due At`}),(0,v.jsx)(`input`,{type:`text`,value:k.due_at,onChange:e=>A(t=>({...t,due_at:e.target.value})),placeholder:`ISO 8601 (e.g., 2026-03-25T09:00:00-07:00)`})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-row`,children:[(0,v.jsx)(`label`,{children:`Sensitive`}),(0,v.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:k.sensitive,onChange:e=>A(t=>({...t,sensitive:e.target.checked}))}),`Mark as sensitive (excluded from system prompt)`]})]}),(0,v.jsxs)(`div`,{className:`mem-inline-form-actions`,children:[(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{nn(!1),rn(null)},children:`Cancel`}),(0,v.jsx)(`button`,{className:`btn-primary`,onClick:O?xr:br,style:{padding:`8px 20px`,fontSize:13},children:O?`Update`:`Save`})]})]}),g&&g.items.length>0?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{style:{overflowX:`auto`},children:(0,v.jsxs)(`table`,{className:`mem-knowledge-table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsxs)(`th`,{onClick:()=>kr(`category`),className:w===`category`?`sorted`:``,children:[`Category`,Br(`category`)]}),(0,v.jsx)(`th`,{children:`Content`}),(0,v.jsxs)(`th`,{onClick:()=>kr(`context`),className:w===`context`?`sorted`:``,children:[`Context`,Br(`context`)]}),(0,v.jsx)(`th`,{children:`Entity`}),(0,v.jsxs)(`th`,{onClick:()=>kr(`confidence`),className:w===`confidence`?`sorted`:``,children:[`Confidence`,Br(`confidence`)]}),(0,v.jsx)(`th`,{children:`Source`}),(0,v.jsxs)(`th`,{onClick:()=>kr(`updated_at`),className:w===`updated_at`?`sorted`:``,children:[`Updated`,Br(`updated_at`)]}),(0,v.jsxs)(`th`,{onClick:()=>kr(`created_at`),className:w===`created_at`?`sorted`:``,children:[`Created`,Br(`created_at`)]}),(0,v.jsx)(`th`,{children:`Due`}),(0,v.jsx)(`th`,{className:`mem-actions-cell`})]})}),(0,v.jsx)(`tbody`,{children:g.items.map(e=>{let t=Mt===e.id,n=e.has_embedding;return(0,v.jsxs)(_.Fragment,{children:[(0,v.jsxs)(`tr`,{className:`${e.superseded_by?`mem-superseded-row`:``} ${t?`mem-expanded-row`:``}`,onClick:()=>Nt(t?null:e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),Nt(t?null:e.id))},tabIndex:0,role:`row`,"aria-expanded":t,style:{cursor:`pointer`},children:[(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-cat-badge ${e.category}`,children:e.category})}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-content-cell`,title:e.content,children:[n!==void 0&&(0,v.jsx)(`span`,{className:`mem-embed-dot ${n?`embedded`:`missing`}`,title:n?`Embedded`:`Embedding missing`,children:(0,v.jsx)(We,{size:6,fill:`currentColor`})}),e.sensitive&&(0,v.jsx)(`span`,{className:`mem-sensitive-badge`,title:`Sensitive`,children:(0,v.jsx)(rt,{size:11})}),(0,v.jsx)(`span`,{className:e.sensitive&&!an.has(e.id)?`mem-sensitive-blur`:e.superseded_by?`mem-superseded-text`:``,onClick:t=>{e.sensitive&&(t.stopPropagation(),on(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}))},children:e.content})]})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,children:e.context})}),(0,v.jsx)(`td`,{children:e.entity?(0,v.jsx)(`span`,{className:`mem-entity-link`,onClick:t=>{t.stopPropagation(),Vt(e.entity),E(0)},title:`Filter by ${e.entity}`,children:e.entity}):(0,v.jsx)(`span`,{className:`mem-date-cell`,children:`—`})}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-confidence`,children:[(0,v.jsx)(`div`,{className:`mem-confidence-bar`,children:(0,v.jsx)(`div`,{className:`mem-confidence-fill ${_t(e.confidence)}`,style:{width:`${e.confidence*100}%`}})}),e.confidence.toFixed(2)]})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,children:e.source||`—`})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.updated_at),children:x(e.updated_at)})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.created_at),children:x(e.created_at)})}),(0,v.jsx)(`td`,{children:e.due_at?(0,v.jsx)(`span`,{className:`mem-due-badge ${gt(e.due_at)?`overdue`:`upcoming`}`,title:b(e.due_at),children:x(e.due_at)}):(0,v.jsx)(`span`,{className:`mem-due-badge none`,children:`—`})}),(0,v.jsx)(`td`,{className:`mem-actions-cell`,children:(0,v.jsxs)(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>wr(e),title:`Edit`,children:(0,v.jsx)(ze,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Cr(e),title:e.sensitive?`Unmark sensitive`:`Mark sensitive`,children:e.sensitive?(0,v.jsx)(tt,{size:13}):(0,v.jsx)(rt,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn`,onClick:()=>Tr(e.id),title:`Copy ID`,children:(0,v.jsx)(Ce,{size:13})}),(0,v.jsx)(`button`,{className:`mem-row-action-btn delete${P===e.id?` is-confirm`:``}`,onClick:()=>Sr(e.id),title:P===e.id?`Click again to delete`:`Delete`,"aria-label":P===e.id?`Confirm delete memory`:`Delete memory`,children:P===e.id?(0,v.jsx)(`span`,{className:`mem-row-delete-label`,children:`Delete?`}):(0,v.jsx)(ge,{size:13})})]})})]}),t&&(0,v.jsx)(`tr`,{className:`mem-detail-row`,children:(0,v.jsx)(`td`,{colSpan:10,children:(0,v.jsxs)(`div`,{className:`mem-detail-panel`,children:[(0,v.jsxs)(`div`,{className:`mem-detail-grid`,children:[(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`ID`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.id})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Domain`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.domain||`—`})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Source`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.source||`—`})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Use Count`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:e.use_count??0})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Created`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.created_at)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Updated`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.updated_at)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Last Used`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.last_used)})]}),(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Reminded At`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:b(e.reminded_at)})]}),e.superseded_by&&(0,v.jsxs)(`div`,{className:`mem-detail-field`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Superseded By`}),(0,v.jsx)(`span`,{className:`mem-detail-value mem-detail-chain`,children:e.superseded_by})]}),e.metadata&&(0,v.jsxs)(`div`,{className:`mem-detail-field mem-detail-full`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Metadata`}),(0,v.jsx)(`span`,{className:`mem-detail-value`,children:typeof e.metadata==`object`?JSON.stringify(e.metadata,null,2):e.metadata})]})]}),(0,v.jsxs)(`div`,{className:`mem-detail-content-full`,children:[(0,v.jsx)(`span`,{className:`mem-detail-label`,children:`Full Content`}),(0,v.jsx)(`div`,{className:`mem-detail-content-text`,children:e.content})]})]})})})]},e.id)})})]})}),(0,v.jsxs)(`div`,{className:`mem-pagination`,children:[(0,v.jsxs)(`span`,{children:[T+1,`–`,Math.min(T+15,g.total),` of `,g.total]}),(0,v.jsxs)(`div`,{className:`mem-pagination-btns`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Previous page`,disabled:T===0,onClick:()=>E(Math.max(0,T-15)),children:(0,v.jsx)(Qe,{size:14})}),(0,v.jsx)(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":`Next page`,disabled:T+15>=g.total,onClick:()=>E(T+15),children:(0,v.jsx)(Ae,{size:14})})]})]})]}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(Ke,{size:28})}),(0,v.jsx)(`p`,{children:Ht||C.length>0||Rt||Bt?`No matching memories`:`No memories stored yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-two-col`,children:[(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(le,{size:14}),` Tool Performance`,(0,v.jsx)(`span`,{className:`mem-section-note`,title:`remember, recall, update_memory, forget and search_past_conversations are not logged`,children:`excludes memory tools`})]}),it.length>0?(0,v.jsx)(`div`,{style:{overflowX:`auto`},children:(0,v.jsxs)(`table`,{className:`mem-tool-table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Tool`}),(0,v.jsx)(`th`,{children:`Calls`}),(0,v.jsx)(`th`,{children:`Success`}),(0,v.jsx)(`th`,{children:`Denied`}),(0,v.jsx)(`th`,{children:`Avg Time`}),(0,v.jsx)(`th`,{children:`Last Used`}),(0,v.jsx)(`th`,{children:`Last Error`})]})}),(0,v.jsx)(`tbody`,{children:it.map(e=>(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-tool-name`,children:e.tool_name})}),(0,v.jsx)(`td`,{children:e.total_calls}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`mem-confidence`,children:[(0,v.jsx)(`div`,{className:`mem-confidence-bar`,style:{width:40},children:(0,v.jsx)(`div`,{className:`mem-confidence-fill ${vt(e.success_rate)}`,style:{width:`${e.success_rate*100}%`}})}),(0,v.jsxs)(`span`,{className:`mem-success-rate ${vt(e.success_rate)}`,children:[Math.round(e.success_rate*100),`%`]})]})}),(0,v.jsx)(`td`,{children:e.denied_count??0}),(0,v.jsx)(`td`,{children:ht(e.avg_duration_ms)}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-date-cell`,title:b(e.last_used),children:x(e.last_used)})}),(0,v.jsx)(`td`,{children:(0,v.jsx)(`span`,{className:`mem-tool-error`,title:e.last_error||``,children:e.last_error||`—`})})]},e.tool_name))})]})}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(le,{size:28})}),(0,v.jsx)(`p`,{children:`No tool calls recorded yet`})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(Pe,{size:14}),` Upcoming & Overdue`]}),dt.length>0?(0,v.jsx)(`div`,{className:`mem-temporal-list`,children:dt.map(e=>{let t=gt(e.due_at);return(0,v.jsxs)(`div`,{className:`mem-temporal-item ${t?`overdue`:`upcoming`}`,children:[(0,v.jsx)(`span`,{className:`mem-temporal-icon`,children:t?(0,v.jsx)(c,{size:16}):(0,v.jsx)(Pe,{size:16})}),(0,v.jsxs)(`div`,{className:`mem-temporal-content`,children:[(0,v.jsx)(`div`,{className:`mem-temporal-text`,children:e.content}),(0,v.jsxs)(`div`,{className:`mem-temporal-date`,children:[t?`OVERDUE`:`Due`,`: `,x(e.due_at),e.context!==`global`&&` \u00B7 ${e.context}`]})]})]},e.id)})}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(Ee,{size:28})}),(0,v.jsx)(`p`,{children:`Nothing upcoming or overdue`})]})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(a,{size:14}),` Conversation History`]}),(0,v.jsxs)(`div`,{className:`mem-conv-search`,children:[(0,v.jsx)(ve,{size:13,className:`search-icon`}),(0,v.jsx)(`input`,{type:`text`,placeholder:`Search conversations...`,value:Yt,onChange:e=>Er(e.target.value),"aria-label":`Search conversations`}),Yt&&(0,v.jsx)(`button`,{className:`mem-search-clear`,onClick:()=>{Xt(``),Qt(null)},"aria-label":`Clear search`,children:(0,v.jsx)(se,{size:12})})]}),Zt===null?ct.length>0?(0,v.jsx)(`div`,{className:`mem-conv-list`,children:ct.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Dr(e.session_id),children:[(0,v.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-session-id`,children:[Ie(e.session_id),e.consolidated&&(0,v.jsx)(`span`,{className:`mem-consolidated-badge`,title:`Consolidated`,children:(0,v.jsx)(et,{size:11})})]}),e.first_message&&(0,v.jsx)(`div`,{className:`mem-conv-preview`,children:e.first_message})]}),(0,v.jsxs)(`div`,{className:`mem-conv-meta`,children:[(0,v.jsxs)(`span`,{children:[e.turn_count,` turns`]}),(0,v.jsx)(`span`,{children:x(e.last_activity)})]})]},e.session_id))}):(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(a,{size:28})}),(0,v.jsx)(`p`,{children:`No conversation history in memory`})]}):Zt.length>0?(0,v.jsx)(`div`,{className:`mem-conv-list`,children:Zt.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-item`,onClick:()=>Dr(e.session_id),children:[(0,v.jsxs)(`div`,{className:`mem-conv-info`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-session-id`,children:[(0,v.jsx)(`span`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),` `,Ie(e.session_id)]}),(0,v.jsx)(`div`,{className:`mem-conv-preview`,children:e.content})]}),(0,v.jsx)(`div`,{className:`mem-conv-meta`,children:(0,v.jsx)(`span`,{children:x(e.timestamp)})})]},e.id))}):(0,v.jsx)(`div`,{className:`mem-empty`,children:(0,v.jsxs)(`p`,{children:[`No conversations match “`,Yt,`”`]})})]}),D&&(0,v.jsxs)(`div`,{className:`mem-conv-detail-overlay`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-detail-header`,children:[(0,v.jsx)(`h2`,{children:Ie(D.sessionId)}),(0,v.jsxs)(`div`,{className:`mem-conv-detail-actions`,children:[r.has(D.sessionId)&&(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>n(D.sessionId),children:`Open chat`}),(0,v.jsx)(`button`,{className:`btn-icon`,onClick:()=>en(null),"aria-label":`Close conversation`,children:(0,v.jsx)(se,{size:16})})]})]}),(0,v.jsxs)(`div`,{className:`mem-conv-detail-body`,children:[D.turns.map(e=>(0,v.jsxs)(`div`,{className:`mem-conv-turn`,children:[(0,v.jsxs)(`div`,{className:`mem-conv-turn-header`,children:[(0,v.jsx)(`div`,{className:`mem-conv-turn-role ${e.role}`,children:e.role}),(0,v.jsx)(`span`,{className:`mem-conv-turn-time`,title:b(e.timestamp),children:x(e.timestamp)})]}),(0,v.jsx)(`div`,{className:`mem-conv-turn-content`,children:e.content})]},e.id)),D.turns.length===0&&(0,v.jsx)(`div`,{className:`mem-empty`,children:`No turns found`})]})]})]}),(0,v.jsxs)(`div`,{className:`mem-section`,children:[(0,v.jsxs)(`div`,{className:`mem-section-title`,children:[(0,v.jsx)(rt,{size:14}),` Settings `,(0,v.jsx)(`span`,{style:{fontSize:10,fontWeight:600,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`1px 6px`,borderRadius:4,marginLeft:6,verticalAlign:`middle`,letterSpacing:`0.5px`},children:`BETA`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Memory enabled`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`When disabled, no knowledge or conversation data is stored during any session (global incognito).`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${j?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!j)I(`memory`);else{N(!0);try{let e=await p({memory_enabled:!1});sn(e.memory_enabled)}catch(e){i.system.warn(`Failed to disable memory`,e)}finally{N(!1)}}},"aria-pressed":j,"aria-label":`Memory is ${j?`enabled`:`disabled`}`,children:j?`On`:`Off`})]}),F&&(()=>{let e={memory:{title:`Enable Agent Memory?`,description:`Agent memory is a work-in-progress. By enabling it:`,bullets:[[`Conversations and facts are stored `,`locally on this machine`],[`Stored data `,`may be lost`,` during updates`],[`You can disable it at any time from this settings panel`]],buttonLabel:`Enable Memory`,onConfirm:async()=>{let e=await p({memory_enabled:!0});sn(e.memory_enabled),Y(`Memory enabled`,`info`)}},mcp:{title:`Enable MCP Memory Access?`,description:`This exposes memory data to external MCP clients:`,bullets:[[`MCP clients can `,`read your stored memories`,` (read-only)`],[`Requires an `,`MCP server restart`,` to take effect`],[`Intended for debugging and troubleshooting only`]],buttonLabel:`Enable MCP Access`,onConfirm:async()=>{let e=await p({mcp_memory_enabled:!0});ln(e.mcp_memory_enabled),Y(`MCP memory access enabled`,`info`)}},discovery:{title:`Enable System Discovery?`,description:`This scans your system to personalize responses:`,bullets:[[`Collects `,`hardware, software, and environment`,` information`],[`Scans files, git repos, browser history, and SSH config`],[`All data stays `,`local on this machine`]],buttonLabel:`Enable Discovery`,onConfirm:async()=>{let e=await p({system_discovery_consent:!0});if(dn(e.system_discovery_consent),e.system_context_error)Y(`System discovery enabled but scan failed: ${e.system_context_error}`,`error`);else{let t=e.system_context_refresh?.stored??0;Y(`System discovery enabled — ${t} system facts collected`,`info`)}Q()}}}[F];return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>I(null)}),(0,v.jsxs)(`div`,{ref:sr,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mem-beta-confirm-title`,"aria-describedby":`mem-beta-confirm-desc`,tabIndex:-1,style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:9999,background:`var(--bg-card)`,border:`1px solid var(--border)`,borderRadius:12,padding:`28px 32px`,maxWidth:420,width:`90vw`,boxShadow:`var(--shadow-lg)`},children:[(0,v.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[(0,v.jsx)(`span`,{style:{fontSize:11,fontWeight:700,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`3px 10px`,borderRadius:4,letterSpacing:`0.5px`},children:`BETA`}),(0,v.jsx)(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:600,color:`var(--text-primary)`},children:e.title})]}),(0,v.jsx)(`p`,{id:`mem-beta-confirm-desc`,style:{fontSize:13,lineHeight:1.6,color:`var(--text-secondary)`,margin:`0 0 8px`},children:e.description}),(0,v.jsx)(`ul`,{style:{fontSize:13,lineHeight:1.7,color:`var(--text-secondary)`,margin:`0 0 24px`,paddingLeft:20},children:e.bullets.map((e,t)=>(0,v.jsx)(`li`,{children:e.map((e,t)=>t%2==1?(0,v.jsx)(`strong`,{style:{color:`var(--text-primary)`},children:e},t):(0,v.jsx)(`span`,{children:e},t))},t))}),(0,v.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>I(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:`Cancel`}),(0,v.jsx)(`button`,{disabled:M,onClick:async()=>{N(!0);try{await e.onConfirm()}catch(e){i.system.warn(`Failed to update setting`,e),Y(`Failed to update setting. Please try again.`,`error`)}finally{N(!1),I(null)}},style:{padding:`8px 24px`,fontSize:13,fontWeight:600,borderRadius:6,border:`none`,cursor:`pointer`,background:`var(--accent-fill)`,color:`var(--accent-fill-text)`},children:e.buttonLabel})]})]})]})})(),(0,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`MCP memory access`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Expose read-only memory tools to MCP clients (for debug/troubleshooting). Requires MCP server restart.`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${cn?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!cn)I(`mcp`);else{N(!0);try{let e=await p({mcp_memory_enabled:!1});ln(e.mcp_memory_enabled)}catch(e){i.system.warn(`Failed to update memory settings`,e)}finally{N(!1)}}},"aria-label":`Toggle MCP memory access`,"aria-pressed":cn,children:cn?`On`:`Off`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`System discovery`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Allow GAIA to scan your system for hardware, software, and environment information to personalize responses.`})]}),(0,v.jsx)(`button`,{className:`mem-toggle${un?` mem-toggle-on`:``}`,disabled:M,onClick:async()=>{if(!un)I(`discovery`);else{N(!0);try{let e=await p({system_discovery_consent:!1});dn(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to update system discovery setting`,e)}finally{N(!1)}}},"aria-label":`Toggle system discovery`,"aria-pressed":un,children:un?`On`:`Off`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Re-initialize memory`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Wipe all memories, conversations, and tool logs, then re-collect system information. This cannot be undone.`})]}),hn?(0,v.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,v.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:async()=>{N(!0);try{let e=await oe();e.system_context.error?Y(e.system_context.error,`error`):Y(`Re-initialized: cleared ${e.cleared.knowledge} entries, restored ${e.system_context.stored} system facts`,`info`),Q()}catch(e){i.system.warn(`Failed to reinitialize memory`,e),Y(`Failed to re-initialize memory`,`error`)}finally{N(!1),gn(!1)}},children:`Yes, re-initialize`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>gn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:()=>gn(!0),children:`Re-initialize`})]}),(0,v.jsxs)(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[(0,v.jsxs)(`div`,{className:`mem-setting-info`,children:[(0,v.jsx)(`span`,{className:`mem-setting-label`,children:`Delete all memories`}),(0,v.jsx)(`span`,{className:`mem-setting-desc`,children:`Permanently wipe all knowledge entries, conversation history, and tool logs. This cannot be undone.`})]}),fn?(0,v.jsxs)(`div`,{className:`mem-delete-confirm`,children:[(0,v.jsx)(`span`,{className:`mem-delete-confirm-label`,children:`Are you sure?`}),(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:async()=>{N(!0);try{let e=await Ne();Y(`Deleted ${e.knowledge} knowledge entries, ${e.conversations} conversations`,`info`),Q()}catch(e){i.system.warn(`Failed to clear memory`,e),Y(`Failed to clear memory`,`error`)}finally{N(!1),pn(!1)}},children:`Yes, delete all`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>pn(!1),style:{padding:`6px 14px`,fontSize:12},children:`Cancel`})]}):(0,v.jsx)(`button`,{className:`mem-btn-danger`,disabled:M,onClick:()=>pn(!0),children:`Delete All`})]})]}),m&&(0,v.jsxs)(`div`,{className:`mem-db-footer`,children:[(0,v.jsxs)(`span`,{children:[`Database: `,He(m.db_size_bytes),m.knowledge?.avg_confidence!=null&&` \u00B7 Avg confidence: ${m.knowledge.avg_confidence.toFixed(2)}`]}),(0,v.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[m.knowledge?.entity_count!=null&&m.knowledge.entity_count>0&&(0,v.jsxs)(`span`,{children:[m.knowledge.entity_count,` entities`]}),m.knowledge?.sensitive_count!=null&&m.knowledge.sensitive_count>0&&(0,v.jsxs)(`span`,{children:[(0,v.jsx)(rt,{size:10}),` `,m.knowledge.sensitive_count,` sensitive`]})]})]})]})}),L===`profile`&&(0,v.jsxs)(`div`,{className:`mem-profile-grid`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,v.jsx)(Ve,{size:16}),` System Discovery`]}),(0,v.jsx)(`p`,{className:`mem-profile-desc`,children:`Scan your system to discover apps, projects, and usage patterns.`}),(0,v.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:z===`running`||z===`saving`,onClick:Ir,children:z===`running`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Discovery`}),Nn.length>0&&(0,v.jsx)(`div`,{className:`mem-log`,ref:In,children:Nn.map((e,t)=>(0,v.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(z===`review`||z===`saving`||z===`done`)&&H.length>0&&(0,v.jsxs)(`div`,{className:`mem-review-section`,children:[(0,v.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,v.jsx)(`div`,{className:`mem-review-list`,children:H.map((e,t)=>(0,v.jsxs)(`label`,{className:`mem-review-item`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:z===`saving`||z===`done`,onChange:()=>{U(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,v.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,v.jsx)(`span`,{className:`mem-source-badge`,children:e._source_name||e.category}),(0,v.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,v.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,disabled:z===`saving`||z===`done`||H.filter(e=>e._checked).length===0,onClick:Lr,children:z===`saving`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${H.filter(e=>e._checked).length})`}),(0,v.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>U(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>U(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),z===`done`&&Pn!==null&&(0,v.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,v.jsx)(Ee,{size:14}),` Saved `,Pn,` items to memory`]}),z===`review`&&H.length===0&&(0,v.jsx)(`div`,{className:`mem-profile-empty`,children:`No items discovered.`})]}),(0,v.jsxs)(`div`,{className:`mem-profile-card`,children:[(0,v.jsxs)(`div`,{className:`mem-profile-card-title`,children:[(0,v.jsx)(ae,{size:16}),` AI Profile Inference`]}),(0,v.jsx)(`p`,{className:`mem-profile-desc`,children:`Use the local LLM to generate profile insights from your data.`}),(0,v.jsx)(`p`,{className:`mem-profile-note`,children:`Requires Lemonade Server running.`}),(0,v.jsxs)(`label`,{className:`mem-profile-checkbox`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:Vn,onChange:e=>Hn(e.target.checked),disabled:W===`running`||W===`saving`}),`Include browser history`]}),(0,v.jsx)(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:W===`running`||W===`saving`,onClick:Rr,children:W===`running`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Running...`]}):`Run Inference`}),Rn.length>0&&(0,v.jsx)(`div`,{className:`mem-log`,ref:Un,children:Rn.map((e,t)=>(0,v.jsx)(`div`,{className:`mem-log-line ${e.kind}`,children:e.text},t))}),(W===`review`||W===`saving`||W===`done`)&&q.length>0&&(0,v.jsxs)(`div`,{className:`mem-review-section`,children:[(0,v.jsx)(`div`,{className:`mem-review-header`,children:`Review & Save`}),(0,v.jsx)(`div`,{className:`mem-review-list`,children:q.map((e,t)=>(0,v.jsxs)(`label`,{className:`mem-review-item`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:e._checked,disabled:W===`saving`||W===`done`,onChange:()=>{J(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),(0,v.jsx)(`span`,{className:`mem-review-content`,children:e.content}),(0,v.jsx)(`span`,{className:`mem-domain-badge ${St[e.domain]||`gray`}`,children:e.domain}),(0,v.jsxs)(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),(0,v.jsxs)(`div`,{className:`mem-review-actions`,children:[(0,v.jsx)(`button`,{className:`btn-primary`,disabled:W===`saving`||W===`done`||q.filter(e=>e._checked).length===0,onClick:zr,children:W===`saving`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mem-spinner-sm`}),` Saving...`]}):`Save Selected (${q.filter(e=>e._checked).length})`}),(0,v.jsxs)(`span`,{className:`mem-review-select-links`,children:[(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>J(e=>e.map(e=>({...e,_checked:!0}))),children:`Select All`}),` / `,(0,v.jsx)(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>J(e=>e.map(e=>({...e,_checked:!1}))),children:`None`})]})]})]}),W===`done`&&zn!==null&&(0,v.jsxs)(`div`,{className:`mem-profile-success`,children:[(0,v.jsx)(Ee,{size:14}),` Saved `,zn,` insights to memory`]}),W===`review`&&q.length===0&&(0,v.jsx)(`div`,{className:`mem-profile-empty`,children:`No insights generated.`})]})]}),L===`goals`&&(0,v.jsxs)(`div`,{className:`mem-goals-tab`,children:[(0,v.jsx)(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(e=>(0,v.jsxs)(`div`,{className:`mem-goals-stat-pill mem-goal-status-${e.replace(`_`,`-`)}`,children:[(0,v.jsx)(`span`,{className:`mem-goals-stat-n`,children:xn?.goals[e]??0}),(0,v.jsx)(`span`,{className:`mem-goals-stat-label`,children:e.replace(`_`,` `)})]},e))}),yn.filter(e=>e.status===`pending_approval`).length>0&&(0,v.jsxs)(`div`,{className:`mem-goals-approval-banner`,children:[(0,v.jsxs)(`div`,{className:`mem-goals-approval-title`,children:[(0,v.jsx)(o,{size:14}),` Agent suggested `,yn.filter(e=>e.status===`pending_approval`).length,` goal(s) — review before execution`]}),yn.filter(e=>e.status===`pending_approval`).map(e=>(0,v.jsxs)(`div`,{className:`mem-goals-approval-item`,children:[(0,v.jsxs)(`div`,{className:`mem-goals-approval-text`,children:[(0,v.jsx)(`strong`,{children:e.title}),(0,v.jsx)(`span`,{children:e.description})]}),(0,v.jsxs)(`div`,{className:`mem-goals-approval-actions`,children:[(0,v.jsx)(`button`,{className:`btn-danger-sm`,onClick:()=>gr(()=>u(e.id),`Couldn't reject the goal`),children:`Reject`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>gr(()=>Be(e.id),`Couldn't accept the goal`),children:`Accept`})]})]},e.id))]}),(0,v.jsx)(`div`,{className:`mem-goals-toolbar`,children:(0,v.jsxs)(`button`,{className:`btn-primary`,onClick:()=>An(e=>!e),children:[(0,v.jsx)(ce,{size:14}),` New Goal`]})}),kn&&(0,v.jsxs)(`div`,{className:`mem-goals-add-form`,children:[(0,v.jsx)(`input`,{className:`mem-input`,placeholder:`Goal title`,value:jn.title,onChange:e=>Mn(t=>({...t,title:e.target.value}))}),(0,v.jsx)(`textarea`,{className:`mem-input`,placeholder:`Description — what should the agent work toward?`,rows:2,value:jn.description,onChange:e=>Mn(t=>({...t,description:e.target.value}))}),(0,v.jsxs)(`div`,{className:`mem-goals-form-row`,children:[(0,v.jsxs)(`select`,{className:`mem-select`,value:jn.priority,onChange:e=>Mn(t=>({...t,priority:e.target.value})),children:[(0,v.jsx)(`option`,{value:`low`,children:`Low priority`}),(0,v.jsx)(`option`,{value:`medium`,children:`Medium priority`}),(0,v.jsx)(`option`,{value:`high`,children:`High priority`})]}),(0,v.jsx)(`button`,{className:`btn-primary`,onClick:()=>{jn.title.trim()&&gr(async()=>{await Re(jn),Mn({title:``,description:``,priority:`medium`}),An(!1)},`Couldn't create the goal`)},children:`Create`}),(0,v.jsx)(`button`,{className:`btn-secondary`,onClick:()=>An(!1),children:`Cancel`})]})]}),Cn?(0,v.jsxs)(`div`,{className:`mem-loading`,children:[(0,v.jsx)(`div`,{className:`mem-spinner`}),` Loading goals...`]}):yn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?(0,v.jsxs)(`div`,{className:`mem-empty`,children:[(0,v.jsx)(`div`,{className:`mem-empty-icon`,children:(0,v.jsx)(at,{size:32})}),(0,v.jsx)(`p`,{children:`No goals yet. Create one or let the agent suggest goals in autonomous mode.`})]}):(0,v.jsx)(`div`,{className:`mem-goals-list`,children:yn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(e=>(0,v.jsxs)(`div`,{className:`mem-goal-card mem-goal-status-${e.status.replace(`_`,`-`)}`,children:[(0,v.jsxs)(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":Tn===e.id,onClick:()=>En(t=>t===e.id?null:e.id),onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),En(t=>t===e.id?null:e.id))},children:[(0,v.jsxs)(`div`,{className:`mem-goal-header-left`,children:[(0,v.jsx)(`span`,{className:`mem-goal-status-dot status-${e.status.replace(`_`,`-`)}`}),(0,v.jsx)(`span`,{className:`mem-goal-title`,children:e.title}),(0,v.jsx)(`span`,{className:`mem-goal-priority mem-priority-${e.priority}`,children:e.priority}),e.source!==`user`&&(0,v.jsxs)(`span`,{className:`mem-goal-source-badge`,children:[(0,v.jsx)(o,{size:10}),` `,e.source.replace(`_`,` `)]})]}),(0,v.jsxs)(`div`,{className:`mem-goal-header-right`,children:[(0,v.jsxs)(`span`,{className:`mem-goal-task-count`,children:[(0,v.jsx)(ye,{size:12}),e.tasks.filter(e=>e.status===`completed`).length,`/`,e.tasks.length]}),e.status===`queued`&&(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:t=>{t.stopPropagation(),gr(()=>Se(e.id),`Couldn't cancel the goal`)},children:`Cancel`}),Dn===e.id?(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:t=>{t.stopPropagation(),On(null),gr(()=>ke(e.id),`Couldn't delete the goal`)},children:`Delete?`}):(0,v.jsx)(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":`Delete goal ${e.title}`,onClick:t=>{t.stopPropagation(),On(e.id)},children:(0,v.jsx)(ge,{size:12})}),(0,v.jsx)(Oe,{size:14,className:Tn===e.id?`mem-chevron-open`:``})]})]}),Tn===e.id&&(0,v.jsxs)(`div`,{className:`mem-goal-body`,children:[e.description&&(0,v.jsx)(`p`,{className:`mem-goal-desc`,children:e.description}),e.progress_notes&&(0,v.jsx)(`p`,{className:`mem-goal-progress`,children:e.progress_notes}),e.tasks.length>0?(0,v.jsx)(`div`,{className:`mem-task-list`,children:e.tasks.map(e=>(0,v.jsxs)(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[(0,v.jsx)(`span`,{className:`mem-task-dot status-${e.status}`}),(0,v.jsx)(`span`,{className:`mem-task-desc`,children:e.description}),(0,v.jsx)(`span`,{className:`mem-task-status-label`,children:e.status}),e.result&&(0,v.jsx)(`span`,{className:`mem-task-result`,children:e.result})]},e.id))}):(0,v.jsx)(`p`,{className:`mem-goal-no-tasks`,children:`No tasks yet — the agent will break this down when it starts.`})]})]},e.id))})]})]}),Pt.length>0&&(0,v.jsx)(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:Pt.map(e=>(0,v.jsxs)(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&(0,v.jsx)(Ee,{size:14}),e.type===`error`&&(0,v.jsx)(c,{size:14}),e.type===`info`&&(0,v.jsx)(Ke,{size:14}),(0,v.jsx)(`span`,{children:e.text})]},e.id))})]})}export{Ct as MemoryDashboard};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-KnDALPx_.js","./rolldown-runtime-XKyaHtl9.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,o as n,r}from"./apiBase-CS6zLsJY.js";import{It as i,Pt as a,Ut as o,W as s,_n as c,at as l,cn as u,i as d}from"./index-Cae5Fje-.js";var f=e(n(),1),p=t(),m=null;function h({isOpen:t,onClose:n,onStop:h,error:g}){let[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(null),C=(0,f.useRef)(null);a(t,n);let w=(0,f.useRef)(null);s(w,t);let T=(0,f.useCallback)(async()=>{try{let e=await l();return v(e),e}catch(e){return r.system.error(`Failed to fetch tunnel status`,e),null}},[]);(0,f.useEffect)(()=>{if(!t||g)return;T();let e=setInterval(async()=>{let t=await T();t?.active&&t?.url&&clearInterval(e)},2e3);return()=>clearInterval(e)},[t,g,T]),(0,f.useEffect)(()=>{if(!_?.active||!_.url||!_.token||!C.current)return;let t=`${_.url}/?token=${_.token}`;r.system.info(`Generating QR code for: ${t}`),(async()=>{if(S(null),!m)try{let t=await d(()=>import(`./browser-KnDALPx_.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1]),import.meta.url);m=t.default||t}catch{r.system.error(`QR code library not available - install with: npm install qrcode`),S(`QR code unavailable on this build. Use the link below instead.`);return}let n=getComputedStyle(document.documentElement),i=n.getPropertyValue(`--text-primary`).trim(),a=n.getPropertyValue(`--bg-primary`).trim();if(!i||!a)r.system.error(`QR code skipped: --text-primary/--bg-primary did not resolve. styles/index.css must be loaded before this modal renders.`),S(`QR code unavailable — the theme did not load. Use the link below instead.`);else try{await m.toCanvas(C.current,t,{width:200,margin:2,color:{dark:i,light:a}})}catch(e){r.system.error(`QR code generation failed`,e),S(`QR code could not be drawn. Use the link below instead.`)}})()},[_?.active,_?.url,_?.token]);let E=(0,f.useRef)(null),D=(0,f.useCallback)(()=>{if(!_?.url||!_?.token)return;let e=`${_.url}/?token=${_.token}`;navigator.clipboard.writeText(e).then(()=>{b(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>b(!1),2e3)})},[_]);if((0,f.useEffect)(()=>()=>{E.current&&clearTimeout(E.current)},[]),!t)return null;let O=_?.active&&_?.url&&_?.token?`${_.url}/?token=${_.token}`:``;return(0,p.jsx)(`div`,{ref:w,className:`modal-overlay`,onClick:n,role:`dialog`,"aria-modal":`true`,"aria-label":`Mobile access`,children:(0,p.jsxs)(`div`,{className:`modal-panel mobile-modal`,onClick:e=>e.stopPropagation(),children:[(0,p.jsxs)(`div`,{className:`modal-header`,children:[(0,p.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,p.jsx)(o,{size:18}),`Mobile access`]}),(0,p.jsx)(`button`,{className:`btn-icon`,onClick:n,"aria-label":`Close`,children:(0,p.jsx)(i,{size:18})})]}),(0,p.jsxs)(`div`,{className:`modal-body mobile-modal-body`,children:[(0,p.jsxs)(`div`,{className:`tunnel-status`,children:[(0,p.jsx)(`span`,{className:`status-dot ${_?.active?`active`:g?`error`:`starting`}`}),(0,p.jsx)(`span`,{children:_?.active?`Tunnel active`:g?`Couldn't start mobile access`:`Starting tunnel...`}),!_?.active&&!g&&(0,p.jsx)(`span`,{className:`tunnel-spinner`})]}),g&&(0,p.jsx)(`div`,{className:`tunnel-error`,children:g}),!g&&(0,p.jsx)(`div`,{className:`qr-code-area`,children:_?.active?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`canvas`,{ref:C,hidden:!!x}),x&&(0,p.jsx)(`div`,{className:`qr-placeholder error`,children:x})]}):(0,p.jsxs)(`div`,{className:`qr-placeholder`,children:[(0,p.jsx)(`div`,{className:`placeholder-spinner`}),(0,p.jsx)(`span`,{children:`Connecting...`})]})}),_?.active&&O&&(0,p.jsxs)(`div`,{className:`tunnel-url-area`,children:[(0,p.jsx)(`label`,{children:`Mobile URL`}),(0,p.jsxs)(`div`,{className:`tunnel-url-row`,children:[(0,p.jsx)(`input`,{type:`text`,readOnly:!0,value:O}),(0,p.jsxs)(`button`,{className:`copy-url-btn ${y?`copied`:``}`,onClick:D,title:`Copy URL`,children:[y?(0,p.jsx)(c,{size:13}):(0,p.jsx)(u,{size:13}),y?`Copied`:`Copy`]})]})]}),_?.active&&_?.publicIp&&_?.url&&!_.url.includes(`ngrok-free.app`)&&(0,p.jsxs)(`div`,{className:`tunnel-password-hint`,children:[(0,p.jsx)(`label`,{children:`Tunnel password`}),(0,p.jsx)(`div`,{className:`tunnel-password-value`,children:_.publicIp}),(0,p.jsx)(`span`,{className:`tunnel-password-note`,children:`Enter this when the tunnel page asks for a password`})]}),!g&&(0,p.jsx)(`div`,{className:`mobile-instructions`,children:(0,p.jsxs)(`ol`,{children:[(0,p.jsx)(`li`,{children:x?`Open the mobile URL above on your phone`:`Scan the QR code with your phone's camera`}),_?.url&&!_.url.includes(`ngrok-free.app`)&&(0,p.jsx)(`li`,{children:`Enter the tunnel password shown above when prompted`}),(0,p.jsx)(`li`,{children:`Chat with GAIA from your mobile device`}),(0,p.jsx)(`li`,{children:`Your data stays secure via encrypted tunnel`})]})}),(0,p.jsxs)(`div`,{className:`mobile-access-actions`,children:[_?.active&&h&&(0,p.jsx)(`button`,{className:`btn-danger`,onClick:h,title:`Close the tunnel and revoke the mobile URL`,children:`Stop tunnel`}),(0,p.jsx)(`button`,{className:`btn-secondary`,onClick:n,children:`Close`})]})]})]})})}export{h as MobileAccessModal};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r,r as i}from"./apiBase-CS6zLsJY.js";import{n as a,t as o}from"./zap-BogJn9oN.js";import{Ft as s,It as c,Kt as l,Pt as u,Vt as d,W as f,ln as p,n as m,ut as h}from"./index-Cae5Fje-.js";var g={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};g.node;var _=t(g),v={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};v.node;var y=t(v),b=e(r(),1),x=n(),S=8e3;function C(e,t){if(!e)return`never`;let n=new Date(e),r=(t||new Date).getTime()-n.getTime(),i=Math.floor(r/1e3);if(i<0){let e=Math.abs(i);if(e<60)return`in ${e}s`;let t=Math.floor(e/60);if(t<60)return`in ${t}m`;let n=Math.floor(t/60);return n<24?`in ${n}h`:`in ${Math.floor(n/24)}d`}if(i<60)return`just now`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function w(e,t){if(!e)return`never`;let n=C(e,t),r=new Date(e);return r.getTime()<=(t||new Date).getTime()?n:`${r.toLocaleString(void 0,{weekday:`short`,hour:`numeric`,minute:`2-digit`})} (${n})`}function T(e){if(!e)return!1;let t=new Date(e).getTime()-Date.now();return t>0&&t<6e4}function E(e){let[t,n]=e.split(`:`).map(Number),r=t>=12?`PM`:`AM`;return`${t===0?12:t>12?t-12:t}:${n.toString().padStart(2,`0`)} ${r}`}function D(e){let t=e>=12?`PM`:`AM`;return`${e===0?12:e>12?e-12:e} ${t}`}function O(e){let t=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];return e.length===5&&!e.includes(5)&&!e.includes(6)?`Weekdays`:e.length===2&&e.includes(5)&&e.includes(6)?`Weekends`:e.length===7?`Every day`:e.map(e=>t[e]).join(`, `)}function k({schedule:e}){let{selectedSchedule:t,selectSchedule:n,updateScheduleStatus:r,runScheduleNow:c,deleteSchedule:l,results:u,resultsLoading:f,loadSchedules:h,loadResults:g}=m(),{setCurrentSession:v,setShowSchedules:E}=s(),D=t===e.name,[O,k]=(0,b.useState)(!1),A=(0,b.useRef)(null),j=(0,b.useCallback)(()=>{A.current&&=(clearTimeout(A.current),null)},[]);(0,b.useEffect)(()=>j,[j]);let[M,N]=(0,b.useState)(()=>new Date),P=(0,b.useRef)(null);(0,b.useEffect)(()=>{let t=e.status===`active`&&T(e.next_run_at);return t&&!P.current?P.current=setInterval(()=>{N(new Date),e.next_run_at&&new Date(e.next_run_at).getTime()<=Date.now()&&h()},1e3):!t&&P.current&&(clearInterval(P.current),P.current=null),()=>{P.current&&=(clearInterval(P.current),null)}},[e.status,e.next_run_at,h]);let F=(0,b.useRef)(e.last_run_at);(0,b.useEffect)(()=>{D&&e.last_run_at!==F.current&&(F.current=e.last_run_at,g(e.name))},[D,e.last_run_at,e.name,g]);let I=e.last_run_at&&Date.now()-new Date(e.last_run_at).getTime()<5e3,L=(0,b.useCallback)(t=>{t.stopPropagation();let n=e.status===`active`?`paused`:`active`;i.ui.info(`Schedule "${e.name}": ${e.status} -> ${n}`),r(e.name,n)},[e.name,e.status,r]),R=(0,b.useCallback)(t=>{t.stopPropagation(),i.ui.info(`Schedule "${e.name}": run now`),c(e.name)},[e.name,c]),z=(0,b.useCallback)(t=>{t.stopPropagation(),j(),O?(i.ui.info(`Deleting schedule "${e.name}"`),l(e.name)):(k(!0),A.current=setTimeout(()=>{A.current=null,k(!1)},S))},[e.name,O,l,j]),B=(0,b.useCallback)(t=>{t.stopPropagation(),e.session_id&&(i.ui.info(`Opening chat session for schedule "${e.name}"`),v(e.session_id),E(!1))},[e.session_id,e.name,v,E]);return(0,x.jsxs)(`div`,{className:`schedule-card ${D?`selected`:``} ${I?`just-ran`:``}`,onClick:()=>n(D?null:e.name),children:[(0,x.jsxs)(`div`,{className:`schedule-card-header`,children:[(0,x.jsx)(`span`,{className:`schedule-card-name`,children:e.name}),(0,x.jsx)(`span`,{className:`schedule-card-status ${e.status}`,children:e.status})]}),(0,x.jsx)(`div`,{className:`schedule-card-prompt`,children:e.prompt}),(0,x.jsxs)(`div`,{className:`schedule-card-meta`,children:[(0,x.jsxs)(`span`,{title:e.description,children:[(0,x.jsx)(p,{size:11}),` `,e.description]}),(0,x.jsxs)(`span`,{children:[`Runs: `,e.run_count]}),e.error_count>0&&(0,x.jsxs)(`span`,{children:[`Errors: `,e.error_count]}),(0,x.jsxs)(`span`,{children:[`Last: `,C(e.last_run_at)]}),(0,x.jsxs)(`span`,{children:[`Next: `,w(e.next_run_at,M)]})]}),e.last_error&&(0,x.jsxs)(`div`,{className:`schedule-card-error`,children:[`Last run failed: `,e.last_error]}),(0,x.jsxs)(`div`,{className:`schedule-card-actions`,children:[e.session_id&&(0,x.jsxs)(`button`,{className:`btn-sm chat`,onClick:B,title:`Open chat session`,children:[(0,x.jsx)(a,{size:11}),` Open Chat`]}),(0,x.jsxs)(`button`,{className:`btn-sm`,onClick:R,disabled:e.running,title:`Run it once now, to try it. Its next scheduled run stays as it is.`,children:[(0,x.jsx)(o,{size:11}),` `,e.running?`Running…`:`Run now`]}),(0,x.jsx)(`button`,{className:`btn-sm`,onClick:L,title:e.status===`active`?`Pause`:`Resume`,children:e.status===`active`?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(_,{size:11}),` Pause`]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(y,{size:11}),` Resume`]})}),(0,x.jsxs)(`button`,{className:`btn-sm danger`,onClick:z,title:`Delete`,children:[(0,x.jsx)(d,{size:11}),` `,O?`Confirm?`:`Delete`]})]}),D&&(0,x.jsxs)(`div`,{className:`schedule-results`,children:[(0,x.jsx)(`h4`,{children:`Execution history`}),f?(0,x.jsx)(`p`,{className:`schedule-results-empty`,children:`Loading...`}):u.length===0?(0,x.jsx)(`p`,{className:`schedule-results-empty`,children:`No executions yet`}):(0,x.jsx)(`div`,{className:`schedule-results-list`,children:u.map(e=>(0,x.jsxs)(`div`,{className:`schedule-result-item`,children:[(0,x.jsx)(`div`,{className:`schedule-result-time`,children:C(e.executed_at)}),e.error?(0,x.jsx)(`div`,{className:`schedule-result-content schedule-result-error`,children:e.error}):(0,x.jsx)(`div`,{className:`schedule-result-content`,children:e.result||`(no output)`})]},e.id))})]})]})}function A(){let{setShowSchedules:e}=s(),{schedules:t,loading:n,error:r,actionError:a,loadSchedules:o,createSchedule:d,dismissActionError:g}=m(),_=(0,b.useCallback)(()=>e(!1),[e]);u(!0,_);let v=(0,b.useRef)(null);f(v,!0);let[y,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(``),[T,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)(!1),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),V=(0,b.useId)(),H=`${V}-when`,U=`${V}-when-error`,W=`${V}-name`,G=`${V}-prompt`,K=!F&&N!==null&&!N.valid,q=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!C.trim())P(null);else return q.current&&clearTimeout(q.current),q.current=window.setTimeout(async()=>{I(!0);try{let e=await h(C);P(e)}catch{P(null)}finally{I(!1)}},400),()=>{q.current&&clearTimeout(q.current)}},[C]);let J=(0,b.useRef)(null);(0,b.useEffect)(()=>(i.ui.info(`Schedule Manager opened`),o(),J.current=window.setInterval(()=>o(),5e3),()=>{J.current&&clearInterval(J.current),g()}),[o,g]);let Y=C.trim()&&T.trim()&&j.trim()&&(N===null||N.valid),X=(0,b.useCallback)(async()=>{if(Y){R(!0),B(null);try{await d(T.trim(),C.trim(),j.trim()),w(``),A(``),M(``),P(null),S(!1),i.ui.info(`Schedule "${T}" created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create schedule`;B(t)}finally{R(!1)}}},[Y,T,C,j,d]);return(0,x.jsx)(`div`,{ref:v,className:`modal-overlay`,onClick:()=>e(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`Scheduled tasks`,children:(0,x.jsxs)(`div`,{className:`modal-panel schedule-modal`,onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)(`div`,{className:`modal-header`,children:[(0,x.jsx)(`h3`,{children:`Scheduled tasks`}),(0,x.jsx)(`button`,{className:`btn-icon`,onClick:()=>e(!1),"aria-label":`Close schedule manager`,children:(0,x.jsx)(c,{size:18})})]}),(0,x.jsxs)(`div`,{className:`modal-body`,children:[(0,x.jsx)(`section`,{className:`schedule-section`,children:y?(0,x.jsxs)(`div`,{className:`schedule-create-form`,children:[(0,x.jsxs)(`div`,{className:`schedule-field`,children:[(0,x.jsx)(`label`,{className:`schedule-field-label`,htmlFor:H,children:`When to run`}),(0,x.jsx)(`textarea`,{id:H,className:`schedule-nl-input`,placeholder:`Describe your schedule in natural language...
|
|
2
|
-
Examples: "every 30m", "daily at 9pm", "every hour from 8am to 6pm on weekdays"`,value:C,onChange:e=>w(e.target.value),"aria-invalid":K,"aria-describedby":K?U:void 0,autoFocus:!0,rows:2})]}),(N||F)&&(0,x.jsx)(`div`,{className:`schedule-parsed-preview ${N?.valid?`valid`:`invalid`}`,"aria-live":`polite`,children:F?(0,x.jsx)(`span`,{className:`schedule-parsed-loading`,children:`Parsing...`}):N?(0,x.jsxs)(x.Fragment,{children:[N.valid?(0,x.jsx)(`div`,{className:`schedule-parsed-description`,children:N.description}):(0,x.jsxs)(`div`,{id:U,children:[(0,x.jsx)(`div`,{className:`schedule-parsed-description`,children:`GAIA didn't understand that schedule.`}),(0,x.jsx)(`div`,{className:`schedule-parsed-hint`,children:N.description})]}),N.valid&&N.next_run_at&&(0,x.jsxs)(`div`,{className:`schedule-parsed-next`,children:[`Next run: `,new Date(N.next_run_at).toLocaleString()]}),N.valid&&(0,x.jsxs)(`div`,{className:`schedule-parsed-details`,children:[N.time_of_day&&(0,x.jsxs)(`span`,{className:`schedule-parsed-tag`,children:[(0,x.jsx)(p,{size:10}),` `,E(N.time_of_day)]}),N.start_hour!=null&&N.end_hour!=null&&(0,x.jsxs)(`span`,{className:`schedule-parsed-tag`,children:[(0,x.jsx)(p,{size:10}),` `,D(N.start_hour),` - `,D(N.end_hour)]}),N.days_of_week&&(0,x.jsx)(`span`,{className:`schedule-parsed-tag`,children:O(N.days_of_week)})]})]}):null}),(0,x.jsxs)(`div`,{className:`schedule-field`,children:[(0,x.jsx)(`label`,{className:`schedule-field-label`,htmlFor:W,children:`Name`}),(0,x.jsx)(`div`,{className:`schedule-form-row`,children:(0,x.jsx)(`input`,{id:W,type:`text`,placeholder:`Schedule name (e.g. daily-summary)`,value:T,onChange:e=>A(e.target.value),className:!T.trim()&&C.trim()?`schedule-field-missing`:``})})]}),(0,x.jsxs)(`div`,{className:`schedule-field`,children:[(0,x.jsx)(`label`,{className:`schedule-field-label`,htmlFor:G,children:`Prompt`}),(0,x.jsx)(`textarea`,{id:G,className:`schedule-prompt-input ${!j.trim()&&C.trim()?`schedule-field-missing`:``}`,placeholder:`Prompt to execute on each run...`,value:j,onChange:e=>M(e.target.value)})]}),z&&(0,x.jsx)(`p`,{className:`schedule-form-error`,children:z}),(0,x.jsxs)(`div`,{className:`schedule-create-actions`,children:[(0,x.jsx)(`button`,{className:`btn-secondary`,onClick:()=>{S(!1),B(null),P(null),w(``),A(``),M(``)},children:`Cancel`}),(0,x.jsx)(`button`,{className:`btn-primary`,onClick:X,disabled:!Y||L,children:L?`Creating...`:`Create Schedule`})]})]}):(0,x.jsxs)(`button`,{className:`btn-primary`,onClick:()=>S(!0),children:[(0,x.jsx)(l,{size:14}),` New schedule`]})}),(0,x.jsxs)(`section`,{className:`schedule-section`,children:[(0,x.jsx)(`h4`,{children:`Active schedules`}),a&&(0,x.jsxs)(`div`,{className:`schedule-action-error`,role:`alert`,children:[(0,x.jsx)(`span`,{children:a}),(0,x.jsx)(`button`,{className:`btn-icon`,onClick:g,"aria-label":`Dismiss error`,children:(0,x.jsx)(c,{size:14})})]}),n?(0,x.jsx)(`p`,{className:`schedule-empty`,children:`Loading schedules...`}):r?(0,x.jsx)(`p`,{className:`schedule-empty`,children:r}):t.length===0?(0,x.jsx)(`p`,{className:`schedule-empty`,children:`No scheduled tasks yet. Create one to get started.`}):(0,x.jsx)(`div`,{className:`schedule-list`,children:t.map(e=>(0,x.jsx)(k,{schedule:e},e.id))})]})]})]})})}export{A as ScheduleManager};
|