From 2f37e853d1259a901f736a823bad29dcc2c3b130 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 13 Jul 2026 23:19:58 -0400 Subject: [PATCH] refac --- src/lib/apis/configs/index.ts | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/lib/apis/configs/index.ts b/src/lib/apis/configs/index.ts index 93df4464dc..b4e938a14d 100644 --- a/src/lib/apis/configs/index.ts +++ b/src/lib/apis/configs/index.ts @@ -311,6 +311,33 @@ export const putOrchestratorPolicy = async ( return res; }; +export const getOrchestratorPolicy = async ( + token: string, + url: string, + key: string, + policyId: string, + authType: string = 'bearer' +): Promise => { + const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers/policy`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + }, + body: JSON.stringify({ + url: url.replace(/\/$/, ''), + key, + auth_type: authType, + policy_id: policyId + }) + }); + if (!res.ok) { + const body = await res.json(); + throw Object.assign(new Error(body.detail || 'Failed to read policy'), { status: res.status }); + } + return res.json(); +}; + export const putOrchestratorLifecycle = async ( token: string, url: string, @@ -352,6 +379,33 @@ export const putOrchestratorLifecycle = async ( return res; }; +export const getOrchestratorLifecycle = async ( + token: string, + url: string, + key: string, + policyId: string, + authType: string = 'bearer' +): Promise => { + const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers/lifecycle`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + }, + body: JSON.stringify({ + url: url.replace(/\/$/, ''), + key, + auth_type: authType, + policy_id: policyId + }) + }); + if (!res.ok) { + const body = await res.json(); + throw Object.assign(new Error(body.detail || 'Failed to read lifecycle'), { status: res.status }); + } + return res.json(); +}; + export const refreshOrchestratorTerminals = async ( token: string, url: string, @@ -661,6 +715,31 @@ export const setModelsConfig = async (token: string, config: object) => { return res; }; +export const getSubagentsConfig = async (token: string) => { + const res = await fetch(`${WEBUI_API_BASE_URL}/configs/subagents`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + }); + if (!res.ok) throw await res.json(); + return res.json(); +}; + +export const setSubagentsConfig = async (token: string, config: object) => { + const res = await fetch(`${WEBUI_API_BASE_URL}/configs/subagents`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + }, + body: JSON.stringify(config) + }); + if (!res.ok) throw await res.json(); + return res.json(); +}; + export const setDefaultPromptSuggestions = async (token: string, promptSuggestions: string) => { let error = null;