okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
61c43ca
main
1package daemon 2 3import ( 4"crypto/rand" 5"encoding/hex" 6"strings" 7"sync" 8) 9 10// ChatClient retains the cursor and live progress keys for one subscription. 11// Callers must serialize stream subscriptions and reset operations. 12type ChatClient struct { 13conn * Connection 14progressCallIDs map [string ]struct {} 15agentID string 16clientID string 17afterSeq int64 18afterGeneration string 19mu sync.Mutex 20} 21 22// NewChatClient shares conn's HTTP transport. A nil connection panics. 23func NewChatClient (conn * Connection ,agentID string )* ChatClient { 24if conn == nil { 25panic ("daemon.NewChatClient: nil connection" ) 26 } 27identity := make ([]byte ,16 ) 28_ ,_ = rand .Read (identity ) 29return & ChatClient { 30conn :conn , 31agentID :strings .TrimSpace (agentID ), 32clientID :"cli-" + hex .EncodeToString (identity ), 33afterSeq :- 1 , 34 } 35}