chore(ui): Remove original UI/API routes
This commit is contained in:
@@ -214,12 +214,14 @@ func (a *App) ImportAgent(pool *state.AgentPool) func(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
os.MkdirAll("./uploads", os.ModePerm)
|
os.MkdirAll("./uploads", os.ModePerm)
|
||||||
|
|
||||||
|
// Safely save the file to prevent path traversal
|
||||||
destination := fmt.Sprintf("./uploads/%s", file.Filename)
|
destination := fmt.Sprintf("./uploads/%s", file.Filename)
|
||||||
if err := c.SaveFile(file, destination); err != nil {
|
if err := c.SaveFile(file, destination); err != nil {
|
||||||
// Handle error
|
// Handle error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safely read the file
|
||||||
data, err := os.ReadFile(destination)
|
data, err := os.ReadFile(destination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import FormFieldDefinition from '../common/FormFieldDefinition';
|
import FormFieldDefinition from '../common/FormFieldDefinition';
|
||||||
import DynamicPromptForm from '../DynamicPromptForm';
|
import DynamicPromptForm from '../DynamicPromptForm';
|
||||||
import DynamicPromptForm from '../DynamicPromptForm';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompts & Goals section of the agent form
|
* Prompts & Goals section of the agent form
|
||||||
|
|||||||
2
webui/react-ui/src/utils/api.js
vendored
2
webui/react-ui/src/utils/api.js
vendored
@@ -176,7 +176,7 @@ export const agentApi = {
|
|||||||
export const chatApi = {
|
export const chatApi = {
|
||||||
// Send a message to an agent using the JSON-based API
|
// Send a message to an agent using the JSON-based API
|
||||||
sendMessage: async (name, message) => {
|
sendMessage: async (name, message) => {
|
||||||
const response = await fetch(buildUrl(API_CONFIG.endpoints.chatApi(name)), {
|
const response = await fetch(buildUrl(API_CONFIG.endpoints.chat(name)), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: API_CONFIG.headers,
|
headers: API_CONFIG.headers,
|
||||||
body: JSON.stringify({ message }),
|
body: JSON.stringify({ message }),
|
||||||
|
|||||||
10
webui/react-ui/src/utils/config.js
vendored
10
webui/react-ui/src/utils/config.js
vendored
@@ -21,10 +21,11 @@ export const API_CONFIG = {
|
|||||||
agents: '/api/agents',
|
agents: '/api/agents',
|
||||||
agentConfig: (name) => `/api/agent/${name}/config`,
|
agentConfig: (name) => `/api/agent/${name}/config`,
|
||||||
agentConfigMetadata: '/api/meta/agent/config',
|
agentConfigMetadata: '/api/meta/agent/config',
|
||||||
createAgent: '/create',
|
createAgent: '/api/agent/create',
|
||||||
deleteAgent: (name) => `/api/agent/${name}`,
|
deleteAgent: (name) => `/api/agent/${name}`,
|
||||||
pauseAgent: (name) => `/api/agent/${name}/pause`,
|
pauseAgent: (name) => `/api/agent/${name}/pause`,
|
||||||
startAgent: (name) => `/api/agent/${name}/start`,
|
startAgent: (name) => `/api/agent/${name}/start`,
|
||||||
|
|
||||||
exportAgent: (name) => `/settings/export/${name}`,
|
exportAgent: (name) => `/settings/export/${name}`,
|
||||||
importAgent: '/settings/import',
|
importAgent: '/settings/import',
|
||||||
|
|
||||||
@@ -33,8 +34,7 @@ export const API_CONFIG = {
|
|||||||
createGroup: '/api/agent/group/create',
|
createGroup: '/api/agent/group/create',
|
||||||
|
|
||||||
// Chat endpoints
|
// Chat endpoints
|
||||||
chat: (name) => `/chat/${name}`,
|
chat: (name) => `/api/chat/${name}`,
|
||||||
chatApi: (name) => `/api/chat/${name}`,
|
|
||||||
notify: (name) => `/notify/${name}`,
|
notify: (name) => `/notify/${name}`,
|
||||||
responses: '/v1/responses',
|
responses: '/v1/responses',
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ export const API_CONFIG = {
|
|||||||
sse: (name) => `/sse/${name}`,
|
sse: (name) => `/sse/${name}`,
|
||||||
|
|
||||||
// Action endpoints
|
// Action endpoints
|
||||||
listActions: '/actions',
|
listActions: '/api/actions',
|
||||||
executeAction: (name) => `/action/${name}/run`,
|
executeAction: (name) => `/api/action/${name}/run`,
|
||||||
|
|
||||||
// Status endpoint
|
// Status endpoint
|
||||||
status: (name) => `/status/${name}`,
|
status: (name) => `/status/${name}`,
|
||||||
|
|||||||
146
webui/routes.go
146
webui/routes.go
@@ -37,12 +37,12 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
Browse: true,
|
Browse: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
webapp.Use("/public", filesystem.New(filesystem.Config{
|
/* webapp.Use("/public", filesystem.New(filesystem.Config{
|
||||||
Root: http.FS(embeddedFiles),
|
Root: http.FS(embeddedFiles),
|
||||||
PathPrefix: "public",
|
PathPrefix: "public",
|
||||||
Browse: true,
|
Browse: true,
|
||||||
}))
|
}))
|
||||||
|
*/
|
||||||
if len(app.config.ApiKeys) > 0 {
|
if len(app.config.ApiKeys) > 0 {
|
||||||
kaConfig, err := GetKeyAuthConfig(app.config.ApiKeys)
|
kaConfig, err := GetKeyAuthConfig(app.config.ApiKeys)
|
||||||
if err != nil || kaConfig == nil {
|
if err != nil || kaConfig == nil {
|
||||||
@@ -51,15 +51,15 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
webapp.Use(v2keyauth.New(*kaConfig))
|
webapp.Use(v2keyauth.New(*kaConfig))
|
||||||
}
|
}
|
||||||
|
|
||||||
webapp.Get("/", func(c *fiber.Ctx) error {
|
/* webapp.Get("/", func(c *fiber.Ctx) error {
|
||||||
return c.Render("views/index", fiber.Map{
|
return c.Render("views/index", fiber.Map{
|
||||||
"Agents": pool.List(),
|
"Agents": pool.List(),
|
||||||
"AgentCount": len(pool.List()),
|
"AgentCount": len(pool.List()),
|
||||||
"Actions": len(services.AvailableActions),
|
"Actions": len(services.AvailableActions),
|
||||||
"Connectors": len(services.AvailableConnectors),
|
"Connectors": len(services.AvailableConnectors),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
webapp.Use("/app", filesystem.New(filesystem.Config{
|
webapp.Use("/app", filesystem.New(filesystem.Config{
|
||||||
Root: http.FS(reactUI),
|
Root: http.FS(reactUI),
|
||||||
PathPrefix: "react-ui/dist",
|
PathPrefix: "react-ui/dist",
|
||||||
@@ -75,30 +75,30 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
return c.Send(indexHTML)
|
return c.Send(indexHTML)
|
||||||
})
|
})
|
||||||
|
|
||||||
webapp.Get("/agents", func(c *fiber.Ctx) error {
|
/* webapp.Get("/agents", func(c *fiber.Ctx) error {
|
||||||
statuses := map[string]bool{}
|
statuses := map[string]bool{}
|
||||||
for _, a := range pool.List() {
|
for _, a := range pool.List() {
|
||||||
agent := pool.GetAgent(a)
|
agent := pool.GetAgent(a)
|
||||||
if agent == nil {
|
if agent == nil {
|
||||||
xlog.Error("Agent not found", "name", a)
|
xlog.Error("Agent not found", "name", a)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
statuses[a] = !agent.Paused()
|
statuses[a] = !agent.Paused()
|
||||||
}
|
}
|
||||||
return c.Render("views/agents", fiber.Map{
|
return c.Render("views/agents", fiber.Map{
|
||||||
"Agents": pool.List(),
|
"Agents": pool.List(),
|
||||||
"Status": statuses,
|
"Status": statuses,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
webapp.Get("/create", func(c *fiber.Ctx) error {
|
/* webapp.Get("/api/create", func(c *fiber.Ctx) error {
|
||||||
return c.Render("views/create", fiber.Map{
|
return c.Render("views/create", fiber.Map{
|
||||||
"Actions": services.AvailableActions,
|
"Actions": services.AvailableActions,
|
||||||
"Connectors": services.AvailableConnectors,
|
"Connectors": services.AvailableConnectors,
|
||||||
"PromptBlocks": services.AvailableBlockPrompts,
|
"PromptBlocks": services.AvailableBlockPrompts,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
// Define a route for the GET method on the root path '/'
|
// Define a route for the GET method on the root path '/'
|
||||||
webapp.Get("/sse/:name", func(c *fiber.Ctx) error {
|
webapp.Get("/sse/:name", func(c *fiber.Ctx) error {
|
||||||
m := pool.GetManager(c.Params("name"))
|
m := pool.GetManager(c.Params("name"))
|
||||||
@@ -110,7 +110,7 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
webapp.Get("/status/:name", func(c *fiber.Ctx) error {
|
/*webapp.Get("/status/:name", func(c *fiber.Ctx) error {
|
||||||
history := pool.GetStatusHistory(c.Params("name"))
|
history := pool.GetStatusHistory(c.Params("name"))
|
||||||
if history == nil {
|
if history == nil {
|
||||||
history = &state.Status{ActionResults: []types.ActionState{}}
|
history = &state.Status{ActionResults: []types.ActionState{}}
|
||||||
@@ -125,57 +125,53 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
|
|
||||||
webapp.Get("/notify/:name", app.Notify(pool))
|
webapp.Get("/notify/:name", app.Notify(pool))
|
||||||
webapp.Post("/chat/:name", app.Chat(pool))
|
webapp.Post("/chat/:name", app.Chat(pool))
|
||||||
webapp.Post("/create", app.Create(pool))
|
*/
|
||||||
webapp.Delete("/delete/:name", app.Delete(pool))
|
webapp.Post("/api/agent/create", app.Create(pool))
|
||||||
webapp.Put("/pause/:name", app.Pause(pool))
|
|
||||||
webapp.Put("/start/:name", app.Start(pool))
|
|
||||||
|
|
||||||
// JSON API endpoints for agent operations
|
|
||||||
webapp.Delete("/api/agent/:name", app.Delete(pool))
|
webapp.Delete("/api/agent/:name", app.Delete(pool))
|
||||||
webapp.Put("/api/agent/:name/pause", app.Pause(pool))
|
webapp.Put("/api/agent/:name/pause", app.Pause(pool))
|
||||||
webapp.Put("/api/agent/:name/start", app.Start(pool))
|
webapp.Put("/api/agent/:name/start", app.Start(pool))
|
||||||
|
|
||||||
// Add JSON-based chat API endpoint
|
// Add JSON-based chat API endpoint
|
||||||
webapp.Post("/api/chat/:name", app.ChatAPI(pool))
|
webapp.Post("/api/chat/:name", app.ChatAPI(pool))
|
||||||
|
|
||||||
webapp.Post("/v1/responses", app.Responses(pool))
|
webapp.Post("/v1/responses", app.Responses(pool))
|
||||||
|
|
||||||
webapp.Get("/talk/:name", func(c *fiber.Ctx) error {
|
/* webapp.Get("/talk/:name", func(c *fiber.Ctx) error {
|
||||||
return c.Render("views/chat", fiber.Map{
|
return c.Render("views/chat", fiber.Map{
|
||||||
// "Character": agent.Character,
|
// "Character": agent.Character,
|
||||||
"Name": c.Params("name"),
|
"Name": c.Params("name"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
webapp.Get("/settings/:name", func(c *fiber.Ctx) error {
|
webapp.Get("/settings/:name", func(c *fiber.Ctx) error {
|
||||||
status := false
|
status := false
|
||||||
for _, a := range pool.List() {
|
for _, a := range pool.List() {
|
||||||
if a == c.Params("name") {
|
if a == c.Params("name") {
|
||||||
status = !pool.GetAgent(a).Paused()
|
status = !pool.GetAgent(a).Paused()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Render("views/settings", fiber.Map{
|
return c.Render("views/settings", fiber.Map{
|
||||||
"Name": c.Params("name"),
|
"Name": c.Params("name"),
|
||||||
"Status": status,
|
"Status": status,
|
||||||
"Actions": services.AvailableActions,
|
"Actions": services.AvailableActions,
|
||||||
"Connectors": services.AvailableConnectors,
|
"Connectors": services.AvailableConnectors,
|
||||||
"PromptBlocks": services.AvailableBlockPrompts,
|
"PromptBlocks": services.AvailableBlockPrompts,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
webapp.Get("/actions-playground", func(c *fiber.Ctx) error {
|
webapp.Get("/actions-playground", func(c *fiber.Ctx) error {
|
||||||
return c.Render("views/actions", fiber.Map{})
|
return c.Render("views/actions", fiber.Map{})
|
||||||
})
|
})
|
||||||
|
|
||||||
webapp.Get("/group-create", func(c *fiber.Ctx) error {
|
|
||||||
return c.Render("views/group-create", fiber.Map{
|
|
||||||
"Actions": services.AvailableActions,
|
|
||||||
"Connectors": services.AvailableConnectors,
|
|
||||||
"PromptBlocks": services.AvailableBlockPrompts,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
webapp.Get("/group-create", func(c *fiber.Ctx) error {
|
||||||
|
return c.Render("views/group-create", fiber.Map{
|
||||||
|
"Actions": services.AvailableActions,
|
||||||
|
"Connectors": services.AvailableConnectors,
|
||||||
|
"PromptBlocks": services.AvailableBlockPrompts,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
*/
|
||||||
// New API endpoints for getting and updating agent configuration
|
// New API endpoints for getting and updating agent configuration
|
||||||
webapp.Get("/api/agent/:name/config", app.GetAgentConfig(pool))
|
webapp.Get("/api/agent/:name/config", app.GetAgentConfig(pool))
|
||||||
webapp.Put("/api/agent/:name/config", app.UpdateAgentConfig(pool))
|
webapp.Put("/api/agent/:name/config", app.UpdateAgentConfig(pool))
|
||||||
@@ -183,8 +179,8 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
|
|||||||
// Add endpoint for getting agent config metadata
|
// Add endpoint for getting agent config metadata
|
||||||
webapp.Get("/api/meta/agent/config", app.GetAgentConfigMeta())
|
webapp.Get("/api/meta/agent/config", app.GetAgentConfigMeta())
|
||||||
|
|
||||||
webapp.Post("/action/:name/run", app.ExecuteAction(pool))
|
webapp.Post("/api/action/:name/run", app.ExecuteAction(pool))
|
||||||
webapp.Get("/actions", app.ListActions())
|
webapp.Get("/api/actions", app.ListActions())
|
||||||
|
|
||||||
webapp.Post("/api/agent/group/generateProfiles", app.GenerateGroupProfiles(pool))
|
webapp.Post("/api/agent/group/generateProfiles", app.GenerateGroupProfiles(pool))
|
||||||
webapp.Post("/api/agent/group/create", app.CreateGroup(pool))
|
webapp.Post("/api/agent/group/create", app.CreateGroup(pool))
|
||||||
|
|||||||
Reference in New Issue
Block a user