package control import ( "context" "crypto/sha256" "encoding/hex" "encoding/json" "os" "path/filepath" ) const MaxFrameBytes = 8 << 20 type Request struct { PluginID string `json:"plugin_id"` Channel string `json:"channel"` Message json.RawMessage `json:"message"` } type Response struct { Message json.RawMessage `json:"message,omitempty"` Error string `json:"error,omitempty"` } type Handler func(ctx context.Context, pluginID, channel string, message json.RawMessage) (json.RawMessage, error) // PipeName gives the desktop process and its CLI clients a deterministic // endpoint scoped to this installation path and Windows user. func PipeName() string { exe, err := os.Executable() if err != nil { exe = "reims-go" } identity := filepath.Clean(exe) sum := sha256.Sum256([]byte(identity)) userScope := currentUserScope() return `\\.\pipe\reims-go-control-` + hex.EncodeToString(sum[:8]) + "-" + userScope }