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)