Compare commits
19 Commits
b2eb9d3116
...
main
Author | SHA1 | Date | |
---|---|---|---|
4a79011793 | |||
0b62ac9ecd | |||
c9b14730ad | |||
2ee8a95a90 | |||
8bc1759dcb | |||
e60b9f62f1 | |||
5d241e9ade | |||
b8c8da9e31 | |||
55a05a5571 | |||
2bfe4161b2 | |||
0b1d9907a7 | |||
c78761fe20 | |||
2e8ec1735a | |||
29d0d25a3b | |||
3f01074e3f | |||
532cda72d3 | |||
0e545e56de | |||
92b9c356b8 | |||
c86165f88c |
@@ -11,7 +11,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/mycelium_client"
|
"git.threefold.info/herocode/heroagent/pkg/mycelium_client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
@@ -8,7 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/mycelium_client"
|
"git.threefold.info/herocode/heroagent/pkg/mycelium_client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/system/stats"
|
"git.threefold.info/herocode/heroagent/pkg/system/stats"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func (h *AdminHandler) getProcessStatsJSON(c *fiber.Ctx) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "Failed to get process stats: " + err.Error(),
|
"error": "Failed to get process stats: " + err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@@ -3,7 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/sal/executor"
|
"git.threefold.info/herocode/heroagent/pkg/sal/executor"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
@@ -7,9 +7,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager/interfaces"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager/interfaces"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager/interfaces/openrpc"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager/interfaces/openrpc"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
@@ -12,16 +12,16 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroagent/api"
|
"git.threefold.info/herocode/heroagent/pkg/heroagent/api"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroagent/handlers"
|
"git.threefold.info/herocode/heroagent/pkg/heroagent/handlers"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroagent/pages"
|
"git.threefold.info/herocode/heroagent/pkg/heroagent/pages"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/sal/executor"
|
"git.threefold.info/herocode/heroagent/pkg/sal/executor"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/servers/redisserver"
|
"git.threefold.info/herocode/heroagent/pkg/servers/redisserver"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/system/stats"
|
"git.threefold.info/herocode/heroagent/pkg/system/stats"
|
||||||
|
|
||||||
// "github.com/freeflowuniverse/heroagent/pkg/vfs/interfaces"
|
// "git.threefold.info/herocode/heroagent/pkg/vfs/interfaces"
|
||||||
// "github.com/freeflowuniverse/heroagent/pkg/vfs/interfaces/mock"
|
// "git.threefold.info/herocode/heroagent/pkg/vfs/interfaces/mock"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||||
@@ -239,7 +239,7 @@ func (hl *HeroLauncher) GetUptime() string {
|
|||||||
func (hl *HeroLauncher) startProcessManager() error {
|
func (hl *HeroLauncher) startProcessManager() error {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
projectRoot := filepath.Join(filepath.Dir(filename), "../..")
|
projectRoot := filepath.Join(filepath.Dir(filename), "../..")
|
||||||
processManagerPath := filepath.Join(projectRoot, "cmd/processmanager/main.go")
|
processManagerPath := filepath.Join(projectRoot, "pkg/processmanager/examples/openrpc/main.go")
|
||||||
|
|
||||||
log.Printf("Starting process manager from: %s", processManagerPath)
|
log.Printf("Starting process manager from: %s", processManagerPath)
|
||||||
|
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"strconv" // Added strconv for JobID parsing
|
"strconv" // Added strconv for JobID parsing
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/herojobs"
|
"git.threefold.info/herocode/heroagent/pkg/herojobs"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
@@ -10,7 +10,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/herojobs"
|
"git.threefold.info/herocode/heroagent/pkg/herojobs"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/logger"
|
"git.threefold.info/herocode/heroagent/pkg/logger"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,11 +65,11 @@ func NewLogHandler(logPath string) (*LogHandler, error) {
|
|||||||
type LogType string
|
type LogType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LogTypeSystem LogType = "system"
|
LogTypeSystem LogType = "system"
|
||||||
LogTypeService LogType = "service"
|
LogTypeService LogType = "service"
|
||||||
LogTypeJob LogType = "job"
|
LogTypeJob LogType = "job"
|
||||||
LogTypeProcess LogType = "process"
|
LogTypeProcess LogType = "process"
|
||||||
LogTypeAll LogType = "all" // Special type to retrieve logs from all sources
|
LogTypeAll LogType = "all" // Special type to retrieve logs from all sources
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetLogs renders the logs page with logs content
|
// GetLogs renders the logs page with logs content
|
||||||
@@ -90,9 +90,9 @@ func (h *LogHandler) GetLogs(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Create search arguments
|
// Create search arguments
|
||||||
searchArgs := logger.SearchArgs{
|
searchArgs := logger.SearchArgs{
|
||||||
Category: category,
|
Category: category,
|
||||||
LogType: logItemType,
|
LogType: logItemType,
|
||||||
MaxItems: maxItems,
|
MaxItems: maxItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fromTime.IsZero() {
|
if !fromTime.IsZero() {
|
||||||
@@ -135,9 +135,9 @@ func (h *LogHandler) GetLogs(c *fiber.Ctx) error {
|
|||||||
// Check if the selected logger is properly initialized
|
// Check if the selected logger is properly initialized
|
||||||
if selectedLogger == nil {
|
if selectedLogger == nil {
|
||||||
return c.Render("admin/system/logs", fiber.Map{
|
return c.Render("admin/system/logs", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"error": "Logger not initialized",
|
"error": "Logger not initialized",
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -149,14 +149,13 @@ func (h *LogHandler) GetLogs(c *fiber.Ctx) error {
|
|||||||
// Handle search error
|
// Handle search error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Render("admin/system/logs", fiber.Map{
|
return c.Render("admin/system/logs", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Calculate total pages
|
// Calculate total pages
|
||||||
totalLogs := len(logs)
|
totalLogs := len(logs)
|
||||||
totalPages := (totalLogs + itemsPerPage - 1) / itemsPerPage
|
totalPages := (totalLogs + itemsPerPage - 1) / itemsPerPage
|
||||||
@@ -196,18 +195,18 @@ func (h *LogHandler) GetLogs(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return c.Render("admin/system/logs", fiber.Map{
|
return c.Render("admin/system/logs", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
"logs": formattedLogs,
|
"logs": formattedLogs,
|
||||||
"total": totalLogs,
|
"total": totalLogs,
|
||||||
"showing": len(formattedLogs),
|
"showing": len(formattedLogs),
|
||||||
"page": page,
|
"page": page,
|
||||||
"totalPages": totalPages,
|
"totalPages": totalPages,
|
||||||
"categoryParam": category,
|
"categoryParam": category,
|
||||||
"typeParam": c.Query("type", ""),
|
"typeParam": c.Query("type", ""),
|
||||||
"fromParam": c.Query("from", ""),
|
"fromParam": c.Query("from", ""),
|
||||||
"toParam": c.Query("to", ""),
|
"toParam": c.Query("to", ""),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,9 +226,9 @@ func (h *LogHandler) GetLogsAPI(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Create search arguments
|
// Create search arguments
|
||||||
searchArgs := logger.SearchArgs{
|
searchArgs := logger.SearchArgs{
|
||||||
Category: category,
|
Category: category,
|
||||||
LogType: logItemType,
|
LogType: logItemType,
|
||||||
MaxItems: maxItems,
|
MaxItems: maxItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fromTime.IsZero() {
|
if !fromTime.IsZero() {
|
||||||
@@ -298,7 +297,7 @@ func (h *LogHandler) GetLogsAPI(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"logs": response,
|
"logs": response,
|
||||||
"total": len(logs),
|
"total": len(logs),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -323,9 +322,9 @@ func (h *LogHandler) GetLogsFragment(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Create search arguments
|
// Create search arguments
|
||||||
searchArgs := logger.SearchArgs{
|
searchArgs := logger.SearchArgs{
|
||||||
Category: category,
|
Category: category,
|
||||||
LogType: logItemType,
|
LogType: logItemType,
|
||||||
MaxItems: maxItems,
|
MaxItems: maxItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fromTime.IsZero() {
|
if !fromTime.IsZero() {
|
||||||
@@ -368,9 +367,9 @@ func (h *LogHandler) GetLogsFragment(c *fiber.Ctx) error {
|
|||||||
// Check if the selected logger is properly initialized
|
// Check if the selected logger is properly initialized
|
||||||
if selectedLogger == nil {
|
if selectedLogger == nil {
|
||||||
return c.Render("admin/system/logs_fragment", fiber.Map{
|
return c.Render("admin/system/logs_fragment", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"error": "Logger not initialized",
|
"error": "Logger not initialized",
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -382,9 +381,9 @@ func (h *LogHandler) GetLogsFragment(c *fiber.Ctx) error {
|
|||||||
// Handle search error
|
// Handle search error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Render("admin/system/logs_fragment", fiber.Map{
|
return c.Render("admin/system/logs_fragment", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -429,15 +428,15 @@ func (h *LogHandler) GetLogsFragment(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Set layout to empty to disable the layout for fragment responses
|
// Set layout to empty to disable the layout for fragment responses
|
||||||
return c.Render("admin/system/logs_fragment", fiber.Map{
|
return c.Render("admin/system/logs_fragment", fiber.Map{
|
||||||
"title": logTypeTitle,
|
"title": logTypeTitle,
|
||||||
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
"logTypes": []LogType{LogTypeAll, LogTypeSystem, LogTypeService, LogTypeJob, LogTypeProcess},
|
||||||
"selectedLogType": logTypeParam,
|
"selectedLogType": logTypeParam,
|
||||||
"logs": formattedLogs,
|
"logs": formattedLogs,
|
||||||
"total": totalLogs,
|
"total": totalLogs,
|
||||||
"showing": len(formattedLogs),
|
"showing": len(formattedLogs),
|
||||||
"page": page,
|
"page": page,
|
||||||
"totalPages": totalPages,
|
"totalPages": totalPages,
|
||||||
"layout": "", // Disable layout for partial template
|
"layout": "", // Disable layout for partial template
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/system/stats"
|
"git.threefold.info/herocode/heroagent/pkg/system/stats"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ func (h *ProcessHandler) GetProcessStatsJSON(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Convert to fiber.Map for JSON response
|
// Convert to fiber.Map for JSON response
|
||||||
response := fiber.Map{
|
response := fiber.Map{
|
||||||
"total": processData.Total,
|
"total": processData.Total,
|
||||||
"filtered": processData.Filtered,
|
"filtered": processData.Filtered,
|
||||||
"timestamp": time.Now().Unix(),
|
"timestamp": time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +127,8 @@ func (h *ProcessHandler) GetProcessesData(c *fiber.Ctx) error {
|
|||||||
// Check if StatsManager is properly initialized
|
// Check if StatsManager is properly initialized
|
||||||
if h.statsManager == nil {
|
if h.statsManager == nil {
|
||||||
return c.Render("admin/system/processes_data", fiber.Map{
|
return c.Render("admin/system/processes_data", fiber.Map{
|
||||||
"error": "System error: Stats manager not initialized",
|
"error": "System error: Stats manager not initialized",
|
||||||
"layout": "",
|
"layout": "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +165,8 @@ func (h *ProcessHandler) GetProcessesData(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
// For regular requests, render the error within the fragment
|
// For regular requests, render the error within the fragment
|
||||||
return c.Render("admin/system/processes_data", fiber.Map{
|
return c.Render("admin/system/processes_data", fiber.Map{
|
||||||
"error": "Failed to get process data: " + err.Error(),
|
"error": "Failed to get process data: " + err.Error(),
|
||||||
"layout": "",
|
"layout": "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,5 +201,3 @@ func (h *ProcessHandler) GetProcessesData(c *fiber.Ctx) error {
|
|||||||
// Return only the table HTML content directly to be injected into the processes-table-content div
|
// Return only the table HTML content directly to be injected into the processes-table-content div
|
||||||
return c.Render("admin/system/processes_data", templateData)
|
return c.Render("admin/system/processes_data", templateData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager/interfaces"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager/interfaces"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager/interfaces/openrpc"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager/interfaces/openrpc"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/system/stats"
|
"git.threefold.info/herocode/heroagent/pkg/system/stats"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
)
|
)
|
@@ -7,8 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroagent/handlers"
|
"git.threefold.info/herocode/heroagent/pkg/heroagent/handlers"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/system/stats"
|
"git.threefold.info/herocode/heroagent/pkg/system/stats"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
)
|
)
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/herojobs"
|
"git.threefold.info/herocode/heroagent/pkg/herojobs"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
@@ -4,14 +4,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager/interfaces/openrpc"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager/interfaces/openrpc"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceHandler handles service-related page routes
|
// ServiceHandler handles service-related page routes
|
||||||
type ServiceHandler struct {
|
type ServiceHandler struct {
|
||||||
client *openrpc.Client
|
client *openrpc.Client
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServiceHandler creates a new service handler with the provided socket path and secret
|
// NewServiceHandler creates a new service handler with the provided socket path and secret
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessDisplayInfo represents information about a process for display purposes
|
// ProcessDisplayInfo represents information about a process for display purposes
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 844 B |
@@ -35,7 +35,7 @@ Key features:
|
|||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a new playbook from HeroScript text
|
// Create a new playbook from HeroScript text
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory/herohandler"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory/herohandler"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -8,7 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -3,8 +3,8 @@ package internal
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlers"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExampleHandler handles example actions
|
// ExampleHandler handles example actions
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/cmd/herohandler/internal"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/cmd/herohandler/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -10,7 +10,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory/herohandler"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory/herohandler"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
const exampleScript = `
|
const exampleScript = `
|
@@ -16,7 +16,7 @@ The VM handler example shows how to:
|
|||||||
To run the example:
|
To run the example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ~/code/github/freeflowuniverse/heroagent/pkg/handlerfactory/cmd/vmhandler
|
cd ~/code/github/freeflowuniverse/herocode/heroagent/pkg/handlerfactory/cmd/vmhandler
|
||||||
go run . tutorial
|
go run . tutorial
|
||||||
#to run just the server do
|
#to run just the server do
|
||||||
go run .
|
go run .
|
@@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory"
|
||||||
)
|
)
|
||||||
|
|
||||||
// runTutorial runs an interactive tutorial demonstrating the VM handler
|
// runTutorial runs an interactive tutorial demonstrating the VM handler
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VMHandler handles VM-related actions
|
// VMHandler handles VM-related actions
|
@@ -8,7 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/handlerfactory"
|
"git.threefold.info/herocode/heroagent/pkg/handlerfactory"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The tutorial functions are defined in tutorial.go
|
// The tutorial functions are defined in tutorial.go
|
@@ -30,7 +30,7 @@ The Handler Factory exposes two interfaces for communication:
|
|||||||
to get started
|
to get started
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /root/code/github/freeflowuniverse/heroagent/pkg/handlerfactory/herohandler/cmd
|
cd /root/code/github/freeflowuniverse/herocode/heroagent/pkg/handlerfactory/herohandler/cmd
|
||||||
go run .
|
go run .
|
||||||
```
|
```
|
||||||
|
|
@@ -5,8 +5,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/paramsparser"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/paramsparser"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Handler interface defines methods that all handlers must implement
|
// Handler interface defines methods that all handlers must implement
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandlerFactory manages a collection of handlers
|
// HandlerFactory manages a collection of handlers
|
@@ -12,7 +12,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ANSI color codes for terminal output
|
// ANSI color codes for terminal output
|
||||||
@@ -43,23 +43,23 @@ type TelnetServer struct {
|
|||||||
sigCh chan os.Signal
|
sigCh chan os.Signal
|
||||||
onShutdown func()
|
onShutdown func()
|
||||||
// Map to store client preferences (like json formatting)
|
// Map to store client preferences (like json formatting)
|
||||||
clientPrefs map[net.Conn]map[string]bool
|
clientPrefs map[net.Conn]map[string]bool
|
||||||
prefsMutex sync.RWMutex
|
prefsMutex sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTelnetServer creates a new telnet server
|
// NewTelnetServer creates a new telnet server
|
||||||
func NewTelnetServer(factory *HandlerFactory, secrets ...string) *TelnetServer {
|
func NewTelnetServer(factory *HandlerFactory, secrets ...string) *TelnetServer {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
return &TelnetServer{
|
return &TelnetServer{
|
||||||
factory: factory,
|
factory: factory,
|
||||||
secrets: secrets,
|
secrets: secrets,
|
||||||
clients: make(map[net.Conn]bool),
|
clients: make(map[net.Conn]bool),
|
||||||
clientPrefs: make(map[net.Conn]map[string]bool),
|
clientPrefs: make(map[net.Conn]map[string]bool),
|
||||||
running: false,
|
running: false,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
sigCh: make(chan os.Signal, 1),
|
sigCh: make(chan os.Signal, 1),
|
||||||
onShutdown: func() {},
|
onShutdown: func() {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,8 +466,6 @@ func (ts *TelnetServer) addJsonFormat(script string) string {
|
|||||||
return strings.Join(lines, "\n")
|
return strings.Join(lines, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// formatHeroscript formats heroscript with colors for console output only
|
// formatHeroscript formats heroscript with colors for console output only
|
||||||
// This is not used for telnet responses, only for server-side logging
|
// This is not used for telnet responses, only for server-side logging
|
||||||
func formatHeroscript(script string) string {
|
func formatHeroscript(script string) string {
|
@@ -3,7 +3,7 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthHandler handles authentication actions
|
// AuthHandler handles authentication actions
|
@@ -5,9 +5,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/paramsparser"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/paramsparser"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BaseHandler provides common functionality for all handlers
|
// BaseHandler provides common functionality for all handlers
|
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandlerFactory manages a collection of handlers for processing HeroScript commands
|
// HandlerFactory manages a collection of handlers for processing HeroScript commands
|
@@ -1,7 +1,7 @@
|
|||||||
package herohandler
|
package herohandler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetFactory returns the handler factory
|
// GetFactory returns the handler factory
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/herohandler"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/herohandler"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -4,10 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
|
|
||||||
// "github.com/freeflowuniverse/heroagent/pkg/handlerfactory/heroscript/handlerfactory/fakehandler"
|
// "git.threefold.info/herocode/heroagent/pkg/handlerfactory/heroscript/handlerfactory/fakehandler"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/processmanagerhandler"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/processmanagerhandler"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HeroHandler is the main handler factory that manages all registered handlers
|
// HeroHandler is the main handler factory that manages all registered handlers
|
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/playbook"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/playbook"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@@ -3,8 +3,8 @@ package processmanagerhandler
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/heroscript/handlerfactory/core"
|
"git.threefold.info/herocode/heroagent/pkg/heroscript/handlerfactory/core"
|
||||||
"github.com/freeflowuniverse/heroagent/pkg/processmanager"
|
"git.threefold.info/herocode/heroagent/pkg/processmanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessManagerHandler handles process manager-related actions
|
// ProcessManagerHandler handles process manager-related actions
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user