mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-21 09:07:40 +02:00
[hAIk]: refactor backend settings and tools routes to use explicit endpoint names (/get_settings, /update_settings, /get_builtin_permissions, /update_builtin_permissions) with matching frontend updates; simplify base_routes.ts to relative /api path; add new appsSlice Redux slice and register in store; remove unused GET_HISTORY reducer; rename structlint to lint across CI workflow, local.sh, and publish.sh; strip ANSI escape codes from NineRouter forwarded output; add swarm-debug as backend dependency
This commit is contained in:
@@ -40,7 +40,7 @@ export interface AppSettings {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
const get_settings_endpoint: string = SETTINGS_API;
|
||||
const get_settings_endpoint: string = `${SETTINGS_API}/get_settings`;
|
||||
async function get_settings_function(): Promise<AppSettings> {
|
||||
const res = await fetch(get_settings_endpoint, {
|
||||
method: 'GET',
|
||||
@@ -55,7 +55,7 @@ export const GET_SETTINGS = createAsyncThunk(
|
||||
);
|
||||
|
||||
|
||||
const update_settings_endpoint: string = SETTINGS_API;
|
||||
const update_settings_endpoint: string = `${SETTINGS_API}/update_settings`;
|
||||
async function update_settings_function(body: Partial<AppSettings>): Promise<{ ok: boolean; settings: AppSettings }> {
|
||||
const res = await fetch(update_settings_endpoint, {
|
||||
method: 'PUT',
|
||||
|
||||
@@ -23,7 +23,7 @@ export const LIST_BUILTIN_TOOLS = createAsyncThunk(
|
||||
);
|
||||
|
||||
|
||||
const get_builtin_permissions_endpoint: string = `${TOOLS_API}/builtin/permissions`;
|
||||
const get_builtin_permissions_endpoint: string = `${TOOLS_API}/get_builtin_permissions`;
|
||||
async function get_builtin_permissions_function(): Promise<{ permissions: Record<string, string> }> {
|
||||
const res = await fetch(get_builtin_permissions_endpoint, {
|
||||
method: 'GET',
|
||||
@@ -38,7 +38,7 @@ export const GET_BUILTIN_PERMISSIONS = createAsyncThunk(
|
||||
);
|
||||
|
||||
|
||||
const update_builtin_permissions_endpoint: string = `${TOOLS_API}/builtin/permissions`;
|
||||
const update_builtin_permissions_endpoint: string = `${TOOLS_API}/update_builtin_permissions`;
|
||||
async function update_builtin_permissions_function(permissions: Record<string, string>): Promise<{ permissions: Record<string, string> }> {
|
||||
const res = await fetch(update_builtin_permissions_endpoint, {
|
||||
method: 'PUT',
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
const port: number = (window as any).__OPENSWARM_PORT__ || 8325;
|
||||
const host: string = window.location.hostname || 'localhost';
|
||||
|
||||
export const API_BASE: string = `http://${host}:${port}/api`;
|
||||
export const WS_BASE: string = `ws://${host}:${port}`;
|
||||
export const API_BASE: string = `/api`;
|
||||
@@ -173,11 +173,6 @@ export function buildExtraReducers(builder: ActionReducerMapBuilder<AgentsState>
|
||||
state.expandedSessionIds = state.expandedSessionIds.filter((id) => id !== sessionId);
|
||||
state.trackedNotificationIds = state.trackedNotificationIds.filter((id) => id !== sessionId);
|
||||
})
|
||||
.addCase(GET_HISTORY.fulfilled, (state, action) => {
|
||||
const history: Record<string, HistorySession> = {};
|
||||
for (const s of action.payload.sessions) history[s.id] = s;
|
||||
state.history = history;
|
||||
})
|
||||
.addCase(RESUME_SESSION.fulfilled, (state, action) => {
|
||||
const session = action.payload;
|
||||
state.sessions[session.id] = { ...session, streamingMessage: null, tool_group_meta: session.tool_group_meta ?? {} };
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import {
|
||||
LIST_APPS,
|
||||
CREATE_APP,
|
||||
UPDATE_APP,
|
||||
DELETE_APP,
|
||||
GET_APP,
|
||||
} from '@/shared/backend-bridge/apps/app_builder';
|
||||
import type { App } from '@/shared/backend-bridge/apps/app_builder';
|
||||
|
||||
interface AppsState {
|
||||
items: Record<string, App>;
|
||||
loading: boolean;
|
||||
loaded: boolean;
|
||||
}
|
||||
|
||||
const initialState: AppsState = {
|
||||
items: {},
|
||||
loading: false,
|
||||
loaded: false,
|
||||
};
|
||||
|
||||
const appsSlice = createSlice({
|
||||
name: 'apps',
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(LIST_APPS.pending, (state) => {
|
||||
state.loading = true;
|
||||
})
|
||||
.addCase(LIST_APPS.fulfilled, (state, action) => {
|
||||
state.loading = false;
|
||||
state.loaded = true;
|
||||
const items: Record<string, App> = {};
|
||||
for (const a of action.payload.apps) {
|
||||
items[a.id] = a;
|
||||
}
|
||||
state.items = items;
|
||||
})
|
||||
.addCase(LIST_APPS.rejected, (state) => {
|
||||
state.loading = false;
|
||||
state.loaded = true;
|
||||
})
|
||||
.addCase(CREATE_APP.fulfilled, (state, action) => {
|
||||
state.items[action.payload.id] = action.payload;
|
||||
})
|
||||
.addCase(UPDATE_APP.fulfilled, (state, action) => {
|
||||
const a = action.payload;
|
||||
if (a?.id) {
|
||||
state.items[a.id] = { ...state.items[a.id], ...a };
|
||||
}
|
||||
})
|
||||
.addCase(DELETE_APP.fulfilled, (state, action) => {
|
||||
delete state.items[action.payload];
|
||||
})
|
||||
.addCase(GET_APP.fulfilled, (state, action) => {
|
||||
const a = action.payload;
|
||||
if (a?.id) {
|
||||
state.items[a.id] = a;
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default appsSlice.reducer;
|
||||
@@ -9,6 +9,7 @@ import settingsReducer from './settingsSlice';
|
||||
import skillRegistryReducer from './skillRegistrySlice';
|
||||
import dashboardLayoutReducer from './dashboardLayoutSlice';
|
||||
import dashboardsReducer from './dashboardsSlice';
|
||||
import appsReducer from './appsSlice';
|
||||
import updateReducer from './updateSlice';
|
||||
// import modelsReducer from './modelsSlice';
|
||||
|
||||
@@ -24,6 +25,7 @@ export const store = configureStore({
|
||||
skillRegistry: skillRegistryReducer,
|
||||
dashboardLayout: dashboardLayoutReducer,
|
||||
dashboards: dashboardsReducer,
|
||||
apps: appsReducer,
|
||||
update: updateReducer,
|
||||
// models: modelsReducer,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user