From c306a472d507a7bdb8598494a34ade7804249d87 Mon Sep 17 00:00:00 2001 From: haikdc Date: Fri, 17 Apr 2026 23:59:44 -0700 Subject: [PATCH] [Haik]: added unified shared/routes in the frontend, gonna start porting shit over to the new backend setup now --- frontend/src/shared/config.ts | 5 ----- frontend/src/shared/routes/agents.ts | 19 +++++++++++++++++++ frontend/src/shared/routes/app_builder.ts | 15 +++++++++++++++ frontend/src/shared/routes/base.ts | 5 +++++ frontend/src/shared/routes/dashboards.ts | 11 +++++++++++ frontend/src/shared/routes/health.ts | 5 +++++ frontend/src/shared/routes/modes.ts | 11 +++++++++++ frontend/src/shared/routes/settings.ts | 7 +++++++ frontend/src/shared/routes/skills.ts | 15 +++++++++++++++ frontend/src/shared/routes/subscriptions.ts | 10 ++++++++++ frontend/src/shared/routes/tools.ts | 16 ++++++++++++++++ 11 files changed, 114 insertions(+), 5 deletions(-) delete mode 100644 frontend/src/shared/config.ts create mode 100644 frontend/src/shared/routes/agents.ts create mode 100644 frontend/src/shared/routes/app_builder.ts create mode 100644 frontend/src/shared/routes/base.ts create mode 100644 frontend/src/shared/routes/dashboards.ts create mode 100644 frontend/src/shared/routes/health.ts create mode 100644 frontend/src/shared/routes/modes.ts create mode 100644 frontend/src/shared/routes/settings.ts create mode 100644 frontend/src/shared/routes/skills.ts create mode 100644 frontend/src/shared/routes/subscriptions.ts create mode 100644 frontend/src/shared/routes/tools.ts diff --git a/frontend/src/shared/config.ts b/frontend/src/shared/config.ts deleted file mode 100644 index a1d94486..00000000 --- a/frontend/src/shared/config.ts +++ /dev/null @@ -1,5 +0,0 @@ -const port = (window as any).__OPENSWARM_PORT__ || 8325; -const host = window.location.hostname || 'localhost'; - -export const API_BASE = `http://${host}:${port}/api`; -export const WS_BASE = `ws://${host}:${port}`; \ No newline at end of file diff --git a/frontend/src/shared/routes/agents.ts b/frontend/src/shared/routes/agents.ts new file mode 100644 index 00000000..823c0ce3 --- /dev/null +++ b/frontend/src/shared/routes/agents.ts @@ -0,0 +1,19 @@ +import { API_BASE, WS_BASE } from '@/shared/routes/base'; + +const AGENTS_API: string = `${API_BASE}/agents`; + +export const AGENTS_WS: string = `${WS_BASE}/api/agents/ws/dashboard`; + +export const AGENTS_SESSIONS_API: string = `${AGENTS_API}/SESSIONS`; +export const AGENTS_SESSION_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/sessions/${sessionId}`; +export const AGENTS_LAUNCH_API: string = `${AGENTS_API}/launch`; +export const AGENTS_UPDATE_SESSION_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/SESSIONS/${sessionId}`; +export const AGENTS_MESSAGE_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/SESSIONS/${sessionId}/message`; +export const AGENTS_STOP_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/sessions/${sessionId}/stop`; +export const AGENTS_APPROVAL_API: string = `${AGENTS_API}/approval`; +export const AGENTS_EDIT_MESSAGE_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/sessions/${sessionId}/edit_message`; +export const AGENTS_SWITCH_BRANCH_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/SESSIONS/${sessionId}/switch_branch`; +export const AGENTS_CLOSE_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/sessions/${sessionId}/close`; +export const AGENTS_RESUME_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/SESSIONS/${sessionId}/resume`; +export const AGENTS_DUPLICATE_API: (sessionId: string) => string = (sessionId: string) => `${AGENTS_API}/SESSIONS/${sessionId}/duplicate`; +export const AGENTS_HISTORY_API: string = `${AGENTS_API}/history`; diff --git a/frontend/src/shared/routes/app_builder.ts b/frontend/src/shared/routes/app_builder.ts new file mode 100644 index 00000000..f2e676d7 --- /dev/null +++ b/frontend/src/shared/routes/app_builder.ts @@ -0,0 +1,15 @@ +import { API_BASE } from '@/shared/routes/base'; + +const APP_BUILDER_API: string = `${API_BASE}/app_builder`; + +export const APP_BUILDER_SOURCE_FILE_API: (appId: string, filepath: string) => string = (appId: string, filepath: string) => `${APP_BUILDER_API}/app/${appId}/source_dir/${filepath}`; +export const APP_BUILDER_SERVE_API: (appId: string, filepath: string) => string = (appId: string, filepath: string) => `${APP_BUILDER_API}/${appId}/serve/${filepath}`; +export const APP_BUILDER_READ_APP_API: (appId: string) => string = (appId: string) => `${APP_BUILDER_API}/app/${appId}`; +export const APP_BUILDER_SEED_API: string = `${APP_BUILDER_API}/app/seed`; +export const APP_BUILDER_FILE_API: (appId: string, filepath: string) => string = (appId: string, filepath: string) => `${APP_BUILDER_API}/app/${appId}/file/${filepath}`; +export const APP_BUILDER_LIST_API: string = `${APP_BUILDER_API}/list`; +export const APP_BUILDER_GET_API: (appId: string) => string = (appId: string) => `${APP_BUILDER_API}/${appId}`; +export const APP_BUILDER_CREATE_API: string = `${APP_BUILDER_API}/create`; +export const APP_BUILDER_UPDATE_API: (appId: string) => string = (appId: string) => `${APP_BUILDER_API}/${appId}`; +export const APP_BUILDER_DELETE_API: (appId: string) => string = (appId: string) => `${APP_BUILDER_API}/${appId}`; +export const APP_BUILDER_EXECUTE_API: string = `${APP_BUILDER_API}/execute`; diff --git a/frontend/src/shared/routes/base.ts b/frontend/src/shared/routes/base.ts new file mode 100644 index 00000000..5ed54bcd --- /dev/null +++ b/frontend/src/shared/routes/base.ts @@ -0,0 +1,5 @@ +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}`; diff --git a/frontend/src/shared/routes/dashboards.ts b/frontend/src/shared/routes/dashboards.ts new file mode 100644 index 00000000..0af3eb59 --- /dev/null +++ b/frontend/src/shared/routes/dashboards.ts @@ -0,0 +1,11 @@ +import { API_BASE } from '@/shared/routes/base'; + +const DASHBOARDS_API: string = `${API_BASE}/dashboards`; + +export const DASHBOARDS_LIST_API: string = `${DASHBOARDS_API}/list`; +export const DASHBOARDS_CREATE_API: string = `${DASHBOARDS_API}/create`; +export const DASHBOARDS_GET_API: (dashboardId: string) => string = (dashboardId: string) => `${DASHBOARDS_API}/${dashboardId}`; +export const DASHBOARDS_UPDATE_API: (dashboardId: string) => string = (dashboardId: string) => `${DASHBOARDS_API}/${dashboardId}`; +export const DASHBOARDS_DELETE_API: (dashboardId: string) => string = (dashboardId: string) => `${DASHBOARDS_API}/${dashboardId}`; +export const DASHBOARDS_DUPLICATE_API: (dashboardId: string) => string = (dashboardId: string) => `${DASHBOARDS_API}/${dashboardId}/duplicate`; +export const DASHBOARDS_GENERATE_NAME_API: (dashboardId: string) => string = (dashboardId: string) => `${DASHBOARDS_API}/${dashboardId}/generate-name`; diff --git a/frontend/src/shared/routes/health.ts b/frontend/src/shared/routes/health.ts new file mode 100644 index 00000000..bb88aead --- /dev/null +++ b/frontend/src/shared/routes/health.ts @@ -0,0 +1,5 @@ +import { API_BASE } from '@/shared/routes/base'; + +const HEALTH_API: string = `${API_BASE}/health`; + +export const HEALTH_CHECK_API: string = `${HEALTH_API}/check`; diff --git a/frontend/src/shared/routes/modes.ts b/frontend/src/shared/routes/modes.ts new file mode 100644 index 00000000..56aa9cf1 --- /dev/null +++ b/frontend/src/shared/routes/modes.ts @@ -0,0 +1,11 @@ +import { API_BASE } from '@/shared/routes/base'; + +const MODES_API: string = `${API_BASE}/modes`; + +export const MODES_LIST_API: string = `${MODES_API}/list`; +export const MODES_GET_API: (modeId: string) => string = (modeId: string) => `${MODES_API}/${modeId}`; +export const MODES_CREATE_API: string = `${MODES_API}/create`; +export const MODES_UPDATE_API: (modeId: string) => string = (modeId: string) => `${MODES_API}/${modeId}`; +export const MODES_RESET_API: (modeId: string) => string = (modeId: string) => `${MODES_API}/${modeId}/reset`; +export const MODES_DELETE_API: (modeId: string) => string = (modeId: string) => `${MODES_API}/${modeId}`; +export const MODES_GET_BY_ID_API: string = `${MODES_API}/get_mode_by_id`; diff --git a/frontend/src/shared/routes/settings.ts b/frontend/src/shared/routes/settings.ts new file mode 100644 index 00000000..5adb86d0 --- /dev/null +++ b/frontend/src/shared/routes/settings.ts @@ -0,0 +1,7 @@ +import { API_BASE } from '@/shared/routes/base'; + +const SETTINGS_API: string = `${API_BASE}/settings`; + +export const SETTINGS_GET_API: string = SETTINGS_API; +export const SETTINGS_UPDATE_API: string = SETTINGS_API; +export const SETTINGS_RESET_SYSTEM_PROMPT_API: string = `${SETTINGS_API}/reset-system-prompt`; diff --git a/frontend/src/shared/routes/skills.ts b/frontend/src/shared/routes/skills.ts new file mode 100644 index 00000000..1f662534 --- /dev/null +++ b/frontend/src/shared/routes/skills.ts @@ -0,0 +1,15 @@ +import { API_BASE } from '@/shared/routes/base'; + +const SKILLS_API: string = `${API_BASE}/skills`; + +export const SKILLS_LIST_API: string = `${SKILLS_API}/list`; +export const SKILLS_WORKSPACE_API: (workspaceId: string) => string = (workspaceId: string) => `${SKILLS_API}/workspace/${workspaceId}`; +export const SKILLS_WORKSPACE_SEED_API: string = `${SKILLS_API}/workspace/seed`; +export const SKILLS_DETAIL_API: (skillId: string) => string = (skillId: string) => `${SKILLS_API}/detail/${skillId}`; +export const SKILLS_CREATE_API: string = `${SKILLS_API}/create`; +export const SKILLS_UPDATE_API: (skillId: string) => string = (skillId: string) => `${SKILLS_API}/${skillId}`; +export const SKILLS_DELETE_API: (skillId: string) => string = (skillId: string) => `${SKILLS_API}/${skillId}`; + +export const SKILLS_REGISTRY_STATS_API: string = `${SKILLS_API}/registry/stats`; +export const SKILLS_REGISTRY_SEARCH_API: string = `${SKILLS_API}/registry/search`; +export const SKILLS_REGISTRY_DETAIL_API: (skillName: string) => string = (skillName: string) => `${SKILLS_API}/registry/detail/${skillName}`; diff --git a/frontend/src/shared/routes/subscriptions.ts b/frontend/src/shared/routes/subscriptions.ts new file mode 100644 index 00000000..1de4aabe --- /dev/null +++ b/frontend/src/shared/routes/subscriptions.ts @@ -0,0 +1,10 @@ +import { API_BASE } from '@/shared/routes/base'; + +const SUBSCRIPTIONS_API: string = `${API_BASE}/subscriptions`; + +export const SUBSCRIPTIONS_STATUS_API: string = `${SUBSCRIPTIONS_API}/status`; +export const SUBSCRIPTIONS_CONNECT_API: string = `${SUBSCRIPTIONS_API}/connect`; +export const SUBSCRIPTIONS_POLL_API: string = `${SUBSCRIPTIONS_API}/poll`; +export const SUBSCRIPTIONS_DISCONNECT_API: string = `${SUBSCRIPTIONS_API}/disconnect`; +export const SUBSCRIPTIONS_PENDING_API: (state: string) => string = (state: string) => `${SUBSCRIPTIONS_API}/pending/${state}`; +export const SUBSCRIPTIONS_CALLBACK_API: string = `${SUBSCRIPTIONS_API}/callback`; diff --git a/frontend/src/shared/routes/tools.ts b/frontend/src/shared/routes/tools.ts new file mode 100644 index 00000000..05905d18 --- /dev/null +++ b/frontend/src/shared/routes/tools.ts @@ -0,0 +1,16 @@ +import { API_BASE } from '@/shared/routes/base'; + +const TOOLS_API: string = `${API_BASE}/tools`; + +export const TOOLS_BUILTIN_API: string = `${TOOLS_API}/builtin`; +export const TOOLS_BUILTIN_PERMISSIONS_API: string = `${TOOLS_API}/builtin/permissions`; +export const TOOLS_LIST_API: string = `${TOOLS_API}/list`; +export const TOOLS_CREATE_API: string = `${TOOLS_API}/create`; +export const TOOLS_GET_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}`; +export const TOOLS_UPDATE_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}`; +export const TOOLS_DELETE_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}`; +export const TOOLS_DISCOVER_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}/discover`; +export const TOOLS_LOAD_USER_TOOLKIT_API: string = `${TOOLS_API}/load_user_toolkit`; +export const TOOLS_OAUTH_CALLBACK_API: string = `${TOOLS_API}/oauth/callback`; +export const TOOLS_OAUTH_START_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}/oauth/start`; +export const TOOLS_OAUTH_DISCONNECT_API: (toolId: string) => string = (toolId: string) => `${TOOLS_API}/${toolId}/oauth/disconnect`;