feat: open terminal integration

This commit is contained in:
Timothy Jaeryang Baek committed 2026-02-27 13:08:59 -06:00
1 parent 7ea6afdf95
commit 4737e1f118
15 files changed
+767 -64

No files matched your search

+57
View File
@@ -172,6 +172,63 @@ export const setToolServerConnections = async (token: string, connections: objec
return res;
};
export const getTerminalServerConnections = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const setTerminalServerConnections = async (token: string, connections: object) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
...connections
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};
export const verifyToolServerConnection = async (token: string, connection: object) => {
let error = null;
+20
View File
@@ -5,6 +5,26 @@ export type FileEntry = {
modified?: number;
};
import { WEBUI_API_BASE_URL } from '$lib/constants';
export type TerminalServer = {
id: string;
url: string;
name: string;
};
export const getTerminalServers = async (
token: string
): Promise<TerminalServer[]> => {
const res = await fetch(`${WEBUI_API_BASE_URL}/terminals/`, {
headers: {
Authorization: `Bearer ${token}`
}
}).catch(() => null);
if (!res || !res.ok) return [];
return res.json().catch(() => []);
};
export const getCwd = async (baseUrl: string, apiKey: string): Promise<string | null> => {
const url = `${baseUrl.replace(/\/$/, '')}/files/cwd`;
const res = await fetch(url, {