@amd-gaia/agent-ui 0.25.0-rc.2 → 0.25.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/gaia-ui.cjs +13 -7
- package/dist/assets/AdvancedSettings-DNQod9tb.js +1 -0
- package/dist/assets/{ConnectorsPane-KLjT1y3F.js → ConnectorsPane-DXvmZT6E.js} +1 -1
- package/dist/assets/DocumentLibrary-H6_dL1FQ.js +1 -0
- package/dist/assets/FileBrowser-JEScQZqn.js +4 -0
- package/dist/assets/{MemoryDashboard-DG9P8Bqf.js → MemoryDashboard-CK5IZKJ8.js} +1 -1
- package/dist/assets/{MobileAccessModal-Jub4U6L2.js → MobileAccessModal-CV7e2cgI.js} +1 -1
- package/dist/assets/{ScheduleManager-BStuwsjn.js → ScheduleManager-A5eLWyGP.js} +1 -1
- package/dist/assets/index-D00FJoXi.js +58 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/services/backend-installer.cjs +32 -6
- package/dist/assets/AdvancedSettings-DabrR6sf.js +0 -1
- package/dist/assets/DocumentLibrary-CElkmNvc.js +0 -1
- package/dist/assets/FileBrowser-ROrpBhVm.js +0 -4
- package/dist/assets/index-CXbVMk3u.js +0 -58
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<meta name="theme-color" content="#17161C" />
|
|
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-D00FJoXi.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-hePW80VL.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="./assets/jsx-runtime-DVeaULmT.js">
|
|
14
14
|
<link rel="stylesheet" crossorigin href="./assets/index-B8E7IBmc.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amd-gaia/agent-ui",
|
|
3
|
-
"version": "0.25.0-rc.
|
|
3
|
+
"version": "0.25.0-rc.8",
|
|
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",
|
|
@@ -1433,18 +1433,42 @@ async function installBackend(opts = {}) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
1435
|
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1436
|
+
const venvArgs = ["venv", GAIA_VENV, "--python", "3.12"];
|
|
1437
|
+
let venvResult = await runCommand("uv", venvArgs, { stageLabel: "venv" });
|
|
1438
|
+
// uv downloads Python 3.12 when none is installed; behind a corporate
|
|
1439
|
+
// proxy that fails on uv's bundled roots exactly like the pip step below.
|
|
1440
|
+
let venvNativeTls = false;
|
|
1441
|
+
if (
|
|
1442
|
+
venvResult.code !== 0 &&
|
|
1443
|
+
isTlsCertError(`${venvResult.stdout || ""}\n${venvResult.stderr || ""}`)
|
|
1444
|
+
) {
|
|
1445
|
+
venvNativeTls = true;
|
|
1446
|
+
log(
|
|
1447
|
+
"TLS trust failure downloading Python — retrying with --native-tls " +
|
|
1448
|
+
"to use the OS certificate store"
|
|
1449
|
+
);
|
|
1450
|
+
report(
|
|
1451
|
+
STAGES.CREATE_VENV,
|
|
1452
|
+
0,
|
|
1453
|
+
"Certificate trust issue — retrying with the system certificate store"
|
|
1454
|
+
);
|
|
1455
|
+
if (fs.existsSync(GAIA_VENV)) {
|
|
1456
|
+
fs.rmSync(GAIA_VENV, { recursive: true, force: true });
|
|
1457
|
+
}
|
|
1458
|
+
venvResult = await runCommand("uv", [...venvArgs, "--native-tls"], {
|
|
1459
|
+
stageLabel: "venv",
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1441
1462
|
if (venvResult.code !== 0) {
|
|
1463
|
+
const manual = `uv venv ${GAIA_VENV_DISPLAY} --python 3.12${
|
|
1464
|
+
venvNativeTls ? " --native-tls" : ""
|
|
1465
|
+
}`;
|
|
1442
1466
|
throw new InstallError(
|
|
1443
1467
|
`Failed to create Python environment (uv venv exit ${venvResult.code}).`,
|
|
1444
1468
|
{
|
|
1445
1469
|
stage: STAGES.CREATE_VENV,
|
|
1446
1470
|
code: venvResult.code,
|
|
1447
|
-
suggestion: `Try creating it manually:\n
|
|
1471
|
+
suggestion: `Try creating it manually:\n ${manual}\nThen restart GAIA.`,
|
|
1448
1472
|
}
|
|
1449
1473
|
);
|
|
1450
1474
|
}
|
|
@@ -1462,6 +1486,8 @@ async function installBackend(opts = {}) {
|
|
|
1462
1486
|
"install",
|
|
1463
1487
|
pipPackage,
|
|
1464
1488
|
"--refresh",
|
|
1489
|
+
// uv skips this by default, leaving the first daemon start to compile GAIA.
|
|
1490
|
+
"--compile-bytecode",
|
|
1465
1491
|
"--python",
|
|
1466
1492
|
GAIA_PYTHON_BIN,
|
|
1467
1493
|
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,r as n,t as r}from"./jsx-runtime-DVeaULmT.js";import{$t as i,Bt as a,R as o,Tt as s,Zt as c,at as l,ct as ee,n as te,r as ne,st as re}from"./index-CXbVMk3u.js";var u=e(t(),1),d=r();function f(){return window.gaiaUpdater}function ie({onClose:e}){let[t,n]=(0,u.useState)({kind:`loading`}),r=(0,u.useRef)(null);(0,u.useEffect)(()=>{let e=f();if(!e){n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`});return}e.listReleases().then(e=>{n(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{n({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})})},[]),(0,u.useEffect)(()=>{function t(t){t.key===`Escape`&&e()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]),(0,u.useEffect)(()=>{let e=r.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,u.useEffect)(()=>{let e=r.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function i(e,t){e.isCurrent||n({kind:`confirm`,release:e,releases:t})}async function a(t){n({kind:`installing`});let r=f();if(!r){n({kind:`error`,message:`Bridge unavailable — please restart the app.`});return}try{await r.installVersion(t.tag),e()}catch(e){let t=e instanceof Error?e.message:String(e);n({kind:`error`,message:`Failed to start rollback: ${t}`})}}function o(e){if(!e)return``;try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return(0,d.jsx)(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,d.jsxs)(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Roll back to a previous version`,ref:r,children:[(0,d.jsxs)(`div`,{className:`version-picker-header`,children:[(0,d.jsx)(`h3`,{children:`Roll back to a previous version`}),(0,d.jsx)(`button`,{className:`version-picker-close`,onClick:e,"aria-label":`Close`,type:`button`,children:`×`})]}),(0,d.jsxs)(`div`,{className:`version-picker-body`,children:[t.kind===`loading`&&(0,d.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,d.jsx)(`span`,{className:`version-picker-spinner`}),`Loading releases…`]}),t.kind===`error`&&(0,d.jsxs)(`div`,{className:`version-picker-error`,children:[(0,d.jsx)(`p`,{children:t.message}),(0,d.jsx)(`p`,{children:(0,d.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse releases on GitHub`})})]}),t.kind===`list`&&(0,d.jsx)(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":`Available releases`,children:t.releases.map(e=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":`${e.version}${e.isCurrent?` — installed`:``}${e.isPinned?` — pinned`:``}`,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>i(e,t.releases),disabled:e.isCurrent,children:[(0,d.jsx)(`span`,{className:`vp-version`,children:e.version}),(0,d.jsx)(`span`,{className:`vp-date`,children:o(e.date)}),e.isCurrent&&(0,d.jsx)(`span`,{className:`vp-badge vp-badge-current`,children:`Installed`}),e.isPinned&&!e.isCurrent&&(0,d.jsx)(`span`,{className:`vp-badge vp-badge-pinned`,children:`Pinned`}),!e.isCurrent&&(0,d.jsx)(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),t.kind===`list`&&(0,d.jsxs)(`p`,{className:`version-picker-more`,children:[`Showing the `,t.releases.length,` most recent.`,` `,(0,d.jsx)(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:`Browse all releases on GitHub`})]}),t.kind===`confirm`&&(0,d.jsxs)(`div`,{className:`version-picker-confirm`,children:[(0,d.jsxs)(`p`,{children:[`This will `,(0,d.jsxs)(`strong`,{children:[`downgrade to v`,t.release.version]}),` and restart the app.`]}),(0,d.jsxs)(`p`,{className:`vp-confirm-note`,children:[`Auto-update will be paused after rollback so the app stays on v`,t.release.version,`. You can resume updates from Settings → About.`]}),(0,d.jsxs)(`div`,{className:`vp-confirm-actions`,children:[(0,d.jsx)(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>n({kind:`list`,releases:t.releases}),children:`Back`}),(0,d.jsx)(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>a(t.release),children:`Confirm downgrade & restart`})]})]}),t.kind===`installing`&&(0,d.jsxs)(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[(0,d.jsx)(`span`,{className:`version-picker-spinner`}),`Starting download…`]})]})]})})}function p(){let[e,t]=(0,u.useState)(null),[r,f]=(0,u.useState)(!0),[p,h]=(0,u.useState)([]),[ae,g]=(0,u.useState)(!1),_=te(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(!1),[w,T]=(0,u.useState)(!1),[E,D]=(0,u.useState)(null),[O,k]=(0,u.useState)(!1),A=(0,u.useRef)(null),[j,M]=(0,u.useState)(!1),[N,P]=(0,u.useState)(!1),[F,I]=(0,u.useState)(!1),[L,R]=(0,u.useState)(null);(0,u.useEffect)(()=>{n.system.info(`Checking system status...`);let e=n.system.time();ee().then(r=>{t(r),n.system.timed(`System status received`,e,{lemonade:r.lemonade_running?`running`:`stopped`,model:r.model_loaded||`none`,embedding:r.embedding_model_loaded?`yes`:`no`,disk:`${r.disk_space_gb}GB free`,memory:r.memory_available_gb==null?`unknown`:`${r.memory_available_gb}GB available`}),r.lemonade_running||n.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{n.system.error(`Failed to get system status`,e),t(null)}).finally(()=>f(!1)),l().then(e=>h(e.servers)).catch(()=>{}),re().then(e=>{let t=e.custom_model??``;y(t),x(t),M(e.dynamic_tools),P(e.dynamic_tools_locked)}).catch(e=>{n.system.error(`Failed to load settings`,e)}).finally(()=>C(!0))},[]),(0,u.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[]);let z=(0,u.useCallback)(async()=>{let e=v.trim(),t=e.length>0?e:``;T(!0),D(null),k(!1);try{n.system.info(`Saving custom_model override`,{custom_model:t});let e=(await s({custom_model:t})).custom_model??``;y(e),x(e),k(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>k(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);n.system.error(`Failed to save custom_model`,e),D(t)}finally{T(!1)}},[v]),oe=(0,u.useCallback)(async()=>{if(N||F)return;let e=j,t=!e;M(t),I(!0),R(null);try{n.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await s({dynamic_tools:t});M(e.dynamic_tools),P(e.dynamic_tools_locked)}catch(t){let r=t instanceof Error?t.message:String(t);n.system.error(`Failed to save dynamic_tools`,t),M(e),R(r)}finally{I(!1)}},[j,N,F]),B=v.trim()!==b.trim(),V=e?e.default_model_name:o,{isLoadingModel:H,isDownloadingModel:U,loadModel:W,downloadModel:G}=ne(V??void 0),K=[{label:`4K`,value:4096},{label:`8K`,value:8192},{label:`16K`,value:16384},{label:`32K`,value:32768}],q=e?.model_context_size??null,[J,Y]=(0,u.useState)(``);(0,u.useEffect)(()=>{q!=null&&Y(String(q))},[q]);let X=(()=>{let e=parseInt(J,10);return Number.isFinite(e)&&e>0?e:null})(),se=X!=null&&X!==q,Z=e?.model_loaded??V,Q=(0,u.useCallback)(async()=>{X&&Z&&(n.system.info(`Reloading ${Z} with ctx_size=${X}`),await W(Z,X))},[X,Z,W]),$=!!(e?.lemonade_running&&e.model_loaded&&e.expected_model_loaded===!1),ce=!!(e?.lemonade_running&&e.model_loaded&&e.context_size_sufficient===!1),le=!(!e?.lemonade_running||e.model_loaded||e.model_downloaded!==!1),ue=($||ce)&&V!==null;return(0,d.jsxs)(`div`,{className:`settings-pane`,children:[(0,d.jsx)(`h2`,{className:`settings-pane-title`,children:`Advanced`}),(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsx)(`h4`,{children:`Local model server`}),r?(0,d.jsx)(`p`,{className:`loading-text`,children:`Checking system...`}):e?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`status-grid`,children:[(0,d.jsx)(m,{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,d.jsx)(m,{label:`Model`,value:e.model_loaded||`None loaded`,ok:!!e.model_loaded&&e.expected_model_loaded!==!1,hint:e.model_loaded?e.expected_model_loaded===!1?`Expected: ${V}`:void 0:`None loaded yet — it loads with the first message.`}),e.model_size_gb!=null&&(0,d.jsx)(m,{label:`Model Size`,value:`${e.model_size_gb} GB`,ok:!0}),e.model_device&&(0,d.jsx)(m,{label:`Device`,value:e.model_device.toUpperCase(),ok:e.model_device!==`cpu`}),e.model_context_size!=null&&(0,d.jsx)(m,{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,d.jsx)(m,{label:`Capabilities`,value:e.model_labels.join(`, `),ok:!0}),(0,d.jsx)(m,{label:`Embedding Model`,value:e.embedding_model_loaded?`Available`:`Not loaded`,ok:e.embedding_model_loaded}),e.gpu_name&&(0,d.jsx)(m,{label:`GPU`,value:`${e.gpu_name}${e.gpu_vram_gb?` (${e.gpu_vram_gb} GB)`:``}`,ok:!0}),(0,d.jsx)(m,{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,d.jsx)(m,{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,d.jsx)(m,{label:`Processor`,value:e.processor_name,ok:!0})]}),le&&(0,d.jsxs)(`div`,{className:`model-action-row model-action-row--download`,children:[(0,d.jsxs)(`div`,{className:`model-action-info`,children:[(0,d.jsx)(`span`,{className:`model-action-label`,children:`Model not downloaded.`}),(0,d.jsxs)(`span`,{className:`model-action-desc`,children:[(0,d.jsx)(`strong`,{children:V}),` is GAIA’s default local model (about 6 GB).`]})]}),(0,d.jsx)(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>G(!1),disabled:U,children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{size:13,className:`btn-spinner`}),` Downloading…`]}):`Download`})]}),ue&&(0,d.jsxs)(`div`,{className:`model-action-row model-action-row--load`,children:[(0,d.jsxs)(`div`,{className:`model-action-info`,children:[(0,d.jsx)(`span`,{className:`model-action-label`,children:$?`Wrong model loaded.`:`Context window too small.`}),(0,d.jsxs)(`span`,{className:`model-action-desc`,children:[`Load `,(0,d.jsx)(`strong`,{children:V}),` with `,32 .toFixed(0),`K token context.`]})]}),(0,d.jsx)(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>W(),disabled:H,children:H?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{size:13,className:`btn-spinner`}),` Loading…`]}):`Load Model`})]}),e.lemonade_running&&V!==null&&(0,d.jsxs)(`div`,{className:`force-redownload-row`,children:[(0,d.jsx)(`span`,{className:`force-redownload-label`,children:`If the model file is corrupted:`}),(0,d.jsx)(`button`,{className:`btn-force-redownload`,onClick:()=>G(!0),disabled:U,children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{size:12,className:`btn-spinner`}),` Downloading…`]}):`Force Re-download`})]})]}):(0,d.jsx)(`div`,{className:`status-error`,children:(0,d.jsx)(`p`,{children:`Could not reach GAIA. Check that it is still running.`})})]}),(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsx)(`h4`,{children:`Custom model ID`}),(0,d.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,d.jsxs)(`div`,{className:`model-input-row`,children:[(0,d.jsx)(`input`,{type:`text`,className:`model-input${b?` has-override`:``}`,placeholder:`Use the model chosen under Model`,value:v,onChange:e=>{y(e.target.value),D(null),k(!1)},onKeyDown:e=>{e.key===`Enter`&&!w&&B&&S&&(e.preventDefault(),z())},disabled:!S||w,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Custom model override`}),(0,d.jsx)(`div`,{className:`model-btn-group`,children:(0,d.jsx)(`button`,{className:`btn-model-save${O?` saved`:``}`,onClick:()=>{z()},disabled:!S||w||!B&&!O,"aria-label":`Save custom model`,children:w?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{size:13,className:`btn-spinner`}),` Saving…`]}):O?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{size:13}),` Saved`]}):`Save`})})]}),(0,d.jsxs)(`p`,{className:`model-status-hint`,children:[`Accepts a Lemonade model ID (e.g. `,(0,d.jsx)(`code`,{children:`Qwen3-4B-Instruct-2507-GGUF`}),`)`,` `,`or a HuggingFace ID (e.g. `,(0,d.jsx)(`code`,{children:`unsloth/Qwen3-4B-GGUF`}),`).`]}),E&&(0,d.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,d.jsx)(i,{size:14}),(0,d.jsxs)(`div`,{className:`model-warning-content`,children:[(0,d.jsx)(`strong`,{children:`Could not save`}),(0,d.jsx)(`p`,{children:E})]})]})]}),(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsx)(`h4`,{children:`Context Size`}),(0,d.jsx)(`p`,{className:`model-override-desc`,children:`Reload the active model with a different context window. Larger contexts use more memory and slow inference; going past the model’s training length may degrade quality.`}),(0,d.jsx)(`div`,{className:`ctx-preset-row`,children:K.map(e=>{let t=X===e.value;return(0,d.jsx)(`button`,{className:`btn-ctx-preset${t?` active`:``}`,onClick:()=>Y(String(e.value)),disabled:H,type:`button`,children:e.label},e.value)})}),(0,d.jsxs)(`div`,{className:`model-input-row`,children:[(0,d.jsx)(`input`,{type:`number`,className:`model-input`,placeholder:q==null?`4096`:String(q),value:J,min:512,step:1024,onChange:e=>Y(e.target.value),disabled:H,"aria-label":`Context size in tokens`}),(0,d.jsx)(`div`,{className:`model-btn-group`,children:(0,d.jsx)(`button`,{className:`btn-model-save`,onClick:()=>{Q()},disabled:H||!se||!e?.lemonade_running,"aria-label":`Reload model with new context size`,children:H?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{size:13,className:`btn-spinner`}),` Reloading…`]}):`Apply`})})]}),(0,d.jsxs)(`p`,{className:`model-status-hint`,children:[`Current: `,(0,d.jsx)(`code`,{children:q==null?`unknown`:`${q.toLocaleString()} tokens`}),e?.model_loaded&&(0,d.jsxs)(d.Fragment,{children:[` on `,(0,d.jsx)(`code`,{children:e.model_loaded})]}),`.`]})]}),(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsxs)(`h4`,{children:[`Dynamic Tools `,(0,d.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,d.jsx)(`p`,{className:`model-override-desc`,children:`Trim each turn’s tool list to a semantically-matched subset to speed up the first response. Currently affects the Doc Agent only.`}),(0,d.jsxs)(`label`,{className:`setting-row`,children:[(0,d.jsx)(`span`,{children:`Enable dynamic tool loading`}),(0,d.jsxs)(`span`,{className:`toggle-switch`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:j,onChange:()=>void oe(),disabled:!S||F||N,"aria-label":j?`Disable dynamic tools`:`Enable dynamic tools`}),(0,d.jsx)(`span`,{className:`toggle-track`})]})]}),N&&(0,d.jsxs)(`p`,{className:`model-status-hint`,children:[`Controlled by `,(0,d.jsx)(`code`,{children:`GAIA_DYNAMIC_TOOLS`}),` — unset that environment variable to change this here.`]}),L&&(0,d.jsxs)(`div`,{className:`model-warning`,role:`alert`,children:[(0,d.jsx)(i,{size:14}),(0,d.jsxs)(`div`,{className:`model-warning-content`,children:[(0,d.jsx)(`strong`,{children:`Could not save`}),(0,d.jsx)(`p`,{children:L})]})]})]}),p.length>0&&(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsx)(`h4`,{children:`MCP Servers`}),(0,d.jsx)(`div`,{className:`status-grid`,children:p.map(e=>(0,d.jsxs)(`div`,{className:`status-row`,children:[(0,d.jsx)(`span`,{className:`status-label`,children:e.name}),(0,d.jsx)(`div`,{className:`status-value-wrap`,children:e.connected?(0,d.jsxs)(`span`,{className:`status-value ok mcp-status-connected`,children:[(0,d.jsx)(c,{size:12}),e.tool_count,` tool`,e.tool_count===1?``:`s`]}):(0,d.jsxs)(`span`,{className:`status-value warn mcp-status-failed`,title:e.error??void 0,children:[(0,d.jsx)(i,{size:12}),`Failed`]})})]},e.name))})]}),(0,d.jsxs)(`section`,{className:`settings-section`,children:[(0,d.jsx)(`h4`,{children:`About`}),(0,d.jsxs)(`div`,{className:`about-info`,children:[(0,d.jsxs)(`p`,{children:[`GAIA v`,`0.25.0rc2`,` `,(0,d.jsx)(`span`,{className:`beta-badge`,children:`BETA`})]}),(0,d.jsx)(`p`,{className:`about-sub`,children:`Privacy-first AI chat for AMD Ryzen AI PCs.`}),_.pinnedVersion&&(0,d.jsxs)(`p`,{className:`about-pinned-notice`,children:[`Auto-update paused (pinned to `,_.pinnedVersion,`).`,` `,(0,d.jsx)(`button`,{type:`button`,className:`about-resume-btn`,onClick:()=>{window.gaiaUpdater?.resumeUpdates().catch(e=>{n.system.error(`Resume updates failed`,e)})},children:`Resume updates`})]})]}),(0,d.jsx)(`div`,{className:`setting-actions`,children:(0,d.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>g(!0),children:`Roll back to a previous version`})})]}),ae&&(0,d.jsx)(ie,{onClose:()=>g(!1)})]})}function m({label:e,value:t,ok:n,hint:r}){return(0,d.jsxs)(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[(0,d.jsx)(`span`,{className:`status-label`,children:e}),(0,d.jsxs)(`div`,{className:`status-value-wrap`,children:[(0,d.jsx)(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&(0,d.jsx)(`span`,{className:`status-hint`,children:(0,d.jsx)(`code`,{children:r})})]})]})}export{p as AdvancedSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{$t as a,B as o,Dt as s,Et as ee,Ft as c,H as l,Ht as u,J as d,Lt as f,Nt as p,Ot as m,Q as te,V as ne,W as h,Wt as g,Xt as _,gt as v,it as y,jt as b,t as x,vt as S,xt as C}from"./index-CXbVMk3u.js";var w={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`]};w.node;var T=t(w),E={name:`link-2`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]};E.node;var D=t(E),O={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`}]]};O.node;var re=t(O),k={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`}]]};k.node;var ie=t(k),A=e(n(),1),j=i();function M(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function N(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 P(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 F(){let{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:i,currentSessionId:w,sessions:E,updateSessionInList:O}=m(),k=E.find(e=>e.id===w)??null,[F,I]=(0,A.useState)(!1),[L,R]=(0,A.useState)(!1),[z,B]=(0,A.useState)(``),[V,H]=(0,A.useState)(``),[U,W]=(0,A.useState)(null),[G,K]=(0,A.useState)(new Set),q=(0,A.useRef)(new Map),[,J]=(0,A.useState)(0);(0,A.useEffect)(()=>{r.doc.info(`Loading document library...`);let e=r.doc.time();v().then(n=>{let i=n.documents||[];t(i),r.doc.timed(`Loaded ${i.length} document(s), ${n.total_chunks||0} chunks, ${n.total_size_bytes||0} bytes total`,e)}).catch(e=>{r.doc.error(`Failed to load documents`,e),t([])})},[t]);let Y=e.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,A.useEffect)(()=>{if(!Y)return;let e=m.getState().documents;for(let t of e)(t.indexing_status===`indexing`||t.indexing_status===`pending`)&&!q.current.has(t.id)&&q.current.set(t.id,Date.now());let n=!1,r=setInterval(async()=>{if(J(e=>e+1),!n){n=!0;try{let e=m.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let n of e)try{let e=await y(n.id);if(e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){q.current.delete(n.id);let e=await v();t(e.documents||[]);break}}catch{}}finally{n=!1}}},2e3);return()=>clearInterval(r)},[Y,t]),(0,A.useEffect)(()=>{let t=new Set(e.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let e of q.current.keys())t.has(e)||q.current.delete(e)},[e]),(0,A.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await v()).documents||[],n=m.getState().documents;(e.length!==n.length||e.some((e,t)=>{let r=n.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(t(e),r.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[t]);let ae=e.reduce((e,t)=>e+t.file_size,0),oe=e.reduce((e,t)=>e+t.chunk_count,0),X=(0,A.useCallback)(async(e,n)=>{let i=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;if(i&&!l(i)){let t=ne(i),n=t?t.message:`The file type "${i}" is not supported for indexing.`;r.doc.warn(`Unsupported file type: ${e} (${i})`),W({filename:e,error:n});return}r.doc.info(`Indexing document: ${e}`);let a=r.doc.time();R(!0),B(`Indexing ${e}...`),W(null);try{let i=await n();if(r.doc.timed(`Indexed "${e}": ${i?.chunk_count||`?`} chunks`,a),w&&i?.id)try{await h(w,i.id);let t=m.getState().sessions.find(e=>e.id===w)?.document_ids??[];t.includes(i.id)||O(w,{document_ids:[...t,i.id]}),r.doc.info(`Auto-attached "${e}" to session ${w}`)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}let o=await v();t(o.documents||[]),B(``)}catch(t){r.doc.error(`Failed to index "${e}"`,t);let n=t instanceof Error?t.message:`Upload failed`;W({filename:e,error:n}),B(``)}finally{R(!1)}},[w,O,t]),Z=(0,A.useCallback)(async(e,t)=>{await X(t,()=>s(e))},[X]),Q=(0,A.useCallback)(async e=>{await X(e.name,()=>ee(e))},[X]),$=(0,A.useCallback)(async e=>{e.preventDefault(),I(!1);let t=Array.from(e.dataTransfer.files);r.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),se=(0,A.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Deleting document: ${i?.filename||n}`);try{await te(n),q.current.delete(n),t(e.filter(e=>e.id!==n)),r.doc.info(`Deleted document: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to delete document: ${i?.filename||n}`,e)}},[e,t]),ce=(0,A.useCallback)(async(e,t)=>{r.doc.info(`Opening folder for: ${e}`);try{await S(e,!0)}catch(e){r.doc.error(`Failed to open folder for: ${t}`,e)}},[]),le=(0,A.useCallback)(async n=>{let i=e.find(e=>e.id===n);r.doc.info(`Cancelling indexing for: ${i?.filename||n}`);try{await d(n),q.current.delete(n);let e=await v();t(e.documents||[]),r.doc.info(`Cancelled indexing for: ${i?.filename||n}`)}catch(e){r.doc.error(`Failed to cancel indexing: ${i?.filename||n}`,e)}},[e,t]),ue=(0,A.useCallback)(async n=>{if(G.has(n))return;let i=e.find(e=>e.id===n);r.doc.info(`Reindexing document: ${i?.filename||n}`),K(e=>new Set(e).add(n));try{await C(n),r.doc.info(`Reindex complete for: ${i?.filename||n}`)}catch(e){let t=e instanceof Error?e.message:String(e);r.doc.error(`Reindex failed for: ${i?.filename||n}`,e),W({filename:i?.filename||n,error:t})}finally{try{let e=await v();t(e.documents||[])}catch(e){r.doc.error(`Failed to refresh documents after reindex`,e)}K(e=>{let t=new Set(e);return t.delete(n),t})}},[e,t,G]),de=(0,A.useCallback)(async t=>{if(!w)return;let n=e.find(e=>e.id===t);r.doc.info(`Attaching document to session: ${n?.filename||t}`);try{await h(w,t);let e=m.getState().sessions.find(e=>e.id===w)?.document_ids??[];e.includes(t)||O(w,{document_ids:[...e,t]}),r.doc.info(`Attached "${n?.filename||t}" to session ${w}`)}catch(e){r.doc.error(`Failed to attach document to session: ${n?.filename||t}`,e)}},[w,e,O]),fe=(0,A.useCallback)(async e=>{e.preventDefault(),V.trim()&&(r.doc.info(`Indexing from path input: ${V.trim()}`),await Z(V.trim(),V.trim().split(/[\\/]/).pop()||`file`),H(``))},[V,Z]),pe=e=>{let t=e.indexing_status||`complete`,n=q.current.get(e.id),r=e.indexed_at?N(e.indexed_at):``,i=e.indexed_at?P(e.indexed_at):``;switch(t){case`indexing`:case`pending`:return(0,j.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,j.jsxs)(`div`,{className:`doc-indexing-bar`,children:[(0,j.jsx)(`div`,{className:`doc-indexing-bar-track`,children:(0,j.jsx)(`div`,{className:`doc-indexing-bar-fill`})}),(0,j.jsxs)(`span`,{className:`doc-indexing-label`,children:[(0,j.jsx)(re,{size:12,className:`doc-spin`}),`Indexing`,n?` (${M(n)})`:`...`]})]}),(0,j.jsxs)(`button`,{className:`btn-cancel`,onClick:t=>{t.stopPropagation(),le(e.id)},title:`Cancel indexing`,"aria-label":`Cancel indexing ${e.filename}`,children:[(0,j.jsx)(T,{size:14}),`Cancel`]})]});case`failed`:return(0,j.jsxs)(`div`,{className:`doc-indexing-status`,children:[(0,j.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,j.jsx)(a,{size:12}),` Failed`]}),(0,j.jsxs)(`button`,{className:`btn-retry`,onClick:t=>{t.stopPropagation(),ue(e.id)},title:`Retry indexing`,"aria-label":`Retry indexing ${e.filename}`,disabled:G.has(e.id),children:[(0,j.jsx)(ie,{size:14}),G.has(e.id)?`Retrying…`:`Retry`]})]});case`cancelled`:return(0,j.jsxs)(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[(0,j.jsx)(T,{size:12}),` Cancelled`]});case`missing`:return(0,j.jsxs)(`span`,{className:`doc-status-badge doc-status-missing`,children:[(0,j.jsx)(a,{size:12}),` File missing`]});default:return(0,j.jsxs)(`span`,{className:`doc-meta`,children:[x(e.file_size),` · `,e.chunk_count,` chunks`,r&&(0,j.jsxs)(`span`,{className:`doc-timestamp`,title:`Indexed: ${i}`,children:[(0,j.jsx)(_,{size:10}),r]})]})}};return(0,j.jsx)(`div`,{className:`modal-overlay`,onClick:()=>n(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`Document Library`,children:(0,j.jsxs)(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`modal-header`,children:[(0,j.jsx)(`h3`,{children:`Document Library`}),(0,j.jsx)(`button`,{className:`btn-icon`,onClick:()=>n(!1),"aria-label":`Close document library`,children:(0,j.jsx)(b,{size:18})})]}),(0,j.jsxs)(`div`,{className:`modal-body`,children:[(0,j.jsx)(`div`,{className:`drop-zone ${F?`drag-over`:``} ${L?`uploading`:``}`,onDragOver:e=>{e.preventDefault(),I(!0)},onDragLeave:()=>I(!1),onDrop:$,children:L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`upload-spinner`}),(0,j.jsx)(`p`,{children:z})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(p,{size:32,strokeWidth:1.5}),(0,j.jsx)(`p`,{children:`Drop files here to index`}),(0,j.jsx)(`span`,{className:`drop-hint`,children:`PDF, TXT, MD, code files, and 50+ formats`})]})}),(0,j.jsxs)(`form`,{className:`path-input-form`,onSubmit:fe,children:[(0,j.jsx)(u,{size:16,className:`path-icon`}),(0,j.jsx)(`input`,{type:`text`,className:`path-input`,value:V,onChange:e=>H(e.target.value),placeholder:`Or enter file path: C:\\docs\\manual.pdf`,"aria-label":`File path to index`}),(0,j.jsx)(`button`,{type:`submit`,className:`btn-secondary`,disabled:!V.trim()||L,children:`Index`}),(0,j.jsxs)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(!1),i(!0)},title:`Browse files on this computer`,children:[(0,j.jsx)(f,{size:14}),`Browse Files`]})]}),U&&(0,j.jsx)(o,{filename:U.filename,error:U.error,onDismiss:()=>W(null)}),e.length>0&&(0,j.jsxs)(`div`,{className:`doc-stats`,children:[(0,j.jsxs)(`span`,{children:[e.length,` document`,e.length===1?``:`s`]}),(0,j.jsx)(`span`,{children:`·`}),(0,j.jsxs)(`span`,{children:[oe,` chunks`]}),(0,j.jsx)(`span`,{children:`·`}),(0,j.jsx)(`span`,{children:x(ae)})]}),(0,j.jsxs)(`div`,{className:`doc-list`,children:[e.length===0&&!L&&(0,j.jsxs)(`div`,{className:`empty-docs`,children:[(0,j.jsx)(g,{size:32,strokeWidth:1}),(0,j.jsx)(`p`,{children:`No documents indexed yet`}),(0,j.jsx)(`span`,{children:`Drop files above or enter a file path`})]}),e.map(e=>(0,j.jsxs)(`div`,{className:`doc-row ${e.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[(0,j.jsxs)(`div`,{className:`doc-info`,children:[(0,j.jsx)(`span`,{className:`doc-name`,children:e.filename}),pe(e)]}),(0,j.jsxs)(`div`,{className:`doc-row-actions`,children:[e.filepath&&(0,j.jsx)(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>ce(e.filepath,e.filename),title:`Open folder: ${e.filepath}`,"aria-label":`Open containing folder for ${e.filename}`,children:(0,j.jsx)(u,{size:14})}),w&&e.indexing_status===`complete`&&!k?.document_ids?.includes(e.id)&&(0,j.jsx)(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>de(e.id),title:`Use in current session`,"aria-label":`Attach ${e.filename} to current session`,children:(0,j.jsx)(D,{size:14})}),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`&&(0,j.jsx)(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>se(e.id),title:`Remove`,"aria-label":`Remove ${e.filename}`,children:(0,j.jsx)(c,{size:14})})]})]},e.id))]})]})]})})}export{F as DocumentLibrary};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,o as n,r,t as i}from"./jsx-runtime-DVeaULmT.js";import{B as a,Ct as o,Dt as s,H as c,Ht as l,Kt as u,Lt as d,Nt as f,Ot as p,Ut as m,V as h,W as g,Wt as _,bt as ee,dt as v,en as te,gt as y,in as ne,jt as b,q as re,rn as ie,t as ae}from"./index-CXbVMk3u.js";var x={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`}]]};x.node;var S=t(x),C={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};C.node;var oe=t(C),w={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};w.node;var T=t(w),E={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`}]]};E.node;var se=t(E),D={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`]};D.node;var O=t(D),k={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};k.node;var A=t(k),j={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`}]]};j.node;var M=t(j),N=e(n(),1),P=i();function ce(e){if(e.type===`folder`)return(0,P.jsx)(T,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?(0,P.jsx)(M,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?(0,P.jsx)(S,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?(0,P.jsx)(_,{size:16}):(0,P.jsx)(m,{size:16})}function le(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 ue(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function de(e){switch(e){case`home`:return(0,P.jsx)(O,{size:14});case`desktop`:return(0,P.jsx)(A,{size:14});case`documents`:return(0,P.jsx)(_,{size:14});case`download`:return(0,P.jsx)(u,{size:14});default:return(0,P.jsx)(T,{size:14})}}var fe=[{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 F(e,t,n,i){let a=[],o=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!c(e)?o.push(t):a.push(t)}let l=[],u=[],d=0,f=``,m=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(m.has(e)){let t=await v(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),n.length>0&&(n.forEach(e=>l.push(e)),u.push(e))}else{let t=await s(e);t?.id&&(l.push(t.id),u.push(e))}}catch(e){d++,f=e instanceof Error?e.message:`Unknown error`}if(n&&l.length>0){let e=[];for(let t of l)try{await g(n,t),e.push(t)}catch(e){r.doc.warn(`Could not attach document to session: ${e}`)}let t=p.getState().sessions.find(e=>e.id===n)?.document_ids??[],a=e.filter(e=>!t.includes(e));a.length>0&&i(n,{document_ids:[...t,...a]})}if(l.length>0)try{let e=await y();p.getState().setDocuments(e.documents||[])}catch(e){r.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:l,supported:a,succeededFiles:u,unsupported:o,failed:d,lastError:f}}function I(){let{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n,setPendingPrompt:i}=p(),[s,u]=(0,N.useState)(``),[m,g]=(0,N.useState)(null),[_,v]=(0,N.useState)([]),[y,x]=(0,N.useState)([]),[S,C]=(0,N.useState)(!1),[w,T]=(0,N.useState)(null),[E,D]=(0,N.useState)(``),[O,k]=(0,N.useState)(null),[A,j]=(0,N.useState)([]),[M,I]=(0,N.useState)(!1),[L,R]=(0,N.useState)(!1),[z,pe]=(0,N.useState)(``),[B,V]=(0,N.useState)(new Set),[H,U]=(0,N.useState)(null),[me,W]=(0,N.useState)(!1),[G,K]=(0,N.useState)(new Set),[q,J]=(0,N.useState)(null),Y=(0,N.useRef)(null),[X,Z]=(0,N.useState)(null),Q=(0,N.useCallback)(async e=>{C(!0),T(null),k(null),D(``),j([]);try{let t=await re(e);u(t.current_path),g(t.parent_path),v(t.entries),t.quick_links.length>0&&x(t.quick_links),r.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;T(t),r.ui.error(`Browse failed`,e)}finally{C(!1)}},[]);(0,N.useEffect)(()=>{Q()},[Q]),(0,N.useEffect)(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);let he=(0,N.useCallback)(async()=>{if(!E.trim()){k(null),j([]);return}R(!0),T(null);try{let e=await o(E.trim(),z||void 0,30);k(e.results),j(e.searched_locations??[]),I(e.truncated===!0),r.ui.info(`Search "${E}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;T(t),r.ui.error(`Search failed`,e)}finally{R(!1)}},[E,z]),ge=e=>{e.key===`Enter`&&he()},_e=(0,N.useCallback)(e=>{e.type===`folder`&&(Q(e.path),V(new Set),U(null))},[Q]),ve=(0,N.useCallback)(async e=>{W(!0);try{let t=await ee(e);U(t)}catch(e){r.ui.error(`Preview failed`,e)}finally{W(!1)}},[]),ye=(0,N.useCallback)(e=>{V(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),be=(0,N.useCallback)(async()=>{if(B.size===0)return;let e=Array.from(B);if(Z(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||c(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=h(r);Z({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`});return}K(new Set(e)),J(`Indexing ${e.length} file(s)...`);try{let r=await F(e,_,t,n);if(r.failed>0)J(`Done: ${r.docIds.length} indexed, ${r.failed} failed`),Z({filename:`${r.failed} file(s)`,error:r.lastError||`Indexing failed for some files`});else{let e=r.unsupported.length>0?` (${r.unsupported.length} skipped — unsupported type)`:``;J(`Successfully indexed ${r.docIds.length} file(s)${e}`)}Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>J(null),5e3),V(new Set)}catch(t){r.doc.error(`Index selected failed`,t),Z({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,t,n,_]),xe=(0,N.useCallback)(async()=>{if(B.size===0)return;let a=Array.from(B);Z(null),K(new Set(a)),J(`Indexing ${a.length} file(s) for analysis...`);try{let r=await F(a,_,t,n);if(r.supported.length===0){let e=a[0].lastIndexOf(`.`),t=e>0?a[0].slice(e).toLowerCase():``,n=h(t);Z({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(r.docIds.length===0){Z({filename:r.supported.length===1?r.supported[0].split(/[\\/]/).pop()||r.supported[0]:`${r.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}r.failed>0&&J(`Warning: ${r.failed} file(s) failed to index and will be excluded.`);let o=(r.succeededFiles.length>0?r.succeededFiles:r.supported).map(e=>e.split(/[\\/]/).pop()||e),s=o.length===1?`Please analyze this document for me: ${o[0]}`:`Please analyze these documents for me:\n${o.map(e=>`- ${e}`).join(`
|
|
2
|
-
`)}`;i(s),e(!1),V(new Set)}catch(e){r.doc.error(`Ask Agent failed`,e),Z({filename:a.length===1?a[0].split(/[\\/]/).pop()||a[0]:`${a.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{K(new Set),J(null)}},[B,t,n,_,i,e]),Se=s?s.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],Ce=Se.map((e,t)=>({label:e,path:Se.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),we=ue(A),$=O?O.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):_;return(0,P.jsx)(`div`,{className:`modal-overlay`,onClick:()=>e(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File Browser`,children:(0,P.jsxs)(`div`,{className:`modal-panel file-browser-modal ${H?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`modal-header`,children:[(0,P.jsxs)(`h3`,{children:[(0,P.jsx)(l,{size:18}),` File Browser`]}),(0,P.jsx)(`button`,{className:`btn-icon`,onClick:()=>e(!1),"aria-label":`Close`,children:(0,P.jsx)(b,{size:18})})]}),(0,P.jsxs)(`div`,{className:`file-browser-body`,children:[(0,P.jsx)(`div`,{className:`fb-quick-links`,children:y.map(e=>(0,P.jsxs)(`button`,{className:`fb-quick-link`,onClick:()=>Q(e.path),title:e.path,children:[de(e.icon),(0,P.jsx)(`span`,{children:e.name})]},e.path))}),(0,P.jsxs)(`div`,{className:`fb-search-bar`,children:[(0,P.jsxs)(`div`,{className:`fb-search-input-wrap`,children:[(0,P.jsx)(d,{size:14,className:`fb-search-icon`}),(0,P.jsx)(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:E,onChange:e=>D(e.target.value),onKeyDown:ge,"aria-label":`Search files`}),E&&(0,P.jsx)(`button`,{className:`fb-search-clear`,onClick:()=>{D(``),k(null),j([])},"aria-label":`Clear search`,children:(0,P.jsx)(b,{size:12})})]}),(0,P.jsx)(`select`,{className:`fb-type-filter`,value:z,onChange:e=>pe(e.target.value),"aria-label":`File type filter`,children:fe.map(e=>(0,P.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,P.jsx)(`button`,{className:`fb-search-btn`,onClick:he,disabled:!E.trim()||L,children:L?`Searching...`:`Search`})]}),!O&&(0,P.jsxs)(`div`,{className:`fb-breadcrumb`,children:[(0,P.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Q(`/`),children:(0,P.jsx)(se,{size:12})}),Ce.map((e,t)=>(0,P.jsxs)(`span`,{className:`fb-crumb-item`,children:[(0,P.jsx)(te,{size:12,className:`fb-crumb-sep`}),(0,P.jsx)(`button`,{className:`fb-crumb`,onClick:()=>Q(e.path),children:e.label})]},t)),m&&(0,P.jsx)(`button`,{className:`fb-up-btn`,onClick:()=>Q(m),title:`Go up`,children:(0,P.jsx)(ne,{size:14})})]}),O&&(0,P.jsxs)(`div`,{className:`fb-search-header`,children:[(0,P.jsxs)(`div`,{className:`fb-search-summary`,children:[(0,P.jsxs)(`span`,{children:[`Found `,O.length,` result(s) for "`,E,`"`]}),we&&(0,P.jsxs)(`span`,{className:`fb-search-scope`,title:A.join(`
|
|
3
|
-
`),children:[`Searching in: `,(0,P.jsx)(`code`,{children:we})]}),M&&(0,P.jsx)(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),(0,P.jsx)(`button`,{className:`fb-back-btn`,onClick:()=>{k(null),D(``),j([])},children:`Back to browsing`})]}),w&&(0,P.jsx)(`div`,{className:`fb-error`,children:w}),(0,P.jsxs)(`div`,{className:`fb-content`,children:[(0,P.jsxs)(`div`,{className:`fb-file-list`,children:[S&&(0,P.jsx)(`div`,{className:`fb-loading`,children:`Loading...`}),!S&&$.length===0&&(0,P.jsx)(`div`,{className:`fb-empty`,children:O?`No files found`:`This folder is empty`}),!S&&$.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!c(t),r=n?h(t):null;return(0,P.jsxs)(`div`,{className:`fb-entry ${e.type} ${B.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?_e(e):ye(e.path),onDoubleClick:()=>e.type===`folder`?_e(e):void 0,title:n?`${r?.label||`This`} file type cannot be indexed`:e.path,children:[(0,P.jsx)(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:B.has(e.path),onChange:()=>ye(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),(0,P.jsx)(`span`,{className:`fb-entry-icon`,children:ce(e)}),(0,P.jsx)(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&(0,P.jsx)(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&(0,P.jsx)(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),ve(e.path)},"aria-label":`Preview ${e.name}`,title:`Preview file`,children:(0,P.jsx)(oe,{size:14})}),(0,P.jsx)(`span`,{className:`fb-entry-size`,children:e.type===`file`?ae(e.size):``}),(0,P.jsx)(`span`,{className:`fb-entry-date`,children:le(e.modified)})]},e.path)})]}),H&&(0,P.jsxs)(`div`,{className:`fb-preview`,children:[(0,P.jsxs)(`div`,{className:`fb-preview-header`,children:[(0,P.jsx)(`span`,{className:`fb-preview-name`,children:H.name}),(0,P.jsx)(`button`,{className:`btn-icon-sm`,onClick:()=>U(null),"aria-label":`Close preview`,children:(0,P.jsx)(b,{size:14})})]}),(0,P.jsxs)(`div`,{className:`fb-preview-meta`,children:[(0,P.jsx)(`span`,{children:H.size_display}),H.total_lines&&(0,P.jsxs)(`span`,{children:[H.total_lines,` lines`]}),H.columns&&(0,P.jsxs)(`span`,{children:[H.columns.length,` columns`]}),H.row_count!==null&&(0,P.jsxs)(`span`,{children:[H.row_count,` rows`]})]}),H.columns&&(0,P.jsxs)(`div`,{className:`fb-preview-columns`,children:[(0,P.jsx)(`strong`,{children:`Columns:`}),` `,H.columns.join(`, `)]}),me?(0,P.jsx)(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):H.is_text&&H.preview_lines.length>0?(0,P.jsx)(`pre`,{className:`fb-preview-content`,children:H.preview_lines.slice(0,30).join(`
|
|
4
|
-
`)}):(0,P.jsx)(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),X&&(0,P.jsx)(a,{filename:X.filename,error:X.error,onDismiss:()=>Z(null)}),(0,P.jsxs)(`div`,{className:`fb-actions`,children:[(0,P.jsx)(`div`,{className:`fb-selection-info`,children:B.size>0?`${B.size} item(s) selected`:`Select files to index or analyze`}),q&&(0,P.jsx)(`span`,{className:`fb-index-status`,children:q}),(0,P.jsxs)(`div`,{className:`fb-action-btns`,children:[(0,P.jsxs)(`button`,{className:`fb-action-btn secondary`,onClick:be,disabled:B.size===0||G.size>0,title:`Index selected files for RAG search`,children:[(0,P.jsx)(f,{size:14}),`Index Selected`]}),(0,P.jsxs)(`button`,{className:`fb-action-btn primary`,onClick:xe,disabled:B.size===0||G.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[(0,P.jsx)(ie,{size:14}),`Ask Agent`]})]})]})]})]})})}export{I as FileBrowser};
|