Implement fleet topology epidemiology tracker and strain plague map.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Adds epidemiology package, auth epidemiology_fix push, strain-based 3D map, and Vitest coverage.
This commit is contained in:
66
server/internal/api/seer_bridge.go
Normal file
66
server/internal/api/seer_bridge.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
fleetai "crypto-miner-server/internal/ai"
|
||||
dbpkg "crypto-miner-server/internal/db"
|
||||
)
|
||||
|
||||
// SeerBridge wires fleet AI scheduler memory + LLM payload streaming.
|
||||
type SeerBridge struct {
|
||||
DB *dbpkg.Database
|
||||
Hub *WSHub
|
||||
}
|
||||
|
||||
func (b *SeerBridge) NotesForPrompt(agentID string) string {
|
||||
if b == nil || b.DB == nil {
|
||||
return ""
|
||||
}
|
||||
rows, err := b.DB.ListSeerNotesForPrompt(agentID, 32)
|
||||
if err != nil || len(rows) == 0 {
|
||||
return ""
|
||||
}
|
||||
lines := make([]string, 0, len(rows))
|
||||
for _, n := range rows {
|
||||
if n.Note != "" {
|
||||
lines = append(lines, n.Note)
|
||||
}
|
||||
}
|
||||
return fleetai.FormatSeerNotesBlock(lines)
|
||||
}
|
||||
|
||||
func (b *SeerBridge) AppendNote(agentID, content, promptHash string) error {
|
||||
if b == nil || b.DB == nil || content == "" {
|
||||
return nil
|
||||
}
|
||||
source := promptHash
|
||||
if source == "" {
|
||||
source = "ai_scheduler"
|
||||
}
|
||||
if err := b.DB.InsertSeerNote(agentID, content, source); err != nil {
|
||||
return err
|
||||
}
|
||||
if b.Hub != nil {
|
||||
b.Hub.BroadcastSeerNotesUpdated(map[string]string{
|
||||
"agent_id": agentID,
|
||||
"note": content,
|
||||
"source": source,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *SeerBridge) EmitEvent(agentID, direction string, payload interface{}) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
eventType := "llm_" + direction
|
||||
body := map[string]interface{}{
|
||||
"direction": direction,
|
||||
"payload": payload,
|
||||
}
|
||||
emitter := &HubSeerEmitter{Hub: b.Hub, DB: b.DB}
|
||||
_ = emitter.EmitSeerEvent(eventType, agentID, body)
|
||||
}
|
||||
|
||||
// Compile-time check.
|
||||
var _ fleetai.SeerBridge = (*SeerBridge)(nil)
|
||||
Reference in New Issue
Block a user