feat: add agent exec

This commit is contained in:
engigu
2025-12-27 20:00:32 +08:00
parent c5a8402782
commit b71b046f0f
15 changed files with 1897 additions and 4 deletions
+1
View File
@@ -39,6 +39,7 @@ func RegisterControllers() *Controllers {
Terminal: controllers.NewTerminalController(),
Settings: controllers.NewSettingsController(userService, loginLogService, executorService),
Dependency: controllers.NewDependencyController(),
Agent: controllers.NewAgentController(),
}
}
+26
View File
@@ -23,6 +23,7 @@ type Controllers struct {
Terminal *controllers.TerminalController
Settings *controllers.SettingsController
Dependency *controllers.DependencyController
Agent *controllers.AgentController
}
func mustSubFS(fsys fs.FS, dir string) fs.FS {
@@ -197,6 +198,31 @@ func Setup(c *Controllers) *gin.Engine {
deps.POST("/reinstall-all", c.Dependency.ReinstallAll)
deps.GET("/installed", c.Dependency.GetInstalled)
}
// Agent routes (Agent 管理)
agents := authorized.Group("/agents")
{
agents.GET("", c.Agent.List)
agents.GET("/pending", c.Agent.ListPending)
agents.GET("/version", c.Agent.GetVersion)
agents.POST("/:id/approve", c.Agent.Approve)
agents.POST("/:id/reject", c.Agent.Reject)
agents.PUT("/:id", c.Agent.Update)
agents.DELETE("/:id", c.Agent.Delete)
agents.POST("/:id/token", c.Agent.RegenerateToken)
agents.POST("/:id/update", c.Agent.ForceUpdate)
}
}
// Agent API(供远程 Agent 调用)
agentAPI := api.Group("/agent")
{
agentAPI.POST("/register", c.Agent.Register)
agentAPI.POST("/status", c.Agent.CheckStatus)
agentAPI.POST("/heartbeat", c.Agent.Heartbeat)
agentAPI.GET("/tasks", c.Agent.GetTasks)
agentAPI.POST("/report", c.Agent.ReportResult)
agentAPI.GET("/download", c.Agent.Download)
}
}