mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-19 03:47:28 +08:00
improve autonomy status visibility and gateway autonomy status output
This commit is contained in:
@@ -342,16 +342,21 @@ func gatewayAutonomyControlCmd(args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
case "status":
|
case "status":
|
||||||
enabled := true
|
enabled := true
|
||||||
|
reason := "default"
|
||||||
if data, err := os.ReadFile(ctrlPath); err == nil {
|
if data, err := os.ReadFile(ctrlPath); err == nil {
|
||||||
var c struct{ Enabled bool `json:"enabled"` }
|
var c struct{ Enabled bool `json:"enabled"` }
|
||||||
if json.Unmarshal(data, &c) == nil {
|
if json.Unmarshal(data, &c) == nil {
|
||||||
enabled = c.Enabled
|
enabled = c.Enabled
|
||||||
|
if !c.Enabled {
|
||||||
|
reason = "control_file"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(pausePath); err == nil {
|
if _, err := os.Stat(pausePath); err == nil {
|
||||||
enabled = false
|
enabled = false
|
||||||
|
reason = "pause_file"
|
||||||
}
|
}
|
||||||
fmt.Printf("Autonomy status: %v\n", enabled)
|
fmt.Printf("Autonomy status: %v (%s)\n", enabled, reason)
|
||||||
fmt.Printf("Control file: %s\n", ctrlPath)
|
fmt.Printf("Control file: %s\n", ctrlPath)
|
||||||
fmt.Printf("Pause file: %s\n", pausePath)
|
fmt.Printf("Pause file: %s\n", pausePath)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ func statusCmd() {
|
|||||||
triggerStats := filepath.Join(workspace, "memory", "trigger-stats.json")
|
triggerStats := filepath.Join(workspace, "memory", "trigger-stats.json")
|
||||||
if data, err := os.ReadFile(triggerStats); err == nil {
|
if data, err := os.ReadFile(triggerStats); err == nil {
|
||||||
fmt.Printf("Trigger Stats: %s\n", strings.TrimSpace(string(data)))
|
fmt.Printf("Trigger Stats: %s\n", strings.TrimSpace(string(data)))
|
||||||
|
if summary := summarizeAutonomyActions(data); summary != "" {
|
||||||
|
fmt.Printf("Autonomy Action Stats: %s\n", summary)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auditPath := filepath.Join(workspace, "memory", "trigger-audit.jsonl")
|
auditPath := filepath.Join(workspace, "memory", "trigger-audit.jsonl")
|
||||||
if errs, err := collectRecentTriggerErrors(auditPath, 5); err == nil && len(errs) > 0 {
|
if errs, err := collectRecentTriggerErrors(auditPath, 5); err == nil && len(errs) > 0 {
|
||||||
@@ -165,6 +168,23 @@ func printTemplateField(name, current, def string) {
|
|||||||
fmt.Printf(" %s: %s\n", name, state)
|
fmt.Printf(" %s: %s\n", name, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func summarizeAutonomyActions(statsJSON []byte) string {
|
||||||
|
var payload struct {
|
||||||
|
Counts map[string]int `json:"counts"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(statsJSON, &payload); err != nil || payload.Counts == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
keys := []string{"autonomy:dispatch", "autonomy:waiting", "autonomy:resume", "autonomy:blocked", "autonomy:complete"}
|
||||||
|
parts := make([]string, 0, len(keys))
|
||||||
|
for _, k := range keys {
|
||||||
|
if v, ok := payload.Counts[k]; ok {
|
||||||
|
parts = append(parts, fmt.Sprintf("%s=%d", strings.TrimPrefix(k, "autonomy:"), v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings.Join(parts, " ")
|
||||||
|
}
|
||||||
|
|
||||||
func autonomyControlState(workspace string) string {
|
func autonomyControlState(workspace string) string {
|
||||||
memDir := filepath.Join(workspace, "memory")
|
memDir := filepath.Join(workspace, "memory")
|
||||||
pausePath := filepath.Join(memDir, "autonomy.pause")
|
pausePath := filepath.Join(memDir, "autonomy.pause")
|
||||||
|
|||||||
Reference in New Issue
Block a user