Refactor start command and enhance tool availability reporting

- Remove unnecessary timing and progress callback logic from the start command in `cmd/start.go`.
- Update the output message for the admin URL to reflect a change to the dashboard URL.
- Introduce a new tools configuration in `widgets/app/app.go` to report the availability of external tools like FFmpeg, Docker, and others, enhancing the application's tool inspection capabilities.
This commit is contained in:
Max 2026-02-15 18:48:27 +08:00
parent c7cdfbdfe6
commit 6c51e74b02
2 changed files with 33 additions and 20 deletions

View file

@ -7,7 +7,6 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"syscall" "syscall"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -82,32 +81,15 @@ var startCmd = &cobra.Command{
config.Development() config.Development()
} }
startTime := time.Now()
// load the application engine // load the application engine
var progressCallback func(string, string)
if config.Conf.Mode == "development" {
fmt.Println(color.CyanString("Loading application engine..."))
progressCallback = func(name string, duration string) {
fmt.Printf(" %s %s %s\n", color.GreenString("✓"), name, color.GreenString("(%s)", duration))
}
}
loadWarnings, err := engine.Load(config.Conf, engine.LoadOption{ loadWarnings, err := engine.Load(config.Conf, engine.LoadOption{
Action: "start", Action: "start",
}, progressCallback) })
if err != nil { if err != nil {
fmt.Println(color.RedString(L("Load: %s"), err.Error())) fmt.Println(color.RedString(L("Load: %s"), err.Error()))
os.Exit(1) os.Exit(1)
} }
loadDuration := time.Since(startTime)
if config.Conf.Mode == "development" {
fmt.Printf("\n%s Engine loaded successfully in %s\n\n",
color.GreenString("✓"),
color.CyanString("%v", loadDuration))
}
port := fmt.Sprintf(":%d", config.Conf.Port) port := fmt.Sprintf(":%d", config.Conf.Port)
if port == ":80" { if port == ":80" {
port = "" port = ""
@ -209,7 +191,7 @@ var startCmd = &cobra.Command{
fmt.Println(color.CyanString("\n%s", endpoint.Interface)) fmt.Println(color.CyanString("\n%s", endpoint.Interface))
fmt.Println(color.WhiteString("--------------------------")) fmt.Println(color.WhiteString("--------------------------"))
fmt.Println(color.WhiteString(L("Website")), color.GreenString(" %s", endpoint.URL)) fmt.Println(color.WhiteString(L("Website")), color.GreenString(" %s", endpoint.URL))
fmt.Println(color.WhiteString(L("Admin")), color.GreenString(" %s/%s/login/admin", endpoint.URL, strings.Trim(root, "/"))) fmt.Println(color.WhiteString(L("Dashboard")), color.GreenString(" %s/%s/auth/entry", endpoint.URL, strings.Trim(root, "/")))
fmt.Println(color.WhiteString(L("API")), color.GreenString(" %s/api", endpoint.URL)) fmt.Println(color.WhiteString(L("API")), color.GreenString(" %s/api", endpoint.URL))
} }
fmt.Println("") fmt.Println("")

View file

@ -580,6 +580,36 @@ func processXgen(process *process.Process) interface{} {
// agentConfig["connectors"] = connector.AIConnectors // agentConfig["connectors"] = connector.AIConnectors
} }
// External tools availability (safe subset for frontend)
toolsConfig := map[string]interface{}{}
if share.Tools != nil {
safeTool := func(info *share.ExtToolInfo) map[string]interface{} {
if info == nil {
return map[string]interface{}{"available": false}
}
return map[string]interface{}{
"available": info.Available,
"name": info.Name,
}
}
toolsConfig["ffmpeg"] = safeTool(share.Tools.FFmpeg)
toolsConfig["ffprobe"] = safeTool(share.Tools.FFprobe)
toolsConfig["pdftoppm"] = safeTool(share.Tools.Pdftoppm)
toolsConfig["mutool"] = safeTool(share.Tools.Mutool)
toolsConfig["imagemagick"] = safeTool(share.Tools.ImageMagick)
if share.Tools.Docker != nil {
docker := map[string]interface{}{
"available": share.Tools.Docker.Available,
"name": "docker",
}
if share.Tools.Docker.Mode != "" {
docker["mode"] = share.Tools.Docker.Mode
}
toolsConfig["docker"] = docker
}
}
// OpenAPI Settings // OpenAPI Settings
openapiConfig := map[string]interface{}{} openapiConfig := map[string]interface{}{}
if openapi.Server != nil { if openapi.Server != nil {
@ -688,6 +718,7 @@ func processXgen(process *process.Process) interface{} {
"optional": Setting.Optional, "optional": Setting.Optional,
"login": xgenLogin, "login": xgenLogin,
"agent": agentConfig, "agent": agentConfig,
"tools": toolsConfig,
"openapi": openapiConfig, "openapi": openapiConfig,
"kb": kbConfig, "kb": kbConfig,
} }