Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839package daemon
import ( "albedo/cli/internal/testwire" "net" "net/http" "net/http/httptest" "testing")
const generationA = testwire.GenerationAconst generationB = testwire.GenerationB
var canonicalSession = testwire.Sessionvar canonicalInput = testwire.Inputvar canonicalEvent = testwire.Eventvar canonicalText = testwire.Textvar writeBatch = testwire.WriteBatchvar writeInitialStream = testwire.InitialStreamvar canonicalProgress = testwire.Progress
func controlledConnection(t *testing.T, handler http.HandlerFunc) *Connection { t.Helper() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/server" { _, _ = w.Write([]byte(testwire.Server)) return } handler(w, r) })) t.Cleanup(server.Close) conn, err := Attach(t.Context(), ConnectionSnapshot{Port: server.Listener.Addr().(*net.TCPAddr).Port, Token: "token", Version: ProtocolVersion}, nil) if err != nil { t.Fatal(err) } t.Cleanup(conn.HTTPClient().CloseIdleConnections) return conn}