@amd-gaia/agent-ui 0.25.4-rc.4 → 0.25.4-rc.7
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-D1PbqQtF.js +1 -0
- package/dist/assets/ConnectorsPane-B_IM_sQZ.js +1 -0
- package/dist/assets/DocumentLibrary-OQGMKNkO.js +4 -0
- package/dist/assets/FileBrowser-dev5yv69.js +4 -0
- package/dist/assets/MemoryDashboard-DwrWAXi6.css +1 -0
- package/dist/assets/MemoryDashboard-Vz8OFC3_.js +1 -0
- package/dist/assets/MobileAccessModal-DpHtJVxo.js +2 -0
- package/dist/assets/ScheduleManager-BbmXSIUD.js +1 -0
- package/dist/assets/ScheduleManager-CjHJ4NbD.css +1 -0
- package/dist/assets/api-BsMIEtSA.js +4 -0
- package/dist/assets/index-CNhwlnjv.css +1 -0
- package/dist/assets/index-eGMUmm-L.js +78 -0
- package/dist/assets/useT-DmcuCJlO.js +3 -0
- package/dist/assets/zap-CORjwTA2.js +1 -0
- package/dist/index.html +4 -4
- package/dist/sw.js +1 -1
- package/main.cjs +8 -5
- package/package.json +1 -1
- package/preload.cjs +3 -0
- package/services/backend-installer.cjs +290 -21
- package/services/engine-install.cjs +100 -9
- package/services/lock-holders.cjs +200 -0
- package/services/quit-guard.cjs +17 -0
- package/dist/assets/AdvancedSettings-DoIDd09m.js +0 -1
- package/dist/assets/ConnectorsPane-CK3h7C7E.js +0 -1
- package/dist/assets/DocumentLibrary-BWvkvxTu.js +0 -4
- package/dist/assets/FileBrowser-DhqWGirJ.js +0 -4
- package/dist/assets/MemoryDashboard-BF-o8284.js +0 -1
- package/dist/assets/MemoryDashboard-Dt6zI60b.css +0 -1
- package/dist/assets/MobileAccessModal-51t2kQaJ.js +0 -2
- package/dist/assets/ScheduleManager-2xjZsnLK.js +0 -2
- package/dist/assets/ScheduleManager-D5c4gVIt.css +0 -1
- package/dist/assets/api-BzlFpP4T.js +0 -4
- package/dist/assets/apiBase-BMkGbdXt.js +0 -1
- package/dist/assets/index-C_Cx5IlD.css +0 -1
- package/dist/assets/index-hAcJijAU.js +0 -78
- package/dist/assets/zap-D7aLu_f0.js +0 -1
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Status: { phase: 'running'|'failed', stage, percent, message, error }
|
|
12
12
|
* percent is null when the stage has none to report. error, when failed:
|
|
13
|
-
* { stage, reason, message, logTail, previousVersion }; reason is
|
|
14
|
-
* FAILURE_REASONS or null,
|
|
15
|
-
* go back to, or null
|
|
13
|
+
* { stage, reason, message, logTail, previousVersion, lockedBy }; reason is
|
|
14
|
+
* one of FAILURE_REASONS or null, previousVersion is the version an update can
|
|
15
|
+
* go back to, or null, and lockedBy names the programs holding GAIA's files
|
|
16
|
+
* after a 'locked' failure on Windows (lock-holders.cjs), or is null.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
"use strict";
|
|
19
20
|
|
|
21
|
+
const defaultLockHolders = require("./lock-holders.cjs");
|
|
22
|
+
|
|
20
23
|
// Keep these in sync with preload.cjs.
|
|
21
24
|
const IPC_PROGRESS_EVENT = "install:progress";
|
|
22
25
|
const IPC_STATUS_REQUEST = "install:status";
|
|
@@ -24,6 +27,7 @@ const IPC_RETRY_REQUEST = "install:retry";
|
|
|
24
27
|
const IPC_CONTINUE_REQUEST = "install:continue";
|
|
25
28
|
const IPC_OPEN_LOG_FILE = "install:open-log-file";
|
|
26
29
|
const IPC_REVERT_REQUEST = "install:revert";
|
|
30
|
+
const IPC_CLOSE_LOCKERS_REQUEST = "install:close-lockers";
|
|
27
31
|
|
|
28
32
|
/** Not an installer stage: the backend is installed and starting. */
|
|
29
33
|
const STARTING_STAGE = "start";
|
|
@@ -40,10 +44,44 @@ const CONTINUE = "continue";
|
|
|
40
44
|
* @param {(err: Error) => void} deps.onFailed - Runs once the failure is on screen.
|
|
41
45
|
* @param {() => string|null} deps.previousVersion - The version an update can go back to.
|
|
42
46
|
* @param {() => Promise<void>} deps.revert - Installs that version; the app then restarts into it.
|
|
47
|
+
* @param {object} [deps.lockHolders] - lock-holders.cjs
|
|
48
|
+
* @param {number} [deps.ownPid] - This app's pid; its own process tree is never offered for closing.
|
|
49
|
+
* @param {string} [deps.platform]
|
|
43
50
|
*/
|
|
44
|
-
function createEngineInstall({
|
|
51
|
+
function createEngineInstall({
|
|
52
|
+
installer,
|
|
53
|
+
ipcMain,
|
|
54
|
+
shell,
|
|
55
|
+
getWindow,
|
|
56
|
+
isPackaged,
|
|
57
|
+
onFailed,
|
|
58
|
+
previousVersion,
|
|
59
|
+
revert,
|
|
60
|
+
lockHolders = defaultLockHolders,
|
|
61
|
+
ownPid = process.pid,
|
|
62
|
+
platform = process.platform,
|
|
63
|
+
}) {
|
|
45
64
|
let status = { phase: "running", stage: null, percent: null, message: "", error: null };
|
|
46
65
|
let wakeForRetry = null;
|
|
66
|
+
let lockedFiles = null;
|
|
67
|
+
let closing = false;
|
|
68
|
+
let quitting = null;
|
|
69
|
+
let installing = null;
|
|
70
|
+
|
|
71
|
+
/** Who holds `files` open, summarized for the screen; null when Windows can't say. */
|
|
72
|
+
async function findHolders(files) {
|
|
73
|
+
try {
|
|
74
|
+
const holders = lockHolders.summarizeHolders(await lockHolders.queryLockHolders(files), ownPid);
|
|
75
|
+
console.log(
|
|
76
|
+
`[main] Holding ${files.join(", ")}: ` +
|
|
77
|
+
(holders.map((h) => `${h.name} pid ${h.pid} (${h.path || "path unknown"}, ${h.isGaia ? "GAIA" : "not GAIA"})`).join("; ") || "nothing now")
|
|
78
|
+
);
|
|
79
|
+
return holders;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(`[main] Could not find which programs hold ${files.join(", ")}: ${err.message}`);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
47
85
|
|
|
48
86
|
function publish(next) {
|
|
49
87
|
status = { ...status, ...next };
|
|
@@ -75,6 +113,28 @@ function createEngineInstall({ installer, ipcMain, shell, getWindow, isPackaged,
|
|
|
75
113
|
return true;
|
|
76
114
|
});
|
|
77
115
|
|
|
116
|
+
// Ends the GAIA processes the screen named, then installs again. Takes no
|
|
117
|
+
// pids from the renderer, and ends only a process that is still the one
|
|
118
|
+
// named, so a pid reused since cannot be hit.
|
|
119
|
+
ipcMain.handle(IPC_CLOSE_LOCKERS_REQUEST, async () => {
|
|
120
|
+
const shown = status.error?.lockedBy;
|
|
121
|
+
if (!wakeForRetry || closing || !shown?.length || !shown.every((h) => h.isGaia)) return false;
|
|
122
|
+
closing = true;
|
|
123
|
+
try {
|
|
124
|
+
const current = await lockHolders.queryLockHolders(lockedFiles);
|
|
125
|
+
const fresh = lockHolders.summarizeHolders(current, ownPid);
|
|
126
|
+
const pids = shown
|
|
127
|
+
.filter((h) => fresh.some((f) => f.isGaia && f.pid === h.pid && f.path === h.path))
|
|
128
|
+
.map((h) => h.pid);
|
|
129
|
+
console.log(`[main] Ending GAIA processes holding the install: ${pids.join(", ") || "none still running"}`);
|
|
130
|
+
await lockHolders.endProcessTrees(pids);
|
|
131
|
+
} finally {
|
|
132
|
+
closing = false;
|
|
133
|
+
}
|
|
134
|
+
wakeForRetry(true);
|
|
135
|
+
return true;
|
|
136
|
+
});
|
|
137
|
+
|
|
78
138
|
// Takes no path: the renderer only ever opens the installer's own log.
|
|
79
139
|
ipcMain.handle(IPC_OPEN_LOG_FILE, async () => {
|
|
80
140
|
const problem = await shell.openPath(installer.getLogPath());
|
|
@@ -83,19 +143,28 @@ function createEngineInstall({ installer, ipcMain, shell, getWindow, isPackaged,
|
|
|
83
143
|
|
|
84
144
|
/**
|
|
85
145
|
* Install, and after a failure wait for Try again. Resolves true once the
|
|
86
|
-
* backend is installed, false when stop() ended the wait.
|
|
146
|
+
* backend is installed, false when stop() ended the install or the wait.
|
|
87
147
|
*/
|
|
88
148
|
async function run() {
|
|
149
|
+
quitting = new AbortController();
|
|
89
150
|
for (;;) {
|
|
90
151
|
publish({ phase: "running", stage: null, percent: null, message: "", error: null });
|
|
91
152
|
try {
|
|
92
|
-
|
|
153
|
+
installing = installer.ensureBackend({
|
|
93
154
|
isPackaged,
|
|
94
155
|
onProgress: (stage, percent, message) => publish({ stage, percent, message }),
|
|
156
|
+
signal: quitting.signal,
|
|
95
157
|
});
|
|
158
|
+
await installing;
|
|
96
159
|
return true;
|
|
97
160
|
} catch (err) {
|
|
161
|
+
if (quitting.signal.aborted) {
|
|
162
|
+
console.log(`[main] Backend install stopped for the quit: ${err.message}`);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
98
165
|
console.error(`[main] Backend install failed: ${err.stack || err}`);
|
|
166
|
+
lockedFiles = err.reason === "locked" && err.lockedFiles?.length ? err.lockedFiles : null;
|
|
167
|
+
const lockedBy = lockedFiles && platform === "win32" ? await findHolders(lockedFiles) : null;
|
|
99
168
|
const retry = new Promise((resolve) => {
|
|
100
169
|
wakeForRetry = resolve;
|
|
101
170
|
});
|
|
@@ -106,8 +175,9 @@ function createEngineInstall({ installer, ipcMain, shell, getWindow, isPackaged,
|
|
|
106
175
|
reason: err.reason || null,
|
|
107
176
|
// The rest is the tool's output, which the log tail carries.
|
|
108
177
|
message: String(err.message).split("\n")[0],
|
|
109
|
-
logTail:
|
|
178
|
+
logTail: logTailOrWhy(),
|
|
110
179
|
previousVersion: previousVersion(),
|
|
180
|
+
lockedBy,
|
|
111
181
|
},
|
|
112
182
|
});
|
|
113
183
|
onFailed(err);
|
|
@@ -119,13 +189,33 @@ function createEngineInstall({ installer, ipcMain, shell, getWindow, isPackaged,
|
|
|
119
189
|
}
|
|
120
190
|
}
|
|
121
191
|
|
|
192
|
+
/** The log's last lines; a log that can't be read says why instead of crashing the failure screen. */
|
|
193
|
+
function logTailOrWhy() {
|
|
194
|
+
try {
|
|
195
|
+
return installer.readLogTail();
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.error(`[main] Could not read the install log: ${err.stack || err}`);
|
|
198
|
+
return [`The install log could not be read: ${err.message}`];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
122
202
|
return {
|
|
123
203
|
run,
|
|
124
204
|
/** The install is done and the backend process is coming up. */
|
|
125
205
|
starting: () => publish({ stage: STARTING_STAGE, percent: null, message: "" }),
|
|
126
|
-
/**
|
|
127
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Quitting: stop a running install, with every process it started, or
|
|
208
|
+
* release a run() waiting on Try again. Resolves once the install has ended.
|
|
209
|
+
*/
|
|
210
|
+
stop: async () => {
|
|
128
211
|
if (wakeForRetry) wakeForRetry(false);
|
|
212
|
+
if (!quitting) return;
|
|
213
|
+
quitting.abort();
|
|
214
|
+
// run() reports the outcome; this only waits for the processes to be gone.
|
|
215
|
+
await installing?.then(
|
|
216
|
+
() => {},
|
|
217
|
+
() => {}
|
|
218
|
+
);
|
|
129
219
|
},
|
|
130
220
|
};
|
|
131
221
|
}
|
|
@@ -139,4 +229,5 @@ module.exports = {
|
|
|
139
229
|
IPC_CONTINUE_REQUEST,
|
|
140
230
|
IPC_OPEN_LOG_FILE,
|
|
141
231
|
IPC_REVERT_REQUEST,
|
|
232
|
+
IPC_CLOSE_LOCKERS_REQUEST,
|
|
142
233
|
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* lock-holders.cjs — which processes hold a file open on Windows (#6570).
|
|
6
|
+
*
|
|
7
|
+
* Asks Windows Restart Manager, the API installers use for "files in use",
|
|
8
|
+
* through a PowerShell script, then sorts the holders into GAIA processes the
|
|
9
|
+
* user can let the app close and other programs it must only name.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
const childProcess = require("child_process");
|
|
15
|
+
|
|
16
|
+
const QUERY_TIMEOUT_MS = 30000;
|
|
17
|
+
const KILL_TIMEOUT_MS = 10000;
|
|
18
|
+
// taskkill's exit code when the process has already exited.
|
|
19
|
+
const TASKKILL_NOT_FOUND = 128;
|
|
20
|
+
|
|
21
|
+
const RM_SCRIPT = String.raw`
|
|
22
|
+
$ErrorActionPreference = 'Stop'
|
|
23
|
+
$files = [string[]](ConvertFrom-Json $env:GAIA_LOCKED_FILES)
|
|
24
|
+
Add-Type -TypeDefinition @'
|
|
25
|
+
using System;
|
|
26
|
+
using System.Runtime.InteropServices;
|
|
27
|
+
public static class GaiaRestartManager {
|
|
28
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
29
|
+
struct RM_UNIQUE_PROCESS { public int dwProcessId; public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime; }
|
|
30
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
31
|
+
struct RM_PROCESS_INFO {
|
|
32
|
+
public RM_UNIQUE_PROCESS Process;
|
|
33
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string strAppName;
|
|
34
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string strServiceShortName;
|
|
35
|
+
public int ApplicationType; public uint AppStatus; public uint TSSessionId;
|
|
36
|
+
[MarshalAs(UnmanagedType.Bool)] public bool bRestartable;
|
|
37
|
+
}
|
|
38
|
+
[DllImport("rstrtmgr.dll", CharSet = CharSet.Unicode)] static extern int RmStartSession(out uint h, int flags, string key);
|
|
39
|
+
[DllImport("rstrtmgr.dll")] static extern int RmEndSession(uint h);
|
|
40
|
+
[DllImport("rstrtmgr.dll", CharSet = CharSet.Unicode)] static extern int RmRegisterResources(uint h, uint nFiles, string[] files, uint nApps, RM_UNIQUE_PROCESS[] apps, uint nServices, string[] services);
|
|
41
|
+
[DllImport("rstrtmgr.dll")] static extern int RmGetList(uint h, out uint needed, ref uint count, [In, Out] RM_PROCESS_INFO[] info, ref uint reasons);
|
|
42
|
+
public static int[] Holders(string[] files) {
|
|
43
|
+
uint h;
|
|
44
|
+
int rc = RmStartSession(out h, 0, Guid.NewGuid().ToString());
|
|
45
|
+
if (rc != 0) throw new Exception("RmStartSession failed with " + rc);
|
|
46
|
+
try {
|
|
47
|
+
rc = RmRegisterResources(h, (uint)files.Length, files, 0, null, 0, null);
|
|
48
|
+
if (rc != 0) throw new Exception("RmRegisterResources failed with " + rc);
|
|
49
|
+
uint needed = 0, count = 0, reasons = 0;
|
|
50
|
+
rc = RmGetList(h, out needed, ref count, null, ref reasons);
|
|
51
|
+
if (rc == 0) return new int[0];
|
|
52
|
+
if (rc != 234) throw new Exception("RmGetList failed with " + rc);
|
|
53
|
+
RM_PROCESS_INFO[] info = new RM_PROCESS_INFO[needed];
|
|
54
|
+
count = needed;
|
|
55
|
+
rc = RmGetList(h, out needed, ref count, info, ref reasons);
|
|
56
|
+
if (rc != 0) throw new Exception("RmGetList failed with " + rc);
|
|
57
|
+
int[] pids = new int[count];
|
|
58
|
+
for (int i = 0; i < count; i++) pids[i] = info[i].Process.dwProcessId;
|
|
59
|
+
return pids;
|
|
60
|
+
} finally { RmEndSession(h); }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
'@
|
|
64
|
+
function Describe($p) {
|
|
65
|
+
[pscustomobject]@{ pid = [int]$p.ProcessId; name = $p.Name; path = $p.ExecutablePath; commandLine = $p.CommandLine }
|
|
66
|
+
}
|
|
67
|
+
$holderIds = [GaiaRestartManager]::Holders($files)
|
|
68
|
+
$byId = @{}
|
|
69
|
+
if ($holderIds.Count -gt 0) {
|
|
70
|
+
foreach ($proc in Get-CimInstance Win32_Process) { $byId[[int]$proc.ProcessId] = $proc }
|
|
71
|
+
}
|
|
72
|
+
$out = @()
|
|
73
|
+
foreach ($holderId in $holderIds) {
|
|
74
|
+
$p = $byId[[int]$holderId]
|
|
75
|
+
if (-not $p) { continue }
|
|
76
|
+
$ancestors = @()
|
|
77
|
+
$child = $p
|
|
78
|
+
while ($ancestors.Count -lt 16) {
|
|
79
|
+
$a = $byId[[int]$child.ParentProcessId]
|
|
80
|
+
# A parent that started after its child is an unrelated process that reused the pid.
|
|
81
|
+
if (-not $a -or $a.ProcessId -eq $child.ProcessId -or $a.CreationDate -gt $child.CreationDate) { break }
|
|
82
|
+
$ancestors += Describe $a
|
|
83
|
+
$child = $a
|
|
84
|
+
}
|
|
85
|
+
$entry = Describe $p
|
|
86
|
+
$entry | Add-Member -NotePropertyName ancestors -NotePropertyValue $ancestors
|
|
87
|
+
$out += $entry
|
|
88
|
+
}
|
|
89
|
+
ConvertTo-Json -InputObject @($out) -Depth 4 -Compress
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
function encodedCommand(script) {
|
|
93
|
+
return Buffer.from(script, "utf16le").toString("base64");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The processes holding any of `files` open, each with its ancestors (parent
|
|
98
|
+
* first): [{ pid, name, path, commandLine, ancestors: [...] }]. Rejects with
|
|
99
|
+
* the script's stderr when Restart Manager or PowerShell fails.
|
|
100
|
+
*/
|
|
101
|
+
function queryLockHolders(files, { execFile = childProcess.execFile, timeoutMs = QUERY_TIMEOUT_MS } = {}) {
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
execFile(
|
|
104
|
+
"powershell.exe",
|
|
105
|
+
["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", encodedCommand(RM_SCRIPT)],
|
|
106
|
+
{
|
|
107
|
+
env: { ...process.env, GAIA_LOCKED_FILES: JSON.stringify(files) },
|
|
108
|
+
timeout: timeoutMs,
|
|
109
|
+
windowsHide: true,
|
|
110
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
111
|
+
},
|
|
112
|
+
(err, stdout, stderr) => {
|
|
113
|
+
if (err) {
|
|
114
|
+
reject(new Error(`Restart Manager lookup for ${files.join(", ")} failed: ${String(stderr || err.message).trim()}`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
resolve(JSON.parse(String(stdout).trim() || "[]"));
|
|
119
|
+
} catch (parseErr) {
|
|
120
|
+
reject(new Error(`Restart Manager lookup printed something other than JSON: ${String(stdout).slice(0, 200)}`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function winPath(p) {
|
|
128
|
+
return String(p || "").replace(/\//g, "\\");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** A GAIA install's own executable: under a .gaia venv, agents or bin folder, or GAIA's desktop or agent binary. */
|
|
132
|
+
function isGaiaExecutable(exePath) {
|
|
133
|
+
const p = winPath(exePath).toLowerCase();
|
|
134
|
+
if (!p) return false;
|
|
135
|
+
if (/\\\.gaia\\(?:venv\\scripts|agents|bin)\\/.test(p)) return true;
|
|
136
|
+
const base = p.split("\\").pop();
|
|
137
|
+
return base === "gaia-desktop.exe" || base === "gaia-agent.exe";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Where a holder came from, for people: the folder holding its `.gaia`, else its own folder. */
|
|
141
|
+
function startedFrom(exePath) {
|
|
142
|
+
const p = winPath(exePath);
|
|
143
|
+
if (!p) return null;
|
|
144
|
+
const at = p.toLowerCase().indexOf("\\.gaia\\");
|
|
145
|
+
if (at > 0) return p.slice(0, at);
|
|
146
|
+
const slash = p.lastIndexOf("\\");
|
|
147
|
+
return slash > 0 ? p.slice(0, slash) : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* One entry per program to name: a GAIA holder reports the topmost GAIA
|
|
152
|
+
* process above it (so gaia.exe stands for its python child), anything else
|
|
153
|
+
* reports itself. Holders inside this app's own process tree are never GAIA
|
|
154
|
+
* to close. Returns [{ pid, name, path, folder, isGaia }].
|
|
155
|
+
*/
|
|
156
|
+
function summarizeHolders(raw, ownPid) {
|
|
157
|
+
const byPid = new Map();
|
|
158
|
+
for (const holder of raw || []) {
|
|
159
|
+
const chain = [holder, ...(holder.ancestors || [])];
|
|
160
|
+
const ownAt = chain.findIndex((p) => p.pid === ownPid);
|
|
161
|
+
const outside = ownAt === -1 ? chain : chain.slice(0, ownAt);
|
|
162
|
+
let root = null;
|
|
163
|
+
for (const p of outside) if (isGaiaExecutable(p.path || p.name)) root = p;
|
|
164
|
+
const shown = root || holder;
|
|
165
|
+
if (byPid.has(shown.pid)) continue;
|
|
166
|
+
byPid.set(shown.pid, {
|
|
167
|
+
pid: shown.pid,
|
|
168
|
+
name: shown.name || null,
|
|
169
|
+
path: shown.path || null,
|
|
170
|
+
folder: startedFrom(shown.path),
|
|
171
|
+
isGaia: Boolean(root),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return [...byPid.values()];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** End each pid and its children; a pid that has already exited is not an error. */
|
|
178
|
+
async function endProcessTrees(pids, { execFile = childProcess.execFile } = {}) {
|
|
179
|
+
for (const pid of pids) {
|
|
180
|
+
await new Promise((resolve, reject) => {
|
|
181
|
+
execFile(
|
|
182
|
+
"taskkill",
|
|
183
|
+
["/PID", String(pid), "/T", "/F"],
|
|
184
|
+
{ timeout: KILL_TIMEOUT_MS, windowsHide: true },
|
|
185
|
+
(err, stdout, stderr) => {
|
|
186
|
+
if (!err || err.code === TASKKILL_NOT_FOUND) resolve();
|
|
187
|
+
else reject(new Error(`Could not end process ${pid}: ${String(stderr || err.message).trim()}`));
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = {
|
|
195
|
+
queryLockHolders,
|
|
196
|
+
summarizeHolders,
|
|
197
|
+
endProcessTrees,
|
|
198
|
+
isGaiaExecutable,
|
|
199
|
+
startedFrom,
|
|
200
|
+
};
|
package/services/quit-guard.cjs
CHANGED
|
@@ -235,9 +235,26 @@ function attachWindowGuards(win, { app, guard, getTray, isQuitting, platform, re
|
|
|
235
235
|
win.on("session-end", () => guard.allow());
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* SIGTERM (logout, shutdown, `kill`) quits without the question: nobody is
|
|
240
|
+
* there to answer it, so the dialog would hold the app until it is SIGKILLed.
|
|
241
|
+
* Electron's own SIGTERM handling quits through the guard, which asks.
|
|
242
|
+
*
|
|
243
|
+
* @param {{proc: NodeJS.Process, app: Electron.App,
|
|
244
|
+
* guard: ReturnType<typeof installQuitGuard>, logger?: {log: Function}}} deps
|
|
245
|
+
*/
|
|
246
|
+
function quitOnTermSignal({ proc, app, guard, logger = console }) {
|
|
247
|
+
proc.on("SIGTERM", () => {
|
|
248
|
+
logger.log("[main] SIGTERM: quitting without asking about running work");
|
|
249
|
+
guard.allow();
|
|
250
|
+
app.quit();
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
238
254
|
module.exports = {
|
|
239
255
|
QUIT_ANYWAY_MS,
|
|
240
256
|
attachWindowGuards,
|
|
257
|
+
quitOnTermSignal,
|
|
241
258
|
backendJson,
|
|
242
259
|
fetchWorkInProgress,
|
|
243
260
|
describeWork,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{G as t,N as n,i as r,n as i,o as a,r as o}from"./apiBase-BMkGbdXt.js";import{At as s,Bt as c,I as l,R as u,V as d,Y as f,jt as p,q as m,ut as h}from"./api-BzlFpP4T.js";import{$ as g,Ft as _,Lt as v,Vt as y,X as b,a as x,c as S,d as C,et as w,l as T,o as E,r as D,s as O,u as k,vt as A}from"./index-hAcJijAU.js";var j=e(t(),1);function M(){let e=g(),[t,n]=(0,j.useState)(null),[a,c]=(0,j.useState)(null),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(!1),[_,y]=(0,j.useState)(null),[b,x]=(0,j.useState)(!1);(0,j.useEffect)(()=>{l().then(e=>{n(e),d(e.saved_base_url??e.base_url??``)}).catch(e=>c(e instanceof Error?e.message:String(e)))},[]);let S=(0,j.useCallback)(async e=>{h(!0),y(null);try{let t=await s(e);n(t),p(``),x(!1)}catch(e){x(k(e)),y(e instanceof Error?e.message:String(e))}finally{h(!1)}},[]),C=()=>void S({mode:`external`,base_url:u.trim(),api_key:f.trim()||void 0});if(a)return r(`section`,{className:`settings-section`,children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),r(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),r(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:e(`settings.server.readFailed`)}),o(`p`,{children:a})]})]})]});if(!t)return null;let w=t.mode===`external`;return r(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(`p`,{className:`model-override-desc`,role:`status`,children:t.source===`env`?e(`settings.server.usesEnv`,{url:t.base_url??``}):w?e(`settings.server.usesYours`,{url:t.base_url??``}):e(`settings.server.usesOwn`)}),t.source===`env`?o(`p`,{className:`model-status-hint`,children:e(`settings.server.unsetEnv`)}):r(i.Fragment,{children:[r(`p`,{className:`model-status-hint`,children:[e(`settings.server.useYours`),` `,o(`bdi`,{children:t.what_gaia_does})]}),r(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),C()},children:[o(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:u,onChange:e=>{d(e.target.value),y(null)},disabled:m,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.server.address`)}),o(`input`,{type:`password`,className:`model-input`,autoComplete:`off`,placeholder:t.api_key_stored?e.bare(`settings.server.keySaved`):e.bare(`settings.server.keyOptional`),value:f,onChange:e=>p(e.target.value),disabled:m,"aria-label":e(`settings.server.key`)}),o(`div`,{className:`model-btn-group`,children:o(`button`,{type:`submit`,className:`btn-model-save`,disabled:m||!u.trim(),children:m?r(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.server.checking`)]}):e(`settings.server.use`)})})]}),w&&o(`div`,{className:`setting-actions`,children:o(`button`,{type:`button`,className:`btn-secondary`,disabled:m,onClick:()=>void S({mode:`gaia`}),children:e(`settings.server.useOwn`)})}),_&&r(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),r(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:e(b?`settings.server.needsKey`:`settings.server.notSwitched`)}),o(`p`,{children:_})]})]})]})]})}var N={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},P={gaia:`settings.server.ownerGaia`,user:`settings.server.ownerUser`,remote:`settings.server.ownerRemote`};function F(e){return e?N[e]??e:`unknown`}function I(e){if(!e)return`unknown`;let t=F(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function L(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}var R={asr:`settings.server.kind.speechRecognition`,embedding:`settings.server.kind.embedding`,image:`settings.server.kind.image`,llm:`settings.server.kind.language`,rerank:`settings.server.kind.reranker`,reranking:`settings.server.kind.reranker`,stt:`settings.server.kind.speechRecognition`,transcription:`settings.server.kind.speechRecognition`,tts:`settings.server.kind.speech`,vision:`settings.server.kind.vision`,"3d":`settings.server.kind.threeD`};function z(e,t){if(!e.model_type)return t(`settings.server.loadedModel`);let n=e.model_type.toLowerCase(),r=R[n];return r?t(r):t(`settings.server.kindOther`,{kind:`${n.charAt(0).toUpperCase()}${n.slice(1)}`})}function B(e,t){let n=[e.name?w(e.name):t.bare(`settings.server.unknownModel`),I(e)];return e.backend!==`remote`&&e.ctx_size&&n.push(L(e.ctx_size)),n.join(` · `)}function V({label:e,value:t,title:n}){return r(`div`,{className:`status-row`,children:[o(`span`,{className:`status-label`,children:e}),o(`span`,{className:`status-value model-server-value`,dir:`auto`,title:n??t,children:t})]})}function ee(){let e=g(),t=a(e=>e.openSettings),[n,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[u,f]=(0,j.useState)(null),[m,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(!1);(0,j.useEffect)(()=>{d().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);let b=(0,j.useCallback)(async t=>{f(t),_(null);try{let n=await p(t);s(n),_({ok:!0,text:e(`settings.server.savedBackend`)})}catch(e){_({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{f(null)}},[e]),S=n?.chat_model??null,C=(0,j.useCallback)(async()=>{if(S?.name){y(!0);try{if(!await h(S.name,S.ctx_size??void 0))return;_({ok:!0,text:e(`settings.server.reloading`,{name:S.name})})}catch(e){_({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},[S,e]),T=o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`settings.server.changeModel`)});if(c)return r(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(x,{message:c})]});if(!n)return r(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(`p`,{className:`loading-text`,children:e(`settings.server.checkingServer`)})]});if(!n.reachable)return r(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),o(x,{message:n.error??e(`settings.errors.serverDownTitle`)}),T]});let E=n.available_backends??[],D=n.preferred_backend??null,O=E.map(e=>e.name);D&&!O.includes(D)&&O.push(D);let k=D??n.default_backend??null,M=E.filter(e=>e.state===`installable`).map(e=>F(e.name)),N=!!S?.name&&S.recipe===`llamacpp`;return r(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[o(`h4`,{children:e(`settings.advanced.modelServer`)}),r(`div`,{className:`status-grid`,children:[o(V,{label:e(`settings.server.server`),value:`${P[n.owner]?e(P[n.owner]):n.owner}${n.version?` v${n.version}`:``}`}),o(V,{label:e(`settings.server.addressShort`),value:n.base_url}),o(V,{label:e(`settings.server.chatModel`),value:S?.name?w(S.name):e(`settings.advanced.noneLoaded`),title:S?.name??void 0}),S&&o(V,{label:e(`settings.server.runsOn`),value:I(S)}),S&&S.backend!==`remote`&&o(V,{label:e(`settings.advanced.context`),value:L(S.ctx_size)}),o(V,{label:e(`settings.advanced.embedding`),value:n.embedding_model?.name?`${n.embedding_model.name} · ${I(n.embedding_model)}`:e(`settings.advanced.noneLoaded`)}),(n.loaded_models??[]).map((t,n)=>o(V,{label:z(t,e),value:B(t,e),title:t.name??void 0},`${t.name??`unknown`}-${n}`))]}),n.embedding_note&&o(`p`,{className:`settings-hint`,children:o(`bdi`,{children:n.embedding_note})}),n.system_info_error&&o(`p`,{className:`settings-hint`,children:o(`bdi`,{children:n.system_info_error})}),r(`div`,{className:`settings-field model-server-backend`,children:[o(`span`,{className:`settings-label`,children:e(`settings.server.backend`)}),E.length===0&&!D?o(`span`,{className:`settings-hint`,children:e(`settings.server.noBackends`)}):r(i.Fragment,{children:[o(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":e(`settings.server.backendShort`),children:O.map(e=>r(`button`,{type:`button`,role:`radio`,"aria-checked":k===e,className:k===e?`is-active`:``,disabled:u!==null,onClick:()=>{e!==k&&b(e)},children:[u===e?o(A,{size:12,className:`spin`}):null,F(e)]},e))}),r(`span`,{className:`settings-hint`,children:[e(`settings.server.backendHint`),M.length>0&&` ${e(`settings.server.installable`,{names:M.join(`, `)})}`]})]}),m?.ok&&o(`p`,{className:`settings-ok`,role:`status`,children:m.text}),m&&!m.ok&&o(x,{message:m.text})]}),r(`div`,{className:`settings-row`,children:[T,N&&r(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void C(),disabled:v,children:[v?o(A,{size:13,className:`spin`}):null,e(`settings.server.reload`)]})]})]})}function H(){let e=g(),[t,a]=(0,j.useState)(null),[s,l]=(0,j.useState)(!0),[d,p]=(0,j.useState)([]),[h,x]=(0,j.useState)(``),[w,k]=(0,j.useState)(``),[N,P]=(0,j.useState)(!1),[F,I]=(0,j.useState)(!1),[L,R]=(0,j.useState)(null),[z,B]=(0,j.useState)(!1),V=(0,j.useRef)(null),[H,W]=(0,j.useState)(!1),[G,ne]=(0,j.useState)(!1),[K,re]=(0,j.useState)(!1),[q,J]=(0,j.useState)(null);(0,j.useEffect)(()=>{n.system.info(`Checking system status...`);let e=n.system.time();f().then(t=>{a(t),n.system.timed(`System status received`,e,{lemonade:t.lemonade_running?`running`:`stopped`,model:t.model_loaded||`none`,embedding:t.embedding_model_loaded?`yes`:`no`,disk:`${t.disk_space_gb}GB free`,memory:t.memory_available_gb==null?`unknown`:`${t.memory_available_gb}GB available`}),t.lemonade_running||n.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{n.system.error(`Failed to get system status`,e),a(null)}).finally(()=>l(!1)),u().then(e=>p(e.servers)).catch(()=>{}),m().then(e=>{let t=e.custom_model??``;x(t),k(t),W(e.dynamic_tools),ne(e.dynamic_tools_locked)}).catch(e=>{n.system.error(`Failed to load settings`,e)}).finally(()=>P(!0))},[]),(0,j.useEffect)(()=>()=>{V.current&&clearTimeout(V.current)},[]);let Y=(0,j.useCallback)(async()=>{let e=h.trim(),t=e.length>0?e:``;I(!0),R(null),B(!1);try{n.system.info(`Saving custom_model override`,{custom_model:t});let e=(await c({custom_model:t})).custom_model??``;x(e),k(e),B(!0),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>B(!1),2200)}catch(e){let t=e instanceof Error?e.message:String(e);n.system.error(`Failed to save custom_model`,e),R(t)}finally{I(!1)}},[h]),ie=(0,j.useCallback)(async()=>{if(G||K)return;let e=H,t=!e;W(t),re(!0),J(null);try{n.system.info(`Saving dynamic_tools setting`,{dynamic_tools:t});let e=await c({dynamic_tools:t});W(e.dynamic_tools),ne(e.dynamic_tools_locked)}catch(t){let r=t instanceof Error?t.message:String(t);n.system.error(`Failed to save dynamic_tools`,t),W(e),J(r)}finally{re(!1)}},[H,G,K]),ae=h.trim()!==w.trim(),X=t?t.default_model_name:b,{isLoadingModel:oe,isDownloadingModel:Z,loadModel:se,downloadModel:ce}=D(X??void 0),Q=!!t?.default_model_is_cloud,$=!Q&&!!(t?.lemonade_running&&t.model_loaded&&t.expected_model_loaded===!1),le=!Q&&!!(t?.lemonade_running&&t.model_loaded&&t.context_size_sufficient===!1),ue=!Q&&!(!t?.lemonade_running||t.model_loaded||t.model_downloaded!==!1),de=($||le)&&X!==null,fe=d.some(e=>!e.connected);return r(`div`,{className:`settings-pane`,children:[o(`h2`,{className:`settings-pane-title`,children:e(`settings.section.advanced`)}),o(`section`,{className:`settings-card`,"aria-label":e(`settings.advanced.status`),children:s?o(`p`,{className:`loading-text`,children:e(`settings.advanced.checking`)}):t?r(i.Fragment,{children:[r(`div`,{className:`status-grid`,children:[o(U,{label:e(`settings.advanced.modelServer`),value:t.lemonade_running?t.lemonade_version?e(`settings.advanced.runningAt`,{version:t.lemonade_version}):e(`settings.advanced.running`):S(t)?e(`settings.advanced.notInstalled`):t.lemonade_error?e(`settings.advanced.unavailable`):e(`settings.advanced.notRunning`),ok:t.lemonade_running,hint:t.lemonade_running?void 0:S(t)?e(`settings.advanced.notInstalledHint`):t.lemonade_error?e(`settings.advanced.queryFailed`,{reason:t.lemonade_error}):t.start_instruction&&!O(t.start_instruction)?t.start_instruction:e(`settings.advanced.notRunningHint`)}),S(t)&&o(E,{className:`btn-primary`}),o(U,{label:e(`settings.section.model`),value:t.model_loaded||e(`settings.advanced.noneLoaded`),ok:!!t.model_loaded&&(Q||t.expected_model_loaded!==!1),hint:t.model_loaded?!Q&&t.expected_model_loaded===!1?e(`settings.advanced.expected`,{name:X??``}):void 0:e(`settings.advanced.loadsFirst`)}),o(U,{label:e(`settings.advanced.disk`),value:r(`bdi`,{dir:`ltr`,children:[t.disk_space_gb,` GB`]}),ok:t.disk_space_gb>5,hint:!t.model_loaded&&t.disk_space_gb<30?e(`settings.advanced.diskLow`,{need:`6 GB`,size:`${t.disk_space_gb} GB`}):void 0})]}),ue&&r(`div`,{className:`model-action-row model-action-row--download`,children:[r(`div`,{className:`model-action-info`,children:[o(`span`,{className:`model-action-label`,children:e(`settings.advanced.notDownloaded`)}),o(`span`,{className:`model-action-desc`,children:e(`settings.advanced.notDownloadedHint`,{name:X??``,need:`6 GB`})})]}),o(`button`,{className:`btn-model-action btn-model-action--download`,onClick:()=>ce(!1),disabled:Z,children:Z?r(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.model.download`)})]}),de&&r(`div`,{className:`model-action-row model-action-row--load`,children:[r(`div`,{className:`model-action-info`,children:[o(`span`,{className:`model-action-label`,children:e($?`settings.advanced.wrongModel`:`settings.advanced.smallContext`)}),o(`span`,{className:`model-action-desc`,children:e(`settings.advanced.loadHint`,{name:X??``,size:`${32 .toFixed(0)}K`})})]}),o(`button`,{className:`btn-model-action btn-model-action--load`,onClick:()=>se(),disabled:oe,children:oe?r(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.loading`)]}):e(`settings.advanced.load`)})]}),r(`details`,{className:`settings-more`,children:[r(`summary`,{children:[o(y,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.advanced.details`)]}),r(`div`,{className:`status-grid`,children:[t.model_size_gb!=null&&o(U,{label:e(`settings.advanced.modelSize`),value:r(`bdi`,{dir:`ltr`,children:[t.model_size_gb,` GB`]}),ok:!0}),t.model_device&&!Q&&o(U,{label:e(`settings.advanced.device`),value:t.model_device.toUpperCase(),ok:t.model_device!==`cpu`}),t.model_context_size!=null&&o(U,{label:e(`settings.advanced.context`),value:e(`settings.ctx.tokens`,{size:`${(t.model_context_size/1024).toFixed(0)}K`}),ok:t.context_size_sufficient}),t.model_labels&&t.model_labels.length>0&&o(U,{label:e(`settings.advanced.capabilities`),value:t.model_labels.join(`, `),ok:!0}),o(U,{label:e(`settings.advanced.embedding`),value:t.embedding_model_loaded?e(`settings.advanced.available`):e(`settings.advanced.notLoaded`),ok:t.embedding_model_loaded}),t.gpu_name&&o(U,{label:`GPU`,value:o(`bdi`,{children:`${t.gpu_name}${t.gpu_vram_gb?` (${C(t.gpu_vram_gb)})`:``}`}),ok:!0}),o(U,{label:e(`settings.advanced.memory`),value:t.memory_available_gb==null?e(`settings.advanced.unknown`):r(`bdi`,{dir:`ltr`,children:[t.memory_available_gb,` GB`]}),ok:t.memory_available_gb!=null&&t.memory_available_gb>2}),t.processor_name&&o(U,{label:e(`settings.advanced.processor`),value:o(`bdi`,{children:t.processor_name}),ok:!0})]}),t.lemonade_running&&X!==null&&!Q&&r(`div`,{className:`force-redownload-row`,children:[o(`span`,{className:`force-redownload-label`,children:e(`settings.advanced.corrupted`)}),o(`button`,{className:`btn-force-redownload`,onClick:()=>ce(!0),disabled:Z,children:Z?r(i.Fragment,{children:[o(A,{size:12,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.advanced.redownload`)})]})]})]}):o(`div`,{className:`status-error`,children:o(`p`,{children:e(`settings.advanced.unreachable`)})})}),r(T,{title:e(`settings.advanced.serverTitle`),hint:e(`settings.advanced.serverHint`),children:[o(ee,{}),o(M,{})]}),r(T,{title:e(`settings.advanced.customTitle`),hint:w||e(`settings.advanced.customHint`),children:[o(`p`,{className:`model-override-desc`,children:e(`settings.advanced.customDesc`)}),r(`div`,{className:`model-input-row`,children:[o(`input`,{type:`text`,className:`model-input${w?` has-override`:``}`,placeholder:e.bare(`settings.advanced.customPlaceholder`),value:h,onChange:e=>{x(e.target.value),R(null),B(!1)},onKeyDown:e=>{e.key===`Enter`&&!F&&ae&&N&&(e.preventDefault(),Y())},disabled:!N||F,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.advanced.customAria`)}),o(`div`,{className:`model-btn-group`,children:o(`button`,{className:`btn-model-save${z?` saved`:``}`,onClick:()=>{Y()},disabled:!N||F||!ae&&!z,"aria-label":e(`settings.advanced.customSave`),children:F?r(i.Fragment,{children:[o(A,{size:13,className:`btn-spinner`}),` `,e(`settings.models.applying`)]}):z?r(i.Fragment,{children:[o(_,{size:13}),` `,e(`settings.advanced.saved`)]}):e(`settings.advanced.save`)})})]}),o(`p`,{className:`model-status-hint`,children:e(`settings.advanced.customIds`)}),L&&o(te,{message:L})]}),r(T,{title:e(`settings.advanced.dynamicTitle`),children:[o(`p`,{className:`model-override-desc`,children:e(`settings.advanced.dynamicDesc`)}),r(`label`,{className:`setting-row`,children:[o(`span`,{children:e(`settings.advanced.dynamicEnable`)}),r(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:H,onChange:()=>void ie(),disabled:!N||K||G,"aria-label":e(H?`settings.advanced.dynamicOff`:`settings.advanced.dynamicOn`)}),o(`span`,{className:`toggle-track`})]})]}),G&&o(`p`,{className:`model-status-hint`,children:e(`settings.advanced.dynamicLocked`)}),q&&o(te,{message:q})]}),d.length>0&&o(T,{title:e(`settings.advanced.mcp`),count:d.length,defaultOpen:fe,children:o(`div`,{className:`status-grid`,children:d.map(t=>r(`div`,{className:`status-row`,children:[o(`bdi`,{className:`status-label`,children:t.name}),o(`div`,{className:`status-value-wrap`,children:t.connected?r(`span`,{className:`status-value ok mcp-status-connected`,children:[o(_,{size:12}),e.plural(`settings.advanced.tools`,t.tool_count)]}):r(`span`,{className:`status-value warn mcp-status-failed`,title:t.error??void 0,children:[o(v,{size:12}),e(`settings.custom.failed`)]})})]},t.name))})}),r(`div`,{className:`about-info`,children:[r(`p`,{children:[r(`bdi`,{dir:`ltr`,children:[`GAIA v`,`0.25.4rc4`]}),` `,o(`span`,{className:`beta-badge`,children:`BETA`})]}),o(`p`,{className:`about-sub`,children:e(`settings.advanced.about`)})]})]})}function te({message:e}){let t=g();return r(`div`,{className:`model-warning`,role:`alert`,children:[o(v,{size:14}),r(`div`,{className:`model-warning-content`,children:[o(`strong`,{children:t(`settings.advanced.saveFailed`)}),o(`p`,{children:e})]})]})}function U({label:e,value:t,ok:n,hint:i}){return r(`div`,{className:`status-row${i?` status-row--has-hint`:``}`,children:[o(`span`,{className:`status-label`,children:e}),r(`div`,{className:`status-value-wrap`,children:[o(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),i&&o(`span`,{className:`status-hint`,children:i})]})]})}export{H as AdvancedSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{G as t,N as n,i as r,n as i,o as a,r as o,t as s}from"./apiBase-BMkGbdXt.js";import{_n as c,bn as l,cn as u,dn as d,fn as f,gn as p,hn as m,ln as h,mn as g,on as _,pn as v,sn as y,un as b,vn as x,yn as S}from"./api-BzlFpP4T.js";import{$ as C,Dt as w,Ft as T,Lt as E,Ot as D,Rt as O,Vt as k,l as A,nt as j,vt as M}from"./index-hAcJijAU.js";var N=e(t(),1),P=n.api;function F(e){switch(e){case`connector.configured`:return`configured`;case`connector.disconnected`:return`disconnected`;case`connection.revoked`:return`disconnected`;case`connector.oauth.completed`:return`oauth_completed`;case`connection.connected`:return`oauth_completed`;case`connector.oauth.error`:return`oauth_error`;case`connector.tested`:return`tested`;case`connector.enabled`:return`enabled`;case`connector.disabled`:return`disabled`;case`connector.grant.changed`:return`grant_changed`;case`connector.activation.changed`:return`activation_changed`;default:return null}}function I(e){let t=(0,N.useRef)(e);(0,N.useEffect)(()=>{t.current=e},[e]),(0,N.useEffect)(()=>{let e=`${s()}/connectors/events`,n=null,r=1e3,i=null,a=!1,o=()=>{a||(n=new EventSource(e),n.onopen=()=>{r=1e3},n.onmessage=e=>{try{let n=JSON.parse(e.data),r=F(n.type);if(r===null){P.debug(`connectors-sse: ignoring event`,n.type);return}let i=n.payload??{},a=i.connector_id??i.provider??null;t.current({connectorId:a,reason:r,payload:i})}catch(e){P.warn(`connectors-sse: malformed event`,e)}},n.onerror=()=>{n?.close(),n=null,!a&&(i=setTimeout(o,r),r=Math.min(r*2,3e4))})};return o(),()=>{a=!0,i&&clearTimeout(i),n?.close()}},[])}function L(e){return e.type===`mcp_server`&&e.configured}function R({connector:e,onChanged:t}){let n=C(),[i,a]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),h=(0,N.useRef)(null),g=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;h.current&&!h.current.contains(t)&&g.current&&!g.current.contains(t)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let _=(0,N.useCallback)(()=>a(!1),[]);if(j(i,_),(0,N.useEffect)(()=>{if(!i)return;let e=()=>{if(!h.current)return;let e=h.current.getBoundingClientRect();m({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)}},[i]),!L(e))return null;let y=e=>{e.stopPropagation(),e.preventDefault()},b=e=>{if(y(e),!i&&h.current){let e=h.current.getBoundingClientRect();m({top:e.bottom+4,right:window.innerWidth-e.right})}a(e=>!e)},x=async e=>{c(!0),u(null);try{await e(),a(!1),t()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return r(`div`,{className:`connector-tile-menu`,onClick:y,onKeyDown:y,children:[o(`button`,{ref:h,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-label":n(`settings.connectors.actions`),onClick:b,disabled:s,children:o(D,{size:14})}),i&&p&&r(`div`,{ref:g,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:p.top,right:p.right},children:[e.enabled?o(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void x(()=>d(e.id)),disabled:s,children:n(`settings.connectors.disable`)}):o(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void x(()=>v(e.id)),disabled:s,children:n(`settings.connectors.enable`)}),o(`div`,{className:`connector-tile-menu-divider`}),o(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void x(()=>f(e.id)),disabled:s,children:n(`settings.connectors.disconnect`)}),l&&o(`div`,{className:`connector-tile-menu-error`,children:l})]})]})}var z={"https://www.googleapis.com/auth/gmail.readonly":`settings.connectors.scope.gmailRead`,"https://www.googleapis.com/auth/gmail.modify":`settings.connectors.scope.gmailModify`,"https://www.googleapis.com/auth/gmail.send":`settings.connectors.scope.gmailSend`,"https://www.googleapis.com/auth/gmail.compose":`settings.connectors.scope.gmailCompose`,"https://www.googleapis.com/auth/calendar.readonly":`settings.connectors.scope.calendarRead`,"https://www.googleapis.com/auth/calendar.events":`settings.connectors.scope.calendarEvents`,"https://www.googleapis.com/auth/drive.readonly":`settings.connectors.scope.driveRead`,"https://www.googleapis.com/auth/drive.file":`settings.connectors.scope.driveFile`,"https://www.googleapis.com/auth/spreadsheets.readonly":`settings.connectors.scope.sheetsRead`,"https://www.googleapis.com/auth/spreadsheets":`settings.connectors.scope.sheets`,openid:`settings.connectors.scope.openid`,"https://www.googleapis.com/auth/userinfo.email":`settings.connectors.scope.email`,email:`settings.connectors.scope.email`,profile:`settings.connectors.scope.profile`,"https://graph.microsoft.com/Mail.ReadWrite":`settings.connectors.scope.outlookMail`,"https://graph.microsoft.com/Mail.Send":`settings.connectors.scope.outlookSend`,"https://graph.microsoft.com/Calendars.ReadWrite":`settings.connectors.scope.outlookCalendar`,"https://graph.microsoft.com/Calendars.Read":`settings.connectors.scope.outlookCalendarRead`,"https://graph.microsoft.com/User.Read":`settings.connectors.scope.microsoftProfile`};function B(e,t){let n=z[e];return n?t(n):e.split(/[/.:]/).pop()??e}var V=6,H=[`use`];function U(e,t){return!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_supported&&!e.revoked_remotely?t(`settings.connectors.notRevoked`,{reason:String(e.revoke_error??t.bare(`settings.advanced.unknown`))}):e.revoke_error?t(`settings.connectors.localOnly`,{reason:String(e.revoke_error)}):t(`settings.connectors.noRevokeApi`)}function W(){let e=C(),[t,n]=(0,N.useState)([]),[a,s]=(0,N.useState)([]),[c,l]=(0,N.useState)(!0),[u,d]=(0,N.useState)(null),[f,m]=(0,N.useState)(null),[h,_]=(0,N.useState)(null),[v,y]=(0,N.useState)(``),b=(0,N.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:t}]=await Promise.all([S(),p()]);n(e),s(t),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},[]);(0,N.useEffect)(()=>{b()},[b]);let x=e=>_(t=>t===e?null:e),w=(0,N.useCallback)(async e=>{try{let t=await g(e);n(n=>n.map(n=>n.id===e?t:n))}catch{b()}},[b]);I((0,N.useCallback)(t=>{t.reason===`disconnected`&&m(U(t.payload,e)),t.connectorId?w(t.connectorId):b()},[w,b,e]));let T=v.trim().toLowerCase(),D=t.filter(e=>!T||e.display_name.toLowerCase().includes(T)||e.description.toLowerCase().includes(T)),O=D.filter(e=>e.configured),k=D.filter(e=>!e.configured&&e.type===`oauth_pkce`),j=D.filter(e=>!e.configured&&e.type!==`oauth_pkce`),P=!t.some(e=>e.configured),F=e=>o(`div`,{className:`connectors-list`,children:e.map(e=>o(G,{connector:e,expanded:h===e.id,onToggle:()=>x(e.id),onChanged:()=>void w(e.id)},e.id))});return r(`section`,{className:`connectors-section`,"aria-label":e(`settings.section.connectors`),children:[o(`p`,{className:`settings-pane-lede`,children:e(`settings.connectors.lede`)}),u&&r(`div`,{className:`error-banner`,children:[o(E,{size:14}),o(`span`,{children:u})]}),f&&r(`div`,{className:`error-banner`,role:`status`,onClick:()=>m(null),children:[o(E,{size:14}),o(`span`,{children:f})]}),c?o(`div`,{className:`connectors-loading`,children:o(M,{size:16,className:`spin`})}):r(i.Fragment,{children:[t.length>V&&o(`input`,{className:`settings-input`,type:`search`,value:v,onChange:e=>y(e.target.value),placeholder:e(`settings.connectors.search`),"aria-label":e(`settings.connectors.search`)}),t.length===0&&!u&&o(`p`,{className:`settings-hint`,children:e(`settings.connectors.none`)}),T&&D.length===0&&o(`p`,{className:`settings-hint`,children:e(`settings.connectors.noMatch`)}),O.length>0&&o(A,{title:e(`settings.connectors.connected`),count:O.length,defaultOpen:!0,forceOpen:!!T,children:F(O)}),k.length>0&&o(A,{title:e(`settings.connectors.accounts`),hint:e(`settings.connectors.accountsHint`),count:k.length,defaultOpen:P,forceOpen:!!T,children:F(k)}),j.length>0&&o(A,{title:e(`settings.connectors.servers`),hint:e(`settings.connectors.serversHint`),count:j.length,forceOpen:!!T,children:F(j)}),a.length>0&&!T&&o(A,{title:e(`settings.connectors.agentServers`),count:a.length,children:o(X,{servers:a,expanded:h,onToggle:x})})]})]})}function G({connector:e,expanded:t,onToggle:n,onChanged:i}){let a=C();return r(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[r(`div`,{className:`connector-tile-row`,children:[r(`button`,{type:`button`,className:`connector-tile-header`,onClick:n,"aria-expanded":t,children:[o(`bdi`,{className:`connector-tile-name`,children:e.display_name}),e.configured&&o(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),e.configured?e.type===`mcp_server`&&e.enabled===!1?o(`span`,{className:`connector-status disabled`,children:a(`settings.connectors.disabled`)}):r(`span`,{className:`connector-status ok`,children:[o(T,{size:12}),e.account_id?o(`bdi`,{dir:`ltr`,children:e.account_id}):a(`settings.connectors.configured`)]}):e.configurable===!1?o(`span`,{className:`connector-status idle`,children:a(`settings.connectors.setupRequired`)}):null,o(`span`,{className:`connector-tile-chevron`,children:o(t?O:k,{size:14})})]}),o(R,{connector:e,onChanged:i})]}),t&&r(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?o(K,{connector:e,onChanged:i}):o(J,{connector:e,onChanged:i}),e.configured&&o(Q,{connectorId:e.id,connectorType:e.type})]})]})}function K({connector:e,onChanged:t}){let n=C(),[s,c]=(0,N.useState)(!1),[l,d]=(0,N.useState)(null),[p,m]=(0,N.useState)({}),[g,_]=(0,N.useState)(null),{agents:v}=a(),b=v.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),x=b.map(e=>e.namespaced_agent_id).join(`,`),[S,T]=(0,N.useState)(()=>new Set);(0,N.useEffect)(()=>{T(new Set(b.map(e=>e.namespaced_agent_id)))},[x]);let D=e=>T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),O=()=>[...S];(0,N.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let k=e=>{let t=window;t.gaia?.openExternal?t.gaia.openExternal(e):window.open(e,`_blank`,`noopener`)},A=async()=>{c(!0),d(null);try{let t=await y(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,O());k(t.authorization_url)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}},j=async()=>{c(!0),d(null),_(null);try{let t=await u(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,O());_(t)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}};(0,N.useEffect)(()=>{e.configured&&_(null)},[e.configured]),I((0,N.useCallback)(t=>{t.connectorId===e.id&&(t.reason===`oauth_error`?(d(String(t.payload.error??n(`settings.connectors.deviceFailed`))),_(null)):t.reason===`oauth_completed`&&_(null))},[e.id,n]));let P=async()=>{c(!0),d(null);try{await f(e.id),t()}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}},F=async()=>{let r=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!p[e.key]?.trim()).map(e=>e.label);if(r.length)d(n(`settings.connectors.required`,{fields:r.join(`, `)}));else{c(!0),d(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await h(e.id,{...p,scopes:n,grant_agents:O()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&k(i),t()}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}}},L=e.oauth_setup_fields??[],R=e.configurable===!1&&!e.configured&&L.length>0;return r(`div`,{className:`configure-body`,children:[e.description&&o(`p`,{className:`connector-desc`,children:o(`bdi`,{children:e.description})}),R&&r(`div`,{className:`oauth-setup-form`,children:[o(`p`,{className:`connector-desc`,children:n(`settings.connectors.firstSetup`)}),L.map(e=>r(`label`,{className:`oauth-setup-field`,children:[o(`span`,{className:`oauth-setup-label`,children:e.label}),o(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.placeholder,value:p[e.key]??``,onChange:t=>m(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&o(`span`,{className:`oauth-setup-help`,children:o(`bdi`,{children:e.help_md})})]},e.key))]}),!e.configured&&b.length>0&&r(`div`,{className:`oauth-grant-onconnect`,children:[o(`p`,{className:`oauth-grant-onconnect-label`,children:n(`settings.connectors.grantOnConnect`)}),b.map(e=>r(`label`,{className:`oauth-grant-onconnect-item`,children:[o(`input`,{type:`checkbox`,checked:S.has(e.namespaced_agent_id),onChange:()=>D(e.namespaced_agent_id)}),o(`span`,{children:e.name})]},e.namespaced_agent_id)),o(`p`,{className:`oauth-grant-onconnect-help`,children:n(`settings.connectors.grantLater`)})]}),!R&&o(q,{connector:e,onChanged:t}),l&&r(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,l]}),r(`div`,{className:`configure-actions`,children:[e.configured?o(`button`,{className:`btn-secondary`,disabled:s,onClick:()=>void P(),children:s?o(M,{size:12,className:`spin`}):n(`settings.connectors.disconnect`)}):R?o(`button`,{className:`btn-primary`,disabled:s,onClick:()=>void F(),children:s?o(M,{size:12,className:`spin`}):r(i.Fragment,{children:[o(w,{size:12}),` `,n(`settings.connectors.saveConnect`)]})}):e.configurable===!1?o(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:n(`settings.connectors.setupRequired`)}):r(i.Fragment,{children:[o(`button`,{className:`btn-primary`,disabled:s||g!==null,onClick:()=>void A(),children:s?o(M,{size:12,className:`spin`}):r(i.Fragment,{children:[o(w,{size:12}),` `,n(`settings.key.connect`)]})}),e.supports_device_code&&o(`button`,{className:`btn-secondary`,disabled:s||g!==null,onClick:()=>void j(),title:n(`settings.connectors.codeTitle`),children:n(`settings.connectors.code`)})]}),(e.docs_url||e.product_url)&&r(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[n(`settings.connectors.learnMore`),` `,o(w,{size:11})]})]}),g&&!e.configured&&r(`div`,{className:`device-code-block`,children:[r(`p`,{className:`device-code-instructions`,children:[n(`settings.connectors.goTo`),` `,o(`a`,{href:g.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),k(g.verification_uri)},children:g.verification_uri})]}),r(`div`,{className:`device-code-value`,children:[o(`code`,{children:g.user_code}),o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(g.user_code),title:n(`settings.connectors.copyCode`),children:n(`gpu.copy`)})]}),r(`p`,{className:`device-code-waiting`,children:[o(M,{size:12,className:`spin`}),` `,n(`settings.connectors.waiting`)]}),o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>_(null),children:n(`settings.key.cancel`)})]})]})}function q({connector:e,onChanged:t}){let n=C(),[a,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)({}),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(!1),[m,g]=(0,N.useState)(null),_=e.oauth_setup_fields??[];if(_.length===0)return null;let v=e.oauth_client,y=v?.source===`keyring`?n(`settings.connectors.savedClient`,{id:v.client_id??``}):v?.source===`env`?n(`settings.connectors.envClient`,{id:v.client_id??``}):n(`settings.connectors.noClient`),b=async()=>{if(!c.client_id?.trim())g(n(`settings.connectors.clientRequired`));else{d(!0),g(null),p(!1);try{await h(e.id,{...Object.fromEntries(Object.entries(c).map(([e,t])=>[e,t.trim()])),save_only:!0}),p(!0),l({}),t(),setTimeout(()=>p(!1),2200)}catch(e){g(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return r(`div`,{className:`oauth-client-editor`,children:[r(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>s(e=>!e),"aria-expanded":a,children:[o(a?O:k,{size:12}),o(`span`,{children:n(`settings.connectors.client`)}),o(`span`,{className:`oauth-client-editor__status`,children:y})]}),a&&r(`div`,{className:`oauth-setup-form`,children:[o(`p`,{className:`connector-desc`,children:n(`settings.connectors.clientHelp`)}),_.map(e=>r(`label`,{className:`oauth-setup-field`,children:[o(`span`,{className:`oauth-setup-label`,children:e.label}),o(`input`,{type:e.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:e.kind===`secret`&&v?.source===`keyring`&&v.has_secret?`••••••••`:e.placeholder,value:c[e.key]??``,onChange:t=>l(n=>({...n,[e.key]:t.target.value})),autoComplete:`off`,spellCheck:!1}),e.help_md&&o(`span`,{className:`oauth-setup-help`,children:o(`bdi`,{children:e.help_md})})]},e.key)),m&&r(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,m]}),o(`div`,{className:`configure-actions`,children:o(`button`,{className:`btn-model-save${f?` saved`:``}`,disabled:u||!c.client_id?.trim(),onClick:()=>void b(),children:u?o(M,{size:12,className:`spin`}):f?r(i.Fragment,{children:[o(T,{size:12}),` `,n(`settings.advanced.saved`)]}):n(`settings.connectors.saveClient`)})})]})]})}function J({connector:e,onChanged:t}){let n=C(),[a,s]=(0,N.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[c,l]=(0,N.useState)(!1),[u,p]=(0,N.useState)(!1),[m,g]=(0,N.useState)(null);(0,N.useEffect)(()=>{s(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let _=e.mcp_env_keys.length===0,y=Object.values(a).every(e=>e.trim()===``),b=async()=>{let n=Object.fromEntries(Object.entries(a).filter(([,e])=>e.trim()!==``));if(_||Object.keys(n).length!==0){l(!0),g(null),p(!1);try{await h(e.id,n),p(!0),t(),setTimeout(()=>p(!1),2200)}catch(e){g(e instanceof Error?e.message:String(e))}finally{l(!1)}}},x=async()=>{l(!0),g(null);try{await f(e.id),s(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){g(e instanceof Error?e.message:String(e))}finally{l(!1)}},S=async()=>{l(!0),g(null);try{e.enabled?await d(e.id):await v(e.id),t()}catch(e){g(e instanceof Error?e.message:String(e))}finally{l(!1)}};return r(`div`,{className:`configure-body`,children:[e.description&&o(`p`,{className:`connector-desc`,children:o(`bdi`,{children:e.description})}),m&&r(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,m]}),e.configured&&r(`div`,{className:`connector-toggle-row`,children:[o(`span`,{className:`connector-toggle-label`,children:n(`settings.connectors.active`)}),r(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void S(),disabled:c,"aria-label":e.enabled?n(`settings.connectors.disableServer`):n(`settings.connectors.enableServer`)}),o(`span`,{className:`toggle-track`})]})]}),e.configured&&e.enabled===!1&&o(`p`,{className:`connector-toggle-help`,children:n(`settings.connectors.disabledHelp`)}),e.mcp_env_keys.map(t=>r(`div`,{className:`mcp-key-row`,children:[o(`label`,{className:`mcp-key-label`,children:t}),o(`input`,{type:`password`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:n.bare(`settings.connectors.enterValue`),value:a[t]??``,onChange:e=>s(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`})]},t)),r(`div`,{className:`configure-actions`,children:[!(_&&e.configured)&&o(`button`,{className:`btn-model-save${u?` saved`:``}`,disabled:c||!_&&y,onClick:()=>void b(),children:c?o(M,{size:12,className:`spin`}):u?r(i.Fragment,{children:[o(T,{size:12}),` `,n(`settings.advanced.saved`)]}):n(_?`settings.key.connect`:`settings.advanced.save`)}),e.configured&&o(`button`,{className:`btn-secondary`,disabled:c,onClick:()=>void x(),children:n(`settings.connectors.disconnect`)}),e.product_url&&r(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[n(`settings.connectors.docs`),` `,o(w,{size:11})]})]})]})}function Y({agent:e,connectorId:t,grantedScopes:n,onChanged:i}){let a=C(),s=e.required_connections?.find(e=>e.connector_id===t),c=e.namespaced_agent_id;if(!s||!c)return null;let[u,d]=(0,N.useState)(()=>new Set(n)),[f,p]=(0,N.useState)(null),[h,g]=(0,N.useState)(null);(0,N.useEffect)(()=>{d(new Set(n))},[n.join(`,`)]);let _=async e=>{if(f!==null)return;let r=new Set(u);r.has(e)?r.delete(e):r.add(e),d(r),p(e),g(null);try{r.size===0?await l(t,c):await m(t,c,[...r]),i()}catch(e){d(new Set(n)),g(e instanceof Error?e.message:String(e))}finally{p(null)}};return r(`div`,{className:`grant-agent-card`,children:[o(`bdi`,{className:`grant-agent-card-name`,children:e.name}),o(`div`,{className:`grant-scope-list`,children:s.scopes.map(e=>r(`label`,{className:`grant-scope-item`,children:[o(`span`,{className:`grant-scope-label`,children:B(e,a)}),r(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>void _(e),disabled:f!==null}),o(`span`,{className:`toggle-track`})]})]},e))}),h&&r(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[o(E,{size:11}),` `,h]})]})}function X({servers:e,expanded:t,onToggle:n}){return o(`div`,{className:`agent-mcps-section`,children:o(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return o(Z,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})})}function Z({server:e,expanded:t,onToggle:n}){let i=C(),a=[e.command,...e.args].join(` `);return r(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[r(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[o(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),o(`span`,{className:`agent-mcp-agent-label`,children:i(`settings.connectors.via`,{name:e.agent_name})}),e.disabled?o(`span`,{className:`agent-mcp-status disabled`,children:i(`settings.connectors.disabled`)}):r(`span`,{className:`agent-mcp-status enabled`,children:[o(T,{size:11}),` `,i(`settings.connectors.active`)]}),o(`span`,{className:`agent-mcp-readonly-badge`,children:i(`settings.connectors.readOnly`)}),o(`span`,{className:`agent-mcp-chevron`,children:o(t?O:k,{size:14})})]}),t&&r(`div`,{className:`agent-mcp-detail`,children:[a&&o(`bdi`,{dir:`ltr`,className:`agent-mcp-command-row`,children:a}),o(`bdi`,{dir:`ltr`,className:`agent-mcp-config-path`,children:e.config_path}),o(`div`,{className:`agent-mcp-config-hint`,children:i(`settings.connectors.editConfig`)})]})]})}function Q({connectorId:e,connectorType:t}){let n=C(),{agents:s}=a(),[l,u]=(0,N.useState)({}),[d,f]=(0,N.useState)({}),[p,m]=(0,N.useState)(!0),h=(0,N.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([x(e),c(e)]);u(t),f(n)}catch{u({}),f({})}finally{m(!1)}},[e]);if((0,N.useEffect)(()=>{h()},[h]),I((0,N.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&h()},[e,h])),p)return null;let g=s.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),_=t===`mcp_server`?s.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return r(`div`,{className:`connection-grants`,children:[o(`div`,{className:`grants-header`,children:n(`settings.connectors.grants`)}),g.length===0?o(`div`,{className:`grants-empty`,children:n(`settings.connectors.noGrants`)}):g.map(t=>o(Y,{agent:t,connectorId:e,grantedScopes:l[t.namespaced_agent_id]??[],onChanged:()=>void h()},t.namespaced_agent_id)),_.length>0&&r(i.Fragment,{children:[o(`div`,{className:`grants-header grants-header--activations`,children:n(`settings.connectors.activeFor`)}),o(`div`,{className:`grants-help`,children:n(`settings.connectors.activationHelp`)}),_.map(t=>o($,{agent:t,connectorId:e,active:!!d[t.namespaced_agent_id],grantedScopes:l[t.namespaced_agent_id]??[],onChanged:()=>void h()},`activation-${t.namespaced_agent_id}`))]})]})}function $({agent:e,connectorId:t,active:n,grantedScopes:i,onChanged:a}){let s=C(),c=e.required_connections?.find(e=>e.connector_id===t),l=e.namespaced_agent_id;if(!l)return null;let[u,d]=(0,N.useState)(n),[f,p]=(0,N.useState)(!1),[m,h]=(0,N.useState)(null);(0,N.useEffect)(()=>{d(n)},[n]);let g=async()=>{if(f)return;let e=!u;d(e),p(!0),h(null);try{if(e){let e=i.length===0?c?[...c.scopes]:[...H]:void 0;await _(t,l,e)}else await b(t,l);a()}catch(e){d(n),h(e instanceof Error?e.message:String(e))}finally{p(!1)}};return r(`div`,{className:`grant-agent-card`,children:[o(`bdi`,{className:`grant-agent-card-name`,children:e.name}),o(`div`,{className:`grant-scope-list`,children:r(`label`,{className:`grant-scope-item`,children:[o(`span`,{className:`grant-scope-label`,children:s(u?`settings.connectors.toolsVisible`:`settings.connectors.toolsHidden`)}),r(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:u,onChange:()=>void g(),disabled:f}),o(`span`,{className:`toggle-track`})]})]})}),m&&r(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[o(E,{size:11}),` `,m]})]})}function ee(){let e=C();return r(`div`,{className:`settings-pane`,children:[o(`h2`,{className:`settings-pane-title`,children:e(`settings.section.connectors`)}),o(W,{})]})}export{ee as ConnectorsPane};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{G as t,N as n,W as r,i,n as a,o,r as s}from"./apiBase-BMkGbdXt.js";import{Ht as c,N as ee,Ut as te,_ as ne,et as re,pt as ie,rt as l,s as u,u as ae,vt as oe}from"./api-BzlFpP4T.js";import{$ as d,Ct as f,G as se,It as ce,J as le,K as ue,Lt as p,Nt as de,Q as fe,Tt as pe,Y as me,at as he,bt as ge,ct as _e,dt as ve,nt as ye,q as be,rt as m,t as h,tt as xe}from"./index-hAcJijAU.js";var g={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`]};g.node;var _=r(g),v={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`}]]};v.node;var Se=r(v),y={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`}]]};y.node;var Ce=r(y),b=e(t(),1),x=e=>e.toLocaleString(`en-US`);function S(e,t){let n=x(e.done);return e.phase===`reading`?e.total==null?t(`docs.progress.readingCount`,{done:n}):t(`docs.progress.reading`,{done:n,total:x(e.total)}):e.total==null?t(`docs.progress.embeddingCount`,{done:n}):t(`docs.progress.embedding`,{done:n,total:x(e.total)})}function C(e){return e.total==null||e.total<=0?null:Math.min(100,Math.floor(e.done/e.total*100))}function we({progress:e}){let t=S(e,d()),n=C(e);return i(`div`,{className:`index-progress is-running`,children:[s(`div`,{className:`index-progress-track${n==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":t,"aria-valuemin":n==null?void 0:0,"aria-valuemax":n==null?void 0:100,"aria-valuenow":n??void 0,children:s(`div`,{className:`index-progress-fill`,style:n==null?void 0:{inlineSize:`${n}%`}})}),i(`span`,{className:`index-progress-label`,children:[t,n!=null&&i(`span`,{className:`index-progress-pct`,children:[` · `,n,`%`]})]})]})}function Te(e){let[t,...n]=e.replace(/^RAG indexing failed for [^:]+:\s*/,``).trim().split(`
|
|
2
|
-
`);return{summary:t.trim(),more:n.join(`
|
|
3
|
-
`).trim()}}function Ee(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(` `)}var De=1e3;function w(e,t,n){if(n)return{...e,[t]:n};if(!(t in e))return e;let{[t]:r,...i}=e;return i}function Oe(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function ke(e,t){try{let n=new Date(e);if(isNaN(n.getTime()))return``;let r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3),a=Math.floor(i/60),o=Math.floor(a/60),s=Math.floor(o/24);return i<60?t(`time.justNow`):a<60?t(`time.minutesAgo`,{n:a}):o<24?t(`time.hoursAgo`,{n:o}):s===1?t(`time.yesterday`):s<7?t(`time.daysAgo`,{n:s}):n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return``}}function Ae(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 T(){let e=d(),{documents:t,setDocuments:r,setShowDocLibrary:g,setShowFileBrowser:v,currentSessionId:y,sessions:x,updateSessionInList:S,draftDocumentIds:C,addDraftDocuments:T,removeDraftDocument:E}=o(),D=x.find(e=>e.id===y)??null,[O,je]=(0,b.useState)(y?`chat`:`next`),k=O===`chat`?y:null,A=`“${D?.title||e(`docs.untitledChat`)}”`,[j,M]=(0,b.useState)(``),Me=(0,b.useCallback)(()=>g(!1),[g]);ye(!0,Me);let N=(0,b.useRef)(null);me(N,!0);let[Ne,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)(!1),[Pe,L]=(0,b.useState)(``),[R,z]=(0,b.useState)(``),[B,V]=(0,b.useState)(null),[H,U]=(0,b.useState)(null),[W,G]=(0,b.useState)(new Set),[Fe,K]=(0,b.useState)({}),q=(0,b.useRef)(new Map),[,Ie]=(0,b.useState)(0);(0,b.useEffect)(()=>{n.doc.info(`Loading document library...`);let e=n.doc.time();l().then(t=>{let i=t.documents||[];r(i),n.doc.timed(`Loaded ${i.length} document(s), ${t.total_chunks||0} chunks, ${t.total_size_bytes||0} bytes total`,e)}).catch(e=>{n.doc.error(`Failed to load documents`,e),r([])})},[r]);let J=t.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,b.useEffect)(()=>{if(!J)return;let e=o.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 t=!1,i=setInterval(async()=>{if(Ie(e=>e+1),!t){t=!0;try{let e=o.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let t of e)try{let e=await ee(t.id);if(K(n=>w(n,t.id,e.progress)),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){q.current.delete(t.id);let e=await l();r(e.documents||[]);break}}catch(e){n.doc.warn(`Indexing status for ${t.filename} unavailable`,e)}}finally{t=!1}}},De);return()=>clearInterval(i)},[J,r]),(0,b.useEffect)(()=>{let e=new Set(t.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let t of q.current.keys())e.has(t)||q.current.delete(t);K(t=>Object.keys(t).reduce((t,n)=>e.has(n)?t:w(t,n,null),t))},[t]),(0,b.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await l()).documents||[],t=o.getState().documents;(e.length!==t.length||e.some((e,n)=>{let r=t.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}))&&(r(e),n.doc.debug(`Document list refreshed (server-side changes detected)`))}catch{}},15e3);return()=>clearInterval(e)},[r]);let Le=t.reduce((e,t)=>e+t.file_size,0),Re=t.reduce((e,t)=>e+t.chunk_count,0),Y=(0,b.useCallback)(async(t,r)=>{if(!k){T([t]),M(e(`docs.willAttach`,{name:r})),n.doc.info(`"${r}" will be attached to the next new chat`);return}await u(k,t);let i=o.getState().sessions.find(e=>e.id===k)?.document_ids??[];i.includes(t)||S(k,{document_ids:[...i,t]}),M(e(`docs.attached`,{name:r,chat:A})),n.doc.info(`Attached "${r}" to session ${k}`)},[k,A,S,T,e]),X=(0,b.useCallback)(async(e,t)=>{if(e.length===0)return;if(!k){T(e),n.doc.info(`"${t}" will be attached to the next new chat`);return}let r=[];for(let t of e)try{await u(k,t),r.push(t)}catch(e){n.doc.warn(`Could not attach document to session: ${e}`)}let i=o.getState().sessions.find(e=>e.id===k)?.document_ids??[],a=r.filter(e=>!i.includes(e));a.length>0&&S(k,{document_ids:[...i,...a]}),n.doc.info(`Attached "${t}" to session ${k}`)},[k,S,T]),Z=(0,b.useCallback)(async(t,i,a)=>{if(!await xe(`embedding`))return;let o=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``,s=o&&!le(o)?be(o)?.message??`The file type "${o}" is not supported for indexing.`:null;if(s&&!a){n.doc.warn(`Unsupported file type: ${t} (${o})`),V({filename:t,error:s});return}n.doc.info(`Indexing document: ${t}`);let c=n.doc.time();I(!0),L(e(`docs.indexingFile`,{name:t})),V(null),U(null),M(``);try{let e=await i();if(n.doc.timed(`Indexed "${t}": ${e?.chunk_count||`?`} chunks`,c),e?.id)try{await Y(e.id,e.filename||t)}catch(e){n.doc.error(`Could not attach "${t}" to ${A}`,e),V({filename:t,error:`Indexed, but not attached to ${A}: ${e instanceof Error?e.message:e}`})}let a=await l();r(a.documents||[]),L(``)}catch(e){let{httpStatus:r,reason:i}=e??{};if(i===`is_folder`&&a){await a();return}n.doc.error(`Failed to index "${t}"`,e);let o=r===400&&s?s:e instanceof Error?e.message:`Upload failed`;V({filename:t,error:o,status:r,kind:i}),L(``)}finally{I(!1)}},[Y,A,r,e]),Q=(0,b.useCallback)(async(t,i)=>{n.doc.info(`"${t}" is a folder; indexing its documents`),L(e(`docs.indexingFolder`,{name:i}));try{let e=await re(t,!1);await X(e.documents.map(e=>e.id).filter(Boolean),i),U(Ee(i,e));let n=await l();r(n.documents||[])}catch(e){n.doc.error(`Failed to index folder "${t}"`,e);let r=e instanceof Error?e.message:`Folder indexing failed`,{httpStatus:a}=e??{};V({filename:i,error:r,status:a})}finally{L(``)}},[X,r,e]),ze=(0,b.useCallback)(async(e,t)=>{await Z(t,()=>te(e),()=>Q(e,t))},[Z,Q]),$=(0,b.useCallback)(async e=>{await Z(e.name,()=>c(e))},[Z]),Be=(0,b.useCallback)(async e=>{e.preventDefault(),P(!1);let t=Array.from(e.dataTransfer.files);n.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await $(e)},[$]),Ve=(0,b.useCallback)(async e=>{let i=t.find(t=>t.id===e);n.doc.info(`Deleting document: ${i?.filename||e}`);try{await ne(e),q.current.delete(e),E(e),r(t.filter(t=>t.id!==e)),n.doc.info(`Deleted document: ${i?.filename||e}`)}catch(t){n.doc.error(`Failed to delete document: ${i?.filename||e}`,t)}},[t,r,E]),He=(0,b.useCallback)(async(e,t)=>{n.doc.info(`Opening folder for: ${e}`);try{await ie(e,!0)}catch(e){n.doc.error(`Failed to open folder for: ${t}`,e)}},[]),Ue=(0,b.useCallback)(async e=>{let i=t.find(t=>t.id===e);n.doc.info(`Cancelling indexing for: ${i?.filename||e}`);try{await ae(e),q.current.delete(e);let t=await l();r(t.documents||[]),n.doc.info(`Cancelled indexing for: ${i?.filename||e}`)}catch(t){n.doc.error(`Failed to cancel indexing: ${i?.filename||e}`,t)}},[t,r]),We=(0,b.useCallback)(async e=>{if(W.has(e))return;let i=t.find(t=>t.id===e);n.doc.info(`Reindexing document: ${i?.filename||e}`),G(t=>new Set(t).add(e));try{await oe(e),n.doc.info(`Reindex complete for: ${i?.filename||e}`)}catch(t){let r=t instanceof Error?t.message:String(t);n.doc.error(`Reindex failed for: ${i?.filename||e}`,t),V({filename:i?.filename||e,error:r})}finally{try{let e=await l();r(e.documents||[])}catch(e){n.doc.error(`Failed to refresh documents after reindex`,e)}G(t=>{let n=new Set(t);return n.delete(e),n})}},[t,r,W]),Ge=(0,b.useCallback)(async e=>{let r=t.find(t=>t.id===e)?.filename||e;M(``);try{await Y(e,r)}catch(e){n.doc.error(`Failed to attach ${r} to ${A}`,e),V({filename:r,error:`Not attached to ${A}: ${e instanceof Error?e.message:e}`})}},[t,Y,A]),Ke=(0,b.useCallback)(async e=>{if(e.preventDefault(),!R.trim())return;let t=R.trim();n.doc.info(`Indexing from path input: ${t}`),await ze(t,t.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||`file`),z(``)},[R,ze]),qe=t=>{let n=t.indexing_status||`complete`,r=q.current.get(t.id),a=t.indexed_at?ke(t.indexed_at,e):``,o=t.indexed_at?Ae(t.indexed_at):``;switch(n){case`indexing`:case`pending`:{let n=Fe[t.id];return i(`div`,{className:`doc-indexing-status`,children:[n?s(we,{progress:n}):i(`div`,{className:`doc-indexing-bar`,children:[s(`div`,{className:`doc-indexing-bar-track`,children:s(`div`,{className:`doc-indexing-bar-fill`})}),i(`span`,{className:`doc-indexing-label`,children:[s(Se,{size:12,className:`doc-spin`}),r?e.hint(e(`docs.indexingLabel`),Oe(r)):e(`docs.indexing`)]})]}),i(`button`,{className:`btn-cancel`,onClick:e=>{e.stopPropagation(),Ue(t.id)},title:e(`docs.cancelIndexing`),"aria-label":e(`docs.cancelIndexingAria`,{name:t.filename}),children:[s(_,{size:14}),e(`docs.cancel`)]})]})}case`failed`:{let n=t.error_kind?se[t.error_kind]:void 0,r=t.last_error?Te(t.last_error):null;return i(`div`,{className:`doc-failure`,children:[i(`div`,{className:`doc-indexing-status`,children:[i(`span`,{className:`doc-status-badge doc-status-failed`,title:t.last_error||void 0,"aria-label":t.last_error?e(`docs.failedAria`,{error:t.last_error}):e(`docs.indexingFailed`),children:[s(p,{size:12}),` `,e(n?`docs.cantRead`:`docs.failed`)]}),i(`button`,{className:n?`btn-retry btn-retry-quiet`:`btn-retry`,onClick:e=>{e.stopPropagation(),We(t.id)},title:e(n?`docs.retryTitleFix`:`docs.retryTitle`),"aria-label":e(`docs.retryAria`,{name:t.filename}),disabled:W.has(t.id),children:[s(Ce,{size:n?12:14}),W.has(t.id)?e(`docs.retrying`):e(`docs.retry`)]})]}),n&&s(`p`,{className:`doc-failure-hint`,children:n}),r&&(r.more?i(`details`,{className:`doc-failure-reason`,children:[s(`summary`,{children:r.summary}),s(`p`,{children:r.more})]}):s(`p`,{className:`doc-failure-reason`,children:r.summary})),!r&&!n&&s(`p`,{className:`doc-failure-reason`,children:e(`docs.noReason`)})]})}case`cancelled`:return i(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[s(_,{size:12}),` `,e(`docs.cancelled`)]});case`missing`:return i(`span`,{className:`doc-status-badge doc-status-missing`,children:[s(p,{size:12}),` `,e(`docs.missing`)]});default:return i(`span`,{className:`doc-meta`,children:[s(`bdi`,{dir:`ltr`,children:h(t.file_size)}),` · `,e.plural(`docs.chunks`,t.chunk_count),a&&i(`span`,{className:`doc-timestamp`,title:e(`docs.indexedAt`,{time:o}),children:[s(de,{size:10}),a]})]})}};return s(`div`,{ref:N,className:`modal-overlay`,onClick:()=>g(!1),role:`dialog`,"aria-modal":`true`,"aria-label":e(`docs.title`),children:i(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`modal-header`,children:[s(`h3`,{children:e(`docs.title`)}),s(`button`,{className:`btn-icon`,onClick:()=>g(!1),"aria-label":e(`docs.close`),children:s(m,{size:18})})]}),i(`div`,{className:`modal-body`,children:[i(`div`,{className:`doc-target`,children:[y?i(`label`,{className:`doc-target-choice`,children:[e(`docs.addTo`),i(`select`,{value:O,onChange:e=>{je(e.target.value),M(``)},children:[s(`option`,{value:`chat`,children:e(`docs.thisChat`,{chat:A})}),s(`option`,{value:`next`,children:e(`docs.nextChat`)})]})]}):s(`span`,{children:e(`docs.nextChatOnly`)}),s(`span`,{className:`doc-target-hint`,children:e(`docs.hint`)})]}),s(`div`,{className:`drop-zone ${Ne?`drag-over`:``} ${F?`uploading`:``}`,onDragOver:e=>{e.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:Be,children:F?i(a.Fragment,{children:[s(`div`,{className:`upload-spinner`}),s(`p`,{children:Pe})]}):i(a.Fragment,{children:[s(he,{size:32,strokeWidth:1.5}),s(`p`,{children:e(`docs.drop`)}),s(`span`,{className:`drop-hint`,children:e(`docs.dropHint`)})]})}),i(`form`,{className:`path-input-form`,onSubmit:Ke,children:[s(f,{size:16,className:`path-icon`}),s(`input`,{type:`text`,className:`path-input`,value:R,onChange:e=>z(e.target.value),placeholder:e(`docs.pathPlaceholder`,{example:fe()}),"aria-label":e(`docs.pathAria`),dir:`auto`}),s(`button`,{type:`submit`,className:`btn-secondary`,disabled:!R.trim()||F,children:e(`docs.index`)}),i(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{g(!1),v(!0)},title:e(`docs.browseTitle`),children:[s(ve,{size:14}),e(`docs.browse`)]})]}),j&&s(`p`,{className:`doc-target-notice`,role:`status`,children:j}),B&&s(ue,{filename:B.filename,error:B.error,status:B.status,kind:B.kind,onDismiss:()=>V(null)}),H&&i(`div`,{className:`doc-folder-notice`,role:`status`,children:[s(ce,{size:14}),s(`span`,{children:H}),s(`button`,{className:`btn-icon-sm`,onClick:()=>U(null),"aria-label":e(`docs.dismissFolder`),children:s(m,{size:12})})]}),t.length>0&&i(`div`,{className:`doc-stats`,children:[s(`span`,{children:e.plural(`docs.count`,t.length)}),s(`span`,{children:`·`}),s(`span`,{children:e.plural(`docs.chunks`,Re)}),s(`span`,{children:`·`}),s(`bdi`,{dir:`ltr`,children:h(Le)})]}),i(`div`,{className:`doc-list`,children:[t.length===0&&!F&&i(`div`,{className:`empty-docs`,children:[s(pe,{size:32,strokeWidth:1}),s(`p`,{children:e(`docs.empty`)}),s(`span`,{children:e(`docs.emptyHint`)})]}),t.map(t=>i(`div`,{className:`doc-row ${t.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[i(`div`,{className:`doc-info`,children:[s(`span`,{className:`doc-name`,dir:`auto`,children:t.filename}),qe(t)]}),i(`div`,{className:`doc-row-actions`,children:[t.filepath&&s(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>He(t.filepath,t.filename),title:e(`docs.openFolder`,{path:t.filepath}),"aria-label":e(`docs.openFolderAria`,{name:t.filename}),children:s(f,{size:14})}),t.indexing_status===`complete`&&!(k?D?.document_ids?.includes(t.id):C.includes(t.id))&&s(`button`,{className:`btn-icon-sm doc-attach`,onClick:()=>Ge(t.id),title:k?e(`docs.useIn`,{chat:A}):e(`docs.useNext`),"aria-label":k?e(`docs.attachAria`,{name:t.filename,chat:A}):e(`docs.attachNextAria`,{name:t.filename}),children:s(ge,{size:14})}),t.indexing_status!==`indexing`&&t.indexing_status!==`pending`&&s(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>Ve(t.id),title:e(`docs.remove`),"aria-label":e(`docs.removeAria`,{name:t.filename}),children:s(_e,{size:14})})]})]},t.id))]})]})]})})}export{T as DocumentLibrary};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{G as t,N as n,W as r,i,o as a,r as o}from"./apiBase-BMkGbdXt.js";import{Ut as s,_t as c,et as l,l as u,rt as ee,s as d,wt as f}from"./api-BzlFpP4T.js";import{Ct as p,Et as m,J as h,K as g,St as _,Tt as v,Ut as te,Wt as ne,Y as re,_t as y,at as ie,dt as ae,kt as oe,nt as se,q as b,rt as x,t as ce,tt as S,wt as C,xt as le,zt as ue}from"./index-hAcJijAU.js";var w={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`}]]};w.node;var T=r(w),E={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};E.node;var D=r(E),O={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`}]]};O.node;var k=r(O),A=e(t(),1);function de(e){if(e.type===`folder`)return o(_,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?o(k,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?o(T,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?o(v,{size:16}):o(C,{size:16})}function fe(e){if(!e)return``;let t=new Date(e),n=new Date,r=n.getTime()-t.getTime(),i=Math.floor(r/36e5);if(i<1)return`Just now`;if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})}function pe(e){if(e.length===0)return``;let[t,...n]=e;return n.length>0?`${t} (+${n.length} more)`:t}function me(e){switch(e){case`home`:return o(D,{size:14});case`desktop`:return o(y,{size:14});case`documents`:return o(v,{size:14});case`download`:return o(oe,{size:14});default:return o(_,{size:14})}}var he=[{label:`All Files`,value:``},{label:`Documents`,value:`pdf,doc,docx,txt,md`},{label:`Spreadsheets`,value:`csv,xlsx,xls,tsv`},{label:`Code`,value:`py,js,ts,java,c,cpp,go,rs,rb,sh`},{label:`Data`,value:`json,xml,yaml,yml,csv,tsv`}];async function ge(e,t,r,i){let o=[],c=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!h(e)?c.push(t):o.push(t)}let u=[],f=[],p=0,m=``,g=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of o)try{if(g.has(e)){let t=await l(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),n.length>0&&(n.forEach(e=>u.push(e)),f.push(e))}else{if(!await S(`embedding`))break;let t=await s(e);t?.id&&(u.push(t.id),f.push(e))}}catch(e){p++,m=e instanceof Error?e.message:`Unknown error`}if(r&&u.length>0){let e=[];for(let t of u)try{await d(r,t),e.push(t)}catch(e){n.doc.warn(`Could not attach document to session: ${e}`)}let t=a.getState().sessions.find(e=>e.id===r)?.document_ids??[],o=e.filter(e=>!t.includes(e));o.length>0&&i(r,{document_ids:[...t,...o]})}else u.length>0&&a.getState().addDraftDocuments(u);if(u.length>0)try{let e=await ee();a.getState().setDocuments(e.documents||[])}catch(e){n.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:u,supported:o,succeededFiles:f,unsupported:c,failed:p,lastError:m}}var j=e=>e.startsWith(`.`);function M({onStartChat:e}){let{setShowFileBrowser:t,currentSessionId:r,updateSessionInList:s,setPendingPrompt:l}=a(),ee=(0,A.useCallback)(()=>t(!1),[t]);se(!0,ee);let d=(0,A.useRef)(null);re(d,!0);let[_,v]=(0,A.useState)(``),[y,oe]=(0,A.useState)(null),[S,C]=(0,A.useState)([]),[w,T]=(0,A.useState)([]),[E,D]=(0,A.useState)(!1),[O,k]=(0,A.useState)(null),[M,_e]=(0,A.useState)(!1),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)([]),[ve,ye]=(0,A.useState)(!1),[z,B]=(0,A.useState)(!1),[V,be]=(0,A.useState)(``),[H,U]=(0,A.useState)(new Set),[W,G]=(0,A.useState)(null),[xe,Se]=(0,A.useState)(!1),[Ce,K]=(0,A.useState)(new Set),[we,q]=(0,A.useState)(null),J=(0,A.useRef)(null),[Y,X]=(0,A.useState)(null),Z=(0,A.useCallback)(async e=>{D(!0),k(null),I(null),P(``),R([]);try{let t=await u(e);v(t.current_path),oe(t.parent_path),C(t.entries),t.quick_links.length>0&&T(t.quick_links),n.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(e){let t=e instanceof Error?e.message:`Failed to load directory`;k(t),n.ui.error(`Browse failed`,e)}finally{D(!1)}},[]);(0,A.useEffect)(()=>{Z()},[Z]),(0,A.useEffect)(()=>()=>{J.current&&clearTimeout(J.current)},[]);let Q=(0,A.useCallback)(async()=>{if(!N.trim())I(null),R([]);else{B(!0),k(null);try{let e=await f(N.trim(),V||void 0,30);I(e.results),R(e.searched_locations??[]),ye(e.truncated===!0),n.ui.info(`Search "${N}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;k(t),n.ui.error(`Search failed`,e)}finally{B(!1)}}},[N,V]),Te=e=>{e.key===`Enter`&&Q()},Ee=(0,A.useCallback)(e=>{e.type===`folder`&&(Z(e.path),U(new Set),G(null))},[Z]),De=(0,A.useCallback)(async e=>{Se(!0);try{let t=await c(e);G(t)}catch(e){n.ui.error(`Preview failed`,e)}finally{Se(!1)}},[]),Oe=(0,A.useCallback)(e=>{U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ke=(0,A.useCallback)(async()=>{if(H.size===0)return;let e=Array.from(H);if(X(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||h(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=b(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 ge(e,S,r,s);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),U(new Set)}catch(t){n.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)}}},[H,r,s,S]),$=(0,A.useRef)(!1),Ae=(0,A.useCallback)(async()=>{if(H.size===0||$.current)return;$.current=!0;let i=Array.from(H);X(null),K(new Set(i)),q(`Indexing ${i.length} file(s) for analysis...`);try{let n=await ge(i,S,r,s);if(n.supported.length===0){let e=i[0].lastIndexOf(`.`),t=e>0?i[0].slice(e).toLowerCase():``,n=b(t);X({filename:i.length===1?i[0].split(/[\\/]/).pop()||i[0]:`${i.length} files`,error:n?.message??`File type "${t}" is not supported for indexing.`});return}if(n.docIds.length===0){X({filename:n.supported.length===1?n.supported[0].split(/[\\/]/).pop()||n.supported[0]:`${n.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}n.failed>0&&q(`Warning: ${n.failed} file(s) failed to index and will be excluded.`);let a=(n.succeededFiles.length>0?n.succeededFiles:n.supported).map(e=>e.split(/[\\/]/).pop()||e),o=a.length===1?`Please analyze this document for me: ${a[0]}`:`Please analyze these documents for me:\n${a.map(e=>`- ${e}`).join(`
|
|
2
|
-
`)}`;r?l({sessionId:r,text:o}):await e(o),t(!1),U(new Set)}catch(e){n.doc.error(`Ask Agent failed`,e),X({filename:i.length===1?i[0].split(/[\\/]/).pop()||i[0]:`${i.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{$.current=!1,K(new Set),q(null)}},[H,r,s,S,l,t,e]),je=_?_.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],Me=je.map((e,t)=>({label:e,path:je.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Ne=pe(L),Pe=S.filter(e=>!j(e.name)),Fe=F?F.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):M?S:Pe,Ie=S.length-Pe.length;return(0,A.useEffect)(()=>{M||F||U(e=>{let t=[...e].filter(e=>!j(e.split(/[\\/]/).pop()??``));return t.length===e.size?e:new Set(t)})},[M,F]),o(`div`,{ref:d,className:`modal-overlay`,onClick:()=>t(!1),role:`dialog`,"aria-modal":`true`,"aria-label":`File browser`,children:i(`div`,{className:`modal-panel file-browser-modal ${W?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`modal-header`,children:[i(`h3`,{children:[o(p,{size:18}),` File browser`]}),o(`button`,{className:`btn-icon`,onClick:()=>t(!1),"aria-label":`Close`,children:o(x,{size:18})})]}),i(`div`,{className:`file-browser-body`,children:[o(`div`,{className:`fb-quick-links`,children:w.map(e=>i(`button`,{className:`fb-quick-link`,onClick:()=>Z(e.path),title:e.path,children:[me(e.icon),o(`span`,{children:e.name})]},e.path))}),i(`div`,{className:`fb-search-bar`,children:[i(`div`,{className:`fb-search-input-wrap`,children:[o(ae,{size:14,className:`fb-search-icon`}),o(`input`,{type:`text`,className:`fb-search-input`,placeholder:`Search files on your PC...`,value:N,onChange:e=>P(e.target.value),onKeyDown:Te,"aria-label":`Search files`}),N&&o(`button`,{className:`fb-search-clear`,onClick:()=>{P(``),I(null),R([])},"aria-label":`Clear search`,children:o(x,{size:12})})]}),o(`select`,{className:`fb-type-filter`,value:V,onChange:e=>be(e.target.value),"aria-label":`File type filter`,children:he.map(e=>o(`option`,{value:e.value,children:e.label},e.value))}),o(`button`,{className:`fb-search-btn`,onClick:Q,disabled:!N.trim()||z,children:z?`Searching...`:`Search`})]}),!F&&i(`div`,{className:`fb-pathbar`,children:[i(`div`,{className:`fb-breadcrumb`,children:[o(`button`,{className:`fb-crumb`,onClick:()=>Z(`/`),children:o(le,{size:12})}),Me.map((e,t)=>i(`span`,{className:`fb-crumb-item`,children:[o(ue,{size:12,className:`fb-crumb-sep`}),o(`button`,{className:`fb-crumb`,onClick:()=>Z(e.path),children:e.label})]},t)),y&&o(`button`,{className:`fb-up-btn`,onClick:()=>Z(y),title:`Go up`,children:o(ne,{size:14})})]}),i(`label`,{className:`fb-hidden-toggle`,children:[o(`input`,{type:`checkbox`,checked:M,onChange:e=>_e(e.target.checked)}),`Show hidden`]})]}),F&&i(`div`,{className:`fb-search-header`,children:[i(`div`,{className:`fb-search-summary`,children:[i(`span`,{children:[`Found `,F.length,` result(s) for "`,N,`"`]}),Ne&&i(`span`,{className:`fb-search-scope`,title:L.join(`
|
|
3
|
-
`),children:[`Searching in: `,o(`code`,{children:Ne})]}),ve&&o(`span`,{children:`Search stopped early, so some matches may be missing. Try a more specific name.`})]}),o(`button`,{className:`fb-back-btn`,onClick:()=>{I(null),P(``),R([])},children:`Back to browsing`})]}),O&&o(`div`,{className:`fb-error`,children:O}),i(`div`,{className:`fb-content`,children:[i(`div`,{className:`fb-file-list`,children:[E&&o(`div`,{className:`fb-loading`,children:`Loading...`}),!E&&Fe.length===0&&o(`div`,{className:`fb-empty`,children:F?`No files found`:Ie>0?`Only hidden items here. Turn on Show hidden to see them.`:`This folder is empty`}),!E&&Fe.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!h(t),r=n?b(t):null;return i(`div`,{className:`fb-entry ${e.type} ${H.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:[o(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:H.has(e.path),onChange:()=>Oe(e.path),onClick:e=>e.stopPropagation(),"aria-label":`Select ${e.name}`}),o(`span`,{className:`fb-entry-icon`,children:de(e)}),o(`span`,{className:`fb-entry-name`,title:e.path,children:e.name}),n&&o(`span`,{className:`fb-unsupported-badge`,children:`Not indexable`}),e.type===`file`&&o(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),De(e.path)},"aria-label":`Preview ${e.name}`,title:`Preview file`,children:o(m,{size:14})}),o(`span`,{className:`fb-entry-size`,children:e.type===`file`?ce(e.size):``}),o(`span`,{className:`fb-entry-date`,children:fe(e.modified)})]},e.path)})]}),W&&i(`div`,{className:`fb-preview`,children:[i(`div`,{className:`fb-preview-header`,children:[o(`span`,{className:`fb-preview-name`,children:W.name}),o(`button`,{className:`btn-icon-sm`,onClick:()=>G(null),"aria-label":`Close preview`,children:o(x,{size:14})})]}),i(`div`,{className:`fb-preview-meta`,children:[o(`span`,{children:W.size_display}),W.total_lines&&i(`span`,{children:[W.total_lines,` lines`]}),W.columns&&i(`span`,{children:[W.columns.length,` columns`]}),W.row_count!==null&&i(`span`,{children:[W.row_count,` rows`]})]}),W.columns&&i(`div`,{className:`fb-preview-columns`,children:[o(`strong`,{children:`Columns:`}),` `,W.columns.join(`, `)]}),xe?o(`div`,{className:`fb-preview-loading`,children:`Loading preview...`}):W.is_text&&W.preview_lines.length>0?o(`pre`,{className:`fb-preview-content`,children:W.preview_lines.slice(0,30).join(`
|
|
4
|
-
`)}):o(`div`,{className:`fb-preview-binary`,children:`Binary file - no preview available`})]})]}),Y&&o(g,{filename:Y.filename,error:Y.error,onDismiss:()=>X(null)}),i(`div`,{className:`fb-actions`,children:[o(`div`,{className:`fb-selection-info`,children:H.size>0?`${H.size} item(s) selected`:`Select files to index or analyze`}),we&&o(`span`,{className:`fb-index-status`,children:we}),i(`div`,{className:`fb-action-btns`,children:[i(`button`,{className:`fb-action-btn secondary`,onClick:ke,disabled:H.size===0||Ce.size>0,title:`Index selected files for RAG search`,children:[o(ie,{size:14}),`Index Selected`]}),i(`button`,{className:`fb-action-btn primary`,onClick:Ae,disabled:H.size===0||Ce.size>0,title:`Index and send selected files to the chat agent for analysis`,children:[o(te,{size:14}),`Ask Agent`]})]})]})]})]})})}export{M as FileBrowser};
|