@amd-gaia/agent-ui 0.26.0-rc.2 → 0.26.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/gaia-ui.cjs +19 -16
- package/dist/assets/{AdvancedSettings-DhQOkz13.js → AdvancedSettings-CaObX4Wa.js} +1 -1
- package/dist/assets/ConnectorsPane-D0I07qUd.js +1 -0
- package/dist/assets/{ConnectorsPane-CzLYXGMl.css → ConnectorsPane-DU5VkSj1.css} +1 -1
- package/dist/assets/{DocumentLibrary-Bxi2x5Ry.js → DocumentLibrary-CijRJVE8.js} +1 -1
- package/dist/assets/{FileBrowser-lOETG5oo.js → FileBrowser-BU-MxcRT.js} +1 -1
- package/dist/assets/{MemoryDashboard-Evh8x9AG.js → MemoryDashboard-BPAUphrI.js} +1 -1
- package/dist/assets/{MobileAccessModal-jZP8OcFv.js → MobileAccessModal-BSC78LTu.js} +1 -1
- package/dist/assets/{ScheduleManager-CoagpVqW.js → ScheduleManager-Bc1GA1nB.js} +1 -1
- package/dist/assets/api-BemWvhdJ.js +4 -0
- package/dist/assets/{index-D8wu2yy4.js → index-BbM3URRX.js} +20 -20
- package/dist/assets/{useT-C0ow1Kps.js → useT-DRJDft_1.js} +2 -2
- package/dist/assets/{zap-D2mvP3-6.js → zap-DSyPz4mM.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/sw.js +1 -1
- package/main.cjs +3 -0
- package/package.json +1 -1
- package/services/backend-installer.cjs +29 -15
- package/dist/assets/ConnectorsPane-DZSS3unX.js +0 -1
- package/dist/assets/api-9RdlUJAP.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as e}from"./useT-
|
|
1
|
+
import{q as e}from"./useT-DRJDft_1.js";var t={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};t.node;var n=e(t),r={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};r.node;var i=e(r);export{n,i as t};
|
package/dist/index.html
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
13
13
|
<meta name="apple-mobile-web-app-title" content="GAIA" />
|
|
14
14
|
<title>GAIA Agent UI</title>
|
|
15
|
-
<script type="module" crossorigin src="./assets/index-
|
|
15
|
+
<script type="module" crossorigin src="./assets/index-BbM3URRX.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="./assets/useT-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="./assets/api-
|
|
17
|
+
<link rel="modulepreload" crossorigin href="./assets/useT-DRJDft_1.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="./assets/api-BemWvhdJ.js">
|
|
19
19
|
<link rel="stylesheet" crossorigin href="./assets/index-LLooEbjq.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
package/dist/sw.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// never sees a stale UI or stale data.
|
|
10
10
|
|
|
11
11
|
const CACHE_PREFIX = 'gaia-assets-';
|
|
12
|
-
const CACHE_NAME = CACHE_PREFIX + '0.26.
|
|
12
|
+
const CACHE_NAME = CACHE_PREFIX + '0.26.0rc3-3dfb1c55e724af2f';
|
|
13
13
|
const ASSETS_PATH = new URL('assets/', self.registration.scope).pathname;
|
|
14
14
|
|
|
15
15
|
self.addEventListener('install', () => {
|
package/main.cjs
CHANGED
|
@@ -403,6 +403,9 @@ async function startBackend() {
|
|
|
403
403
|
PYTHONUNBUFFERED: "1",
|
|
404
404
|
...(app.isPackaged && {
|
|
405
405
|
GAIA_BUNDLED_LEMONADE_DIR: path.join(process.resourcesPath, "vendor", "lemonade"),
|
|
406
|
+
// The daemon exits once this is deleted: a Trashed macOS app or a
|
|
407
|
+
// deleted AppImage runs no uninstall step. An AppImage's exe is a mount.
|
|
408
|
+
GAIA_APP_PATH: process.env.APPIMAGE || app.getPath("exe"),
|
|
406
409
|
}),
|
|
407
410
|
},
|
|
408
411
|
detached: false,
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
35
|
|
|
36
|
-
const { spawn, spawnSync,
|
|
36
|
+
const { spawn, spawnSync, execFileSync } = require("child_process");
|
|
37
37
|
const crypto = require("crypto");
|
|
38
38
|
const fs = require("fs");
|
|
39
39
|
const path = require("path");
|
|
@@ -437,16 +437,24 @@ function makeProgressReporter(onProgress) {
|
|
|
437
437
|
// ── Command helpers ──────────────────────────────────────────────────────────
|
|
438
438
|
|
|
439
439
|
/**
|
|
440
|
-
* Check if a command exists on PATH.
|
|
440
|
+
* Check if a command exists on PATH. Throws when the lookup itself can't run.
|
|
441
441
|
*/
|
|
442
442
|
function commandExists(cmd) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
443
|
+
// `command -v` is a shell built-in, so it works where `which` isn't installed; the name is $1, never script text.
|
|
444
|
+
const [file, args] = IS_WINDOWS
|
|
445
|
+
? ["where", [cmd]]
|
|
446
|
+
: ["sh", ["-c", 'command -v "$1"', "sh", cmd]];
|
|
447
|
+
const result = spawnSync(file, args, { stdio: "ignore", shell: false, windowsHide: true });
|
|
448
|
+
if (result.error || result.status === null) {
|
|
449
|
+
const reason = result.error ? result.error.message : `killed by ${result.signal}`;
|
|
450
|
+
throw new InstallError(`Could not check whether "${cmd}" is on PATH: running ${file} failed (${reason}).`, {
|
|
451
|
+
code: result.error ? result.error.code : null,
|
|
452
|
+
suggestion: IS_WINDOWS
|
|
453
|
+
? "Make sure C:\\Windows\\System32 is on PATH, then restart GAIA."
|
|
454
|
+
: "Make sure /bin/sh exists and /bin is on PATH, then restart GAIA.",
|
|
455
|
+
});
|
|
449
456
|
}
|
|
457
|
+
return result.status === 0;
|
|
450
458
|
}
|
|
451
459
|
|
|
452
460
|
/**
|
|
@@ -842,14 +850,20 @@ function checkDiskSpace() {
|
|
|
842
850
|
logError(`statfsSync failed: ${err.message}`);
|
|
843
851
|
}
|
|
844
852
|
|
|
845
|
-
// Fallback: platform-specific
|
|
853
|
+
// Fallback: platform-specific tools. Non-fatal if unavailable.
|
|
846
854
|
try {
|
|
847
855
|
if (IS_WINDOWS) {
|
|
848
|
-
//
|
|
849
|
-
const drive = path.parse(parent).root.replace(
|
|
850
|
-
const out =
|
|
851
|
-
|
|
852
|
-
|
|
856
|
+
// The drive letter reaches PowerShell through the environment, not the script text.
|
|
857
|
+
const drive = path.parse(parent).root.replace(/[:\\]+$/, "");
|
|
858
|
+
const out = execFileSync(
|
|
859
|
+
"powershell",
|
|
860
|
+
["-NoProfile", "-Command", "(Get-PSDrive -Name $env:GAIA_DISK_DRIVE).Free"],
|
|
861
|
+
{
|
|
862
|
+
encoding: "utf8",
|
|
863
|
+
timeout: 5000,
|
|
864
|
+
windowsHide: true,
|
|
865
|
+
env: { ...process.env, GAIA_DISK_DRIVE: drive },
|
|
866
|
+
}
|
|
853
867
|
).trim();
|
|
854
868
|
const freeBytes = parseInt(out, 10);
|
|
855
869
|
if (!Number.isNaN(freeBytes)) {
|
|
@@ -861,7 +875,7 @@ function checkDiskSpace() {
|
|
|
861
875
|
}
|
|
862
876
|
} else {
|
|
863
877
|
// `df -k <parent>` — second line, 4th column is available 1K blocks.
|
|
864
|
-
const out =
|
|
878
|
+
const out = execFileSync("df", ["-k", parent], { encoding: "utf8", timeout: 5000 });
|
|
865
879
|
const lines = out.trim().split("\n");
|
|
866
880
|
if (lines.length >= 2) {
|
|
867
881
|
const cols = lines[lines.length - 1].trim().split(/\s+/);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{I as t,J as n,a as r,c as i,f as a,l as o,o as s,u as c}from"./useT-C0ow1Kps.js";import{Cn as l,Dn as u,En as d,Sn as f,Tn as p,_n as m,bn as h,gn as g,hn as _,mn as v,pn as y,vn as b,wn as x,xn as S,yn as C}from"./api-9RdlUJAP.js";import{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-D8wu2yy4.js";var N=e(n(),1),P=t.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=null,n=1e3,r=null,i=!1,a=()=>{i||(e=new EventSource(`${s()}/connectors/events`),e.onopen=()=>{n=1e3},e.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)}},e.onerror=()=>{e?.close(),e=null,!i&&(r=setTimeout(a,n),n=Math.min(n*2,3e4))})};return a(),()=>{i=!0,r&&clearTimeout(r),e?.close()}},[])}function L(e){return e.type===`mcp_server`&&e.configured}function R({connector:e,onChanged:t}){let n=r(),[i,a]=(0,N.useState)(!1),[s,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(null),[f,p]=(0,N.useState)(null),m=(0,N.useRef)(null),g=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;m.current&&!m.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(!m.current)return;let e=m.current.getBoundingClientRect();p({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 v=e=>{e.stopPropagation(),e.preventDefault()},y=e=>{if(v(e),!i&&m.current){let e=m.current.getBoundingClientRect();p({top:e.bottom+4,right:window.innerWidth-e.right})}a(e=>!e)},x=async e=>{l(!0),d(null);try{await e(),a(!1),t()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}};return c(`div`,{className:`connector-tile-menu`,onClick:v,onKeyDown:v,children:[o(`button`,{ref:m,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-label":n(`settings.connectors.actions`),onClick:y,disabled:s,children:o(D,{size:14})}),i&&f&&c(`div`,{ref:g,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:f.top,right:f.right},children:[e.enabled?o(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void x(()=>b(e.id)),disabled:s,children:n(`settings.connectors.disable`)}):o(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void x(()=>h(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(()=>C(e.id)),disabled:s,children:n(`settings.connectors.disconnect`)}),u&&o(`div`,{className:`connector-tile-menu-error`,children:u})]})]})}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=r(),[t,n]=(0,N.useState)([]),[a,s]=(0,N.useState)([]),[u,f]=(0,N.useState)(!0),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null),[_,v]=(0,N.useState)(null),[y,b]=(0,N.useState)(``),x=(0,N.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:t}]=await Promise.all([d(),l()]);n(e),s(t),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[]);(0,N.useEffect)(()=>{x()},[x]);let C=e=>v(t=>t===e?null:e),w=(0,N.useCallback)(async e=>{try{let t=await S(e);n(n=>n.map(n=>n.id===e?t:n))}catch{x()}},[x]);I((0,N.useCallback)(t=>{t.reason===`disconnected`&&g(U(t.payload,e)),t.connectorId?w(t.connectorId):x()},[w,x,e]));let T=y.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:_===e.id,onToggle:()=>C(e.id),onChanged:()=>void w(e.id)},e.id))});return c(`section`,{className:`connectors-section`,"aria-label":e(`settings.section.connectors`),children:[o(`p`,{className:`settings-pane-lede`,children:e(`settings.connectors.lede`)}),p&&c(`div`,{className:`error-banner`,children:[o(E,{size:14}),o(`span`,{children:p})]}),h&&c(`div`,{className:`error-banner`,role:`status`,onClick:()=>g(null),children:[o(E,{size:14}),o(`span`,{children:h})]}),u?o(`div`,{className:`connectors-loading`,children:o(M,{size:16,className:`spin`})}):c(i.Fragment,{children:[t.length>V&&o(`input`,{className:`settings-input`,type:`search`,value:y,onChange:e=>b(e.target.value),placeholder:e(`settings.connectors.search`),"aria-label":e(`settings.connectors.search`)}),t.length===0&&!p&&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:_,onToggle:C})})]})]})}function G({connector:e,expanded:t,onToggle:n,onChanged:i}){let a=r();return c(`div`,{className:`connector-tile${t?` connector-tile--open`:``}`,children:[c(`div`,{className:`connector-tile-row`,children:[c(`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`)}):c(`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&&c(`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=r(),[s,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(null),[f,p]=(0,N.useState)({}),[m,h]=(0,N.useState)(null),{agents:y}=a(),b=y.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()=>{l(!0),d(null);try{let t=await v(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{l(!1)}},j=async()=>{l(!0),d(null),h(null);try{let t=await _(e.id,e.available_scopes?.length?e.available_scopes:e.default_scopes,O());h(t)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}};(0,N.useEffect)(()=>{e.configured&&h(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`))),h(null)):t.reason===`oauth_completed`&&h(null))},[e.id,n]));let P=async()=>{l(!0),d(null);try{await C(e.id),t()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},F=async()=>{let r=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!f[e.key]?.trim()).map(e=>e.label);if(r.length)d(n(`settings.connectors.required`,{fields:r.join(`, `)}));else{l(!0),d(null);try{let n=e.available_scopes?.length?e.available_scopes:e.default_scopes,r=await g(e.id,{...f,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{l(!1)}}},L=e.oauth_setup_fields??[],R=e.configurable===!1&&!e.configured&&L.length>0;return c(`div`,{className:`configure-body`,children:[e.description&&o(`p`,{className:`connector-desc`,children:o(`bdi`,{children:e.description})}),R&&c(`div`,{className:`oauth-setup-form`,children:[o(`p`,{className:`connector-desc`,children:n(`settings.connectors.firstSetup`)}),L.map(e=>c(`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:f[e.key]??``,onChange:t=>p(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&&c(`div`,{className:`oauth-grant-onconnect`,children:[o(`p`,{className:`oauth-grant-onconnect-label`,children:n(`settings.connectors.grantOnConnect`)}),b.map(e=>c(`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}),u&&c(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,u]}),c(`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`}):c(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`)}):c(i.Fragment,{children:[o(`button`,{className:`btn-primary`,disabled:s||m!==null,onClick:()=>void A(),children:s?o(M,{size:12,className:`spin`}):c(i.Fragment,{children:[o(w,{size:12}),` `,n(`settings.key.connect`)]})}),e.supports_device_code&&o(`button`,{className:`btn-secondary`,disabled:s||m!==null,onClick:()=>void j(),title:n(`settings.connectors.codeTitle`),children:n(`settings.connectors.code`)})]}),(e.docs_url||e.product_url)&&c(`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})]})]}),m&&!e.configured&&c(`div`,{className:`device-code-block`,children:[c(`p`,{className:`device-code-instructions`,children:[n(`settings.connectors.goTo`),` `,o(`a`,{href:m.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),k(m.verification_uri)},children:m.verification_uri})]}),c(`div`,{className:`device-code-value`,children:[o(`code`,{children:m.user_code}),o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(m.user_code),title:n(`settings.connectors.copyCode`),children:n(`gpu.copy`)})]}),c(`p`,{className:`device-code-waiting`,children:[o(M,{size:12,className:`spin`}),` `,n(`settings.connectors.waiting`)]}),o(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>h(null),children:n(`settings.key.cancel`)})]})]})}function q({connector:e,onChanged:t}){let n=r(),[a,s]=(0,N.useState)(!1),[l,u]=(0,N.useState)({}),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(!1),[h,_]=(0,N.useState)(null),v=e.oauth_setup_fields??[];if(v.length===0)return null;let y=e.oauth_client,b=y?.source===`keyring`?n(`settings.connectors.savedClient`,{id:y.client_id??``}):y?.source===`env`?n(`settings.connectors.envClient`,{id:y.client_id??``}):n(`settings.connectors.noClient`),x=async()=>{if(!l.client_id?.trim())_(n(`settings.connectors.clientRequired`));else{f(!0),_(null),m(!1);try{await g(e.id,{...Object.fromEntries(Object.entries(l).map(([e,t])=>[e,t.trim()])),save_only:!0}),m(!0),u({}),t(),setTimeout(()=>m(!1),2200)}catch(e){_(e instanceof Error?e.message:String(e))}finally{f(!1)}}};return c(`div`,{className:`oauth-client-editor`,children:[c(`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:b})]}),a&&c(`div`,{className:`oauth-setup-form`,children:[o(`p`,{className:`connector-desc`,children:n(`settings.connectors.clientHelp`)}),v.map(e=>c(`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`&&y?.source===`keyring`&&y.has_secret?`••••••••`:e.placeholder,value:l[e.key]??``,onChange:t=>u(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)),h&&c(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,h]}),o(`div`,{className:`configure-actions`,children:o(`button`,{className:`btn-model-save${p?` saved`:``}`,disabled:d||!l.client_id?.trim(),onClick:()=>void x(),children:d?o(M,{size:12,className:`spin`}):p?c(i.Fragment,{children:[o(T,{size:12}),` `,n(`settings.advanced.saved`)]}):n(`settings.connectors.saveClient`)})})]})]})}function J({connector:e,onChanged:t}){let n=r(),[a,s]=(0,N.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),[p,m]=(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,v=Object.values(a).every(e=>e.trim()===``),y=async()=>{let n=Object.fromEntries(Object.entries(a).filter(([,e])=>e.trim()!==``));if(_||Object.keys(n).length!==0){u(!0),m(null),f(!1);try{await g(e.id,n),f(!0),t(),setTimeout(()=>f(!1),2200)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}},x=async()=>{u(!0),m(null);try{await C(e.id),s(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}},S=async()=>{u(!0),m(null);try{e.enabled?await b(e.id):await h(e.id),t()}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}};return c(`div`,{className:`configure-body`,children:[e.description&&o(`p`,{className:`connector-desc`,children:o(`bdi`,{children:e.description})}),p&&c(`div`,{className:`configure-error`,children:[o(E,{size:12}),` `,p]}),e.configured&&c(`div`,{className:`connector-toggle-row`,children:[o(`span`,{className:`connector-toggle-label`,children:n(`settings.connectors.active`)}),c(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void S(),disabled:l,"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=>c(`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)),c(`div`,{className:`configure-actions`,children:[!(_&&e.configured)&&o(`button`,{className:`btn-model-save${d?` saved`:``}`,disabled:l||!_&&v,onClick:()=>void y(),children:l?o(M,{size:12,className:`spin`}):d?c(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:l,onClick:()=>void x(),children:n(`settings.connectors.disconnect`)}),e.product_url&&c(`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=r(),s=e.required_connections?.find(e=>e.connector_id===t),l=e.namespaced_agent_id;if(!s||!l)return null;let[d,p]=(0,N.useState)(()=>new Set(n)),[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(null);(0,N.useEffect)(()=>{p(new Set(n))},[n.join(`,`)]);let v=async e=>{if(m!==null)return;let r=new Set(d);r.has(e)?r.delete(e):r.add(e),p(r),h(e),_(null);try{r.size===0?await u(t,l):await f(t,l,[...r]),i()}catch(e){p(new Set(n)),_(e instanceof Error?e.message:String(e))}finally{h(null)}};return c(`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=>c(`label`,{className:`grant-scope-item`,children:[o(`span`,{className:`grant-scope-label`,children:B(e,a)}),c(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:d.has(e),onChange:()=>void v(e),disabled:m!==null}),o(`span`,{className:`toggle-track`})]})]},e))}),g&&c(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[o(E,{size:11}),` `,g]})]})}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=r(),a=[e.command,...e.args].join(` `);return c(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[c(`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`)}):c(`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&&c(`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=r(),{agents:s}=a(),[l,u]=(0,N.useState)({}),[d,f]=(0,N.useState)({}),[m,h]=(0,N.useState)(!0),g=(0,N.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([p(e),x(e)]);u(t),f(n)}catch{u({}),f({})}finally{h(!1)}},[e]);if((0,N.useEffect)(()=>{g()},[g]),I((0,N.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&g()},[e,g])),m)return null;let _=s.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),v=t===`mcp_server`?s.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return c(`div`,{className:`connection-grants`,children:[o(`div`,{className:`grants-header`,children:n(`settings.connectors.grants`)}),_.length===0?o(`div`,{className:`grants-empty`,children:n(`settings.connectors.noGrants`)}):_.map(t=>o(Y,{agent:t,connectorId:e,grantedScopes:l[t.namespaced_agent_id]??[],onChanged:()=>void g()},t.namespaced_agent_id)),v.length>0&&c(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`)}),v.map(t=>o($,{agent:t,connectorId:e,active:!!d[t.namespaced_agent_id],grantedScopes:l[t.namespaced_agent_id]??[],onChanged:()=>void g()},`activation-${t.namespaced_agent_id}`))]})]})}function $({agent:e,connectorId:t,active:n,grantedScopes:i,onChanged:a}){let s=r(),l=e.required_connections?.find(e=>e.connector_id===t),u=e.namespaced_agent_id;if(!u)return null;let[d,f]=(0,N.useState)(n),[p,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(null);(0,N.useEffect)(()=>{f(n)},[n]);let v=async()=>{if(p)return;let e=!d;f(e),h(!0),_(null);try{if(e){let e=i.length===0?l?[...l.scopes]:[...H]:void 0;await y(t,u,e)}else await m(t,u);a()}catch(e){f(n),_(e instanceof Error?e.message:String(e))}finally{h(!1)}};return c(`div`,{className:`grant-agent-card`,children:[o(`bdi`,{className:`grant-agent-card-name`,children:e.name}),o(`div`,{className:`grant-scope-list`,children:c(`label`,{className:`grant-scope-item`,children:[o(`span`,{className:`grant-scope-label`,children:s(d?`settings.connectors.toolsVisible`:`settings.connectors.toolsHidden`)}),c(`span`,{className:`toggle-switch`,children:[o(`input`,{type:`checkbox`,checked:d,onChange:()=>void v(),disabled:p}),o(`span`,{className:`toggle-track`})]})]})}),g&&c(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[o(E,{size:11}),` `,g]})]})}function ee(){let e=r();return c(`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{I as e,o as t}from"./useT-C0ow1Kps.js";var n=`gaia:draft:`,r=e=>`chat:${e}`,i=`new-chat`;function a(t){try{return localStorage.getItem(n+t)??``}catch(n){return e.ui.warn(`Couldn't read the saved draft for ${t}`,n),``}}function o(t,r){try{r?localStorage.setItem(n+t,r):localStorage.removeItem(n+t)}catch(n){e.ui.warn(`Couldn't save the draft for ${t}`,n)}}function s(e){o(e,``)}function c(e){if(!(e instanceof L)||e.httpStatus!==409||!e.body)return null;let{code:t,acknowledge:n}=e.body;return(t===`no_fit`||t===`low_disk`)&&typeof n==`string`?e.body:null}async function l(){return V(`GET`,`/onboarding/preflight`)}async function u(e=!1){return V(`GET`,`/setup/check?skip_chat_model=${e}`)}async function d(e,t=!1,n={}){return V(`POST`,`/setup/run`,{skip_chat_model:e,gaia_lemonade:t,acknowledge_low_disk:!!n.acknowledgeLowDisk,keep_trying:!!n.keepTrying,extra_models:n.extraModels??[],server_only:!!n.serverOnly,upgrade_embedded:!!n.upgradeEmbedded})}async function f(e){return V(`POST`,`/setup/cancel`,e?{model_id:e}:void 0)}async function p(e,t){return V(`POST`,`/setup/models/skip`,{model_id:e,skipped:t})}async function m(e,t={}){return V(`POST`,`/setup/models/download`,{model_id:e,acknowledge_low_disk:!!t.acknowledgeLowDisk,keep_trying:!!t.keepTrying})}async function h(e){return V(`POST`,`/setup/models/remove`,{model_id:e})}async function g(){return V(`GET`,`/setup/status`)}async function ee(){return V(`GET`,`/setup/plan`)}async function te(e,t=!1){return V(`POST`,`/setup/chat-model`,{model_id:e,acknowledge_no_fit:t})}async function ne(){return V(`POST`,`/setup/npu/recheck`)}async function re(){return V(`POST`,`/setup/npu/memlock-fix`)}async function ie(e){return V(`POST`,`/setup/vision-model`,{model_id:e})}async function ae(e){return V(`GET`,`/setup/needs/${e}`)}async function oe(e){return V(`GET`,e==null?`/gpu-memory`:`/gpu-memory?setting_gb=${e}`)}async function se(e){return V(`POST`,`/gpu-memory/apply`,{setting_gb:e,confirm:!0})}async function ce(){return V(`POST`,`/gpu-memory/revert`,{confirm:!0})}async function le(e){return V(`POST`,`/gpu-memory/pending`,{setting_gb:e})}async function ue(){return V(`DELETE`,`/gpu-memory/pending`)}async function de(){return V(`GET`,`/onboarding/start`)}async function fe(){return V(`POST`,`/setup/report`)}async function pe(e){let n=await fetch(`${t()}/setup/report/${encodeURIComponent(e)}`,{headers:B});if(!n.ok)throw new L(`Couldn't read the report (HTTP ${n.status}).`,n.status,await n.text().catch(()=>``),null);return n.blob()}async function me(){return V(`GET`,`/connectors`)}async function he(e){return V(`GET`,`/connectors/${e}`)}async function ge(e,t,n=[]){return V(`POST`,`/connectors/${e}/authorize`,{scopes:t,grant_agents:n},B)}async function _e(e,t,n=[]){return V(`POST`,`/connectors/${e}/authorize-device`,{scopes:t,grant_agents:n},B)}async function ve(e,t){return V(`POST`,`/connectors/${e}/configure`,{config:t},B)}async function ye(e){await V(`DELETE`,`/connectors/${e}`,void 0,B)}async function _(e){return V(`POST`,`/connectors/${e}/enable`,{},B)}async function v(e){return V(`POST`,`/connectors/${e}/disable`,{},B)}async function y(){return V(`GET`,`/connectors/agent-mcps`)}async function b(e){return V(`GET`,`/connectors/${e}/grants`)}async function x(e,t,n){await V(`PUT`,`/connectors/${e}/grants/${encodeURIComponent(t)}`,{scopes:n},B)}async function S(e,t){await V(`DELETE`,`/connectors/${e}/grants/${encodeURIComponent(t)}`,void 0,B)}async function C(e){return V(`GET`,`/connectors/${e}/activations`)}async function w(e,t,n){return V(`PUT`,`/connectors/${e}/activations/${encodeURIComponent(t)}`,n?{scopes:n}:{},B)}async function T(e,t){await V(`DELETE`,`/connectors/${e}/activations/${encodeURIComponent(t)}`,void 0,B)}async function E(e){return V(`POST`,`/chat/cancel`,{session_id:e})}async function D(e,t){return V(`POST`,`/chat/followup`,{session_id:e,text:t})}async function O(e){return V(`GET`,`/chat/followup/${encodeURIComponent(e)}`)}async function k(e){return V(`GET`,`/chat/context/${encodeURIComponent(e)}`)}async function A(e){return V(`GET`,`/chat/performance/${encodeURIComponent(e)}`)}async function j(e,t,n){return V(`POST`,`/chat/retry-with`,{session_id:e,message_id:t,model:n})}async function M(e,t,n){return V(`POST`,`/chat/retry-with/choose`,{session_id:e,message_id:t,keep:n})}async function N(){return V(`GET`,`/chat/active`)}async function P(e,t,n={}){return V(`POST`,`/chat/confirm-tool`,{session_id:e,approved:t,always:n.always??!1,...n.confirmId?{confirm_id:n.confirmId}:{}})}async function be(e,t,n){return V(`POST`,`/chat/user-input`,{session_id:e,request_id:t,value:n})}async function xe(e){return V(`GET`,`/chat/permissions/${encodeURIComponent(e)}`)}async function Se(){return V(`GET`,`/chat/permissions`)}async function Ce(e){return V(`PUT`,`/chat/permissions`,{mode:e})}async function we(e,t){return V(`PUT`,`/chat/permissions/${encodeURIComponent(e)}`,{mode:t})}async function Te(e,t){let n=t?`?key=${encodeURIComponent(t)}`:``;return V(`DELETE`,`/chat/permissions/${encodeURIComponent(e)}/grants${n}`)}function F(e){try{let t=JSON.parse(e).detail;return Array.isArray(t)?t.map(e=>e?.msg??JSON.stringify(e)).join(`; `)||e:t&&typeof t==`object`&&typeof t.message==`string`?t.message:t&&typeof t!=`string`?JSON.stringify(t):t||e}catch{return e}}function I(e){try{let t=JSON.parse(e).detail?.status;return typeof t==`string`?t:null}catch{return null}}function Ee(e){try{let t=JSON.parse(e).detail;return Array.isArray(t)?t.map(e=>Array.isArray(e?.loc)?e.loc[e.loc.length-1]:void 0).filter(e=>typeof e==`string`):[]}catch{return[]}}function De(e){try{let t=JSON.parse(e).detail;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}}var L=class extends Error{httpStatus;detail;reason;fields;body;constructor(e,t,n,r,i=[],a=null){super(e),this.name=`ApiError`,this.httpStatus=t,this.detail=n,this.reason=r,this.fields=i,this.body=a}};function R(e){return e.trim().toLowerCase()===`internal server error`}function Oe(e){let t=e.trim();return t!==``&&!R(t)&&!/^[<{[]/.test(t)}function z(e,t){switch(e){case 403:return t||`Access denied.`;case 404:return t||`The requested item was not found.`;case 413:return t||`File too large to process.`;case 500:return Oe(t)?t:`Server error. Please try again.`;case 502:return`Service unavailable. Is the backend running?`;case 503:return t||`Service unavailable.`;default:return t||`Request failed (HTTP ${e})`}}var B={"x-gaia-ui":`1`,"x-gaia-client":`agent-ui`},ke=/key|token|secret|password/i;function Ae(e){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ke.test(e)&&typeof t==`string`&&t?`***`:t]))}async function V(n,r,i,a,o){let s=`${t()}${r}`,c=e.api.time();e.api.info(`${n} ${s}`,i===void 0?``:{body:Ae(i)});let l=i===void 0?{}:{"Content-Type":`application/json`},u={method:n,headers:{...B,...a,...l},body:i===void 0?void 0:JSON.stringify(i),signal:o},d;try{d=await fetch(s,u)}catch(t){throw e.api.error(`${n} ${s} - network error`,t),t}if(!d.ok){let t=await d.text().catch(()=>``);e.api.error(`${n} ${s} - HTTP ${d.status}`,{errorText:t});let r=F(t);throw new L(z(d.status,r),d.status,r,I(t),Ee(t),De(t))}let f=d.headers.get(`content-type`)||``;if(!f.includes(`application/json`)){let t=await d.text().catch(()=>``);if(d.status===204||t.trim()===``){e.api.timed(`${n} ${s} -> ${d.status} (no body)`,c);return}throw e.api.error(`${n} ${s} -> ${d.status} (non-JSON body)`,{contentType:f,preview:t.slice(0,200)}),Error(`${n} ${r}: expected JSON, got ${f||`no Content-Type`} (HTTP ${d.status}: ${t.slice(0,120)})`)}let p=await d.json();return e.api.timed(`${n} ${s} -> ${d.status}`,c,p),p}async function je(e){return V(`GET`,`/system/status`,void 0,void 0,e)}async function Me(e){return V(`GET`,`/system/resources`,void 0,void 0,e)}async function Ne(e=!1){return V(`POST`,e?`/system/warm-up?fresh=true`:`/system/warm-up`)}async function Pe(){return V(`GET`,`/system/warm-up`)}async function Fe(){return V(`GET`,`/system/model-server`)}async function Ie(e){return V(`PUT`,`/system/model-server/backend`,{backend:e})}async function Le(){return V(`GET`,`/settings`)}async function Re(e){return V(`PUT`,`/settings`,e)}async function H(e,t,n=!1){return V(`POST`,`/system/load-model`,{model_name:e,ctx_size:t,force:n})}async function ze(e,t,n=e=>window.confirm(e)){try{return await H(e,t),!0}catch(r){if(!(r instanceof L)||r.httpStatus!==409)throw r;return n(`${r.detail}
|
|
2
|
-
|
|
3
|
-
Load ${e} anyway?`)?(await H(e,t,!0),!0):!1}}async function Be(e,t=!1,n=!1){return V(`POST`,`/system/download-model`,{model_name:e,force:t,load_after:n})}async function Ve(){return V(`GET`,`/agents`)}async function He(e){return V(`POST`,`/agents/install`,{id:e})}async function Ue(e){return V(`GET`,`/agents/${encodeURIComponent(e)}/install-status`)}async function We(){return V(`GET`,`/lemonade/target`)}async function Ge(){return V(`GET`,`/lemonade/detect`)}async function Ke(e){try{return await V(`POST`,`/lemonade/target`,e)}catch(e){throw e instanceof L&&e.httpStatus===502&&e.detail?new L(e.detail,e.httpStatus,e.detail,e.reason,e.fields):e}}async function qe(){return V(`GET`,`/providers`)}async function Je(){return V(`GET`,`/providers/active`)}async function Ye(e,t){return V(`POST`,`/providers/${encodeURIComponent(e)}/connect`,t)}var Xe=2e3;async function Ze(e,t,n,r=()=>!1){for(;;)try{return await Ye(e,t)}catch(e){if(!(e instanceof L)||e.httpStatus!==409||r())throw e;n(e.detail),await new Promise(e=>setTimeout(e,Xe))}}async function Qe(e){return V(`DELETE`,`/providers/${encodeURIComponent(e)}/key`)}async function $e(e){return V(`GET`,`/providers/${encodeURIComponent(e)}/models`)}async function et(e){return V(`GET`,`/providers/local/context?model=${encodeURIComponent(e)}`)}async function tt(e,t){return V(`PUT`,`/providers/local/context`,{model:e,ctx_size:t})}async function nt(){return V(`GET`,`/providers/local/status`)}async function rt(e=!1){return V(`POST`,`/providers/local/restart`,{confirm:e})}async function it(e){return V(`POST`,`/providers/select`,{model:e})}async function at(e,t){return V(`POST`,`/providers/local/custom/check`,{url:e,quant:t||null})}async function ot(e,t){return V(`POST`,`/providers/local/custom`,{url:e,quant:t||null})}async function st(e){return V(`DELETE`,`/providers/local/custom/${encodeURIComponent(e)}`)}async function ct(e){return V(`GET`,`/spending/prices/${encodeURIComponent(e)}`)}async function lt(){return V(`GET`,`/spending`)}async function ut(e,t,n){let r=new URLSearchParams({since:t});return n&&r.set(`model`,n),V(`GET`,`/spending/chat/${encodeURIComponent(e)}?${r}`)}async function dt(e){return V(`PUT`,`/spending/limit`,{limit_usd:e})}async function ft(){return V(`POST`,`/spending/allow-month`)}async function pt(){return V(`GET`,`/skills`)}async function mt(){let e=new Map,t=0;for(let n=0;;n+=200){let r=await V(`GET`,`/sessions?limit=200&offset=${n}`);t=r.total;for(let t of r.sessions)e.has(t.id)||e.set(t.id,t);if(r.sessions.length<200||n+200>=t)break}return{sessions:[...e.values()],total:t}}async function ht(e={}){return V(`POST`,`/sessions`,e)}async function gt(e,t){return V(`PUT`,`/sessions/${e}`,t)}async function _t(e){await V(`DELETE`,`/sessions/${e}`),s(r(e))}async function vt(e){return V(`GET`,`/sessions/${e}`)}async function yt(e,t){return V(`PUT`,`/sessions/${e}/pin`,{pinned:t})}async function bt(e,t,n){return V(`GET`,`/sessions/search?${new URLSearchParams({q:e,include_automated:String(t)})}`,void 0,void 0,n)}async function xt(e){return V(`POST`,`/sessions/${e}/read`)}async function St(e){return V(`PATCH`,`/sessions/${e}/private`)}async function Ct(e){let{total:t}=await V(`GET`,`/sessions/${e}/messages?limit=1&offset=0`);return t}async function wt(e){let t=`/sessions/${e}/messages`,n=await V(`GET`,`${t}?limit=100&offset=0`),r=[...n.messages],i=n.total;for(;r.length<i;){let e=await V(`GET`,`${t}?limit=${Math.min(100,i-r.length)}&offset=${r.length}`);if(e.messages.length===0)throw Error(`Incomplete transcript received. Please reload the conversation.`);r.push(...e.messages)}return{messages:r,total:i}}async function Tt(e){return V(`GET`,`/sessions/${e}/export?format=markdown`)}async function Et(e,t){return V(`DELETE`,`/sessions/${e}/messages/${t}`)}async function Dt(e,t){return V(`DELETE`,`/sessions/${e}/messages/${t}/and-below`)}var Ot=new Set([`status`,`step`,`thinking`,`commentary`,`plan`,`tool_start`,`tool_end`,`tool_result`,`tool_args`,`tool_confirm`,`skill_use`,`agent_error`,`permission_request`,`needs_confirmation`,`needs_input`,`policy_alert`,`followup_taken`,`followup_returned`,`followup_unavailable`,`context_usage`]);function kt(n,r,i,a,o,s,c){let l;l=typeof i==`function`?{onChunk:i,onAgentEvent:()=>{},onDone:a||(()=>{}),onError:o||(t=>{e.stream.error(`Unhandled stream error`,t)})}:i;let u=new AbortController,d=e.stream.time();e.stream.info(`Starting SSE stream for session=${n}`,{messageLength:r.length});let f=Y(u,l,U,Mt);return fetch(`${t()}/chat/send`,{method:`POST`,headers:{...B,"Content-Type":`application/json`},body:JSON.stringify({session_id:n,message:r,stream:!0,...s?{agent_type:s}:{},...c?{device:c}:{}}),signal:u.signal}).then(e=>(f.received(),f.connected(),X(e,l,d,{silentCloseIsError:!0}))).catch(t=>{f.received(),f.timedOut()?(e.stream.error(`No answer to /chat/send within ${U/1e3}s`),l.onError(new J(`send`,U))):t.name===`AbortError`?e.stream.warn(`Stream aborted by user`):(e.stream.error(`Stream fetch error`,t),l.onError(t))}),u}var At=3e4,jt=6e5,U=9e4,Mt=3e3,W=`Waiting for GAIA to start this answer…`,G=3e4,K=class extends Error{idleMs;constructor(e){super(`The connection to GAIA went silent for ${Math.round(e/1e3)} s.`),this.idleMs=e,this.name=`StreamStalledError`}},q=class extends Error{cause;unreachable;constructor(e,t=!1){super(`The connection to GAIA was cut: ${e instanceof Error?e.message:String(e)}`),this.cause=e,this.unreachable=t,this.name=`StreamDroppedError`}},J=class extends Error{endpoint;timeoutMs;constructor(e,t){super(`GAIA did not start answering within ${Math.round(t/1e3)} s.`),this.endpoint=e,this.timeoutMs=t,this.name=`StreamTimeoutError`}};function Y(e,t,n,r){let i=!1,a=r===void 0?void 0:setTimeout(()=>{t.onAgentEvent({type:`status`,status:`working`,phase:`waiting`,message:W})},r),o=setTimeout(()=>{i=!0,e.abort()},n),s=!1;return{received:()=>{clearTimeout(a),clearTimeout(o)},connected:()=>{s||(s=!0,t.onConnected?.())},timedOut:()=>i}}async function Nt(e,t){let n,r=new Promise((e,r)=>{n=setTimeout(()=>r(new K(t)),t)});try{return await Promise.race([e.read(),r])}finally{clearTimeout(n)}}async function X(t,n,r,{silentCloseIsError:i=!1}={}){if(e.stream.info(`SSE connection opened -> HTTP ${t.status}`),!t.ok){let r=await t.text().catch(()=>``);e.stream.error(`SSE connection failed: HTTP ${t.status}`,r);let i=F(r),a=i&&!R(i)?i:z(t.status,i);n.onError(new L(a,t.status,i,I(r)));return}let a=t.body?.getReader();if(!a){e.stream.error(`No response body reader available`),n.onError(Error(`No response body`));return}let o=new TextDecoder,s=``,c=!1,l=0,u=0,d=0,f=!1,p=!1,m=!1;try{for(;;){let t;try{t=await Nt(a,f?jt:At)}catch(t){if(t?.name===`AbortError`)throw t;if(!(t instanceof K)){if(e.stream.error(`SSE connection cut mid-stream`,t),c||p)return;if(m)break;throw new q(t)}if(e.stream.error(`SSE stream silent for ${t.idleMs/1e3}s; dropping the connection`),await a.cancel().catch(t=>e.stream.warn(`Could not cancel the stalled stream`,t)),c||p)return;if(m)break;throw t}let{done:i,value:h}=t;if(i){e.stream.debug(`SSE reader done (stream ended)`);break}s+=o.decode(h,{stream:!0});let g=s.split(`
|
|
4
|
-
`);s=g.pop()||``;for(let t of g)if(t.startsWith(`data: `)){let i=t.slice(6).trim();if(!i)continue;try{let t=JSON.parse(i);if(f=t.type===`status`&&t.phase===`queued`,t.type===`chunk`)l++,u+=(t.content||``).length,(l<=3||l%50==0)&&e.stream.debug(`Chunk #${l} (+${(t.content||``).length} chars)`),n.onChunk(t);else if(t.type===`answer`)n.onChunk(t);else if(t.type===`done`)c=!0,e.stream.timed(`Stream complete: ${l} chunks, ${u} chars, ${d} agent events`,r),n.onDone(t);else if(t.type===`error`)e.stream.error(`Stream error event:`,t.content),p=!0,n.onError(Error(t.content||`Unknown error`));else if(t.type===`agent_created`)e.stream.info(`Agent created: ${t.agent_id}`),n.onAgentCreated?.(t);else if(t.type===`mcp_status`){let n=t.servers??[];e.stream.debug(`MCP status: ${n.length} server(s)`,n);for(let t of n)t.connected||e.stream.warn(`MCP server "${t.name}" is not connected: ${t.error??`no error reported`}`)}else Ot.has(t.type)?(d++,t.type===`agent_error`&&!t.recoverable&&(m=!0),e.stream.debug(`Agent event: ${t.type}`,t),n.onAgentEvent(t)):e.stream.warn(`Unknown SSE event type: ${t.type}`,t)}catch{e.stream.warn(`Malformed SSE data, skipping`,{raw:i.slice(0,100)})}}}}finally{a.releaseLock()}if(!c){if(e.stream.timed(`SSE connection closed without done event: ${l} chunks, ${d} agent events`,r),i&&l===0&&d===0&&!p){n.onError(Error(`GAIA closed the connection before any answer arrived. Send the message again; if it keeps happening, check the GAIA server log.`));return}n.onDone({type:`done`})}}function Pt(n,r){let i=new AbortController,a=e.stream.time();e.stream.info(`Attaching to background run for session=${n}`);let o=Y(i,r,G);return fetch(`${t()}/chat/attach?session_id=${encodeURIComponent(n)}`,{method:`GET`,signal:i.signal}).then(t=>{if(o.received(),o.connected(),t.status===404)e.stream.info(`Run for session=${n} finished before the attach`),r.onDone({type:`done`,content:``});else return X(t,r,a)}).catch(t=>{o.received(),o.timedOut()?(e.stream.error(`No answer to /chat/attach within ${G/1e3}s`),r.onError(new J(`attach`,G))):t.name===`AbortError`?e.stream.warn(`Run attach detached by client`):t instanceof TypeError?(e.stream.error(`Run attach could not connect`,t),r.onError(new q(t,!0))):(e.stream.error(`Run attach fetch error`,t),r.onError(t))}),i}async function Ft(){return V(`GET`,`/documents`)}async function It(e){return V(`POST`,`/documents/upload-path`,{filepath:e})}async function Lt(n){let r=`${t()}/documents/upload`,i=e.api.time();e.api.info(`POST ${r}`,{fileName:n.name,size:n.size});let a=new FormData;a.append(`file`,n);let o;try{o=await fetch(r,{method:`POST`,headers:B,body:a})}catch(t){throw e.api.error(`POST ${r} - network error`,t),t}if(!o.ok){let t=await o.text().catch(()=>``);e.api.error(`POST ${r} - HTTP ${o.status}`,{errorText:t});let n=F(t);throw new L(z(o.status,n),o.status,n,I(t))}let s=await o.json();return e.api.timed(`POST ${r} -> ${o.status}`,i,s),s}async function Rt(e){return V(`DELETE`,`/documents/${e}`)}async function zt(e){return V(`GET`,`/documents/${e}/status`)}function Bt(e,n){let r=new URL(`${t()}/documents/${encodeURIComponent(e)}/file`,window.location.href);return n&&(r.hash=`page=${n}`),r.href}async function Vt(e){return V(`POST`,`/documents/${e}/cancel`)}async function Ht(e){return V(`POST`,`/documents/${e}/reindex`)}async function Ut(e,t){return V(`POST`,`/sessions/${e}/documents`,{document_id:t})}async function Wt(e,t){return V(`DELETE`,`/sessions/${e}/documents/${t}`)}async function Gt(e){return V(`GET`,`/files/browse${e?`?path=${encodeURIComponent(e)}`:``}`)}async function Kt(e,t=!0){return V(`POST`,`/documents/index-folder`,{folder_path:e,recursive:t})}async function qt(e,t=!0){return V(`POST`,`/files/open`,{path:e,reveal:t})}async function Jt(e){return V(`POST`,`/files/open`,{path:e,launch:!0})}async function Yt(e){return V(`POST`,`/files/status`,{paths:e})}async function Xt(n){let r=`${t()}/files/upload`,i=e.api.time();e.api.info(`POST ${r}`,{fileName:n.name,size:n.size});let a=new FormData;a.append(`file`,n);let o=await fetch(r,{method:`POST`,headers:B,body:a});if(!o.ok){let t=await o.text().catch(()=>``);e.api.error(`POST ${r} - HTTP ${o.status}`,{errorText:t});let n=F(t);throw new L(z(o.status,n),o.status,n,I(t))}let s=await o.json();return e.api.timed(`POST ${r} -> ${o.status}`,i,s),s}function Zt(n,r,i){let a=`${t()}/files/upload-media?name=${encodeURIComponent(n.name)}`;return e.api.info(`POST ${a}`,{fileName:n.name,size:n.size}),new Promise((t,o)=>{let s=new XMLHttpRequest;s.open(`POST`,a);for(let[e,t]of Object.entries(B))s.setRequestHeader(e,t);s.upload.onprogress=e=>{e.lengthComputable&&r(Math.floor(e.loaded/e.total*100))},s.onerror=()=>o(new L(z(0,`network error`),0,`network error`,null)),s.onabort=()=>o(new DOMException(`Upload cancelled`,`AbortError`)),i?.addEventListener(`abort`,()=>s.abort()),s.onload=()=>{if(s.status>=200&&s.status<300){t(JSON.parse(s.responseText));return}e.api.error(`POST ${a} - HTTP ${s.status}`,{errorText:s.responseText});let n=F(s.responseText);o(new L(z(s.status,n),s.status,n,I(s.responseText)))},s.send(n)})}async function Qt(e,t,n){let r=new URLSearchParams({query:e});return t&&r.set(`file_types`,t),n&&r.set(`max_results`,String(n)),V(`GET`,`/files/search?${r}`)}async function $t(e,t){let n=new URLSearchParams({path:e});return t&&n.set(`lines`,String(t)),V(`GET`,`/files/preview?${n}`)}async function en(){return V(`POST`,`/tunnel/start`)}async function tn(){return V(`POST`,`/tunnel/stop`)}async function nn(){return V(`GET`,`/tunnel/status`)}async function rn(){return V(`GET`,`/mcp/status`)}async function an(){return V(`GET`,`/schedules`)}function Z(){return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}async function on(e,t,n){return V(`POST`,`/schedules`,{name:e,interval:t,prompt:n,timezone:Z()})}async function sn(e,t){return V(`PUT`,`/schedules/${encodeURIComponent(e)}`,{status:t})}async function cn(e){return V(`POST`,`/schedules/${encodeURIComponent(e)}/run`)}async function ln(e){return V(`DELETE`,`/schedules/${encodeURIComponent(e)}`)}async function Q(e,t=20){return V(`GET`,`/schedules/${encodeURIComponent(e)}/results?limit=${t}`)}async function un(e){return V(`POST`,`/schedules/parse`,{input:e,timezone:Z()})}async function dn(e){return V(`GET`,`/sessions/${encodeURIComponent(e)}/changes`)}async function fn(e,t){return V(`GET`,`/sessions/${encodeURIComponent(e)}/changes/${encodeURIComponent(t)}/diff`)}async function pn(e,t,n=!1){return V(`POST`,`/sessions/${encodeURIComponent(e)}/changes/${encodeURIComponent(t)}/undo`,{force:n})}async function mn(){return V(`GET`,`/settings/undo`)}async function hn(e,t){return V(`PUT`,`/settings/undo`,{retention_days:e,max_mb:t})}var $=e=>`/sessions/${encodeURIComponent(e)}`;async function gn(e){return V(`GET`,`${$(e)}/environment`)}async function _n(e,t){return V(`POST`,`${$(e)}/environment/folders`,{path:t})}async function vn(e,t){return V(`POST`,`${$(e)}/environment/folders/remove`,{path:t})}async function yn(e,t){return V(`PUT`,`${$(e)}/environment/internet`,{on:t})}async function bn(e){return V(`GET`,`${$(e)}/outputs`)}async function xn(e){return V(`GET`,`${$(e)}/capabilities`)}async function Sn(e){return V(`GET`,`${$(e)}/changes/total`)}async function Cn(e,t=!1){return V(`POST`,`${$(e)}/changes/undo`,{force:t})}async function wn(e){return V(`GET`,`${$(e)}/changes/git`)}async function Tn(e,t,n){return V(`POST`,`${$(e)}/changes/git/commit`,{root:t,message:n,confirmed:!0})}async function En(e,t,n,r){return V(`POST`,`${$(e)}/changes/git/pr`,{root:t,title:n,body:r,confirmed:!0})}export{lt as $,s as $n,M as $t,Je as A,u as An,Qt as At,We as B,l as Bn,tn as Bt,_t as C,y as Cn,$t as Ct,Be as D,S as Dn,Ne as Dt,Bt as E,me as En,vn as Et,et as F,m as Fn,yn as Ft,Fe as G,le as Gn,gt as Gt,rn as H,g as Hn,Cn as Ht,zt as I,pe as In,Ke as It,Q as J,c as Jn,Lt as Jt,bn as K,h as Kn,Re as Kt,gn as L,re as Ln,Ie as Lt,xn as M,ie as Mn,it as Mt,ut as N,fe as Nn,kt as Nt,Tt as O,se as On,rt as Ot,ct as P,ue as Pn,tt as Pt,Le as Q,r as Qn,E as Qt,Yt as R,oe as Rn,dt as Rt,ln as S,x as Sn,yt as St,Ge as T,b as Tn,st as Tt,Ct as U,de as Un,pn as Ut,nt as V,ee as Vn,St as Vt,wt as W,ne as Wn,sn as Wt,Sn as X,d as Xn,Xt,vt as Y,p as Yn,It as Yt,wn as Z,i as Zn,Zt,on as _,T as _n,Jt as _t,ot as a,xe as an,Kt as at,Et as b,_ as bn,I as bt,V as c,j as cn,Ft as ct,Gt as d,Ce as dn,an as dt,P as en,a as er,je as et,Vt as f,we as fn,mt as ft,En as g,ve as gn,xt as gt,Ze as h,_e as hn,ze as ht,B as i,O as in,Pe as it,Ue as j,te as jn,bt as jt,Qe as k,f as kn,cn as kt,Ut as l,Te as ln,$e as lt,Tn as m,ge as mn,dn as mt,W as n,A as nn,fn as nt,_n as o,Se as on,He as ot,at as p,w as pn,pt,Me as q,ce as qn,hn as qt,J as r,k as rn,mn as rt,ft as s,be as sn,Ve as st,L as t,N as tn,o as tr,nn as tt,Pt as u,D as un,qe as ut,ht as v,v as vn,qt as vt,Wt as w,C as wn,Ht as wt,Dt as x,he as xn,un as xt,Rt as y,ye as yn,F as yt,z,ae as zn,en as zt};
|