mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-04 17:57:38 +08:00
fix: remove garbled terminal output
This commit is contained in:
@@ -27,7 +27,7 @@ func agentCmd() {
|
||||
switch args[i] {
|
||||
case "--debug", "-d":
|
||||
logger.SetLevel(logger.DEBUG)
|
||||
fmt.Println("馃攳 Debug mode enabled")
|
||||
fmt.Println("Debug mode enabled")
|
||||
case "-m", "--message":
|
||||
if i+1 < len(args) {
|
||||
message = args[i+1]
|
||||
|
||||
@@ -55,7 +55,7 @@ func channelHelp() {
|
||||
func channelTestCmd() {
|
||||
to := ""
|
||||
channelName := ""
|
||||
message := "This is a test message from ClawGo 馃"
|
||||
message := "This is a test message from ClawGo"
|
||||
|
||||
args := os.Args[3:]
|
||||
for i := 0; i < len(args); i++ {
|
||||
@@ -104,11 +104,11 @@ func channelTestCmd() {
|
||||
|
||||
fmt.Printf("Sending test message to %s (%s)...\n", channelName, to)
|
||||
if err := mgr.SendToChannel(ctx, channelName, to, message); err != nil {
|
||||
fmt.Printf("鉁?Failed to send message: %v\n", err)
|
||||
fmt.Printf("Failed to send message: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("鉁?Test message sent successfully!")
|
||||
fmt.Println("Test message sent successfully.")
|
||||
}
|
||||
|
||||
func whatsAppChannelCmd() {
|
||||
|
||||
@@ -103,7 +103,7 @@ func configSetCmd() {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("鉁?Updated %s = %v\n", path, value)
|
||||
fmt.Printf("Updated %s = %v\n", path, value)
|
||||
running, err := triggerGatewayReload()
|
||||
if err != nil {
|
||||
if running {
|
||||
@@ -116,7 +116,7 @@ func configSetCmd() {
|
||||
}
|
||||
fmt.Printf("Updated config file. Hot reload not applied: %v\n", err)
|
||||
} else {
|
||||
fmt.Println("鉁?Gateway hot reload signal sent")
|
||||
fmt.Println("Gateway hot reload signal sent")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func configReloadCmd() {
|
||||
fmt.Printf("Hot reload not applied: %v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("鉁?Gateway hot reload signal sent")
|
||||
fmt.Println("Gateway hot reload signal sent")
|
||||
}
|
||||
|
||||
func configCheckCmd() {
|
||||
@@ -164,11 +164,11 @@ func configCheckCmd() {
|
||||
}
|
||||
validationErrors := config.Validate(cfg)
|
||||
if len(validationErrors) == 0 {
|
||||
fmt.Println("鉁?Config validation passed")
|
||||
fmt.Println("Config validation passed")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("鉁?Config validation failed:")
|
||||
fmt.Println("Config validation failed:")
|
||||
for _, ve := range validationErrors {
|
||||
fmt.Printf(" - %v\n", ve)
|
||||
}
|
||||
@@ -301,7 +301,7 @@ func providerCmd() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("鉁?Provider configuration saved.")
|
||||
fmt.Println("Provider configuration saved.")
|
||||
running, err := triggerGatewayReload()
|
||||
if err != nil {
|
||||
if running {
|
||||
@@ -311,7 +311,7 @@ func providerCmd() {
|
||||
fmt.Printf("Gateway not running, reload skipped: %v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("鉁?Gateway hot reload signal sent")
|
||||
fmt.Println("Gateway hot reload signal sent")
|
||||
}
|
||||
|
||||
func providerListCmd() {
|
||||
|
||||
@@ -177,15 +177,15 @@ func cronAddCmd(storePath string) {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("鉁?Added job '%s' (%s)\n", job.Name, job.ID)
|
||||
fmt.Printf("Added job '%s' (%s)\n", job.Name, job.ID)
|
||||
}
|
||||
|
||||
func cronRemoveCmd(storePath, jobID string) {
|
||||
cs := cron.NewCronService(storePath, nil)
|
||||
if cs.RemoveJob(jobID) {
|
||||
fmt.Printf("鉁?Removed job %s\n", jobID)
|
||||
fmt.Printf("Removed job %s\n", jobID)
|
||||
} else {
|
||||
fmt.Printf("鉁?Job %s not found\n", jobID)
|
||||
fmt.Printf("Job %s not found\n", jobID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,8 +205,8 @@ func cronEnableCmd(storePath string, disable bool) {
|
||||
if disable {
|
||||
status = "disabled"
|
||||
}
|
||||
fmt.Printf("鉁?Job '%s' %s\n", job.Name, status)
|
||||
fmt.Printf("Job '%s' %s\n", job.Name, status)
|
||||
} else {
|
||||
fmt.Printf("鉁?Job %s not found\n", jobID)
|
||||
fmt.Printf("Job %s not found\n", jobID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,26 +100,26 @@ func gatewayCmd() {
|
||||
|
||||
enabledChannels := channelManager.GetEnabledChannels()
|
||||
if len(enabledChannels) > 0 {
|
||||
fmt.Printf("鉁?Channels enabled: %s\n", enabledChannels)
|
||||
fmt.Printf("Channels enabled: %s\n", enabledChannels)
|
||||
} else {
|
||||
fmt.Println("鈿?Warning: No channels enabled")
|
||||
fmt.Println("Warning: no channels enabled")
|
||||
}
|
||||
|
||||
fmt.Printf("鉁?Gateway started on %s:%d\n", cfg.Gateway.Host, cfg.Gateway.Port)
|
||||
fmt.Printf("Gateway started on %s:%d\n", cfg.Gateway.Host, cfg.Gateway.Port)
|
||||
fmt.Println("Press Ctrl+C to stop. Send SIGHUP to hot-reload config.")
|
||||
|
||||
if err := cronService.Start(); err != nil {
|
||||
fmt.Printf("Error starting cron service: %v\n", err)
|
||||
}
|
||||
fmt.Println("鉁?Cron service started")
|
||||
fmt.Println("Cron service started")
|
||||
|
||||
if err := heartbeatService.Start(); err != nil {
|
||||
fmt.Printf("Error starting heartbeat service: %v\n", err)
|
||||
}
|
||||
fmt.Println("鉁?Heartbeat service started")
|
||||
fmt.Println("Heartbeat service started")
|
||||
if cfg.Sentinel.Enabled {
|
||||
sentinelService.Start()
|
||||
fmt.Println("鉁?Sentinel service started")
|
||||
fmt.Println("Sentinel service started")
|
||||
}
|
||||
|
||||
registryServer := api.NewServer(cfg.Gateway.Host, cfg.Gateway.Port, cfg.Gateway.Token, nodes.DefaultManager())
|
||||
@@ -360,7 +360,7 @@ func gatewayCmd() {
|
||||
if err := registryServer.Start(ctx); err != nil {
|
||||
fmt.Printf("Error starting node registry server: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("鉁?Node registry server started on %s:%d\n", cfg.Gateway.Host, cfg.Gateway.Port)
|
||||
fmt.Printf("Node registry server started on %s:%d\n", cfg.Gateway.Host, cfg.Gateway.Port)
|
||||
}
|
||||
|
||||
if err := channelManager.StartAll(ctx); err != nil {
|
||||
@@ -374,10 +374,10 @@ func gatewayCmd() {
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, gatewayNotifySignals()...)
|
||||
applyReload := func() {
|
||||
fmt.Println("\n鈫?Reloading config...")
|
||||
fmt.Println("\nReloading config...")
|
||||
newCfg, err := config.LoadConfig(getConfigPath())
|
||||
if err != nil {
|
||||
fmt.Printf("鉁?Reload failed (load config): %v\n", err)
|
||||
fmt.Printf("Reload failed (load config): %v\n", err)
|
||||
return
|
||||
}
|
||||
if strings.EqualFold(strings.TrimSpace(os.Getenv(envRootGranted)), "1") || strings.EqualFold(strings.TrimSpace(os.Getenv(envRootGranted)), "true") {
|
||||
@@ -391,7 +391,7 @@ func gatewayCmd() {
|
||||
}
|
||||
|
||||
if reflect.DeepEqual(cfg, newCfg) {
|
||||
fmt.Println("鉁?Config unchanged, skip reload")
|
||||
fmt.Println("Config unchanged, skip reload")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -422,13 +422,13 @@ func gatewayCmd() {
|
||||
cfg = newCfg
|
||||
runtimecfg.Set(cfg)
|
||||
configureGatewayNodeP2P(agentLoop, registryServer, cfg)
|
||||
fmt.Println("鉁?Config hot-reload applied (logging/metadata only)")
|
||||
fmt.Println("Config hot-reload applied (logging/metadata only)")
|
||||
return
|
||||
}
|
||||
|
||||
newAgentLoop, newChannelManager, err := buildGatewayRuntime(ctx, newCfg, msgBus, cronService)
|
||||
if err != nil {
|
||||
fmt.Printf("鉁?Reload failed (init runtime): %v\n", err)
|
||||
fmt.Printf("Reload failed (init runtime): %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -462,11 +462,11 @@ func gatewayCmd() {
|
||||
sentinelService.SetManager(channelManager)
|
||||
|
||||
if err := channelManager.StartAll(ctx); err != nil {
|
||||
fmt.Printf("鉁?Reload failed (start channels): %v\n", err)
|
||||
fmt.Printf("Reload failed (start channels): %v\n", err)
|
||||
return
|
||||
}
|
||||
go agentLoop.Run(ctx)
|
||||
fmt.Println("鉁?Config hot-reload applied")
|
||||
fmt.Println("Config hot-reload applied")
|
||||
}
|
||||
|
||||
for {
|
||||
@@ -488,7 +488,7 @@ func gatewayCmd() {
|
||||
cronService.Stop()
|
||||
agentLoop.Stop()
|
||||
channelManager.StopAll(ctx)
|
||||
fmt.Println("鉁?Gateway stopped")
|
||||
fmt.Println("Gateway stopped")
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -589,7 +589,7 @@ func gatewayInstallServiceCmd() error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("鉁?Gateway service registered: %s (%s)\n", gatewayServiceName, scope)
|
||||
fmt.Printf("Gateway service registered: %s (%s)\n", gatewayServiceName, scope)
|
||||
fmt.Printf(" Unit file: %s\n", unitPath)
|
||||
fmt.Println(" Start service: clawgo gateway start")
|
||||
fmt.Println(" Restart service: clawgo gateway restart")
|
||||
@@ -1028,7 +1028,7 @@ func buildGatewayRuntime(ctx context.Context, cfg *config.Config, msgBus *bus.Me
|
||||
startupInfo := agentLoop.GetStartupInfo()
|
||||
toolsInfo := startupInfo["tools"].(map[string]interface{})
|
||||
skillsInfo := startupInfo["skills"].(map[string]interface{})
|
||||
fmt.Println("\n馃摝 Agent Status:")
|
||||
fmt.Println("\nAgent Status:")
|
||||
fmt.Printf(" 鈥?Tools: %d loaded\n", toolsInfo["count"])
|
||||
fmt.Printf(" 鈥?Skills: %d/%d available\n", skillsInfo["available"], skillsInfo["total"])
|
||||
|
||||
|
||||
@@ -151,11 +151,11 @@ func nodeRegisterCmd(args []string) {
|
||||
fmt.Printf("Error registering node: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("鉁?Node registered: %s -> %s\n", info.ID, opts.GatewayBase)
|
||||
fmt.Printf("Node registered: %s -> %s\n", info.ID, opts.GatewayBase)
|
||||
if !opts.Watch {
|
||||
return
|
||||
}
|
||||
fmt.Printf("鉁?Heartbeat loop started: every %ds\n", opts.HeartbeatSec)
|
||||
fmt.Printf("Heartbeat loop started: every %ds\n", opts.HeartbeatSec)
|
||||
if err := runNodeHeartbeatLoop(client, opts, info); err != nil {
|
||||
fmt.Printf("Heartbeat loop stopped: %v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -175,7 +175,7 @@ func nodeHeartbeatCmd(args []string) {
|
||||
fmt.Printf("Error sending heartbeat: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("鉁?Heartbeat sent: %s -> %s\n", opts.ID, opts.GatewayBase)
|
||||
fmt.Printf("Heartbeat sent: %s -> %s\n", opts.ID, opts.GatewayBase)
|
||||
}
|
||||
|
||||
func parseNodeRegisterArgs(args []string, cfg *config.Config) (nodeRegisterOptions, error) {
|
||||
@@ -409,23 +409,23 @@ func runNodeHeartbeatLoop(client *http.Client, opts nodeRegisterOptions, info no
|
||||
for {
|
||||
if err := runNodeHeartbeatSocket(ctx, opts, info); err != nil {
|
||||
if ctx.Err() != nil {
|
||||
fmt.Println("鉁?Node heartbeat stopped")
|
||||
fmt.Println("Node heartbeat stopped")
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("Warning: node socket closed for %s: %v\n", info.ID, err)
|
||||
}
|
||||
if ctx.Err() != nil {
|
||||
fmt.Println("鉁?Node heartbeat stopped")
|
||||
fmt.Println("Node heartbeat stopped")
|
||||
return nil
|
||||
}
|
||||
if regErr := postNodeRegister(ctx, client, opts.GatewayBase, opts.Token, info); regErr != nil {
|
||||
fmt.Printf("Warning: re-register failed for %s: %v\n", info.ID, regErr)
|
||||
} else {
|
||||
fmt.Printf("鉁?Node re-registered: %s\n", info.ID)
|
||||
fmt.Printf("Node re-registered: %s\n", info.ID)
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Println("鉁?Node heartbeat stopped")
|
||||
fmt.Println("Node heartbeat stopped")
|
||||
return nil
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
@@ -466,7 +466,7 @@ func runNodeHeartbeatSocket(ctx context.Context, opts nodeRegisterOptions, info
|
||||
if err := waitNodeAck(ctx, acks, errs, "registered", info.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("鉁?Node socket connected: %s\n", info.ID)
|
||||
fmt.Printf("Node socket connected: %s\n", info.ID)
|
||||
|
||||
ticker := time.NewTicker(time.Duration(opts.HeartbeatSec) * time.Second)
|
||||
pingTicker := time.NewTicker(nodeSocketPingInterval(opts.HeartbeatSec))
|
||||
@@ -493,7 +493,7 @@ func runNodeHeartbeatSocket(ctx context.Context, opts nodeRegisterOptions, info
|
||||
if err := waitNodeAck(ctx, acks, errs, "heartbeat", info.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("鉁?Heartbeat ok: %s\n", info.ID)
|
||||
fmt.Printf("Heartbeat ok: %s\n", info.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ var embeddedFiles embed.FS
|
||||
var version = "0.2.0"
|
||||
var buildTime = "unknown"
|
||||
|
||||
const logo = "馃"
|
||||
const logo = ">"
|
||||
const gatewayServiceName = "clawgo-gateway.service"
|
||||
const envRootGranted = "CLAWGO_ROOT_GRANTED"
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ func (c *MaixCamChannel) handlePersonDetection(msg MaixCamMessage) {
|
||||
w, _ := msg.Data["w"].(float64)
|
||||
h, _ := msg.Data["h"].(float64)
|
||||
|
||||
content := fmt.Sprintf("馃摲 Person detected!\nClass: %s\nConfidence: %.2f%%\nPosition: (%.0f, %.0f)\nSize: %.0fx%.0f",
|
||||
content := fmt.Sprintf("Person detected.\nClass: %s\nConfidence: %.2f%%\nPosition: (%.0f, %.0f)\nSize: %.0fx%.0f",
|
||||
classInfo, score*100, x, y, w, h)
|
||||
|
||||
metadata := map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user